/* WHAT THE HOAX?! Command Center — design tokens and components.
   Black and ivory carry the identity; orange marks actions and status only;
   purple is a quiet accent and never sits behind small ivory text. */

@font-face { font-family: 'Fredoka'; src: url('/fonts/Fredoka.ttf') format('truetype'); font-weight: 300 700; font-stretch: 75% 125%; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('/fonts/SpaceMono-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('/fonts/SpaceMono-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Instrument Serif'; src: url('/fonts/InstrumentSerif-Italic.ttf') format('truetype'); font-style: italic; font-display: swap; }

:root {
  --ink: #111111;
  --ink-1: #151413;
  --ink-2: #1a1917;
  --ink-3: #22201d;
  --ink-4: #2b2925;
  --line: rgba(242, 232, 213, 0.09);
  --line-2: rgba(242, 232, 213, 0.17);
  --ivory: #F2E8D5;
  --ivory-2: rgba(242, 232, 213, 0.74);
  --muted: #9C9488;
  --orange: #E7773C;
  --orange-hi: #F08A52;
  --orange-soft: rgba(231, 119, 60, 0.13);
  --purple: #655078;
  --purple-soft: rgba(101, 80, 120, 0.30);
  --purple-text: #B9A5CF;

  --f-ui: 'Fredoka', ui-rounded, system-ui, sans-serif;
  --f-mono: 'Space Mono', ui-monospace, monospace;
  --f-serif: 'Instrument Serif', Georgia, serif;

  --r-1: 4px; --r-2: 8px; --r-3: 14px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --side: 248px; --side-rail: 76px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, .7);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--ivory);
  font: 400 15px/1.5 var(--f-ui); font-stretch: 100%;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
/* Film grain: the cinematic layer, kept almost invisible. */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--orange); }
img, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--orange); color: var(--ink); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: var(--r-1); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
h1 { font-size: clamp(26px, 3.2vw, 36px); text-shadow: -2px 0 0 rgba(101, 80, 120, .6); } /* the one sanctioned glitch */
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
.label { font: 700 11px/1.3 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.aside { font: italic 400 1.15em/1.3 var(--f-serif); color: var(--ivory-2); }
.mono { font-family: var(--f-mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Shell ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { border-radius: 50%; opacity: .8; }
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; transition: grid-template-columns .2s var(--ease); }
.shell.rail { grid-template-columns: var(--side-rail) 1fr; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s-4);
  background: var(--ink-1); border-right: 1px solid var(--line); padding: var(--s-4) var(--s-3); overflow: hidden auto; z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-1) var(--s-2) var(--s-3); text-decoration: none; }
