:root {
  --text: #19202a;
  --muted: #697386;
  --border: #dfe3e8;
  --bg: #f6f7f9;
  --white: #ffffff;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --ink: var(--text);
  --action: var(--blue);
  --line: var(--border);
  --page: var(--white);
  --subtle: #fafbfc;
  --radius: 7px;
  --radius-card: 10px;
  --review: #a16207;
  --changes: #b91c1c;
  --ok: #166534;
}

* { box-sizing: border-box; }
/* `hidden` must win over any display rule, e.g. the boxer's flex overlay. */
[hidden] { display: none !important; }
html { color-scheme: light; }
h1, h2, h3 { text-wrap: balance; }
a, button, .button, input, select, textarea, label { touch-action: manipulation; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: .5rem .85rem;
  background: var(--blue);
  color: var(--white);
  font-weight: 600;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
}

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

/* —— Top bar —— */
.topbar {
  height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 42px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--text); }
.logo {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: #111827;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 800;
}

.main-nav,
header nav {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 28px;
  margin-right: auto;
  color: var(--muted);
  font-size: .9rem;
  flex-wrap: wrap;
}
.main-nav a,
header nav a {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.main-nav a:hover,
header nav a:hover { color: var(--text); text-decoration: none; }
.main-nav a.active,
header nav a.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--blue);
}

.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  color: var(--white);
  background: var(--blue);
  border-radius: var(--radius-card);
  font-size: .72rem;
  font-weight: 700;
}

.account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
}
.account .ghost.compact {
  min-height: 36px;
  padding: 0 12px;
}
.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: #334155;
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 700;
}
.who { color: var(--text); }
.inline { display: inline; margin: 0; }
button.link,
.link {
  background: none;
  border: 0;
  color: var(--blue);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-weight: 600;
  font-size: .82rem;
}

/* —— Page shell —— */
main {
  width: min(1120px, calc(100% - 40px));
  margin: 38px auto 72px;
}
body.login main {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
body.preview-page main {
  width: min(1400px, calc(100% - 32px));
  margin-top: 24px;
}

.page-narrow { width: min(900px, 100%); margin-left: auto; margin-right: auto; }

.page-head,
.page-heading {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.page-head h1,
.page-heading h1,
h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.2;
  letter-spacing: -.025em;
  font-weight: 700;
}
.page-heading p,
.page-head .lede {
  margin: 6px 0 0;
  color: var(--muted);
}
.back-link {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: .84rem;
}
.back-link:hover { color: var(--text); }
.preview-heading {
  margin: 0 0 10px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.25;
  word-break: break-word;
}

.meta { color: var(--muted); font-size: .84rem; }
.hint { color: var(--muted); font-size: .8rem; }

.empty-panel {
  padding: 36px 28px;
  text-align: center;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
}
.empty-panel > p:first-child {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.empty-panel .meta { margin: 8px 0 0; }
.empty-panel .button,
.empty-panel .empty-actions {
  margin-top: 18px;
}
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* —— Cards / panels —— */
.card,
section.panel,
.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
  margin: 0 0 1.15rem;
  overflow: hidden;
}
.card-heading,
.panel-heading {
  min-height: 72px;
  padding: 18px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}
.card-heading h2,
.panel-heading h2,
section.panel > h2,
.panel > h2,
.review-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.card-heading p,
.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .82rem;
}
.panel-body { padding: 20px 22px; }
.panel > h2 { padding: 18px 22px 0; }
.panel > .meta:first-of-type,
.panel > p.meta { padding: 0 22px; }
section.panel > *:last-child { margin-bottom: 0; }

.card-actions,
.panel-actions {
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  background: #fafbfc;
  border-top: 1px solid var(--border);
}
.panel-actions { justify-content: space-between; }
.panel-actions > span { color: var(--muted); font-size: .75rem; }

/* —— Forms —— */
.form-grid {
  padding: 24px 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label,
form p label {
  display: block;
  margin-bottom: 7px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text);
}
.field small,
form p .helptext,
.helptext {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: .76rem;
}

