/* Content library viewer. Phone first; plain system type; colour tokens with a dark set. Operate mode: clear and fast. */

:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #efefea;
  --text: #1c1d1f;
  --muted: #595c61;
  --line: #d9d9d2;
  --accent: #1d56cf;
  --accent-hover: #1645a8;
  --on-accent: #ffffff;
  --focus: #1d56cf;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --chip-draft-bg: #e9e9e6;
  --chip-draft: #3f4145;
  --chip-in_review-bg: #fdefcf;
  --chip-in_review: #6e4300;
  --chip-approved-bg: #d9f1e1;
  --chip-approved: #155c30;
  --chip-scheduled-bg: #dee8ff;
  --chip-scheduled: #1a479e;
  --chip-posted-bg: #ece1fa;
  --chip-posted: #552a87;
  --radius: 10px;
  --gutter: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 100%;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #131416;
    --surface: #1c1e21;
    --surface-2: #26292d;
    --text: #ececea;
    --muted: #a9acb1;
    --line: #363a3f;
    --accent: #8ab0ff;
    --accent-hover: #adc8ff;
    --on-accent: #0b1730;
    --focus: #8ab0ff;
    --danger: #ff9b92;
    --danger-bg: #3a1d1b;
    --chip-draft-bg: #33363a;
    --chip-draft: #dcdcd8;
    --chip-in_review-bg: #463410;
    --chip-in_review: #ffd98a;
    --chip-approved-bg: #173b25;
    --chip-approved: #9be3b4;
    --chip-scheduled-bg: #1c2d52;
    --chip-scheduled: #b3cbff;
    --chip-posted-bg: #33224a;
    --chip-posted: #dcc4ff;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h1:focus { outline: none; }
