@import url("/static/theme.css");

/* ==========================================================
   Ad Director component library.
   A quiet production workbench: clear hierarchy and task-led color.
   ========================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg-scene);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { text-decoration: none; color: var(--accent-hover); }

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; border: 2px solid transparent; }

a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- motion ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes segpulse { 50% { opacity: .55; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-5px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 max(24px, calc((100vw - 1440px) / 2)); min-height: 68px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  transition: background-color .25s ease, border-color .25s ease;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 750; font-size: 15.5px; letter-spacing: -.01em; color: var(--text);
}
.brand:hover { color: var(--text); }
.brand .logo {
  width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-ink); font-size: 13px; flex: none;
  transition: transform .18s ease, box-shadow .18s ease;
}
.brand:hover .logo { background: var(--accent-hover); }
.topnav { display: flex; gap: 3px; flex: 1; margin-left: 26px; }
.topnav a {
  color: var(--muted); padding: 7px 14px; border-radius: 9px;
  font-size: 13.5px; font-weight: 550; letter-spacing: .01em;
  transition: color .15s ease, background .15s ease;
}
.topnav a:hover { color: var(--text); background: var(--panel2); }
.topnav a.on { color: var(--accent); background: var(--accent-soft); font-weight: 650; }

/* legacy user block (superseded by the user chip, kept for contract) */
.who { color: var(--muted); font-size: 12.5px; text-align: right; line-height: 1.35; }
.who .name { color: var(--text); font-weight: 600; }

/* theme toggle */
.theme-btn {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border); border-radius: 9px;
  color: var(--muted); cursor: pointer; padding: 0;
  transition: color .15s ease, background .15s ease, border-color .15s ease, transform .15s ease;
}
.theme-btn:hover { color: var(--text); background: var(--panel2); border-color: var(--border2); }
.theme-btn:active { transform: scale(.92); }
.theme-btn svg { display: block; }
.theme-btn .i-moon { display: none; }
[data-theme="light"] .theme-btn .i-moon { display: block; }
[data-theme="light"] .theme-btn .i-sun { display: none; }

/* user chip + dropdown */
.umenu { position: relative; flex: none; }
.uchip {
  display: flex; align-items: center; gap: 9px;
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 11px 4px 4px; cursor: pointer; color: var(--text);
  font-family: inherit;
  transition: background .15s ease, border-color .15s ease;
}
.uchip:hover { background: var(--panel2); border-color: var(--border2); }
.uavatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  color: var(--accent); font-size: 10.5px; font-weight: 750; letter-spacing: .03em;
}
.uname { font-size: 13.5px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uchev { color: var(--muted); flex: none; transition: transform .18s ease; }
.umenu:has(.udrop.open) .uchev { transform: rotate(180deg); }
.udrop {
  position: absolute; right: 0; top: calc(100% + 9px); min-width: 246px;
  background: var(--panel); border: 1px solid var(--border2); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 120;
  display: none;
}
.udrop.open { display: block; animation: dropIn .16s ease; }
.udrop-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.udrop-name { font-weight: 650; font-size: 13.5px; }
.udrop-email { color: var(--muted); font-size: 12.5px; margin-top: 1px; word-break: break-all; }
.udrop-spend {
  color: var(--muted); font-size: 12px; margin-top: 8px;
  font-family: var(--mono); letter-spacing: -.02em;
}
.udrop-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; border-radius: 8px;
  padding: 8px 12px; font-size: 13.5px; font-weight: 550; font-family: inherit;
  color: var(--text); cursor: pointer;
  transition: background .13s ease, color .13s ease;
}
.udrop-item:hover { background: var(--panel2); color: var(--text); }
.udrop-item.danger { color: var(--red); }
.udrop-item.danger:hover { background: rgba(242, 107, 98, .1); color: var(--red); }
@media (max-width: 720px) { .uname, .uchev { display: none; } .uchip { padding: 4px; } }

