:root {
  --bg: #020e13;
  --card: #06262e;
  --text: #e6f4f7;
  --dim: #7fa3ad;
  --accent: #fcee23;
  --keep: #34d399;
  --skip: #f87171;
  --line: rgba(252,238,35,.14);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
h1 { font-size: 24px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 24px 0 10px; }
.dim { color: var(--dim); font-weight: 400; }
.err { color: var(--skip); }
button, .pick { font: inherit; border: 0; border-radius: 14px; padding: 12px 18px; cursor: pointer; color: var(--text); background: var(--card); }
button:disabled { opacity: .35; }
.primary { background: var(--accent); color: #1a0d08; font-weight: 600; }
#v-home.dropping { outline: 3px dashed var(--accent); outline-offset: -8px; border-radius: 14px; }
@media (hover: none) { .drop-hint { display: none; } }
.danger { background: var(--skip); color: #1a0508; font-weight: 600; }
.link { background: none; padding: 8px 4px; color: var(--accent); }
.big { display: block; text-align: center; font-size: 18px; padding: 18px; margin-top: 8px; }
input[type=password], input[type=email], #join-code, .sform input, .sform select, #hook-new { width: 100%; font: inherit; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); margin-bottom: 12px; }
.row { display: flex; gap: 12px; justify-content: center; }

.view { min-height: 100%; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 70vh; gap: 12px; }
.center form { width: 100%; max-width: 320px; }
.logo { width: 88px; height: 88px; }
.bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.status { background: var(--card); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; font-size: 14px; }
.status button { padding: 4px 10px; margin-left: 8px; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding-bottom: 24px; }
.grid .tile { aspect-ratio: 9 / 16; background: var(--card); border-radius: 6px; overflow: hidden; }
.grid video, .grid img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

.swipe { display: flex; flex-direction: column; height: 100dvh; min-height: 0; }
.deck { position: relative; flex: 1; min-height: 0; }
.card {
  position: absolute; inset: 0; border-radius: 20px; overflow: hidden; background: #000;
  touch-action: none; user-select: none; -webkit-user-select: none; will-change: transform;
}
.card video { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.card.next { transform: scale(.95); opacity: .6; }
.card .stamp {
  position: absolute; top: 24px; padding: 6px 14px; border: 3px solid; border-radius: 10px;
  font-size: 28px; font-weight: 800; letter-spacing: .05em; opacity: 0;
}
.card .stamp.keep { left: 20px; color: var(--keep); transform: rotate(-12deg); }
.card .stamp.skip { right: 20px; color: var(--skip); transform: rotate(12deg); }
.card .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 16px 12px; font-size: 13px; color: #ddd; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.actions { display: flex; justify-content: center; gap: 48px; padding: 16px 0 8px; }
.round { width: 68px; height: 68px; border-radius: 50%; font-size: 28px; padding: 0; background: var(--card); }
.round.skip { color: var(--skip); }
.round.keep { color: var(--keep); }
.status.mini { text-align: center; background: none; padding: 0 0 6px; color: var(--dim); }

body:has(#tabs:not([hidden])) .view { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { flex: 1; background: none; border-radius: 0; padding: 16px 0; color: var(--dim); }
.tabs button.on { color: var(--accent); font-weight: 600; }
.small { font-size: 13px; margin: 0 0 10px; }
textarea, input[type=search] { width: 100%; font: inherit; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
#hook-search { margin-bottom: 6px; }
.fam { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 6px; }
.hook { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.hook p { margin: 0; flex: 1; }
.hook .tag { font-size: 12px; color: var(--dim); white-space: nowrap; }
.hook button { padding: 2px 8px; background: none; color: var(--skip); }
.instr { display: flex; flex-direction: column; }
#iv-log { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.iv-msg { margin: 0; padding: 10px 14px; border-radius: 14px; max-width: 85%; white-space: pre-wrap; line-height: 1.4; }
.iv-msg.ai { background: var(--card); align-self: flex-start; }
.iv-msg.you { background: var(--panel); border: 1px solid var(--edge); align-self: flex-end; }
#iv-doc { min-height: 50vh; width: 100%; font: 15px/1.5 ui-monospace, Menlo, monospace; resize: vertical; margin-bottom: 10px; }
#iv-answer { font: inherit; resize: vertical; }
#instr-text { min-height: 60vh; font: 16px/1.5 ui-monospace, Menlo, monospace; resize: vertical; }
#instr-status { margin: 8px 0 0; }

.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.95); display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 16px; z-index: 10; }
.viewer video, .viewer img { object-fit: contain; width: 100%; max-height: 78vh; background: #000; border-radius: 12px; }
.viewer .row { flex-wrap: wrap; }

.dcard { inset: 0; margin: auto; height: 100%; width: auto; max-width: 100%; aspect-ratio: 9 / 16; container-type: size; }
.dcard video, .dcard img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.dcard .wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #ddd; font-size: 15px; background: rgba(0,0,0,.35); }
/* Hook overlay in 1080×1920 canvas units (video-brand.md): block centred on y=880, left x=86. */
.ov { --u: calc(100cqw / 1080); position: absolute; left: calc(86 * var(--u)); top: calc(880 * var(--u)); transform: translateY(-50%); display: flex; flex-direction: column; align-items: flex-start; gap: calc(8 * var(--u)); pointer-events: none; }
.ov span { display: block; white-space: nowrap; font-family: Didot, "Didot LT STD", Baskerville, serif; line-height: 1.1; color: #0a0a0a; background: rgba(255,255,255,.92); padding: calc(10 * var(--u)) calc(22 * var(--u)); }
.ov span.hi { background: #fcee23; }
.caption { margin: 10px 0 0; max-height: 4.4em; overflow-y: auto; font-size: 14px; white-space: pre-wrap; color: var(--dim); }
#hook-type { font: inherit; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.hook .tmpl { font-family: inherit; }
.tprev { position: relative; height: 46vh; margin-bottom: 10px; }
.tprev .card { touch-action: auto; }
#trial-caption { resize: vertical; margin-bottom: 6px; }
.vline { padding: 12px 0; border-bottom: 1px solid var(--line); }
.vline.on { border-left: 3px solid var(--accent); padding-left: 10px; }
.vline .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); margin-bottom: 6px; }
.vline textarea { resize: none; }
.vline button { padding: 6px 12px; font-size: 14px; }
.trow { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.trow video { width: 54px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; background: var(--card); pointer-events: none; }
.trow p { margin: 0; flex: 1; }
#v-trial.reviewing .editonly, #v-trial:not(.reviewing) .reviewonly { display: none !important; }
.bedit { display: grid; gap: 6px; }
.bedit label { display: grid; grid-template-columns: 7.5em 1fr; align-items: center; gap: 10px; font-size: 14px; color: var(--dim); }
.bedit input[type=range] { width: 100%; accent-color: var(--accent); }
.rgrid { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.rgrid figure { margin: 0; flex: 0 0 min(64vw, 240px); scroll-snap-align: start; }
.rgrid video { width: 100%; aspect-ratio: 9 / 16; border-radius: 12px; background: #000; display: block; }
.rgrid figcaption { font-size: 13px; color: var(--dim); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.ovc { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sedit { display: grid; gap: 8px; }
.srow { display: grid; grid-template-columns: 6em 1fr; align-items: center; gap: 10px; font-size: 14px; color: var(--dim); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { flex: none; padding: 6px 12px; font-size: 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--card); }
.chip.on { border-color: var(--accent); color: var(--accent); }
.lbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.selbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 3; }
.selbar span { flex: 1; }
.grid .tile { position: relative; }
.tile .badge { position: absolute; left: 6px; bottom: 6px; font-size: 12px; color: #fff; background: rgba(0,0,0,.55); border-radius: 6px; padding: 1px 6px; pointer-events: none; }
.tile .pickn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 800; color: #1a0d08; background: rgba(255,107,74,.55); outline: 3px solid var(--accent); outline-offset: -3px; border-radius: 6px; pointer-events: none; }
.cgrid { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.cgrid figure { margin: 0; flex: 0 0 min(72vw, 300px); scroll-snap-align: start; }
.cgrid canvas { width: 100%; aspect-ratio: 4 / 5; border-radius: 12px; background: #000; display: block; margin-bottom: 6px; }
.cgrid textarea { resize: none; }
.trow img { width: 54px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 6px; background: var(--card); }
#car-write { margin-bottom: 8px; }
#car-caption { resize: vertical; margin-bottom: 6px; }
.trim { position: relative; height: 36px; touch-action: none; cursor: pointer; }
.trim::before { content: ''; position: absolute; left: 0; right: 0; top: 15px; height: 6px; border-radius: 3px; background: var(--line); }
.trim .tsel { position: absolute; top: 15px; height: 6px; background: var(--accent); }
.trim .th { position: absolute; top: 4px; width: 14px; height: 28px; margin-left: -7px; border-radius: 5px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.trim.off { opacity: .5; cursor: default; }

/* ── Frankie Command Center palette, clean version ── */
:root { --panel: rgba(6,59,71,.28); --edge: rgba(255,255,255,.07); --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace; }
body { font-size: 15px; background: #020e13 radial-gradient(circle, rgba(252,238,35,.045) 1px, transparent 1px) 0 0 / 24px 24px fixed; }
h1 { font-size: 15px; font-weight: 800; letter-spacing: .28em; text-transform: uppercase; color: var(--accent); }
h2 { font: 500 11px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--dim); margin: 22px 0 10px; }
h2 .dim { color: #3e626e; letter-spacing: .1em; }
.bar { position: sticky; top: 0; z-index: 4; margin: 0 -16px 10px; padding: 14px 16px; background: rgba(2,14,19,.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--edge); }
.bar .dim, #usage { font: 11px var(--mono); color: #4f7883; }
button, .pick { border-radius: 12px; border: 1px solid var(--edge); background: var(--panel); font-size: 14px; font-weight: 500; transition: background .15s, transform .1s; }
button:active { transform: scale(.97); }
.primary { background: var(--accent); color: #0b1f24; font-weight: 700; border-color: transparent; box-shadow: 0 6px 24px -8px rgba(252,238,35,.45); }
.danger { background: rgba(248,113,113,.1); color: var(--skip); border-color: rgba(248,113,113,.3); }
.link { border: 0; background: none; font-weight: 600; }
.big { font-size: 16px; padding: 16px; }
textarea, input[type=search], input[type=password], input[type=email], #join-code, .sform input, .sform select, #hook-new, #hook-type { border-radius: 12px; background: var(--panel); border: 1px solid var(--edge); }
textarea:focus, input:focus { outline: none; border-color: rgba(252,238,35,.45); }
.status { border-radius: 12px; background: var(--panel); border: 1px solid var(--edge); }
.status.mini { border: 0; background: none; font: 11px var(--mono); letter-spacing: .08em; color: var(--dim); }
.grid { gap: 6px; }
.grid .tile { border-radius: 10px; }
.card, .rgrid video, .cgrid canvas, .viewer video, .viewer img { border-radius: 16px; }
.tile .badge { border-radius: 6px; background: rgba(2,14,19,.7); color: var(--accent); }
.tile .pickn { color: #0b1f24; background: rgba(252,238,35,.4); border-radius: 10px; }
.chip { border-radius: 999px; border: 1px solid var(--edge); background: var(--panel); font-size: 13px; padding: 6px 13px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #0b1f24; font-weight: 700; }
.round { background: var(--panel); border: 1px solid currentColor; }
.tabs { background: rgba(2,14,19,.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--edge); }
.tabs button { border: 0; border-radius: 0; background: none; font-size: 12px; color: #4f7883; }
.tabs button.on { color: var(--accent); }
.viewer { background: rgba(2,14,19,.96); }
.hook, .vline, .trow { border-bottom-color: var(--edge); }
.fam { font-family: var(--mono); color: var(--dim); }
/* edit panels */
.bedit, .sedit { background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; padding: 12px 14px; gap: 10px; }
.bedit label { grid-template-columns: auto 1fr; font-size: 13px; }
.bedit label span { font-family: var(--mono); font-size: 12px; color: var(--dim); min-width: 9.5em; }
.bedit label:has(input[type=range]) { grid-template-columns: auto 140px; justify-content: start; }
.srow { grid-template-columns: 5.5em 1fr; font-size: 12px; }
.trim::before { background: rgba(255,255,255,.1); }
.trim .th { background: var(--accent); border-radius: 4px; }
.status.mini { font: 13px/1.4 inherit; font-family: inherit; letter-spacing: 0; }
.big { width: 100%; }
.vline button { white-space: nowrap; flex: none; }

/* Library thumbnail size: 3 (default), 4 or 6 across. */
#library[data-size="4"] { grid-template-columns: repeat(4, 1fr); gap: 3px; }
#library[data-size="4"] .tile { aspect-ratio: 3 / 4; border-radius: 6px; }
#library[data-size="6"] { grid-template-columns: repeat(6, 1fr); gap: 2px; }
#library[data-size="6"] .tile { aspect-ratio: 1 / 1; border-radius: 4px; }
#library[data-size="6"] .tile .badge { font-size: 9px; left: 3px; bottom: 3px; padding: 0 4px; }
#library[data-size="6"] .tile .pickn { font-size: 18px; border-radius: 4px; }
/* keep content in a centred column with side margin */
body { padding-left: 20px; padding-right: 20px; }
.view { max-width: 620px; margin: 0 auto; }
.bar { margin: 0 -20px 10px; padding: 14px 20px; }
.tabs { padding-left: max(0px, calc((100vw - 660px) / 2)); padding-right: max(0px, calc((100vw - 660px) / 2)); }
.viewer video, .viewer img { max-width: 620px; margin: 0 auto; }
.lbar .chips { min-width: 0; }
#lib-carousel { white-space: nowrap; flex: none; }
@media (max-width: 480px) { .drop-hint { display: none; } }
/* trial review: one reel at a time */
.rstage { position: relative; width: min(100%, 340px); margin: 0 auto; }
.rstage video { width: 100%; aspect-ratio: 9 / 16; display: block; background: #000; border-radius: 18px; border: 1px solid var(--edge); }
.rnav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 24px; line-height: 1; background: rgba(2,14,19,.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.rnav.prev { left: -8px; } .rnav.next { right: -8px; }
.rmeta { display: flex; justify-content: space-between; width: min(100%, 340px); margin: 12px auto 0; font: 12px var(--mono); color: var(--dim); }
.rwhen { color: var(--accent); }
.rstage.one .rnav { display: none; }
.rline { width: min(100%, 340px); margin: 8px auto 0; font-size: 17px; font-weight: 600; line-height: 1.35; }
.rdots { display: flex; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.rdots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.18); cursor: pointer; }
.rdots i.on { background: var(--accent); width: 22px; border-radius: 4px; }
#trial-post { font-size: 17px; padding: 20px; letter-spacing: .02em; }
#trial-review { --rw: min(100%, 340px, calc(56dvh * 9 / 16)); }
.rstage, .rmeta { width: var(--rw); }
.rline { display: none; }
#v-trial.reviewing #trial-post { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 3; }
/* arrows beside the reel, not on it */
#trial-review { --rw: min(calc(100% - 108px), 340px, calc(56dvh * 9 / 16)); }
.rstage { display: flex; align-items: center; justify-content: center; gap: 12px; width: auto; }
.rstage video { width: var(--rw); }
.rnav { position: static; transform: none; flex: none; }
/* laptop: reel on the left, caption + approve on the right */
@media (min-width: 700px) {
  #v-trial.reviewing { max-width: 900px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: repeat(7, auto) 1fr; column-gap: 28px; align-content: start; }
  #v-trial.reviewing > .bar { grid-column: 1 / -1; grid-row: 1; }
  #v-trial.reviewing > #trial-status { grid-column: 1 / -1; grid-row: 2; }
  #v-trial.reviewing > #trial-review { grid-column: 1; grid-row: 3 / 9; --rw: min(340px, calc(62dvh * 9 / 16)); }
  #v-trial.reviewing > h2:not(.editonly) { grid-column: 2; grid-row: 3; margin-top: 0; }
  #v-trial.reviewing > #trial-caption { grid-column: 2; grid-row: 4; }
  #v-trial.reviewing > #trial-post { grid-column: 2; grid-row: 5; position: static; }
  #v-trial.reviewing > #trial-wide { grid-column: 2; grid-row: 6; }
  #v-trial.reviewing > #trial-diy { grid-column: 2; grid-row: 7; }
  #v-trial.reviewing > #trial-edit { grid-column: 2; grid-row: 8; justify-self: end; align-self: start; }
  #v-trial.reviewing > #trial-delete { grid-column: 2; grid-row: 8; justify-self: start; align-self: start; }
}
.rnav.prev { order: -1; }

/* loading: thin bar while any request is out, spinner on the button doing the work */
#loadbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none; }
#loadbar::after { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 35%; background: var(--accent); animation: loadbar 1s ease-in-out infinite; }
body.loading #loadbar { opacity: 1; }
@keyframes loadbar { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
button.busy { opacity: 1; cursor: progress; }
button.busy::before { content: ''; display: inline-block; width: .9em; height: .9em; margin-right: .5em; vertical-align: -.1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* pay page, settings, hook add */
a.pay { display: block; width: 100%; max-width: 320px; text-align: center; text-decoration: none; padding: 16px; border-radius: 14px; }
.center h2 { margin-top: 24px; }
.sform { display: flex; flex-direction: column; gap: 0; margin-bottom: 8px; }
.sform .chips { margin-bottom: 12px; }
.sform .chip input { width: auto; padding: 0; margin: 0 6px 0 0; border: 0; }
.instr header.bar { margin-top: 16px; }
.hookadd { display: flex; gap: 8px; margin-bottom: 12px; }
.hookadd input { flex: 1; margin-bottom: 0; }
#trial-wide .row button, #trial-diy button { flex: 1; }
#trial-diy { margin-top: 12px; }
#wide-note { margin: 16px 0 0; text-align: center; }

/* mini tour after onboarding: dim the app, keep the tab bar lit with the current tab ringed */
.tour { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.75); display: flex; flex-direction: column; justify-content: flex-end; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
.tour-card { background: var(--card); border: 1px solid var(--edge); border-radius: 16px; padding: 16px; max-width: 520px; width: 100%; margin: 0 auto; }
.tour-card h2 { margin: 2px 0 6px; }
.tour-card p { margin: 0 0 12px; line-height: 1.45; }
.tour-card .row { display: flex; justify-content: space-between; align-items: center; }
.tour-card .row .primary { margin-left: auto; }
body.touring .tabs { z-index: 21; pointer-events: none; }
.tabs button.tour-on { color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 2px var(--accent); border-radius: 12px; }