.brand img.mascot { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.brand img.word { width: 132px; height: auto; }
.brand-sub { font: 700 9.5px/1 var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav a {
  display: flex; align-items: center; gap: var(--s-3); padding: 9px var(--s-3); border-radius: var(--r-2);
  text-decoration: none; color: var(--ivory-2); font-weight: 500; position: relative; white-space: nowrap;
}
.nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; }
.nav a:hover { background: var(--ink-3); color: var(--ivory); }
.nav a[aria-current="page"] { background: var(--ink-3); color: var(--ivory); }
.nav a[aria-current="page"]::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--orange); }
.nav .count { margin-left: auto; font: 700 10.5px/1 var(--f-mono); background: var(--orange); color: var(--ink); padding: 3px 6px; border-radius: 99px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-2); border-top: 1px solid var(--line); padding-top: var(--s-3); }
.side-foot .btn { justify-content: flex-start; }
.shell.rail .side-foot .btn { justify-content: center; }
.side-foot .tz { font: 400 11px/1.4 var(--f-mono); color: var(--muted); padding: 0 var(--s-3); }
.shell.rail .brand img.word, .shell.rail .brand-sub, .shell.rail .nav span, .shell.rail .side-foot .tz, .shell.rail .nav .count, .shell.rail .collapse span { display: none; }
.shell.rail .nav a { justify-content: center; padding: 10px; }
.shell.rail .brand { justify-content: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
#view:focus { outline: none; } /* focused only to move screen readers to the new page */
.topbar { display: none; }
.page { padding: var(--s-6) clamp(16px, 3.4vw, 48px) var(--s-7); max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head .eyebrow { margin-bottom: var(--s-2); }
.page-head p.lede { color: var(--ivory-2); margin-top: var(--s-2); max-width: 64ch; }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.scrim { display: none; }

@media (max-width: 900px) {
  .shell, .shell.rail { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .22s var(--ease); box-shadow: var(--shadow); }
  .shell.open .side { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 15; }
  .shell.rail .brand img.word, .shell.rail .brand-sub, .shell.rail .nav span, .shell.rail .side-foot .tz, .shell.rail .nav .count { display: revert; }
  .shell.rail .nav a { justify-content: flex-start; padding: 9px var(--s-3); }
  .collapse { display: none !important; }
  .topbar {
    display: flex; align-items: center; gap: var(--s-3); position: sticky; top: 0; z-index: 10;
    padding: 10px 16px; background: rgba(17, 17, 17, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .topbar img { height: 26px; width: auto; }
  .page { padding: var(--s-5) 16px var(--s-7); }
}

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 38px;
  padding: 8px 14px; border-radius: var(--r-2); border: 1px solid var(--line-2); background: var(--ink-2);
  color: var(--ivory); font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--ink-3); border-color: rgba(242, 232, 213, .3); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: var(--ink); font-weight: 600; }
.btn-primary:hover { background: var(--orange-hi); border-color: var(--orange-hi); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ivory-2); }
.btn-quiet:hover { background: var(--ink-3); color: var(--ivory); border-color: transparent; }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn-icon { padding: 8px; min-width: 38px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid var(--ivory-2); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-primary.busy::after { border-color: var(--ink); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 13px; color: var(--ivory-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .count { font: 400 11px var(--f-mono); color: var(--muted); align-self: flex-end; margin-top: -2px; }
.field .count.over { color: var(--orange); }
input[type="text"], input[type="password"], input[type="search"], input[type="datetime-local"], input[type="date"], input[type="url"], input[type="number"], select, textarea {
  width: 100%; background: var(--ink-3); border: 1px solid var(--line-2); border-radius: var(--r-2);
  padding: 9px 12px; color: var(--ivory); min-height: 38px; color-scheme: dark;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: rgba(242, 232, 213, .38); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; }
.check input { accent-color: var(--orange); width: 16px; height: 16px; }

.seg { display: inline-flex; background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-2); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--ivory-2); font-size: 13.5px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--ink-4); color: var(--ivory); }
.seg button:hover { color: var(--ivory); }

/* ---------- Surfaces ---------- */
.card { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-5); min-width: 0; }
.card.tight { padding: var(--s-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: var(--s-2); }
.grid { display: grid; gap: var(--s-4); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .card { padding: var(--s-4); }
  .table-wrap { margin: 0 calc(var(--s-4) * -1); padding: 0 var(--s-4); }
  .hide-sm { display: none; }
  .page-actions { width: 100%; }
}
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-5); }
.divider { height: 1px; background: var(--line); margin: var(--s-4) 0; border: 0; }

