:root {
  --bg: #0c0e12; --panel: #14171d; --panel2: #1a1e26; --line: #262b35; --text: #e9ecf2; --muted: #8e97a8;
  --blue: #4f8cff; --violet: #8b6cff; --ok: #3ecf8e; --warn: #f2b84b; --bad: #ff6b7a;
  --grad: linear-gradient(135deg, var(--blue), var(--violet));
  --r: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 13px; margin: 0 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
h3 { font-size: 16px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: #fff; color: #000; padding: 6px 10px; border-radius: 8px; z-index: 99; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.side { background: #0f1116; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; letter-spacing: .02em; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; }
.logo svg { width: 18px; height: 18px; stroke: #fff; }
.nav { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav.on { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--blue); }
.spacer { flex: 1; }
main { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }

/* cards + forms */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 22px; }
.cta { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; color: var(--text); transition: border-color .15s, transform .15s; }
.cta:hover { border-color: var(--blue); transform: translateY(-2px); text-decoration: none; }
.cta .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; margin-bottom: 10px; }
.cta .ic svg { width: 20px; height: 20px; stroke: #fff; }
label, .lbl { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 500; }
.input, select, textarea { width: 100%; background: #0e1015; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 16px; }
textarea { min-height: 170px; resize: vertical; line-height: 1.55; }
.input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }
.title-input { font-size: 20px; font-weight: 600; background: transparent; border-color: transparent; padding-left: 0; }
.title-input:hover, .title-input:focus { border-color: var(--line); padding-left: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 160px; }
.row.tight > * { flex: 0 0 auto; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel2); color: var(--text); border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; }
.btn:hover { border-color: #3a4150; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--grad); border: 0; color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.seg { display: inline-flex; background: #0e1015; border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--panel2); color: var(--text); box-shadow: 0 0 0 1px var(--blue) inset; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--panel2); color: var(--muted); }
.chip.ok, .chip.completed { background: rgba(62,207,142,.14); color: var(--ok); }
.chip.processing, .chip.queued { background: rgba(79,140,255,.16); color: var(--blue); }
.chip.failed, .chip.bad { background: rgba(255,107,122,.14); color: var(--bad); }
.chip.warn { background: rgba(242,184,75,.14); color: var(--warn); }
.notice { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; background: rgba(242,184,75,.09); border: 1px solid rgba(242,184,75,.35); }
.notice.err { background: rgba(255,107,122,.09); border-color: rgba(255,107,122,.4); }
.notice.info { background: rgba(79,140,255,.09); border-color: rgba(79,140,255,.35); }
.err-text { color: var(--bad); font-size: 14px; margin-top: 8px; }
code, pre { background: #0e1015; border: 1px solid var(--line); border-radius: 8px; font: 13px ui-monospace, Menlo, Consolas, monospace; }
code { padding: 1px 6px; } pre { padding: 12px; overflow-x: auto; margin: 8px 0; }

/* presenter tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.tile { position: relative; aspect-ratio: 3/4; border-radius: 12px; overflow: hidden; border: 2px solid transparent; background: #0e1015; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 30px; color: var(--muted); }
.tile .tl { position: absolute; inset: auto 0 0 0; padding: 18px 6px 6px; font-size: 12px; text-align: center; background: linear-gradient(transparent, rgba(0,0,0,.82)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .bdg { position: absolute; top: 6px; left: 6px; font-size: 10px; padding: 2px 7px; border-radius: 99px; background: rgba(0,0,0,.6); }
.tile .x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.7); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.tile.sel { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,140,255,.3); }
.tile.add { display: grid; place-items: center; text-align: center; border: 2px dashed var(--line); color: var(--muted); font-size: 13px; padding: 8px; }
.tile.add b { display: block; font-size: 26px; font-weight: 400; }

/* studio */
.studio { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 20px; align-items: start; }
.sticky { position: sticky; top: 16px; }
.stage { background: #0a0b0f; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; text-align: center; padding: 18px; min-height: 220px; overflow: hidden; }
.stage video, .stage img.pv { width: 100%; max-height: 68vh; border-radius: 10px; background: #000; display: block; object-fit: contain; }
.spin { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: s 1s linear infinite; margin: 0 auto 12px; }
@keyframes s { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } .cta { transition: none; } }
details.writer { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 12px; background: #0f1116; }
details.writer summary { cursor: pointer; font-weight: 600; min-height: 32px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.scroll-x { overflow-x: auto; }

/* login */
.center { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login { width: min(420px, 100%); }
.login .brand { justify-content: center; padding-bottom: 8px; font-size: 24px; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: #1d222b; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.45); }
.toast.bad { border-color: var(--bad); }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; justify-content: space-around; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 20; background: rgba(15,17,22,.97); }
  .brand, .spacer, .hide-m { display: none; }
  .nav { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 8px; flex: 1; text-align: center; border-radius: 10px; }
  .nav.on { box-shadow: none; }
  main { padding: 18px 14px 96px; overflow-x: hidden; }
  h1 { font-size: 21px; }
  th.hide-m, td.hide-m { display: none; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}
