:root {
  --bg: #0b0b0d;
  --bg-2: #121216;
  --bg-3: #1a1a20;
  --line: #26262e;
  --line-2: #34343e;
  --fg: #f3f1ec;
  --fg-2: #a9a6a0;
  --fg-3: #6f6c68;
  --accent: #ff5a36;
  --accent-soft: rgba(255, 90, 54, .14);
  --ok: #7bd88f;
  --warn: #f2c14e;
  --err: #ff6b6b;
  --gutter: clamp(16px, 3.2vw, 56px);
  --radius: 10px;
  --sans: "Instrument Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.muted { color: var(--fg-2); }
.faint { color: var(--fg-3); }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 32px;
  height: var(--nav-h); padding: 0 var(--gutter);
  background: rgba(11, 11, 13, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; letter-spacing: -.02em; text-decoration: none; }
.brand img { border-radius: 7px; display: block; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 8px 14px; border-radius: 8px; text-decoration: none;
  color: var(--fg-2); font-size: 14px; font-weight: 500;
}
.nav a:hover { color: var(--fg); background: var(--bg-2); }
.nav a.active { color: var(--fg); background: var(--bg-3); }
.top-right { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.status-dot { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-2); }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--fg-3); }
.status-dot.on::before { background: var(--ok); box-shadow: 0 0 0 4px rgba(123, 216, 143, .15); }
.status-dot.off::before { background: var(--err); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line-2);
  background: transparent; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { border-color: var(--fg-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #140600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ghost { border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { color: var(--fg); background: var(--bg-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

main { padding: 40px var(--gutter) 80px; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 36px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
h1 { font-size: clamp(28px, 3.6vw, 52px); line-height: 1.05; letter-spacing: -.035em; margin: 0; font-weight: 600; }
h2 { font-size: 20px; letter-spacing: -.02em; margin: 0 0 16px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-2); margin: 0 0 14px; }
.lead { color: var(--fg-2); max-width: 62ch; margin: 12px 0 0; }

.figures { display: flex; flex-wrap: wrap; gap: clamp(24px, 4vw, 64px); }
.figure .k { font-size: 12px; color: var(--fg-3); }
.figure .v { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.figure .s { font-size: 12px; color: var(--fg-3); }

/* Studio */
.studio-head { display: flex; flex-wrap: wrap; gap: 20px 40px; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; }
.project-pick { display: flex; flex-direction: column; gap: 10px; min-width: 0; flex: 1 1 520px; }
.project-pick select {
  appearance: none; background: transparent; border: 0; padding: 0; cursor: pointer;
  font-size: clamp(28px, 3.6vw, 52px); font-weight: 600; letter-spacing: -.035em; line-height: 1.05;
  max-width: 100%; text-overflow: ellipsis;
}
.project-pick select option { font-size: 16px; background: var(--bg-2); }
.meta-line { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--fg-2); }
.meta-line b { color: var(--fg); font-weight: 600; }

.timeline { margin-bottom: 36px; }
.tl-track { position: relative; display: flex; height: 64px; border-radius: var(--radius); overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); }
.tl-seg {
  position: relative; min-width: 0; padding: 10px 10px; border: 0; border-right: 1px solid var(--line);
  background: transparent; text-align: left; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
}
.tl-seg:last-child { border-right: 0; }
.tl-seg:hover { background: var(--bg-3); }
.tl-seg.active { background: var(--accent-soft); }
.tl-seg .n { font-family: var(--mono); font-size: 11px; color: var(--fg-3); }
.tl-seg.active .n { color: var(--accent); }
.tl-seg .t { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; box-shadow: 0 0 12px var(--accent); }
.tl-scale { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; color: var(--fg-3); }

.studio-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: clamp(28px, 4vw, 72px); align-items: start; }
.player-col { position: sticky; top: calc(var(--nav-h) + 20px); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.phone {
  position: relative; width: 100%; max-width: 360px; aspect-ratio: 9 / 16;
  border-radius: 22px; overflow: hidden; background: #000;
  box-shadow: 0 0 0 1px var(--line-2), 0 30px 80px -20px rgba(255, 90, 54, .25);
}
.phone video { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.phone .empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 32px; text-align: center; color: var(--fg-3); font-size: 14px; }
.controls { width: 100%; max-width: 360px; }
.controls .row { display: flex; align-items: center; gap: 12px; }
.controls input[type=range] { flex: 1; accent-color: var(--accent); }
.controls .times { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--fg-3); margin-top: 6px; }
.controls .times span:nth-child(2) { color: var(--fg-2); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scene-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.scene-list li {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 12px; align-items: baseline;
  padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.scene-list li:hover { background: var(--bg-2); }
.scene-list .n { font-family: var(--mono); font-size: 12px; color: var(--fg-3); }
.scene-list .t { font-weight: 600; }
.scene-list .tc { font-family: var(--mono); font-size: 12px; color: var(--fg-3); }
.scene-list .d { grid-column: 2 / 4; color: var(--fg-2); font-size: 14px; }
.scene-list li.active .n, .scene-list li.active .t { color: var(--accent); }

.side-block { padding-bottom: 28px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.side-block:last-child { border-bottom: 0; }

.tiers { display: flex; flex-direction: column; gap: 8px; }
.tier {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 4px 12px; align-items: baseline;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.tier input { accent-color: var(--accent); margin: 0; }
.tier:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tier .name { font-weight: 600; }
.tier .price { font-family: var(--mono); font-size: 13px; }
.tier .desc { grid-column: 2 / 4; font-size: 13px; color: var(--fg-2); }

.progress { height: 4px; border-radius: 4px; background: var(--bg-3); overflow: hidden; margin: 10px 0 6px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .6s ease; }
.job-line { font-size: 13px; color: var(--fg-2); }
.job-line.err { color: var(--err); white-space: pre-wrap; word-break: break-word; }

/* Lists */
.rows { border-top: 1px solid var(--line); }
.row-item {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 8px 24px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line);
}
.row-item .title { font-weight: 600; font-size: 16px; }
.row-item .sub { font-size: 13px; color: var(--fg-2); margin-top: 2px; }
.row-item .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg-3); color: var(--fg-2); }
.tag.ok { background: rgba(123, 216, 143, .14); color: var(--ok); }
.tag.warn { background: rgba(242, 193, 78, .14); color: var(--warn); }
.tag.err { background: rgba(255, 107, 107, .14); color: var(--err); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.empty-note { padding: 40px 0; color: var(--fg-3); border-bottom: 1px solid var(--line); }

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: clamp(32px, 4vw, 72px); align-items: start; }
.panel { position: sticky; top: calc(var(--nav-h) + 24px); }

/* Forms */
form.stack { display: flex; flex-direction: column; gap: 14px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--fg-2); }
.f input, .f select, .f textarea {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; color: var(--fg); font-size: 15px; width: 100%;
}
.f textarea { min-height: 120px; resize: vertical; font-family: var(--mono); font-size: 13px; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--accent); }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--fg-3); }
.checks { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; }
.checks label { display: flex; gap: 6px; align-items: center; color: var(--fg); }
.checks input { accent-color: var(--accent); }

