/* Carl FX Agents — Clipping Studio. Brand: ink #05050A, graphite #0E1016, cobalt #4F8CFF / #1E4FD8,
   Playfair Display 900 for big words, Inter caps with wide tracking for labels. Red only for LIVE. No green. */
@font-face { font-family: 'Inter'; src: url('/static/fonts/Inter-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/static/fonts/Inter-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/static/fonts/Inter-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Playfair Display'; src: url('/static/fonts/PlayfairDisplay-var.ttf') format('truetype'); font-weight: 400 900; font-display: swap; }

:root {
  --ink: #05050A; --graphite: #0E1016; --panel: #11141C; --panel-2: #161A24; --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
  --white: #FFFFFF; --muted: #A7AEBF; --dim: #6B7283; --cobalt: #4F8CFF; --deep: #1E4FD8; --live: #FF2D2D;
  --cobalt-soft: rgba(79,140,255,.14); --radius: 14px; --radius-sm: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--white); }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; font-weight: 500; font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; min-height: 100vh;
  background-image: radial-gradient(1200px 600px at 85% -10%, rgba(79,140,255,.10), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(30,79,216,.08), transparent 60%); background-attachment: fixed; }
a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }

/* type */
.eyebrow { font-weight: 600; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.serif { font-family: 'Playfair Display', Georgia, serif; font-weight: 900; letter-spacing: -.01em; }
h1, h2, h3 { margin: 0; }
h1.serif { font-size: 30px; line-height: 1.08; }
h2.serif { font-size: 22px; line-height: 1.15; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; letter-spacing: 0; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-logo { width: 160px; opacity: .85; }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: rgba(5,5,10,.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1440px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 20px; width: auto; display: block; }
.brand .eyebrow { font-size: 10px; letter-spacing: .26em; color: var(--muted); border-left: 1px solid var(--line-2); padding-left: 10px; white-space: nowrap; }
.top-spacer { flex: 1; }
.chips { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; overflow: hidden; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.chip.on { color: var(--white); border-color: rgba(79,140,255,.45); }
.chip.on .dot { background: var(--cobalt); box-shadow: 0 0 8px var(--cobalt); }
.chip.warn { color: var(--white); border-color: var(--white); }
.chip.warn .dot { background: var(--white); }
.live-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 6px; background: var(--live); color: #fff; font-weight: 700; font-size: 11px; letter-spacing: .2em; }
.live-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.menu-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel); display: grid; place-items: center; cursor: pointer; font-weight: 700; font-size: 13px; }
.tabs-top { display: none; gap: 4px; }
.tab-link { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; cursor: pointer; border: 0; background: none; }
.tab-link.active { color: var(--white); background: var(--panel-2); }
.tab-link:hover { color: var(--white); text-decoration: none; }

/* bottom nav (phones) */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: rgba(9,10,16,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.bottom-nav button { background: none; border: 0; padding: 10px 4px 12px; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; cursor: pointer; position: relative; }
.bottom-nav button .ico { display: block; font-size: 18px; letter-spacing: 0; margin-bottom: 2px; font-weight: 700; }
.bottom-nav button.active { color: var(--white); }
.bottom-nav button.active::after { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--cobalt); border-radius: 2px; }
.badge { position: absolute; top: 6px; left: 54%; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--cobalt); color: #fff; font-size: 10px; letter-spacing: 0; display: grid; place-items: center; }

/* layout */
main { max-width: 1440px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }
.grid-live { display: grid; gap: 16px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.card { background: linear-gradient(180deg, var(--panel), var(--graphite)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.tight { padding: 12px; }
.card h3 { font-weight: 600; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 2px 10px; }
.hairline { height: 1px; background: var(--line); margin: 12px 0; border: 0; }

/* buttons + inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--white); font-weight: 600; font-size: 13px; letter-spacing: .04em; cursor: pointer; transition: transform .08s ease, background .15s ease, border-color .15s ease; text-decoration: none; }
.btn:hover { border-color: rgba(255,255,255,.28); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--deep); border-color: var(--deep); }
.btn.primary:hover { background: #2457e6; }
.btn.cobalt { background: var(--cobalt); border-color: var(--cobalt); color: #05050A; }
.btn.ghost { background: transparent; }
.btn.small { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.danger { border-color: rgba(255,255,255,.35); }
.seg { display: inline-flex; background: var(--ink); border: 1px solid var(--line-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 7px 12px; border-radius: 9px; font-weight: 600; font-size: 12px; letter-spacing: .08em; cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--panel-2); color: var(--white); box-shadow: inset 0 0 0 1px rgba(79,140,255,.45); }
label.field { display: grid; gap: 6px; }
label.field > span { font-weight: 600; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; background: var(--ink); border: 1px solid var(--line-2); border-radius: 11px; padding: 11px 12px; outline: none; font-size: 15px; }
input:focus, select:focus, textarea:focus { border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(79,140,255,.18); }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.srt { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; min-height: 200px; }
input[type=range] { width: 100%; accent-color: var(--cobalt); height: 28px; }
input[type=checkbox] { accent-color: var(--cobalt); width: 18px; height: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* live */
.paused-banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--deep); color: #fff; font-weight: 600; }
.paused-banner .serif { font-size: 20px; }
.player { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.player video, .player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.player .overlay-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); background: radial-gradient(circle at 50% 40%, rgba(79,140,255,.10), transparent 60%), #07080d; }
.player .overlay-msg .serif { font-size: 22px; color: var(--white); display: block; margin-bottom: 6px; }
.player .tag { position: absolute; top: 10px; left: 10px; z-index: 2; }
.timeline { display: grid; gap: 4px; }
.timeline .labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.playhead { font-variant-numeric: tabular-nums; }
.clip-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.clip-buttons.four { grid-template-columns: repeat(4, 1fr); }
.clip-btn { height: 84px; border-radius: 16px; border: 1px solid rgba(79,140,255,.45); background: linear-gradient(180deg, rgba(79,140,255,.20), rgba(30,79,216,.10)); color: #fff; cursor: pointer; display: grid; place-items: center; align-content: center; gap: 2px; transition: transform .08s ease, background .15s; }
.clip-btn:active { transform: scale(.96); background: rgba(79,140,255,.35); }
.clip-btn:disabled { opacity: .35; cursor: not-allowed; }
.clip-btn .n { font-family: 'Playfair Display', Georgia, serif; font-weight: 900; font-size: 34px; line-height: 1; }
.clip-btn .l { font-size: 10.5px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.latency-box { display: grid; gap: 10px; }
.big-num { font-family: 'Playfair Display', Georgia, serif; font-weight: 900; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.note { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--cobalt-soft); border: 1px solid rgba(79,140,255,.3); font-size: 13.5px; }
.note.plain { background: var(--panel-2); border-color: var(--line-2); }

/* clips list */
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: none; border: 1px solid var(--line-2); background: none; color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.filters button.active { color: var(--white); border-color: var(--cobalt); background: var(--cobalt-soft); }
.clip-list { display: grid; gap: 10px; }
.clip-card { display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center; padding: 10px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); cursor: pointer; color: inherit; text-decoration: none; transition: border-color .15s, background .15s; }
.clip-card:hover { border-color: var(--line-2); text-decoration: none; }
.clip-card.fresh { border-color: var(--cobalt); box-shadow: 0 0 0 1px var(--cobalt) inset; }
.thumb { width: 112px; aspect-ratio: 16/9; border-radius: 9px; background: #07080d center/cover no-repeat; position: relative; overflow: hidden; border: 1px solid var(--line); }
.thumb .dur { position: absolute; right: 5px; bottom: 5px; background: rgba(0,0,0,.7); border-radius: 5px; padding: 1px 6px; font-size: 11px; font-weight: 700; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; }
.clip-meta { min-width: 0; display: grid; gap: 4px; }
.clip-title { font-weight: 700; font-size: 14.5px; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.pill.work { color: var(--white); border-color: rgba(79,140,255,.5); }
.pill.work::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--cobalt); margin-right: 6px; animation: pulse 1.2s infinite; }
.pill.ready { background: var(--cobalt); border-color: var(--cobalt); color: #05050A; }
.pill.editing { color: var(--cobalt); border-color: var(--cobalt); }
.pill.approved { background: var(--white); border-color: var(--white); color: var(--ink); }
.pill.published { background: var(--deep); border-color: var(--deep); color: #fff; }
.pill.failed, .pill.blocked { border-style: dashed; color: var(--muted); }
.pill.marker { color: var(--muted); }
.pill.prio { border-color: var(--white); color: var(--white); }
.pill.src { font-size: 9.5px; height: 19px; padding: 0 7px; color: var(--dim); }

/* clip page */
.clip-page { display: grid; gap: 16px; }
.clip-head { display: grid; gap: 6px; }
.timeline-steps { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; padding: 4px 0; }
.timeline-steps::-webkit-scrollbar { display: none; }
.step { flex: 1 0 auto; min-width: 84px; display: grid; gap: 6px; justify-items: start; position: relative; padding-right: 10px; }
.step .bar { height: 3px; width: 100%; background: var(--line-2); border-radius: 2px; }
.step.done .bar { background: var(--cobalt); }
.step.now .bar { background: linear-gradient(90deg, var(--cobalt), var(--white)); }
.step .t { font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.step.done .t, .step.now .t { color: var(--white); }
.step .at { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.editor-grid { display: grid; gap: 16px; }
.video-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.video-box video { width: 100%; display: block; max-height: 70vh; background: #000; }
.preview-wrap { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.preview-canvas { width: 120px; aspect-ratio: 9/16; border-radius: 10px; border: 1px solid var(--line-2); background: #000; display: block; }
.files { display: grid; gap: 8px; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 11px; background: var(--ink); border: 1px solid var(--line); }
.file-row .name { min-width: 0; }
.pubs { display: grid; gap: 10px; }
.pub { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink); display: grid; gap: 10px; }
.stat-inputs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-inputs input { padding: 8px; font-size: 14px; }
.manual-tag { font-size: 10px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 6px; padding: 2px 6px; }
.events { display: grid; gap: 6px; font-size: 13px; }
.events .ev { display: grid; grid-template-columns: 72px 1fr; gap: 10px; }

/* stats */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { padding: 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); display: grid; gap: 4px; }
.tile .big-num { font-size: 34px; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 8px; border-radius: 4px; background: var(--ink); border: 1px solid var(--line); overflow: hidden; }
.bar-fill { height: 100%; background: var(--cobalt); border-radius: 4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl-wrap { overflow-x: auto; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 18px; padding: 28px 22px; border-radius: 20px; background: linear-gradient(180deg, var(--panel), var(--graphite)); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.auth-card .logo { width: 150px; }
.err { color: #fff; background: rgba(255,255,255,.06); border: 1px dashed rgba(255,255,255,.3); padding: 9px 12px; border-radius: 10px; font-size: 13.5px; }

/* menu sheet */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.sheet { position: fixed; right: 12px; top: 60px; z-index: 41; width: min(340px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; padding: 14px; display: grid; gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }

/* toasts */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b)); z-index: 60; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--cobalt); border-radius: 12px; padding: 11px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: rise .18s ease-out; }
.toast.warn { border-left-color: var(--white); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.token-box { word-break: break-all; padding: 12px; border-radius: 10px; background: var(--ink); border: 1px dashed var(--cobalt); font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* laptop */
@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .tabs-top { display: flex; }
  main { padding: 22px 24px 48px; }
  #toasts { bottom: 24px; }
  .grid-live { grid-template-columns: minmax(0, 1.45fr) minmax(360px, 1fr); align-items: start; }
  .grid-live .side { position: sticky; top: 78px; max-height: calc(100vh - 96px); overflow: auto; padding-right: 2px; }
  .editor-grid { grid-template-columns: minmax(0, 1.3fr) minmax(340px, 1fr); align-items: start; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .clip-buttons .clip-btn { height: 78px; }
  .grid-live .player { aspect-ratio: auto; height: min(42vh, calc((100vw - 460px) * 0.5625)); }
  .grid-live .section-head h1.serif { font-size: 30px; }
  h1.serif { font-size: 36px; }
  .preview-wrap { grid-template-columns: 150px 1fr; }
  .preview-canvas { width: 150px; }
}
@media (max-width: 899px) { .side-only-desktop { display: none; } }
@media (max-width: 420px) {
  .chips .chip.opt { display: none; }
  .brand .eyebrow { display: none; }
  .stat-inputs { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