/* ---------- layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 40px 32px 80px; }
main.wide { max-width: 1560px; }

.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 28px; }
.page-head h1 { font-size: 30px; margin: 0; font-weight: 650; letter-spacing: -.035em; line-height: 1.2; }
.page-head .sub { color: var(--muted); font-size: 13.5px; }
.page-head .spacer { flex: 1; }

/* run page: main content + sticky sidebar */
.run-cols { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
.col-main { min-width: 0; }
.col-side { position: sticky; top: 86px; }
@media (max-width: 1100px) {
  .run-cols { grid-template-columns: 1fr; }
  .col-side { position: static; }
}

/* ---------- cards / forms ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px 24px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color .18s ease, box-shadow .18s ease, background .25s ease;
}
.card:hover { border-color: var(--border2); }
.card h2 { font-size: 15px; margin: 0 0 14px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h2 .count { color: var(--muted); font-weight: 400; }
.card h2 .spacer { flex: 1; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid.two { grid-template-columns: 1fr; } }

label {
  display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px;
  font-weight: 600; letter-spacing: normal;
}
input, textarea, select {
  width: 100%; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 13px; font-size: 14px;
  font-family: inherit; line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .65; }
input:hover, textarea:hover, select:hover { border-color: var(--border2); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
  background: var(--panel);
}
[data-theme="light"] input:focus, [data-theme="light"] textarea:focus, [data-theme="light"] select:focus { background: #fff; }
textarea { min-height: 96px; resize: vertical; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.flex1 { flex: 1; min-width: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--accent);
  color: var(--accent-ink); border: 1px solid transparent; border-radius: 7px;
  padding: 10px 18px; font-size: 14px; font-weight: 650; letter-spacing: .01em;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  box-shadow: none;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, filter .18s ease;
}
.btn:hover {
  background: var(--accent-hover); color: var(--accent-ink);
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }
.btn.secondary {
  background: transparent; border: 1px solid var(--border2); color: var(--text);
  box-shadow: none;
}
.btn.secondary:hover { background: var(--panel2); border-color: var(--muted); color: var(--text); }
.btn.danger {
  background: transparent; border: 1px solid rgba(242, 107, 98, .45); color: var(--red);
  box-shadow: none;
}
.btn.danger:hover { background: rgba(242, 107, 98, .1); border-color: var(--red); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--muted); border: none; box-shadow: none; }
.btn.ghost:hover { background: var(--panel2); color: var(--text); }
.btn.small { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn.success { background: var(--green); color: #102c1c; }
[data-theme="light"] .btn.success { color: #fff; }
.btn.success:hover { filter: brightness(1.06); }

/* ---------- badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: normal;
  line-height: 1.5;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.running { background: var(--accent-soft); color: var(--accent); }
.badge.running::before { animation: pulse 1.2s infinite; }
.badge.completed { background: rgba(62, 193, 115, .14); color: var(--green); }
.badge.failed, .badge.cancelled, .badge.disabled { background: rgba(242, 107, 98, .13); color: var(--red); }
.badge.queued, .badge.pending, .badge.blocked { background: rgba(217, 163, 56, .15); color: var(--amber); }
.badge.approved, .badge.answered, .badge.admin, .badge.user { background: rgba(169, 126, 248, .15); color: var(--purple); }

.pill {
  background: var(--panel2); border: 1px solid var(--border2); border-radius: 9px;
  padding: 5px 10px; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px;
}

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; padding-bottom: 10px; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--row-hover); }

/* ---------- messages ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--red); font-size: 13px; margin: 8px 0; }
.ok { color: var(--green); font-size: 13px; margin: 8px 0; }
.empty { text-align: center; color: var(--muted); padding: 46px 14px; font-size: 14px; }
.empty .big { font-size: 40px; margin-bottom: 12px; opacity: .55; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--panel); border: 1px solid var(--border2); border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 12px 16px; font-size: 13.5px; min-width: 230px; max-width: 370px;
  box-shadow: var(--shadow-lg); animation: toastIn .2s ease;
}
.toast.ok { border-left-color: var(--green); margin: 0; color: var(--text); }
.toast.err { border-left-color: var(--red); margin: 0; color: var(--text); }

/* ---------- run log ---------- */
.log {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; max-height: 420px; overflow-y: auto;
  font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.6;
}
.col-side .log { max-height: 62vh; }
.log .ts { color: var(--muted); }
.log .tool { color: var(--purple); }
.log .err { color: var(--red); }

/* ---------- question card ---------- */
.qcard {
  border: 1px solid var(--accent-border); border-radius: 14px; padding: 16px 18px; margin: 12px 0;
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  animation: slideIn .22s ease;
}
.qcard .qtitle { font-weight: 650; margin-bottom: 10px; }
.qcard .opt { margin: 4px 6px 0 0; }

/* ---------- auth page ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.08fr 1fr; }
.auth-hero {
  display: flex; align-items: center;
  padding: clamp(32px, 6vw, 96px);
  background: #1d2d40; color: #edf2f7;
}
.auth-hero-inner { width: 100%; max-width: 540px; margin: 0 auto; }
.auth-hero .brand { font-size: 16.5px; color: #edf2f7; margin-bottom: 80px; }
.auth-hero .brand .logo { background: #78b7fa; color: #10243b; }
.auth-hero .brand .logo { width: 34px; height: 34px; border-radius: 10px; font-size: 14px; }
.auth-hero h1 {
  font-size: clamp(38px, 4.5vw, 66px); line-height: 1.06; letter-spacing: -.045em;
  font-weight: 550; margin: 0 0 24px; color: #edf2f7;
}
.auth-hero .tag { font-size: 16px; line-height: 1.75; color: #b6c7da; margin: 0; max-width: 39ch; }
.auth-process { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 64px 0 0; padding: 0; counter-reset: production; }
.auth-process li { border-top: 2px solid #49637e; padding-top: 14px; counter-increment: production; font-size: 14px; }
.auth-process li::before { content: counter(production, decimal-leading-zero); display: block; color: #9db5cf; font-size: 12px; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.auth-process li:last-child { border-color: #78b7fa; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 30; background: var(--panel); box-shadow: var(--shadow-sm); }
.auth-wrap { width: 100%; max-width: 400px; margin: 0; padding: 0; }
.auth-wrap .card { padding: 0; border: none; background: transparent; box-shadow: none; }
.auth-wrap h1 { font-size: 28px; font-weight: 600; margin: 0 0 8px; letter-spacing: -.03em; }
.auth-tabs {
  display: flex; gap: 4px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 11px; padding: 4px; margin: 20px 0;
}
.auth-tabs button {
  flex: 1; background: none; border: none; color: var(--muted); padding: 9px;
  border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.auth-tabs button:hover { color: var(--text); }
.auth-tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
@media (max-width: 920px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { padding: 34px 26px; }
  .auth-hero .brand { margin-bottom: 22px; }
  .auth-hero h1 { font-size: 29px; }
  .auth-process { display: none; }
  .auth-hero .tag { margin-bottom: 0; }
}

/* ---------- products / thumbs ---------- */
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.thumb {
  position: relative; width: 88px; height: 88px; border-radius: 11px; overflow: hidden;
  border: 1px solid var(--border2); background: var(--bg2); cursor: zoom-in;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.thumb:hover { transform: scale(1.045); box-shadow: var(--shadow-md); border-color: var(--muted); z-index: 2; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* storyboard art is 9:16 — show it bigger and in its own aspect */
.thumbs.story .thumb { width: 128px; height: 228px; }
/* character/reference sheets are 16:9 landscape */
.thumbs.story.chars .thumb { width: 228px; height: 128px; }
/* reference frames and question images: source aspect, readable size */
.thumbs.story.refframes .thumb,
.thumbs.keepaspect .thumb { width: auto; height: auto; }
.thumbs.story.refframes .thumb img,
.thumbs.keepaspect .thumb img {
  width: auto; height: auto; max-height: 168px; max-width: 300px;
  object-fit: contain; background: var(--panel);
}
.thumbs.story.refframes .thumb img { max-height: 200px; max-width: 340px; }
.thumb .del {
  position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 7px;
  background: rgba(8, 10, 14, .82); color: #f26b62; border: none; cursor: pointer;
  font-size: 12px; line-height: 1; display: grid; place-items: center;
  opacity: 0; transition: opacity .15s ease, transform .15s ease;
  backdrop-filter: blur(4px);
}
.thumb:hover .del { opacity: 1; }
.thumb .del:hover { transform: scale(1.1); }
.thumb .playbtn {
  position: absolute; inset: 0; margin: auto; width: 32px; height: 32px;
  display: grid; place-items: center; border-radius: 50%; pointer-events: none;
  background: rgba(8, 10, 14, .55); color: #fff; font-size: 12px;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.thumb:hover .playbtn { background: rgba(8, 10, 14, .72); }
.kchip {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  font-size: 9px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase;
  padding: 2.5px 8px; border-radius: 999px;
  background: rgba(8, 10, 14, .8); color: #c9d6ea; backdrop-filter: blur(4px);
}
.kchip.reference { color: #8fb4ff; }
.kchip.avatar { color: #cfaaff; }
.thumb .fname {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 6px; font-size: 9.5px;
  background: rgba(8, 10, 14, .72); color: rgba(238, 242, 251, .75);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  backdrop-filter: blur(4px);
}
.thumb .fname .fsize { color: rgba(238, 242, 251, .5); margin-left: 5px; font-variant-numeric: tabular-nums; }
.drop {
  border: 1.5px dashed var(--border2); border-radius: 12px; padding: 20px; text-align: center;
  color: var(--muted); font-size: 13px; cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.drop.over { transform: scale(1.005); }

/* lightbox — shared image + video viewer for reference media */
#lightbox {
  position: fixed; inset: 0; z-index: 300; display: none;
  place-items: center; padding: 22px;
}
#lightbox.open { display: grid; }
#lightbox .lb-backdrop {
  position: absolute; inset: 0; background: rgba(4, 6, 11, .86); cursor: zoom-out;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#lightbox .lb-panel {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  max-width: min(1100px, 94vw); max-height: 92vh;
  background: var(--panel); border: 1px solid var(--border2);
  border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: slideIn .18s ease;
}
#lightbox .lb-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
#lightbox .lb-bar .spacer { flex: 1; }
#lightbox .lb-title {
  font-size: 13px; color: var(--text); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw;
}
#lightbox .lb-act {
  font-size: 12px; color: var(--muted); text-decoration: none;
  padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border2);
}
#lightbox .lb-act:hover { color: var(--text); border-color: var(--muted); }
#lightbox .lb-close {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border2);
  background: transparent; color: var(--muted); font-size: 17px; line-height: 1;
  cursor: pointer;
}
#lightbox .lb-close:hover { color: var(--text); border-color: var(--muted); }
#lightbox .lb-stage {
  flex: 1 1 auto; min-height: 0; display: grid; place-items: center;
  padding: 14px; background: var(--bg2);
}
#lightbox .lb-stage img {
  max-width: 100%; max-height: calc(92vh - 62px); border-radius: 10px;
  object-fit: contain; box-shadow: var(--shadow-md);
}
#lightbox .lb-stage video {
  max-width: 100%; max-height: calc(92vh - 62px); border-radius: 10px;
  background: #000; display: block;
}
#lightbox .lb-fallback {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--muted); font-size: 13px; padding: 30px;
}