/* ---------- Status ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; white-space: nowrap;
  font: 700 10.5px/1.5 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--ivory-2);
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip.plain::before { display: none; }
.st-draft { color: var(--muted); }
.st-ready { color: var(--ivory); border-color: rgba(242, 232, 213, .4); }
.st-scheduled, .st-handed_off { color: var(--purple-text); background: var(--purple-soft); border-color: transparent; }
.st-publishing, .st-processing, .st-connecting { color: var(--orange); border-color: rgba(231, 119, 60, .5); }
.st-publishing::before, .st-processing::before { animation: pulse 1.4s ease-in-out infinite; }
.st-needs_action, .st-needs_reconnect, .st-blocked { color: var(--orange); background: var(--orange-soft); border-color: transparent; }
.st-failed, .st-error { color: var(--ink); background: var(--orange); border-color: var(--orange); }
.st-published, .st-connected { color: var(--ivory); background: rgba(242, 232, 213, .1); border-color: transparent; }
.st-cancelled, .st-archived, .st-not_connected, .st-not_configured { color: var(--muted); border-style: dashed; }
@keyframes pulse { 50% { opacity: .25; } }

.plat { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; white-space: nowrap; }
.plat i { width: 8px; height: 8px; border-radius: 2px; flex: none; background: var(--c); }
.plat-tag { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font: 700 9.5px/1 var(--f-mono); color: var(--on, var(--ink)); background: var(--c); flex: none; }

.notice { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-2); background: var(--ink-3); border: 1px solid var(--line); font-size: 14px; }
.notice.warn { border-color: rgba(231, 119, 60, .45); background: var(--orange-soft); }
.notice.error { border-color: var(--orange); background: rgba(231, 119, 60, .2); }
.notice.info { border-color: rgba(185, 165, 207, .35); }
.notice b { font-weight: 600; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; stroke: currentColor; }
.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.issues li { display: grid; grid-template-columns: 16px 1fr; gap: var(--s-2); }
.issues li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--muted); }
.issues li.error::before { background: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.issues li.warn::before { background: transparent; border: 2px solid var(--orange); width: 9px; height: 9px; }
.issues li.ok::before { background: var(--ivory); }
.issues .fix { color: var(--muted); font-size: 12.5px; display: block; }

/* ---------- Data ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font: 700 10.5px/1.3 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--ink-3); }
.table td.r, .table th.r { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 calc(var(--s-5) * -1); padding: 0 var(--s-5); }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.stat .d { font: 400 12px var(--f-mono); color: var(--muted); }
.delta-up { color: var(--ivory); } .delta-down { color: var(--orange); }

.thumb { aspect-ratio: 9 / 16; width: 54px; border-radius: var(--r-1); background: var(--ink-4) center / cover no-repeat; flex: none; border: 1px solid var(--line); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.sm { width: 34px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3); padding: var(--s-6) var(--s-4); color: var(--ivory-2); }
.empty img { width: 64px; height: 64px; border-radius: 50%; opacity: .85; filter: grayscale(.2); }
.empty h3 { color: var(--ivory); }
.empty p { max-width: 46ch; font-size: 14px; }

.skel { background: linear-gradient(90deg, var(--ink-3) 0%, var(--ink-4) 50%, var(--ink-3) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-2); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Toasts / dialogs ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink-3); border: 1px solid var(--line-2); border-left: 3px solid var(--ivory); padding: 12px 14px; border-radius: var(--r-2); box-shadow: var(--shadow); font-size: 14px; animation: rise .2s var(--ease); }
.toast.error { border-left-color: var(--orange); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
dialog { background: var(--ink-2); color: var(--ivory); border: 1px solid var(--line-2); border-radius: var(--r-3); padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .66); }
dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--ink-2); z-index: 1; }
dialog .dlg-body { padding: var(--s-5); }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--ink-2); flex-wrap: wrap; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(800px 500px at 50% 20%, rgba(101, 80, 120, .25), transparent 70%); }
.login .card { width: min(400px, 100%); display: flex; flex-direction: column; gap: var(--s-4); text-align: center; padding: var(--s-6); }
.login .card img.mascot { width: 88px; height: 88px; margin: 0 auto; border-radius: 50%; }
.login .card img.word { width: 220px; margin: 0 auto; }
.login form { display: flex; flex-direction: column; gap: var(--s-3); text-align: left; }

/* ---------- Studio ---------- */
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-4); }
.lib-card { display: flex; flex-direction: column; background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; text-decoration: none; transition: border-color .15s, transform .15s var(--ease); }
.lib-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.lib-card .poster { aspect-ratio: 4 / 5; background: var(--ink-3) center / cover no-repeat; position: relative; display: grid; place-items: center; }
.lib-card .poster .chip { position: absolute; left: 10px; top: 10px; background: rgba(17, 17, 17, .78); backdrop-filter: blur(6px); }
.lib-card .poster .chip.st-failed { background: var(--orange); }
.lib-card .poster .noposter { font: 700 11px var(--f-mono); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.lib-card .meta { padding: var(--s-3) var(--s-4) var(--s-4); display: flex; flex-direction: column; gap: 6px; }
.lib-card h3 { font-size: 15.5px; line-height: 1.3; }
.drop {
  border: 1.5px dashed var(--line-2); border-radius: var(--r-3); padding: var(--s-6) var(--s-4); text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2); color: var(--ivory-2); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--orange); background: var(--orange-soft); color: var(--ivory); }