/* Planner */
.day { margin-bottom: 28px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.day-head b { font-size: 16px; }

/* Trends */
.score { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 13px; }
.score .bar { width: 90px; height: 4px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.score .bar i { display: block; height: 100%; background: var(--accent); }

/* Costs */
.calc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 48px; margin-top: 8px; }
.calc .f input[type=range] { padding: 0; background: none; border: 0; accent-color: var(--accent); }
.calc-out { display: flex; flex-wrap: wrap; gap: 48px; padding-top: 32px; margin-top: 32px; border-top: 1px solid var(--line); }
.calc-out .v { font-size: clamp(28px, 3vw, 44px); font-weight: 600; letter-spacing: -.03em; }
.tier-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.tier-table th, .tier-table td { text-align: left; padding: 16px 16px 16px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tier-table th { font-size: 12px; color: var(--fg-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.tier-table td:first-child { font-weight: 600; white-space: nowrap; }

/* Dialog + toast */
dialog { background: var(--bg-2); color: var(--fg); border: 1px solid var(--line-2); border-radius: 14px; padding: 28px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--fg); color: var(--bg); padding: 12px 20px; border-radius: 10px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--err); color: #1a0000; }

footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 24px var(--gutter); border-top: 1px solid var(--line); font-size: 12px; color: var(--fg-3); }

.mobile-nav { display: none; }


.studio-title { min-width: 0; }
.studio-title .eyebrow { display: flex; align-items: center; gap: 12px; }
.studio-title select {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; color: var(--fg-2);
  font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 500; padding: 3px 8px; max-width: 60vw;
}
#studio-title { margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--fg-3); white-space: nowrap;
}
.tabs button:hover { color: var(--fg); }
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.render-cover {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center; background: rgba(11, 11, 13, .88); backdrop-filter: blur(6px);
}
.cover-pct { font-size: 44px; font-weight: 600; }
.render-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; }
.limits { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.lead.tight { margin: 0 0 20px; font-size: 14px; }
.mt { margin-top: 36px; }
.f textarea.plain { font-family: var(--sans); font-size: 15px; min-height: 90px; }
.start-split { margin-top: 48px; }
.mini { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; display: flex; justify-content: space-between; gap: 12px; }
.mini:first-child { border-top: 1px solid var(--line); }
.mini .l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .r { color: var(--fg-3); white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.row-item.click { cursor: pointer; }
.row-item.click:hover { background: var(--bg-2); }
.calc-box { margin-top: 56px; border-top: 1px solid var(--line); padding-top: 20px; }
.calc-box summary { cursor: pointer; font-weight: 600; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-2); }
.calc-box[open] summary { margin-bottom: 24px; }

@media (max-width: 980px) {
  .split { grid-template-columns: 1fr; }
  .panel { position: static; }
  .calc { grid-template-columns: 1fr; }
  .row-item { grid-template-columns: minmax(0, 1fr) auto; }
  .row-item > :nth-child(2), .row-item > :nth-child(3) { grid-column: 1 / 2; }
  .row-item .actions { grid-row: 1; grid-column: 2; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar { gap: 12px; }
  .nav, .top-right .status-dot { display: none; }
  .top-right { margin-left: auto; }
  main { padding-top: 24px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .studio-grid { grid-template-columns: 1fr; }
  .player-col { position: static; }
  .tabs { position: sticky; top: var(--nav-h); z-index: 5; background: var(--bg); margin: 0 calc(var(--gutter) * -1) 20px; padding: 10px var(--gutter); overflow-x: auto; }
  .phone { max-width: min(340px, 100%); }
  .tl-track { height: 44px; }
  .tl-seg { padding: 6px; }
  .tl-seg .t { display: none; }
  .project-pick select { font-size: 24px; white-space: normal; }
  .tl-scale span:not(:first-child):not(:last-child) { display: none; }
  .f-row { grid-template-columns: 1fr; }
  .tier-table thead { display: none; }
  .tier-table tr { display: block; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .tier-table td { display: block; border: 0; padding: 2px 0; }
  footer { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(18, 18, 22, .94); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .mobile-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 8px 2px; text-decoration: none; font-size: 11px; font-weight: 600; color: var(--fg-3); border-radius: 8px;
  }
  .mobile-nav a::before { content: ""; width: 18px; height: 3px; border-radius: 3px; background: currentColor; opacity: .4; }
  .mobile-nav a.active { color: var(--fg); }
  .mobile-nav a.active::before { background: var(--accent); opacity: 1; }
}

.work-col { min-width: 0; }
html, body { overflow-x: clip; }

.conns { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.conn { display: flex; justify-content: space-between; gap: 10px; color: var(--fg-3); }
.conn b { color: var(--fg-2); font-weight: 600; margin-right: 4px; }
.conn.on { color: var(--fg); }
.conn.on b { color: var(--ok); }
button.link { background: none; border: 0; padding: 0; font-weight: 600; font-size: 13px; color: var(--fg-2); }
button.link.accent { color: var(--accent); }
button.link:hover { text-decoration: underline; }
button.link:disabled { opacity: .4; cursor: not-allowed; text-decoration: none; }
.row-item.ch { grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1.6fr) minmax(0, 1fr) auto; }
.conn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 980px) { .row-item.ch { grid-template-columns: minmax(0, 1fr) auto; } }