/* modal */
.modal-bg {
  position: fixed; inset: 0; background: var(--overlay); z-index: 150;
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.modal {
  background: var(--panel); border: 1px solid var(--border2); border-radius: var(--radius-xl);
  padding: 24px; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
}

/* ---------- stats / progress ---------- */
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 15px 20px; min-width: 136px; box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.stat:hover { border-color: var(--border2); }
.stat .v { font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }

.progressbar { height: 6px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progressbar .fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px; transition: width .45s ease;
}

/* ---------- milestone stage bar ---------- */
.stagebar { display: flex; gap: 5px; margin: 4px 0 2px; }
.stagebar .seg { flex: 1; min-width: 0; cursor: default; }
.stagebar .seg .track {
  height: 8px; border-radius: 6px; background: var(--bg2);
  border: 1px solid var(--border); overflow: hidden; position: relative;
}
.stagebar .seg .track .f {
  position: absolute; inset: 0; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 6px; transition: width .5s ease;
}
.stagebar .seg.done .track .f { background: linear-gradient(90deg, #2ea043, var(--green)); }
.stagebar .seg.active .track { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.stagebar .seg.active .track .f { animation: segpulse 1.6s ease-in-out infinite; }
.stagebar .seg .lbl {
  margin-top: 6px; font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stagebar .seg.done .lbl { color: var(--green); }
.stagebar .seg.active .lbl { color: var(--accent); font-weight: 750; }
.stagebar.failed .seg .track .f { background: linear-gradient(90deg, #c33, var(--red)); }
.stagebar-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.stagebar-head .pct { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.stagebar-head .cur { color: var(--muted); font-size: 12.5px; }

/* ---------- segmented donut ---------- */
.donut { display: block; }
.donut .track-seg { stroke: var(--border); }
.donut .fill-seg { stroke: var(--accent); transition: stroke-dasharray .5s ease; }
.donut.done .fill-seg { stroke: var(--green); }
.donut.failed .fill-seg { stroke: var(--red); }
.donut text { fill: var(--text); font-size: 11px; font-weight: 700; text-anchor: middle; }
.donut-wrap { display: flex; align-items: center; gap: 10px; }
.donut-wrap .cur { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; max-width: 90px; }

/* ---------- compact doc chips ---------- */
.dochips { display: flex; flex-wrap: wrap; gap: 6px; }
.dochip {
  background: var(--panel2); border: 1px solid var(--border2); border-radius: 9px;
  padding: 5px 11px; font-size: 12.5px; color: var(--text); white-space: nowrap;
  transition: border-color .14s ease, background .14s ease, transform .14s ease;
}
.dochip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); transform: translateY(-1px); }

/* scrollable boxes inside cards */
.scrollbox { max-height: 280px; overflow-y: auto; border-radius: 8px; }
.col-side .scrollbox table { table-layout: fixed; width: 100%; }
.col-side .scrollbox td { word-break: break-word; }

/* collapsible sections (partial clips) */
.fold { margin: 14px 0 6px; }
.fold > summary {
  cursor: pointer; list-style: none; font-size: 11.5px; color: var(--muted);
  font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  padding: 9px 13px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--panel2); display: flex; align-items: center; gap: 8px;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.fold > summary:hover { border-color: var(--accent); color: var(--text); }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸"; color: var(--accent); transition: transform .15s ease; }
.fold[open] > summary::before { content: "▾"; }
.fold[open] > summary { margin-bottom: 10px; }

/* compact audio list */
.audlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 9px; margin: 10px 0; }
.aud {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 9px 11px;
  transition: border-color .15s ease;
}
.aud:hover { border-color: var(--border2); }
.aud .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.aud audio { width: 100%; height: 32px; display: block; }

/* compact clip filmstrip — poster tiles, video loads only on click */
.clipgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 10px 0; }
.clipv video { width: 100%; border-radius: 12px; background: #000; display: block; aspect-ratio: 9 / 16; }
.clipv .poster {
  position: relative; width: 100%; aspect-ratio: 9 / 16; border-radius: 12px;
  overflow: hidden; background: var(--bg2); cursor: pointer; border: 1px solid var(--border2);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.clipv .poster:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--muted); }
.clipv .poster.noimg { background: linear-gradient(160deg, #1a222c, #0b0f15); }
.clipv .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clipv .poster .playbtn {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 26px; color: #fff; background: rgba(5, 7, 10, .38); transition: background .15s ease;
}
.clipv .poster:hover .playbtn { background: rgba(5, 7, 10, .16); }
.clipv .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 5px; }

/* compact answers list */
.ansrow { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ansrow:last-child { border-bottom: none; }
.ansq {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ansa { font-weight: 650; font-size: 12.5px; text-align: right; max-width: 45%; word-break: break-word; }
.anst { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- human-verified gates ---------- */
.gatelbl {
  display: inline-block; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--amber); background: rgba(217, 163, 56, .13); border: 1px solid rgba(217, 163, 56, .38);
  border-radius: 7px; padding: 2px 8px; margin-bottom: 8px; font-weight: 750;
}
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 10px 0; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.fld input, .fld select, .fld textarea {
  width: 100%; background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px; font-size: 13px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}
.fld textarea { resize: vertical; }
.verdict {
  display: inline-block; font-weight: 750; color: var(--accent);
  text-transform: uppercase; font-size: 11px; letter-spacing: .05em;
}

/* reference strip */
.refstrip { margin: 8px 0 12px; }
.refvideo { max-width: 260px; margin-bottom: 8px; }
.refvideo video { width: 100%; border-radius: 12px; background: #000; display: block; }
.refvideo .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* takes */
.takes { display: grid; gap: 8px; margin: 8px 0; }
.take {
  display: flex; gap: 10px; align-items: center; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 12px; padding: 9px 11px; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.take:hover { border-color: var(--border2); }
.take input { width: auto; accent-color: var(--accent); }
.take .tk { flex: 1; min-width: 0; }
.take .tk audio { width: 100%; height: 34px; display: block; margin-top: 4px; }
.take:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); background: var(--accent-soft); }

/* per-board rows (review + board map) */
.boardq, #boardList { display: grid; gap: 9px; margin: 8px 0; }
.boardrow {
  display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 13px; padding: 10px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.boardrow:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }
.boardrow .bthumb {
  width: 84px; height: 148px; object-fit: cover; border-radius: 9px;
  border: 1px solid var(--border2); cursor: zoom-in; background: var(--panel);
  transition: transform .16s ease, box-shadow .16s ease;
}
.boardrow .bthumb:hover { transform: scale(1.03); box-shadow: var(--shadow-md); }
.boardrow .bmeta { min-width: 0; display: grid; gap: 4px; }
.boardrow .btitle { font-weight: 650; font-size: 13px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.boardrow .bref {
  display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted);
  word-break: break-word;
}
.boardrow .refthumb {
  width: auto; height: auto; max-height: 120px; max-width: 180px;
  object-fit: contain; border-radius: 6px; background: var(--panel);
  border: 1px solid var(--border2); cursor: zoom-in; flex: none;
  transition: transform .16s ease;
}
.boardrow .refthumb:hover { transform: scale(1.06); }
.boardrow .bprev { font-size: 11.5px; color: var(--amber); word-break: break-word; }
.boardrow .bacts { display: flex; flex-direction: column; gap: 6px; }
.boardrow .bacts .bkeep, .boardrow .bacts .brev { min-width: 76px; }
.boardrow .bacts .btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.boardrow .bnote, .cliprow .cnote {
  grid-column: 2 / -1; width: 100%; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border2); border-radius: 9px; padding: 7px 10px; font-size: 12.5px;
  font-family: inherit; transition: border-color .15s ease, box-shadow .15s ease;
}
.boardrow .bnote:focus, .cliprow .cnote:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* storyboard blocks */
.boardblock {
  border: 1px solid var(--border); border-radius: 14px; background: var(--panel2);
  padding: 12px 14px; margin: 0;
}
.boardblock-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .01em;
}
.boardstrip {
  display: grid; grid-template-columns: repeat(4, minmax(0, 150px)); gap: 9px; margin: 8px 0 10px;
}
.bcell {
  position: relative; aspect-ratio: 9 / 16; border-radius: 9px; overflow: hidden;
  border: 1px solid var(--border2); background: var(--panel); cursor: zoom-in;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.bcell:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--muted); }
.bcell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bcell .fname {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 6px; font-size: 9.5px;
  background: rgba(8, 10, 14, .72); color: rgba(238, 242, 251, .75);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.boardrows { display: grid; gap: 9px; }

/* board reference images */
.brefs { grid-column: 2 / -1; display: grid; gap: 6px; }
.brefthumbs { display: flex; flex-wrap: wrap; gap: 7px; align-items: flex-start; }
.brefthumb {
  position: relative; width: auto; height: auto; border-radius: 7px; overflow: visible;
  border: 1px solid var(--border2); background: var(--panel);
  transition: transform .15s ease, box-shadow .15s ease;
}
.brefthumb:hover { transform: scale(1.06); box-shadow: var(--shadow-sm); }
.brefthumb img {
  width: auto; height: auto; max-height: 80px; max-width: 150px; object-fit: contain;
  display: block; border-radius: 7px; cursor: zoom-in; background: var(--panel);
}
.brefthumb .brefdel {
  position: absolute; top: -7px; right: -7px; width: 18px; height: 18px;
  border-radius: 50%; border: 1px solid var(--border2); background: var(--panel);
  color: var(--muted); font-size: 11px; line-height: 1; cursor: pointer; padding: 0;
  transition: color .13s ease, border-color .13s ease, transform .13s ease;
}
.brefthumb .brefdel:hover { color: var(--red); border-color: var(--red); transform: scale(1.15); }
.brefadd { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.brefadd .brefurl {
  flex: 1; min-width: 150px; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border2); border-radius: 9px; padding: 7px 10px; font-size: 12px;
  font-family: inherit; transition: border-color .15s ease, box-shadow .15s ease;
}
.brefadd .brefurl:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* per-clip review rows */
.clipq { display: grid; gap: 9px; margin: 8px 0; }
.cliprow {
  display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; align-items: start;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 13px; padding: 10px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cliprow:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }
.cliprow .clipv .poster { aspect-ratio: 9 / 16; border-radius: 9px; }
.cliprow .bmeta { display: grid; gap: 5px; min-width: 0; }
.cliprow .flagchk { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); cursor: pointer; }
.cliprow .flagchk input, .cliprow .flagchk .cflag { width: auto; accent-color: var(--red); }

/* ---------- new-run intake form ---------- */
.nr-head { margin-bottom: 18px; }
.nr-head h2 { font-size: 19px; margin: 0 0 4px; font-weight: 750; letter-spacing: -.02em; }
.nr-sec {
  border: 1px solid var(--border); border-radius: 14px; padding: 15px 17px;
  margin-bottom: 12px; background: var(--panel2);
}
.nr-sec-t {
  font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.nr-sec label { margin-top: 9px; }
.nr-sec label:first-of-type { margin-top: 0; }
.nr-row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.nr-row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 700px) { .nr-row2, .nr-row3 { grid-template-columns: 1fr; } }
.nr-opt {
  display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  border: 1px solid var(--border2); border-radius: 11px; padding: 11px 13px;
  background: var(--panel);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.nr-opt:hover { border-color: var(--muted); transform: translateY(-1px); }
.nr-opt.on {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--ring);
}
.nr-opt input { display: none; }
.nr-opt-t { font-weight: 650; font-size: 13.5px; color: var(--text); }
.nr-opt-badge {
  display: inline-block; margin-left: 8px; font-size: 10px; letter-spacing: .05em;
  color: var(--muted); border: 1px solid var(--border2); border-radius: 999px;
  padding: 1px 8px; text-transform: uppercase; vertical-align: middle; font-weight: 650;
}
.nr-file {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  border: 1.5px dashed var(--border2); border-radius: 11px; padding: 11px 13px;
  transition: border-color .15s ease, background .15s ease;
}
.nr-file:hover { border-color: var(--accent); background: var(--accent-soft); }
.nr-foot {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--border);
}

/* ---------- new-run wizard modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: var(--overlay); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 6vh 18px 60px;
}
.modal-overlay .modal, #newRunCard.modal { max-width: 780px; padding: 26px 28px 24px; }

.nr-steps {
  display: flex; gap: 2px; margin: 4px 0 22px;
  border-bottom: 1px solid var(--border); padding-bottom: 15px;
}
.nr-step-dot {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 11px; border-radius: 9px; flex: 0 0 auto; min-width: 0;
  transition: background .15s ease;
}
.nr-step-dot:hover { background: var(--panel2); }
.nr-step-dot .n {
  width: 23px; height: 23px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 750;
  background: var(--bg2); border: 1px solid var(--border2); color: var(--muted);
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.nr-step-dot .t {
  font-size: 11.5px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.nr-step-dot.on .n {
   background: var(--accent);
   border-color: transparent; color: var(--accent-ink); box-shadow: none;
}
.nr-step-dot.on .t { color: var(--text); }
.nr-step-dot.done .n { background: rgba(62, 193, 115, .15); border-color: var(--green); color: var(--green); }
@media (max-width: 620px) { .nr-step-dot .t { display: none; } .nr-step-dot { justify-content: center; } }

.nr-step-panel { animation: fadeUp .24s ease; }

.nr-review { display: grid; gap: 2px; }
.nr-review-row {
  display: flex; gap: 14px; padding: 8px 11px; border-radius: 9px; font-size: 13.5px;
}
.nr-review-row:nth-child(odd) { background: var(--panel2); }
.nr-review-row .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; width: 130px; flex: none; padding-top: 2px; }
.nr-review-row .v { color: var(--text); word-break: break-word; white-space: pre-wrap; }

/* ---------- model picker (model-picker.js) ---------- */
.mp-wrap { position: relative; }
.mp-input { width: 100%; }
.mp-dd {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 130;
  background: var(--panel); border: 1px solid var(--border2); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; padding: 5px;
  animation: dropIn .14s ease;
}
.mp-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: background .12s ease;
}
.mp-row:hover, .mp-row.mp-active { background: var(--accent-soft); }
.mp-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; flex: none; }

/* ---------- skeleton + spinner utilities ---------- */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--bg2); border-radius: var(--radius-sm);
  min-height: 14px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--shimmer), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.5s ease infinite;
}
.spinner {
  display: inline-block; width: 16px; height: 16px; flex: none;
  border: 2px solid var(--border2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}

/* Keep navigation and working controls usable without shrinking the page. */
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 400; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); border-radius: 6px; }
.skip-link:focus { top: 12px; }
button { font-family: inherit; }
input, select, textarea { min-width: 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.btn.small { min-height: 34px; }
.audlist { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.stat .v, .rcard-cost { font-variant-numeric: tabular-nums; }
.thumb:focus-within .del { opacity: 1; }

@media (hover: none) { .thumb .del { opacity: 1; } }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 18px 0; }
  .topbar .brand { margin-right: auto; }
  .topnav { order: 3; flex: 1 0 100%; margin: 0; overflow-x: auto; padding: 0 0 9px; }
  .topnav a { padding: 8px 12px; }
  main, main.wide { padding: 26px 18px 56px; }
  .page-head { gap: 12px; }
  .page-head > .sub { flex-basis: 100%; order: 1; }
  .page-head .spacer { display: none; }
  .page-head > .btn:last-child { margin-left: auto; }
  .card { padding: 18px; }
  .modal-overlay { padding: 12px; }
  .toast { min-width: 0; max-width: calc(100vw - 32px); }
  #toasts { bottom: 16px; right: 16px; }
}