.drop svg { width: 30px; height: 30px; stroke: var(--orange); }
.progress { height: 4px; background: var(--ink-4); border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--orange); width: 0; transition: width .2s; }
.player { background: #000; border-radius: var(--r-2); overflow: hidden; border: 1px solid var(--line); }
.player video { width: 100%; max-height: 62vh; margin: 0 auto; }
.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: var(--s-3) var(--s-4); }
.specs div { display: flex; flex-direction: column; gap: 2px; }
.specs b { font-weight: 500; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); margin-bottom: var(--s-5); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--ivory-2); font-weight: 500; white-space: nowrap; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ivory); border-bottom-color: var(--orange); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s-5); align-items: start; }
.split > *, .grid > *, .stack-lg > *, .stack > * { min-width: 0; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* Platform copy cards and previews */
.pcard { border-top: 3px solid var(--c); }
.pcard .card-head { margin-bottom: var(--s-3); }
.variants { display: grid; gap: var(--s-3); }
.variant { background: var(--ink-3); border: 1px solid var(--line); border-radius: var(--r-2); padding: var(--s-3) var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); }
.variant textarea { background: var(--ink-2); }
.variant .row .label { margin-right: auto; }
.previews { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: var(--s-4); overflow-x: auto; padding-bottom: var(--s-2); }
@media (max-width: 1200px) { .previews { grid-template-columns: repeat(4, 240px); } }
.phone { aspect-ratio: 9 / 18; border-radius: 22px; border: 1px solid var(--line-2); background: #000 center / cover no-repeat; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.phone::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, .85)); pointer-events: none; }
.phone .ov { position: relative; z-index: 1; padding: 14px 52px 16px 14px; font-size: 12.5px; line-height: 1.38; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.phone .ov b { display: block; margin-bottom: 4px; font-size: 13px; }
.phone .ov .more { color: rgba(255, 255, 255, .7); }
.phone .ov .tags { color: #fff; font-weight: 600; }
.phone .ov .yt-title { font-weight: 600; font-size: 13.5px; }
.phone .rails { position: absolute; right: 10px; bottom: 70px; z-index: 1; display: flex; flex-direction: column; gap: 14px; }
.phone .rails i { width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .22); display: block; }
.phone .cover { position: absolute; top: 34%; left: 10px; right: 10px; z-index: 1; text-align: center; font-weight: 700; font-size: 20px; line-height: 1.1; color: var(--ivory); text-shadow: 0 2px 10px rgba(0, 0, 0, .8); }
.phone .tag { position: absolute; top: 12px; left: 12px; z-index: 1; }

/* ---------- Calendar ---------- */
.cal-toolbar { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--s-4); }
.cal-toolbar .title { font-size: 18px; font-weight: 600; min-width: 170px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: var(--ink-1); padding: 8px; font: 700 10.5px var(--f-mono); letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.cal .day { background: var(--ink-2); min-height: 118px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal .day.out { background: var(--ink-1); }
.cal .day.out .dnum { opacity: .4; }
.cal .day.today .dnum { background: var(--orange); color: var(--ink); }
.cal .day.empty-plan { box-shadow: inset 0 0 0 1px rgba(231, 119, 60, .28); }
.cal .day.over { background: var(--ink-3); box-shadow: inset 0 0 0 2px var(--orange); }
.cal .dnum { font: 700 12px var(--f-mono); align-self: flex-start; padding: 2px 6px; border-radius: 99px; }
.cal .gap { font: 400 10px var(--f-mono); color: var(--orange); letter-spacing: .04em; }
.ev { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; background: var(--ink-3); border-left: 3px solid var(--c); font-size: 12px; cursor: grab; text-align: left; border-top: 0; border-right: 0; border-bottom: 0; width: 100%; color: var(--ivory); min-width: 0; }
.ev:hover { background: var(--ink-4); }
.ev .t { font: 700 10.5px var(--f-mono); color: var(--ivory-2); flex: none; }
.ev .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ev .thumb { width: 18px; }
.ev.st-failed, .ev.st-needs_action { box-shadow: inset 0 0 0 1px var(--orange); }
.ev.st-published { opacity: .78; }
.ev.st-cancelled { opacity: .45; text-decoration: line-through; }
.ev .warn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); flex: none; margin-left: auto; }
.week { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: var(--s-2); overflow-x: auto; }
.week .col { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-2); padding: var(--s-2); display: flex; flex-direction: column; gap: 6px; min-height: 340px; }
.week .col.over { border-color: var(--orange); }
.week .col h4 { font: 700 11px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 4px 2px 8px; border-bottom: 1px solid var(--line); }
.week .col.today h4 { color: var(--orange); }
.week .ev { flex-direction: column; align-items: flex-start; }
@media (max-width: 680px) {
  .cal .day { min-height: 70px; padding: 4px 3px; }
  .cal .ev { padding: 3px; justify-content: center; }
  .cal .ev .t, .cal .ev .n, .cal .ev .thumb, .cal .gap { display: none; }
  .cal .ev::after { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
  .cal .dow { padding: 6px 2px; font-size: 9.5px; letter-spacing: .04em; }
}
.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: 13px; color: var(--ivory-2); }