select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="file"],
textarea {
  width: 100%;
  min-height: 44px;
  padding: .55rem .75rem;
  color: var(--text);
  background: var(--white);
  border: 1px solid #cfd5dd;
  border-radius: var(--radius);
}
textarea { min-height: 96px; resize: vertical; }
select:focus,
input:focus,
textarea:focus {
  border-color: var(--blue);
}
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
  outline: none;
}
.optional {
  color: var(--muted);
  font-weight: 500;
  font-size: .84em;
}
form p { margin: 0 0 1rem; }
.form-card form p { padding: 0 22px; }
.form-card form p:first-of-type { padding-top: 8px; }

.button,
button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: .86rem;
  border: 1px solid #cfd5dd;
  background: var(--white);
  color: var(--text);
  text-decoration: none;
}
.button:hover,
button:hover,
a.button:hover { background: #f8fafc; text-decoration: none; }
button.danger { color: var(--changes); border-color: currentColor; }
button.danger:hover { background: #fef2f2; }
.button.primary,
button.primary,
a.button.primary {
  color: var(--white);
  background: var(--blue);
  border-color: var(--blue);
}
.button.primary:hover,
button.primary:hover,
a.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: var(--text); background: var(--white); border: 1px solid #cfd5dd; }
.button.ghost,
button.ghost {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}
.button.ghost:hover,
button.ghost:hover {
  color: var(--text);
  background: #f1f5f9;
}
.button.compact,
button.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: .8rem;
}
button:disabled,
.button:disabled,
a.button:disabled,
button[disabled] {
  opacity: .55;
  cursor: not-allowed;
}
.take.chosen button:disabled {
  opacity: 1;
  color: var(--blue-dark);
  background: var(--blue-light);
  border-color: #bfdbfe;
  cursor: default;
}

.upload-box {
  margin: 22px;
  min-height: 200px;
  padding: 36px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px dashed #b9c1cc;
  border-radius: var(--radius-card);
  background: #fafbfc;
}
.upload-symbol {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: 50%;
  font-size: 1.3rem;
}
.upload-box h3 { margin: 0; font-size: .98rem; }
.upload-box p { margin: 5px 0 18px; color: var(--muted); font-size: .82rem; }

.note {
  margin: 0 22px 22px;
  padding: 14px 16px;
  border-left: 3px solid var(--blue);
  background: var(--blue-light);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.note strong { display: block; font-size: .82rem; }
.note p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }

.msg {
  background: var(--blue-light);
  border: 1px solid #bfdbfe;
  padding: .65rem .85rem;
  border-radius: var(--radius);
  font-size: .86rem;
  margin: 0 0 1rem;
}
.msg.error,
.error {
  color: var(--changes);
}
.msg.error {
  background: #fef2f2;
  border-color: #fecaca;
}

.login-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
  padding: 1.75rem;
  width: 100%;
  max-width: 22rem;
}
.login-box h1 { font-size: 1.35rem; margin-bottom: .75rem; }
.login-box form p { margin: .75rem 0 0; }
.login-box input { width: 100%; }
.login-box button[type="submit"] { width: 100%; margin-top: 1rem; }

