:root {
  --paper: #f7f2e8;
  --paper-deep: #efe7d8;
  --surface: #fffdf8;
  --ink: #141918;
  --muted: #68665f;
  --line: #1d2321;
  --line-soft: #b9b1a4;
  --green: #79ca4b;
  --green-soft: #dcefcf;
  --pink-soft: #f8cfda;
  --blue: #0878ba;
  --blue-deep: #075985;
  --blue-soft: #cde9f7;
  --red-soft: #f8d1ca;
  --yellow-soft: #fbe9ad;
  --shadow: 0 12px 30px rgb(50 42 28 / 10%);
  --display: "Arial Rounded MT Bold", "Trebuchet MS", ui-rounded, sans-serif;
  --body: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: var(--ink);
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: var(--body);
  background:
    radial-gradient(circle at 16% 18%, rgb(255 255 255 / 28%) 0 1px, transparent 1.5px) 0 0 / 18px 18px,
    var(--paper);
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.term-pane:focus-visible {
  outline: 4px solid rgb(8 120 186 / 28%);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  color: #fff;
  background: var(--ink);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 2px solid var(--ink);
}

@media (min-width: 761px) {
  .app-shell {
    height: 100vh;
    height: 100dvh;
  }
}

.app-header {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 18px 28px;
  border-bottom: 2px solid var(--ink);
  background: rgb(247 242 232 / 96%);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue-deep);
  font-family: var(--display);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.title-block h1,
.term-header h2,
.active-heading h2,
.pane-heading h2,
.section-heading h3 {
  margin: 0;
  font-family: var(--display);
}

.title-block h1 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1;
}