/* ---------- Ideas board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: var(--s-3); overflow-x: auto; padding-bottom: var(--s-3); align-items: start; }
.lane { background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); min-height: 200px; }
.lane.over { border-color: var(--orange); }
.lane-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; }
.idea { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-2); padding: var(--s-3); cursor: grab; display: flex; flex-direction: column; gap: 6px; text-align: left; color: var(--ivory); width: 100%; }
.idea:hover { border-color: var(--line-2); }
.idea.dragging { opacity: .4; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 400 10.5px var(--f-mono); }
.chart .grid-l { stroke: var(--line); }
.chart .axis { stroke: var(--line-2); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(80px, 160px) 1fr auto; gap: var(--s-3); align-items: center; font-size: 13px; }
.bar .track { height: 10px; background: var(--ink-3); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--ivory-2); border-radius: 3px; }
.heat { display: grid; grid-template-columns: 40px repeat(8, minmax(0, 1fr)); gap: 3px; font: 400 10.5px var(--f-mono); color: var(--muted); }
.heat .cell { aspect-ratio: 1.6; border-radius: 3px; background: var(--ink-3); display: grid; place-items: center; color: var(--ivory); font-size: 10px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.code { font: 400 12.5px/1.6 var(--f-mono); background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-2); padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.steps { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.steps li::marker { color: var(--orange); font-family: var(--f-mono); font-size: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--ink-4); object-fit: cover; flex: none; border: 1px solid var(--line-2); }
.acct-head { display: flex; align-items: center; gap: var(--s-3); }
.acct-head .pname { font-size: 18px; font-weight: 600; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font: 400 11.5px var(--f-mono); padding: 3px 8px; border-radius: 6px; background: var(--ink-3); border: 1px solid var(--line); color: var(--ivory-2); }
.pill.off { opacity: .55; text-decoration: line-through; }
details > summary { cursor: pointer; color: var(--ivory-2); }
details > summary:hover { color: var(--ivory); }

.chart-wrap { position: relative; }
.chart-wrap .tip { position: absolute; pointer-events: none; background: var(--ink-3); border: 1px solid var(--line-2); border-radius: var(--r-1); padding: 6px 8px; font: 400 12px/1.35 var(--f-mono); white-space: nowrap; box-shadow: var(--shadow); transform: translate(-50%, -110%); z-index: 2; }
.chart .hair { stroke: var(--line-2); }