/* —— Filters / tables —— */
.filters {
  display: flex;
  gap: .75rem 1rem;
  margin: 0 0 1.15rem;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 18px 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 10rem;
  flex: 1;
}
.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}
.filter-field select { width: 100%; min-height: 40px; }
.filter-actions { display: flex; gap: .75rem; align-items: center; min-height: 40px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
}
th, td {
  text-align: left;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
th {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #fafbfc;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fafc; }
.panel table,
.card table {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* —— Status —— */
.status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
  background: #f1f3f5;
}
.status.card_review,
.status.footage_review,
.status.queued,
.status.running { color: #92400e; background: #fef3c7; }
.status.card_changes,
.status.failed,
.status.needs_labels { color: #991b1b; background: #fee2e2; }
.status.approved { color: #166534; background: #dcfce7; }
/* Waiting on the owner to choose takes -- their move, not a reviewer's. */
.status.clips { color: #1d4ed8; background: #eff6ff; }
.status.accepted,
.status.labelled,
.status.done { color: #166534; background: #dcfce7; }
/* Labelling after acceptance: the owner's move, like choosing takes. */
.status.transcript,
.status.frames,
.status.boxes { color: #1d4ed8; background: #eff6ff; }
.status.uploaded { color: #1e3a5f; background: #e8eef7; }
.status.missing { color: var(--muted); background: #f1f3f5; }

/* —— Scene detail —— */
.scene-title-row {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
}
.scene-title-row .lede { margin: 8px 0 0; color: var(--muted); }
.title-with-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.flow,
.workflow-tabs,
.fw-steps {
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
}
.flow li,
.fw-steps li {
  padding: 8px 13px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
}
.flow li.current,
.fw-steps li.current {
  color: var(--text);
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}
.flow li.done,
.fw-steps li.done {
  color: var(--ok);
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.next-step {
  margin-bottom: 24px;
  padding: 13px 16px;
  color: #334155;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .86rem;
}
.next-step strong { color: var(--text); }

/* —— Next step: the one thing to do, and the button that does it —— */
.next-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid #cbd5e1;
  border-radius: var(--radius-card);
}
.next-action.is-yours {
  background: var(--blue-light);
  border-color: #bfdbfe;
  border-left-color: var(--blue);
}
.next-action-step {
  margin: 0;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.next-action.is-yours .next-action-step { color: var(--blue-dark); }
.next-action-text { margin: 4px 0 0; font-size: .95rem; color: var(--text); }
.next-action form { margin: 0; }
.next-action .button,
.next-action button { flex-shrink: 0; gap: 8px; white-space: nowrap; min-height: 44px; padding: 0 20px; }

/* A labelling page's continue button stays in reach down a long task list. */
.panel.actions.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 1rem -12px 0;
  padding: 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--border);
}
html { scroll-padding-bottom: 88px; }

@media (max-width: 640px) {
  .next-action { flex-direction: column; align-items: stretch; }
  .next-action .button, .next-action button { width: 100%; }
}

.clip-progress .card-heading {
  align-items: center;
}
.clip-timing {
  margin: 0 0 .5rem;
  font-size: .95rem;
}
.clip-timing-list {
  margin: .75rem 0 0;
  padding-left: 1.15rem;
  line-height: 1.55;
}
.clip-timing-list li { margin: .15rem 0; }

.detail-grid,
.scene-layout,
.fw-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .75fr);
  gap: 20px;
  align-items: start;
  margin-top: 0;
}
.detail-grid-single { grid-template-columns: 1fr; }
.detail-main,
.detail-side,
.scene-main,
.fw-content { min-width: 0; display: grid; gap: 20px; align-content: start; }

.source-file {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.source-file a { color: var(--blue); font-size: .87rem; font-weight: 600; }
.source-file small { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; }
.file-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: var(--radius);
  font-size: .62rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* —— POV uploads (footage reference look) —— */
.fw-section-heading {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}
.fw-section-heading h2 { margin: 0; font-size: .98rem; }
.fw-section-heading p {
  max-width: 690px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.55;
}

table.pov-slots {
  width: 100%;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}
table.pov-slots th,
table.pov-slots td {
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  vertical-align: middle;
}
table.pov-slots tr:last-child th,
table.pov-slots tr:last-child td { border-bottom: 0; }
table.pov-slots th {
  width: 180px;
  background: transparent;
  text-transform: none;
  letter-spacing: 0;
  font-size: .84rem;
  font-weight: 700;
  color: var(--text);
}
.pov-state .meta { font-size: .75rem; }
/* File pickers: a dashed drop area with the site's own button, instead of
   the browser's grey one. The "No file chosen" text is the browser's. */
input[type="file"] {
  padding: 8px;
  color: var(--muted);
  font-size: .84rem;
  background: var(--subtle);
  border: 1.5px dashed #cbd5e1;
  cursor: pointer;
}
input[type="file"]:hover { border-color: var(--blue); background: var(--blue-light); }
input[type="file"]:disabled { cursor: progress; opacity: .6; }
input[type="file"]::file-selector-button {
  margin-right: 12px;
  min-height: 34px;
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  color: var(--blue-dark);
  background: var(--white);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--blue-light); }
.pov-file { min-height: 40px; padding: 4px; }
.upload-box input[type="file"] { border-style: solid; background: var(--white); }
.pov-file::file-selector-button { min-height: 30px; }

/* —— Review panel —— */
.review-panel { position: sticky; top: 20px; margin: 0; }
.review-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.comment-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  padding: 16px 18px;
}
.comment-empty {
  margin: 0;
  padding: 12px 4px;
  text-align: left;
  color: var(--muted);
  font-size: .84rem;
}
.comment {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbfc;
  padding: .7rem .75rem;
}
.comment.resolved {
  background: #fff;
  border-style: dashed;
}
.comment-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
  margin-bottom: .35rem;
}
.track-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--blue);
  background: var(--blue-light);
  border: 1px solid #dbeafe;
  border-radius: 999px;
  padding: .1rem .45rem;
}
.status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--ok);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: .1rem .45rem;
  margin-left: auto;
}
.comment-meta { color: var(--muted); font-size: 12px; }
.comment-body { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text); }
.comment.reply {
  margin: .55rem 0 0;
  padding: .55rem .65rem;
  border-left: 2px solid #bfdbfe;
  background: #fff;
}
.reply-form,
.comment-compose {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-top: .55rem;
  align-items: stretch;
}
.comment-compose {
  margin: 0;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
.compose-track {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.reply-form textarea,
.comment-compose textarea,
.comment-compose select { width: 100%; }
.comment-compose button { align-self: flex-start; }

.actions.panel {
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
  margin-top: 1rem;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  overflow: visible;
}
.actions.panel form {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* —— Preview page —— */
.preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .75rem;
  margin: 0 0 .85rem;
}
.preview-name { color: var(--text); font-weight: 600; }
.preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 1rem;
  align-items: stretch;
}
.preview-layout-single { grid-template-columns: 1fr; }
.preview-doc,
.preview-comments { min-width: 0; }
.preview-comments {
  position: sticky;
  top: .75rem;
  align-self: start;
  max-height: calc(100vh - 5.5rem);
  overflow: auto;
}
.preview-comments .review-panel { min-height: calc(100vh - 6.5rem); display: flex; flex-direction: column; }
.preview-comments .comment-list { flex: 1; overflow: auto; }
.preview-comments .comment-compose { margin-top: auto; }

.file-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 6.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: #fff;
}
.file-image { max-width: 100%; overflow: auto; max-height: calc(100vh - 6.5rem); }
.file-image img {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: #fff;
}
.file-docx {
  background: #eceff3;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: .65rem;
  overflow: auto;
  height: calc(100vh - 6.5rem);
}
.file-docx .docx-wrapper { background: transparent !important; padding: 0 !important; width: 100% !important; }
.file-docx .docx-wrapper > section.docx {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
  margin: 0 auto .65rem !important;
  padding: 1.1rem 1.35rem !important;
  width: 100% !important;
  max-width: none !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

article { line-height: 1.55; }
article p { margin: 0 0 .75rem; }
article.comment p { margin: 0; }
pre.ledger {
  white-space: pre-wrap;
  font-size: .82rem;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
}

/* —— Guide: every section open, read top to bottom —— */
.guide-sections { display: grid; gap: 20px; }
.guide-section { margin: 0; scroll-margin-top: 16px; }
.guide-section .card-heading h2 { font-size: 1.2rem; }
.prose { font-size: .95rem; line-height: 1.65; max-width: 860px; }
.prose > :first-child { margin-top: 0; }
.prose h3 { margin: 1.6rem 0 .5rem; font-size: 1rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 .85rem; }
.prose li { margin: .2rem 0; }
.prose li::marker { color: var(--muted); }
.prose code { padding: 1px 5px; font-size: .88em; background: var(--bg); border-radius: 4px; }
.prose table { margin: .5rem 0 1.25rem; font-size: .88rem; box-shadow: none; }
.prose th, .prose td { padding: .55rem .8rem; }
.prose table { border: 1px solid var(--border); border-radius: var(--radius); }
.prose em { color: var(--muted); }
.prose img { max-width: 100%; height: auto; display: block; }
.guide-examples {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: .75rem 0 1rem;
}
.guide-example { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; background: var(--white); }
.guide-example img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.guide-example figcaption { padding: 10px 12px 12px; font-size: .86rem; line-height: 1.5; border-top: 3px solid; }
.guide-example figcaption strong { display: block; margin-bottom: 2px; text-transform: uppercase; font-size: .72rem; letter-spacing: .05em; }
.guide-example.is-do figcaption { border-top-color: #22c55e; }
.guide-example .fs-btn { margin: 8px 0 0; }
.guide-example.is-do strong { color: var(--ok); }
.guide-example.is-dont figcaption { border-top-color: #ef4444; }
.guide-example.is-dont strong { color: var(--changes); }
.prose { max-width: none; }
.prose > :not(.guide-examples) { max-width: 860px; }

.guide-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
}
.guide-list li { border-bottom: 1px solid var(--border); }
.guide-list li:last-child { border-bottom: 0; }
.guide-list a {
  display: block;
  padding: 1rem 1.15rem;
  color: var(--text);
  font-weight: 600;
}
.guide-list a:hover { background: #f8fafc; text-decoration: none; }
.guide-list .meta { padding: 1rem 1.15rem; }

@media (max-width: 960px) {
  .detail-grid,
  .scene-layout,
  .fw-layout,
  .preview-layout { grid-template-columns: 1fr; }
  .review-panel,
  .preview-comments { position: static; max-height: none; }
  .preview-comments .review-panel { min-height: 0; }
  .file-docx,
  .file-frame { height: 70vh; }
}

@media (max-width: 760px) {
  /* Wide tables scroll sideways instead of being clipped. */
  table { display: block; overflow-x: auto; white-space: nowrap; }
  /* The menu moves to its own scrolling row instead of disappearing. */
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 18px 0; gap: 0 16px; }
  .main-nav {
    order: 3; width: 100%; height: 44px; margin: 0;
    flex-wrap: nowrap; gap: 22px; overflow-x: auto; white-space: nowrap;
  }
  .account .who { display: none; }
  main { width: min(100% - 28px, 620px); margin-top: 28px; }
  .page-head, .page-heading, .scene-title-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: 1; }
  /* One scrolling row, so the next step stays near the top of the page. */
  .flow, .fw-steps { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .flow li, .fw-steps li { flex: none; white-space: nowrap; }
}

@media (max-width: 480px) {
  .title-with-status { flex-direction: column; align-items: flex-start; gap: 8px; }
  .panel-actions, .card-actions { flex-direction: column; align-items: stretch; }
  .button, button, a.button { width: 100%; }
  .account button, .fs-btn { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Take picker -------------------------------------------------------
   One block per proposed take, ranked. The tier stripe is what the eye
   should land on first: the recommendation is usually the right answer and
   is already selected, so the page should read as "confirm", not "decide". */

.take-list {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.take {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--page);
}

.take.tier-1 { border-left-color: var(--ok); }
.take.tier-2 { border-left-color: var(--blue); }
.take.tier-3 { border-left-color: var(--review); }

.take.chosen {
  background: var(--blue-light);
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}
.take.chosen .status-pill {
  color: var(--blue-dark);
  background: #fff;
  border-color: #bfdbfe;
  margin-left: 0;
}

.take-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.tier-badge {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}

.tier-badge.tier-1 { background: #dcfce7; color: var(--ok); }
.tier-badge.tier-2 { background: var(--blue-light); color: var(--blue-dark); }
.tier-badge.tier-3 { background: #fef3c7; color: var(--review); }

.take video,
.clip video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

/* A clip or frame whose file isn't in storage (see fullscreen.js). */
.media-missing {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: .85rem;
}

.take form { margin-top: 10px; }
.take p { margin: 6px 0; }

/* ---- Final clips ------------------------------------------------------- */

.clip-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-bottom: 20px;
}

.clip { margin: 0; }

.clip figcaption {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 5px;
}

#final-clips h3 {
  margin: 14px 0 8px;
  font-size: .95rem;
}

/* ---- Labelling: transcript, frames, boxes ------------------------------ */

.label-transcript-row {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 360px) 1fr;
  align-items: start;
}
.label-transcript-row textarea { width: 100%; }

.frame-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.frame-option { margin: 0; position: relative; }
.fs-btn { min-height: 30px; padding: 0 10px; font-size: .78rem; margin-left: .5rem; }
.take .fs-btn { margin: .4rem 0 0; }
.frame-option .fs-btn {
  position: absolute; top: 8px; right: 8px; width: auto; margin: 0;
  min-height: 28px; padding: 0 8px; color: #fff; background: rgba(0, 0, 0, .6); border: 0;
}
.frame-option .fs-btn:hover { background: rgba(0, 0, 0, .8); }
img:fullscreen { width: 100%; height: 100%; object-fit: contain; background: #000; }
.frame-option button {
  width: 100%;
  padding: 4px;
  display: grid;
  gap: 4px;
  text-align: left;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.frame-option button:disabled { cursor: default; opacity: 1; }
.frame-option img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  background: #000;
  display: block;
}
.frame-option.chosen button {
  background: var(--blue-light);
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}
.frame-upload { max-width: 360px; margin-top: 12px; }
.frame-upload img { width: 100%; border-radius: var(--radius); display: block; }
.frame-upload-row { display: grid; gap: 8px; margin: 16px 0 0; }
.frame-upload-row label { font-size: .86rem; font-weight: 600; }
.frame-upload-row .optional { display: block; font-weight: 400; font-size: .8rem; }

.boxer {
  display: grid;
  gap: 16px;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: start;
  margin-bottom: 16px;
}
.boxer-tasks { display: grid; gap: 4px; padding: 0 12px 12px; }
.boxer-task {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: left;
}
.boxer-task:hover { background: var(--subtle); }
.boxer-task.current { color: var(--blue-dark); background: var(--blue-light); border-color: var(--blue); }
.boxer-task .tag { color: var(--muted); font-size: .8rem; }
.boxer-task .tag.done { color: var(--ok); }
.boxer-instruction { font-size: 1.05rem; margin: 2px 0 10px; }
.boxer-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  user-select: none;
  cursor: crosshair;
  touch-action: none;
}
.boxer-stage img { max-width: 100%; max-height: 68vh; display: block; border-radius: var(--radius); }
.boxer-rect,
.boxer-thumb-rect {
  position: absolute;
  border: 3px solid #22c55e;
  background: rgba(34, 197, 94, .14);
  /* A dark edge so the box reads on bright and dark footage alike. */
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .35);
  pointer-events: none;
}
.boxer-thumb-rect { border-width: 2px; }
.boxer-nv {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius);
  pointer-events: none;
}
.boxer-coords { font-variant-numeric: tabular-nums; }
.boxer-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.boxer .field input[type=text] { width: 100%; }

.label-summary {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.boxer-thumb { position: relative; line-height: 0; }
.boxer-thumb img { width: 100%; border-radius: var(--radius); display: block; }

@media (max-width: 760px) {
  .label-transcript-row,
  .boxer { grid-template-columns: 1fr; }
}

/* —— Dashboard —— */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.chart {
  padding: 18px 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.chart h2 { font-size: 1rem; margin: 0 0 .75rem; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.bars a {
  display: grid;
  grid-template-columns: minmax(6rem, 35%) 1fr 2.5rem;
  align-items: center;
  gap: .6rem;
  color: var(--text);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--radius);
}
.bars a:hover, .bars a:focus-visible { background: var(--blue-light); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.bar-track { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--blue); border-radius: 6px; }
.bar-count { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
