:root {
  color-scheme: light;
  --ink: #211719;
  --muted: #6f6264;
  --line: #ded6d2;
  --paper: #f7f1ee;
  --panel: #fffaf7;
  --blood: #70131c;
  --blood-dark: #4d0d13;
  --gold: #b8873a;
  --mist: #ebe4df;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #2b0b10 0, #3a1017 170px, #f1e8e2 170px);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--blood);
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button.primary,
#draftButton {
  background: var(--blood);
  border-color: var(--blood);
  color: #fff;
}

button.primary:hover,
#draftButton:hover {
  background: var(--blood-dark);
}

.shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  min-height: 128px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: #e5c2c2;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1 {
  margin: 0;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  margin: 0 0 10px;
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .08);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(430px, 1fr) 390px;
  gap: 14px;
  align-items: start;
}

.left-pane,
.form-pane,
.right-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 35px rgba(44, 17, 20, .12);
}

.left-pane,
.right-pane {
  padding: 16px;
}

.form-pane {
  padding: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}

.tab.active {
  background: var(--blood);
  border-color: var(--blood);
  color: #fff;
}

.field-label,
label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.prompt-row {
  display: grid;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 10px;
}

.check-list {
  max-height: 170px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 6px;
  display: grid;
  gap: 4px;
}

.check-empty,
.check-row {
  min-height: 32px;
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 14px;
}

.check-empty {
  color: var(--muted);
  background: var(--paper);
}

.check-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 7px;
  align-items: start;
  cursor: pointer;
}

.check-row:hover {
  background: var(--paper);
}

.check-row.checked {
  border: 1px solid #b51d2a;
  background: #fff1f2;
  font-weight: 650;
}

.check-row input {
  width: auto;
  margin: 2px 0 0;
}

textarea {
  min-height: 250px;
  resize: vertical;
  line-height: 1.45;
}

.clearable {
  position: relative;
}

.clearable input,
.clearable textarea {
  padding-right: 38px;
}

.field-clear {
  position: absolute;
  top: 5px;
  right: 5px;
  min-height: 28px;
  width: 28px;
  padding: 0;
  border-radius: 5px;
  color: var(--muted);
  line-height: 1;
}

.clearable-textarea .field-clear {
  top: 7px;
}

.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.notice {
  margin-top: 14px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.notice.error {
  color: #781720;
  border-color: #d8a9ad;
  background: #fff0f1;
}

.notice.success {
  color: #2f5f3e;
  border-color: #a7d1b2;
  background: #effaf2;
}

.notice a {
  color: inherit;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.entry-label {
  display: block;
}

.hidden {
  display: none !important;
}

.right-pane {
  display: grid;
  gap: 18px;
}

.stack {
  display: grid;
  gap: 8px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.result-card,
.source-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 10px;
  font-size: 14px;
  line-height: 1.42;
}

.result-card.exact-match {
  border-color: #b51d2a;
  background: #fff1f2;
}

.warning-line {
  margin: 4px 0;
  color: #8c111c;
  font-weight: 700;
}

.result-card strong,
.source-card strong {
  display: block;
  margin-bottom: 3px;
}

.result-card a {
  color: var(--blood);
  font-weight: 650;
}

.source-card button {
  margin-top: 8px;
  min-height: 32px;
}

.source-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.image-placeholder {
  background: var(--paper);
  border: 1px dashed #c9bdb8;
  border-radius: 7px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.image-placeholder p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 300px 1fr;
  }

  .right-pane {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 18px, 760px);
    padding-top: 14px;
  }

  .topbar {
    min-height: 112px;
    display: block;
  }

  .status-pill {
    display: inline-block;
    margin-top: 14px;
  }

  .workspace,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