p { margin: 0 0 12px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 8px; top: -48px; z-index: 10; padding: 8px 12px; background: var(--surface); border-radius: var(--radius); }
.skip:focus { top: 8px; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar { max-width: 1100px; margin: 0 auto; padding: 0 var(--gutter); min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; padding: 12px 0; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .link-button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 8px;
  font: inherit; font-size: 0.9375rem; color: var(--accent); background: none; border: 0; cursor: pointer; text-decoration: none;
}
.nav a:hover, .link-button:hover { background: var(--surface-2); }
.who { max-width: 1100px; margin: -6px auto 0; padding: 0 var(--gutter) 8px; font-size: 0.8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { display: block; max-width: 1100px; margin: 0 auto; padding: 20px var(--gutter) 48px; }
main:focus { outline: none; }
.loading, .empty, .muted { color: var(--muted); }
.lede { color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: -8px 0 4px; text-decoration: none; font-size: 0.9375rem; }
.back:hover { text-decoration: underline; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; padding: 0 16px;
  font: inherit; font-size: 0.9375rem; font-weight: 600; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-align: left;
}
.button:hover { background: var(--surface-2); }
.button:disabled { opacity: 0.6; cursor: progress; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-hover); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.notice { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); }
.notice-error { background: var(--danger-bg); color: var(--danger); }
.notice p:last-child { margin-bottom: 0; }
.notice .button { margin-top: 8px; }
.command { padding: 12px; overflow-x: auto; background: var(--surface-2); border-radius: var(--radius); font-size: 0.875rem; }

/* Sign-in */
.signin { max-width: 420px; margin: 12vh auto 0; text-align: center; }
.signin .button { width: 100%; justify-content: center; margin-top: 8px; }

/* Lists of links (clients, campaigns) */
.rows { list-style: none; margin: 8px 0 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.rows li + li { border-top: 1px solid var(--line); }
.row { display: flex; flex-direction: column; justify-content: center; min-height: 56px; padding: 10px 14px; color: var(--text); text-decoration: none; }
.row:hover { background: var(--surface-2); }
.row-title { font-weight: 600; }
.row-meta { font-size: 0.875rem; color: var(--muted); }

/* Filters and the campaign panel */
.filters { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 16px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 140px; max-width: 240px; }
.field label { font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px;
}
select { min-height: 44px; }
.panel { margin: 0 0 20px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.disclosure { padding: 0 14px; }
.disclosure > summary { display: flex; align-items: center; min-height: 52px; cursor: pointer; list-style-position: inside; }
.disclosure > summary .summary-title { font-weight: 700; margin-left: 4px; }
.disclosure[open] > summary { margin-bottom: 4px; }
.disclosure[open] { padding-bottom: 14px; }
.button.more { margin-top: 12px; }
.files { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.button.file { font-weight: 500; }

/* Status chips: the word carries the meaning, colour only helps */
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; background: var(--chip-draft-bg); color: var(--chip-draft); }
.chip-in_review { background: var(--chip-in_review-bg); color: var(--chip-in_review); }
.chip-approved { background: var(--chip-approved-bg); color: var(--chip-approved); }
.chip-scheduled { background: var(--chip-scheduled-bg); color: var(--chip-scheduled); }
.chip-posted { background: var(--chip-posted-bg); color: var(--chip-posted); }

/* Piece grid */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; height: 100%; overflow: hidden; color: var(--text); text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card:hover { border-color: var(--muted); }
.card img, .cover-missing { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; background: var(--surface-2); }
.card-body { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 10px; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.code { font-size: 0.8125rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hook { font-size: 0.875rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 0.75rem; color: var(--muted); }

/* One piece */
.piece-title { overflow-wrap: anywhere; }
.piece-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pager { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0 16px; }
.pager .button { text-decoration: none; }
.piece-layout { display: grid; gap: 16px; }
.preview { display: flex; flex-direction: column; gap: 10px; }
.preview video { display: block; width: 100%; max-height: 72vh; aspect-ratio: 9 / 16; object-fit: contain; background: #000; border-radius: var(--radius); }
.piece-side { display: flex; flex-direction: column; gap: 16px; }
.piece-side .panel { margin: 0; }
.caption { margin: 0 0 12px; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 0.9375rem; background: var(--surface-2); border-radius: 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.facts dt { font-size: 0.875rem; color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.score-block + .score-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.score-block h3 { font-size: 1rem; }

/* Segmented radio groups (version, verdict): real radios, styled as buttons */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; border: 0; }
.segmented legend { width: 100%; margin-bottom: 6px; padding: 0; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; cursor: pointer; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.segmented input:checked + label { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

.review-form textarea { display: block; width: 100%; min-height: 88px; margin: 4px 0 8px; padding: 10px; resize: vertical; }
.field-label { font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.form-error { color: var(--danger); margin: 0 0 8px; }
.form-error:empty { display: none; }
.reviews { list-style: none; margin: 0; padding: 0; }
.reviews li + li { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.review-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 0.875rem; }
.review-notes { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.verdict { padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: var(--chip-draft-bg); color: var(--chip-draft); }
.verdict-good { background: var(--chip-approved-bg); color: var(--chip-approved); }
.verdict-ok { background: var(--chip-in_review-bg); color: var(--chip-in_review); }
.verdict-bad { background: var(--danger-bg); color: var(--danger); }
.status-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }

/* Asset library */
.library-files section { margin-top: 20px; }
.thumbs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.thumb { display: block; overflow: hidden; border-radius: 8px; background: var(--surface-2); }
.thumb img, .thumb.cover-missing { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.file-rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.file-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; }
.file-row + .file-row { border-top: 1px solid var(--line); }
.file-name { overflow-wrap: anywhere; font-size: 0.9375rem; }
.file-row video { width: 100%; max-height: 60vh; background: #000; border-radius: 8px; }

@media (min-width: 720px) {
  h1 { font-size: 1.75rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
}

@media (min-width: 900px) {
  .piece-layout { grid-template-columns: minmax(280px, 380px) 1fr; align-items: start; }
  .preview { position: sticky; top: 16px; }
}

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