.title-block > p:last-child {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.review-count {
  max-width: 260px;
  margin: 0;
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 800;
  text-align: right;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 17px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  font-family: var(--display);
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:not(:disabled):hover {
  box-shadow: 3px 4px 0 var(--ink);
  transform: translateY(-2px);
}

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

.button-primary {
  color: #fff;
  background: var(--blue);
}

.button-secondary {
  background: var(--paper);
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(520px, 1.75fr) minmax(320px, 0.95fr);
  overflow: hidden;
}

.queue-pane,
.term-pane,
.review-pane {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.queue-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 22px 18px;
  border-right: 2px solid var(--ink);
  background: rgb(247 242 232 / 78%);
}

.pane-heading {
  margin-bottom: 18px;
}

.field-label {
  display: grid;
  gap: 7px;
  margin-bottom: 15px;
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 800;
}

.field-label input,
.field-label select,
.field-label textarea {
  width: 100%;
  min-width: 0;
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 10px 11px;
  background: var(--surface);
  font-family: var(--body);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.45;
}

.field-label textarea {
  resize: vertical;
}

.focus-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 16px;
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 800;
}

.focus-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.term-queue {
  min-height: 0;
  display: grid;
  gap: 7px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.term-queue-empty {
  padding: 14px;
  border: 1px dashed var(--line-soft);
  color: var(--muted);
  line-height: 1.4;
}

.term-queue button {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  text-align: left;
  background: var(--surface);
  cursor: pointer;
}

.term-queue button:hover {
  background: var(--blue-soft);
}

.term-queue button[aria-current="true"] {
  border-width: 2px;
  background: var(--blue-soft);
  box-shadow: 4px 4px 0 var(--ink);
}

.queue-term-title {
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 800;
}

.queue-term-status {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.term-pane {
  padding: 26px clamp(20px, 3vw, 38px) 42px;
  background: rgb(255 253 248 / 68%);
}

.term-header,
.active-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.term-header {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ink);
}

.term-header h2 {
  font-size: clamp(1.55rem, 2.5vw, 2.25rem);
}

.term-progress {
  margin: 0;
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.section-heading {
  margin: 0 0 14px;
}

.section-heading h3 {
  font-size: 1.1rem;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.wording-grid,
.media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.review-card {
  width: 100%;
  min-width: 0;
  min-height: 138px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.review-card:hover {
  background: #fff;
}

.review-card[aria-current="true"] {
  border-color: var(--blue);
  box-shadow: 5px 5px 0 var(--blue);
}

.review-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.review-card-title {
  font-family: var(--display);
  font-size: 0.83rem;
  font-weight: 800;
}

.review-card-copy {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.92rem;
  line-height: 1.52;
  white-space: pre-wrap;
}

.review-card-meta {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.card-status,
.status-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-family: var(--display);
  font-size: 0.64rem;
  font-weight: 800;
  white-space: nowrap;
  background: var(--paper-deep);
}

.status-approved {
  background: var(--green-soft);
}

.status-needs-revision,
.status-hold,
.status-stale,
.status-reopened {
  background: var(--yellow-soft);
}

.status-pending {
  background: var(--pink-soft);
}

.status-out-of-scope {
  color: var(--muted);
  background: var(--paper-deep);
}

.media-section {
  margin-top: 34px;
  padding-top: 24px;
  border-top: 2px solid var(--ink);
}

.media-grid > div {
  min-width: 0;
}

.media-grid .script-review {
  grid-column: 1 / -1;
}

.term-pane[data-media-first="true"] .media-section {
  margin-top: 0;
  margin-bottom: 28px;
  padding-top: 0;
  padding-bottom: 24px;
  border-top: 0;
  border-bottom: 2px solid var(--ink);
}

.term-pane[data-media-first="true"] .media-grid .script-review {
  grid-column: auto;
}

.visual-card {
  min-height: 420px;
}

.visual-card img {
  width: 100%;
  max-height: 520px;
  display: block;
  border: 1px solid var(--line-soft);
  object-fit: contain;
  background: #fff;
}

.reference-details,
.history-details {
  margin-top: 24px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--paper);
}

.reference-details summary,
.history-details summary {
  padding: 12px 14px;
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.reference-details dl {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) 1fr;
  gap: 8px 16px;
  margin: 0;
  padding: 0 16px 16px;
}

.reference-details dt {
  color: var(--muted);
  font-weight: 800;
}

.reference-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.review-pane {
  border-left: 2px solid var(--ink);
  background: rgb(247 242 232 / 88%);
}

.review-sticky {
  padding: 24px 20px 30px;
}

.active-heading h2 {
  font-size: 1.3rem;
  line-height: 1.15;
}

.assessment {
  margin: 20px 0;
  padding: 14px;
  border: 2px solid var(--ink);
  border-left: 7px solid var(--blue);
  border-radius: 5px;
  background: var(--blue-soft);
}

.assessment h3 {
  margin: 0 0 7px;
  font-family: var(--display);
  font-size: 0.82rem;
}

.assessment p,
.assessment li {
  font-size: 0.8rem;
  line-height: 1.45;
}

.assessment p {
  margin: 0;
}

.assessment ul:empty {
  display: none;
}

.response-field[hidden] {
  display: none;
}

.decision-options {
  display: grid;
  gap: 8px;
}

.decision-options[hidden] {
  display: none;
}

.decision-options button {
  min-height: 48px;
  padding: 9px 11px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  text-align: left;
  background: var(--surface);
  cursor: pointer;
}

.decision-options button:hover,
.decision-options button[aria-pressed="true"] {
  background: var(--green-soft);
}

.decision-options button[data-decision="needs-revision"]:hover,
.decision-options button[data-decision="hold"]:hover,
.decision-options button[aria-pressed="true"][data-decision="needs-revision"],
.decision-options button[aria-pressed="true"][data-decision="hold"] {
  background: var(--yellow-soft);
}

.decision-options strong,
.decision-options small {
  display: block;
}

.decision-options strong {
  font-family: var(--display);
  font-size: 0.78rem;
}

.decision-options small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.35;
}

.request-change {
  width: 100%;
}

.request-change[hidden] {
  display: none;
}

.history-details {
  margin-top: 18px;
  border-width: 1.5px;
  background: var(--surface);
}

#history-list {
  display: grid;
  gap: 10px;
  padding: 0 12px 14px;
}

.history-entry {
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.75rem;
  line-height: 1.45;
}

.history-entry p {
  margin: 3px 0;
}

.autosave {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.75rem;
}

.navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 18px;
  border-top: 2px solid var(--ink);
  color: var(--paper);
  font-size: 0.7rem;
  background: var(--ink);
}

dialog {
  width: min(760px, calc(100vw - 32px));
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 0;
  background: var(--paper);
  box-shadow: 12px 14px 0 rgb(20 25 24 / 35%);
}

dialog::backdrop {
  background: rgb(20 25 24 / 55%);
}

dialog form {
  padding: 22px;
}

dialog h2 {
  margin-top: 0;
  font-family: var(--display);
}

dialog textarea {
  width: 100%;
  margin: 8px 0 16px;
  border: 2px solid var(--ink);
  padding: 10px;
  font: 0.75rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fff;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  font-weight: 700;
  background: var(--yellow-soft);
  box-shadow: 4px 4px 0 var(--ink);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(220px, 0.62fr) minmax(480px, 1.4fr);
    overflow-y: auto;
  }

  .review-pane {
    grid-column: 1 / -1;
    border-top: 2px solid var(--ink);
    border-left: 0;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .header-actions,
  .header-actions .button {
    width: 100%;
  }

  .review-count {
    max-width: none;
    text-align: left;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .queue-pane,
  .term-pane,
  .review-pane {
    width: 100%;
    overflow: visible;
  }

  .queue-pane {
    border-right: 0;
    border-bottom: 2px solid var(--ink);
  }

  .term-queue {
    max-height: 340px;
    overflow-y: auto;
  }

  .term-pane {
    padding: 24px 16px 34px;
  }

  .term-header,
  .active-heading {
    display: grid;
  }

  .term-progress {
    text-align: left;
  }

  .wording-grid,
  .media-grid {
    grid-template-columns: 1fr;
  }

  .media-grid .script-review {
    grid-column: 1;
  }

  .visual-card {
    min-height: 0;
  }

  .reference-details dl {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .reference-details dd {
    margin-bottom: 10px;
  }

  .review-pane {
    border-top: 2px solid var(--ink);
  }

  .app-footer {
    flex-direction: column;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
