:root {
  --bg: #F5F7FB; --surface: #FFFFFF; --surface-2: #F0F4FA; --ink: #0F1B2D; --muted: #5A6A80; --line: #E1E7F0;
  --blue: #2563EB; --blue-ink: #1D4ED8; --blue-soft: #EAF1FE; --on-blue: #FFFFFF;
  --ok: #15803D; --ok-soft: #E8F6EE; --warn: #B45309; --warn-soft: #FEF3E2; --bad: #B91C1C; --bad-soft: #FDECEC;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 6px 24px rgba(15, 27, 45, .06);
  --r: 16px; --f: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;   /* always light, also when the computer or phone is set to dark */
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--f); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.hidden { display: none !important; }

/* ---------- buttons, fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; font-size: 15px;
  cursor: pointer; text-decoration: none; color: var(--ink); transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--blue); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.primary:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 2px; }
label.f { display: block; font-weight: 700; font-size: 14px; margin: 16px 0 6px; }
label.f small { font-weight: 500; color: var(--muted); }
.input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 16px; }
.input:focus { border-color: var(--blue); outline: none; }
textarea.input { min-height: 84px; resize: vertical; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 380px; }
.brandmark { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.brandmark img { width: 36px; height: 36px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 8px 0 0; }

/* ---------- shell: sidebar list + main, one column on phones ---------- */
.shell { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; }
.side { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 18px 18px 12px; display: flex; flex-direction: column; gap: 14px; border-bottom: 1px solid var(--line); }
.side-head .row { display: flex; align-items: center; justify-content: space-between; }
.list { overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.item { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px; border-radius: 12px;
  text-decoration: none; color: inherit; border: 1.5px solid transparent; }
.item:hover { background: var(--surface-2); }
.item.on { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.item .thumb { width: 44px; height: 56px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.item .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 28px 16px; text-align: center; font-size: 15px; }
.side-foot { padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.meter { display: flex; align-items: center; gap: 8px; }
.meter i { display: block; width: 70px; height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.meter i b { display: block; height: 100%; background: var(--blue); }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; font-size: 13px; }
.linkbtn:hover { color: var(--ink); }
main { min-width: 0; overflow-y: auto; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 28px 40px; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.working, .chip.queued { background: var(--blue-soft); color: var(--blue-ink); }
.chip.waiting { background: var(--warn-soft); color: var(--warn); }
.chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.error { background: var(--bad-soft); color: var(--bad); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.working .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- pages ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.top h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; }
.top .sub { color: var(--muted); font-size: 14px; margin-top: 4px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.back { display: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; }
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card .hint { color: var(--muted); font-size: 14px; margin: 0; }

/* new reel */
.newgrid { max-width: 640px; }
.drop { display: block; border: 2px dashed var(--line); border-radius: var(--r); padding: 28px 16px; text-align: center; cursor: pointer; background: var(--surface-2);
  transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop strong { display: block; font-size: 16px; }
.drop span { color: var(--muted); font-size: 14px; }
.bar { height: 10px; border-radius: 10px; background: var(--surface-2); overflow: hidden; margin: 14px 0 6px; }
.bar b { display: block; height: 100%; width: 0; background: var(--blue); transition: width .3s; }
.barlabel { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* reel page: chat on the left, the video and actions on the right */
.reel { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.panel { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; }
.status { display: flex; flex-direction: column; gap: 10px; }
.status .now { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--blue-soft); border-top-color: var(--blue); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.steps li { display: flex; gap: 8px; }
.steps li::before { content: "✓"; color: var(--ok); font-weight: 700; }
.steps li:last-child { color: var(--ink); }
.steps li:last-child::before { content: "•"; color: var(--blue); }
.video { border-radius: var(--r); overflow: hidden; background: #000; aspect-ratio: 9 / 16; max-height: 70vh; margin: 0 auto; width: 100%; }
.video video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.vlabel { font-size: 13px; color: var(--muted); text-align: center; margin-top: 6px; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chat { display: flex; flex-direction: column; min-height: 60vh; }
.msgs { display: flex; flex-direction: column; gap: 14px; padding-bottom: 16px; }
.msg { max-width: 92%; padding: 12px 16px; border-radius: 16px; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--blue); color: var(--on-blue); border-bottom-right-radius: 6px; }
.msg.claude { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
.msg.system { align-self: center; background: var(--surface-2); color: var(--muted); font-size: 14px; text-align: center; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg time { display: block; font-size: 11px; opacity: .6; margin-top: 6px; }
.composer { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 18px); padding-top: 18px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer form { display: flex; gap: 10px; align-items: flex-end; background: var(--surface); border: 1.5px solid var(--line); border-radius: 18px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow); }
.composer form:focus-within { border-color: var(--blue); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; min-height: 28px; max-height: 160px; padding: 8px 0; font-size: 16px; }
.composer .btn { min-height: 40px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.quick button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.quick button:hover { border-color: var(--blue); color: var(--blue-ink); }

/* sidebar: nav, client filter, groups */
.nav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.nav a { text-align: center; padding: 8px 6px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); text-decoration: none; }
.nav a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.input.sm { min-height: 40px; padding: 6px 10px; font-size: 14px; }
.group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.ghead { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px 2px; display: flex; gap: 6px; }
.ghead span { background: var(--surface-2); border-radius: 999px; padding: 0 7px; letter-spacing: 0; }
.item .n { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb.you { background: var(--warn-soft); color: var(--warn); font-weight: 800; }
.thumb.busy { background: var(--blue-soft); }
.thumb.done { background: var(--ok-soft); color: var(--ok); font-weight: 800; }
.spin.sm { width: 14px; height: 14px; border-width: 2px; }
.spin.idle { animation-duration: 2.4s; opacity: .6; }

/* home */
.home { max-width: 820px; display: flex; flex-direction: column; gap: 16px; }
.home .top { margin-bottom: 0; align-items: center; }
.todos { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.todo { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  text-decoration: none; color: inherit; }
.todo:hover { border-color: var(--blue); background: var(--blue-soft); }
.todo .t { font-weight: 700; } .todo .s { font-size: 13px; color: var(--muted); }
.todo .n { font-weight: 700; color: var(--blue-ink); font-size: 14px; text-align: right; }
.howsteps { list-style: none; counter-reset: s; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.howsteps li { counter-increment: s; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.howsteps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-ink); font-weight: 800; display: grid; place-items: center; }
.howsteps b { color: var(--ink); }

/* reel: steps, the "what now" card, chat */
.stepper { list-style: none; margin: -6px 0 20px; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--muted); padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface-2); }
.stepper li span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: var(--surface); }
.stepper li.done { color: var(--ok); } .stepper li.done span { background: var(--ok-soft); }
.stepper li.cur { background: var(--blue); color: var(--on-blue); } .stepper li.cur span { background: var(--on-blue); color: var(--blue); }
.card.now { display: flex; flex-direction: column; gap: 10px; border-width: 2px; }
.card.now.you { border-color: var(--warn); }
.card.now.busy { border-color: color-mix(in srgb, var(--blue) 45%, transparent); }
.card.now.done { border-color: var(--ok); }
.card.now.bad { border-color: var(--bad); margin-bottom: 12px; }
.card.now .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kicker { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--warn); margin-bottom: -6px; }
.nowhead { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; line-height: 1.3; }
.activity summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--muted); }
.activity .steps { margin-top: 8px; }
.btn.quiet { border-color: transparent; background: var(--surface-2); font-weight: 600; }
.chathead { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.chathint { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 0; }
.chathint:empty { display: none; }
.msg.pending { opacity: .7; }
.msg.user time { opacity: .85; }

@media (min-width: 861px) {   /* desktop: steps and the "what now" card stay in view; only the chat scrolls */
  .shell.inreel main { overflow: hidden; }
  .shell.inreel .wrap { height: 100%; display: flex; flex-direction: column; padding-bottom: 16px; }
  .shell.inreel .reel { flex: 1; min-height: 0; }
  .reel .chat { height: 100%; min-height: 0; }
  .reel .msgs { flex: 1; overflow-y: auto; padding-right: 6px; }
  .reel .panel { max-height: 100%; overflow-y: auto; padding-bottom: 4px; }
  .reel .video { max-height: 52vh; }
}

/* reference reels */
.refs { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.refs:empty { display: none; }
.ref { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.ref .t { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref .s { font-size: 13px; color: var(--muted); }
.ref .linkbtn { font-size: 16px; padding: 6px 10px; }
.rthumb { width: 54px; height: 72px; border-radius: 8px; background: var(--surface-2) center / cover; display: grid; place-items: center; }
.attach { display: grid; place-items: center; width: 36px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 18px; flex: none; }
.attach:hover { background: var(--surface-2); }
.composer form { padding-left: 8px; }

/* clients and their brand images */
.stack { max-width: 760px; display: flex; flex-direction: column; gap: 16px; }
.stack .top { margin-bottom: 4px; }
.stack .drop { margin-top: 14px; padding: 18px 16px; }
.clist { display: flex; flex-direction: column; gap: 6px; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.inline .input { flex: 1; min-width: 200px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 14px; }
.tile { position: relative; aspect-ratio: 4 / 5; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.assets img { object-fit: contain; padding: 8px; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.tile button { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(15, 27, 45, .72);
  color: #fff; font-size: 14px; cursor: pointer; display: grid; place-items: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.swatch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.swatch i { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); }
.swatch code { color: var(--ink); }
.brandmd { margin-top: 14px; }
.brandmd summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.mdtext { font-size: 14px; margin-top: 10px; } .mdtext p { margin: 0 0 8px; } .mdtext ul { margin: 4px 0 8px; padding-left: 20px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 9; box-shadow: var(--shadow); }

/* ---------- tablet / phone ---------- */
@media (max-width: 1100px) { .reel { grid-template-columns: minmax(0, 1fr) 320px; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .shell.inreel .side { display: none; }
  .shell:not(.inreel) main { display: none; }
  .shell.newpage main { display: block; } .shell.newpage .side { display: none; }
  .side { border-right: 0; min-height: 100%; }
  .wrap { padding: 16px 16px 24px; }
  .back { display: inline-flex; }
  .top { flex-direction: column; gap: 8px; margin-bottom: 14px; }
  .top h1 { font-size: 22px; }
  .reel { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .panel { position: static; order: -1; }
  .video { max-height: 62vh; width: auto; }
  .chat { min-height: 0; }
  .howsteps { grid-template-columns: minmax(0, 1fr); }
  .home .top { align-items: flex-start; }
}
#pnow:empty, #pvid:empty { display: none; }
