@font-face { font-family: 'Big Shoulders Display'; src: url('/fonts/big-shoulders-display-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Big Shoulders Display'; src: url('/fonts/big-shoulders-display-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/fonts/instrument-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/fonts/instrument-sans-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/fonts/instrument-sans-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  /* A monitor housing, lit by two color temperatures */
  --housing: #1c2129;
  --panel: #232933;
  --raised: #2c3340;
  --line: #3a4250;
  --text: #eef0f3;
  --muted: #a3acba;
  --tungsten: #ffb04a;   /* 3200K: actions, focus marks */
  --daylight: #8eb9f5;   /* 5600K: selection and state */
  --tally: #ff5a4f;      /* recording only */
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --ui: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--housing);
  color: var(--text);
  font: 400 15px/1.5 var(--ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--daylight); }
code { font-size: 0.92em; background: var(--raised); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--daylight); outline-offset: 2px; }

h2 { font: 600 22px/1.1 var(--display); letter-spacing: 0.01em; margin: 0 0 14px; }
h3 { font: 600 18px/1.2 var(--display); margin: 22px 0 6px; }
.fine { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.muted { color: var(--muted); }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
  background: var(--housing);
}
.wordmark { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.wordmark .mark { width: 26px; height: 26px; color: var(--tungsten); }
.wordmark span { font: 800 30px/1 var(--display); letter-spacing: 0.02em; }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
.topnav { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.linkish {
  background: none; border: 0; color: var(--muted); text-decoration: none;
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: 14px;
}
.linkish:hover { color: var(--text); background: var(--panel); }
.cost { color: var(--tungsten); font-weight: 600; }

/* Layout */
.studio {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  grid-template-areas: "rig monitor move" "rig reel finish";
  grid-template-rows: auto 1fr;
  gap: 0;
  align-items: start;
}
.monitor { grid-area: monitor; padding: 18px 22px 0; min-width: 0; }
.reel { grid-area: reel; padding: 8px 22px 40px; min-width: 0; }
.rig { grid-area: rig; border-right: 1px solid var(--line); }
.moves { grid-area: move; border-left: 1px solid var(--line); }
.finish { grid-area: finish; border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.panel { padding: 18px 18px 28px; }
.tabs { display: none; }

/* Viewfinder */
.viewfinder {
  position: relative; width: 100%; margin: 0 auto;
  background: #0f1217; border-radius: var(--r-md);
  overflow: hidden; aspect-ratio: 2.39 / 1;
  box-shadow: 0 0 0 1px var(--line);
  max-height: 62vh;
}
.viewfinder canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: manipulation; }
.frame-lines { position: absolute; inset: 0; pointer-events: none; }
.frame-lines i { position: absolute; width: 22px; height: 22px; border: 2px solid rgba(238, 240, 243, 0.55); }
.frame-lines i:nth-child(1) { top: 12px; left: 12px; border-right: 0; border-bottom: 0; }
.frame-lines i:nth-child(2) { top: 12px; right: 12px; border-left: 0; border-bottom: 0; }
.frame-lines i:nth-child(3) { bottom: 12px; left: 12px; border-right: 0; border-top: 0; }
.frame-lines i:nth-child(4) { bottom: 12px; right: 12px; border-left: 0; border-top: 0; }
.frame-lines b { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%); }
.frame-lines b::before, .frame-lines b::after { content: ''; position: absolute; background: rgba(238, 240, 243, 0.45); }
.frame-lines b::before { left: 8px; top: 0; width: 2px; height: 18px; }
.frame-lines b::after { top: 8px; left: 0; height: 2px; width: 18px; }
.focus-mark {
  position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 2px solid var(--tungsten); border-radius: 50%; pointer-events: none;
  animation: focusmark 900ms ease-out forwards;
}
@keyframes focusmark { from { transform: scale(1.6); opacity: 1; } 70% { opacity: 1; } to { transform: scale(1); opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .frame-lines i { animation: frame-in 700ms cubic-bezier(.2, .7, .2, 1) both; }
  .frame-lines i:nth-child(2) { animation-delay: 60ms; }
  .frame-lines i:nth-child(3) { animation-delay: 120ms; }
  .frame-lines i:nth-child(4) { animation-delay: 180ms; }
  @keyframes frame-in { from { opacity: 0; transform: scale(1.8); } to { opacity: 1; transform: none; } }
}

.tally {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(15, 18, 23, 0.75); padding: 4px 12px; border-radius: 999px;
  font: 600 18px/1 var(--display); letter-spacing: 0.04em;
}
.tally .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tally); }
.vf-status {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: min(420px, 80%); background: rgba(15, 18, 23, 0.82); border-radius: var(--r-md);
  padding: 10px 14px; text-align: center;
}
.vf-status p { margin: 6px 0 0; font-size: 13px; }
.meter { height: 4px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--tungsten); transition: width 160ms linear; }
.meter.indeterminate .meter-fill { width: 30%; animation: sweep 1.2s ease-in-out infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.drop-hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(15, 18, 23, 0.7); border: 2px dashed var(--daylight); border-radius: var(--r-md);
  font: 600 24px var(--display);
}

/* HUD */
.hud { display: flex; align-items: baseline; gap: 26px; padding: 12px 4px 6px; flex-wrap: wrap; }
.hud-cell { display: flex; align-items: baseline; gap: 2px; }
.hud-num { font: 800 34px/1 var(--display); }
.hud-unit { font: 600 18px/1 var(--display); color: var(--muted); }
.hud-wide { flex-direction: column; gap: 2px; margin-left: auto; text-align: right; align-items: flex-end; }
.hud-small { font-size: 13px; line-height: 1.3; }

/* Lens ring: engraved focal marks under a fixed index */
.lens-ring {
  position: relative; display: flex; justify-content: space-between; align-items: end;
  margin: 8px 0 16px; padding: 20px 14px 10px;
  background: repeating-linear-gradient(90deg, transparent 0 11px, rgba(238, 240, 243, 0.08) 11px 12px), linear-gradient(#262c36, #1f242c);
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.lens-ring button {
  position: relative; background: none; border: 0; cursor: pointer; color: var(--muted);
  font: 600 22px/1 var(--display); padding: 4px 8px; border-radius: var(--r-sm);
}
.lens-ring button::before {
  content: ''; position: absolute; left: 50%; top: -14px; width: 2px; height: 9px;
  background: rgba(238, 240, 243, 0.35); transform: translateX(-50%);
}
.lens-ring button:hover { color: var(--text); }
.lens-ring button[aria-checked="true"] { color: var(--tungsten); }
.lens-ring button[aria-checked="true"]::before { background: var(--tungsten); height: 13px; top: -18px; width: 3px; }

/* Composer */
.composer textarea, .compiled textarea {
  width: 100%; resize: vertical; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px; line-height: 1.45;
}
.compiled textarea:focus { border-color: var(--daylight); outline: none; }
.composer {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px 10px 10px;
}
.composer:focus-within { border-color: #4b5668; }
.composer textarea { border: 0; background: transparent; padding: 6px 6px 10px; resize: none; font-size: 15px; }
.composer textarea:focus { outline: none; }
.composer-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: stretch; }
.chip {
  display: inline-flex; flex-direction: column; justify-content: center; align-items: flex-start;
  min-height: 42px; padding: 3px 11px; border-radius: 8px; cursor: pointer; text-align: left;
  background: var(--raised); border: 1px solid var(--line);
}
.chip:hover { border-color: #566173; }
.chip[aria-expanded="true"] { border-color: var(--daylight); }
.chip-k { font-size: 11px; line-height: 1.2; color: var(--muted); }
.chip-v { font-size: 13px; line-height: 1.25; font-weight: 500; white-space: nowrap; }
.takes-pick { display: flex; align-items: center; gap: 2px; padding: 3px 6px 3px 11px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line); }
.takes-pick .chip-k { margin-right: 6px; }
.takes-pick button { width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.takes-pick button[aria-checked="true"] { background: var(--housing); color: var(--text); box-shadow: inset 0 0 0 1px var(--daylight); }
.composer-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.pop {
  position: absolute; left: 10px; top: calc(100% + 6px); z-index: 12; width: min(560px, calc(100% - 20px));
  max-height: min(60vh, 520px); overflow: auto; padding: 14px; border-radius: 12px;
  background: var(--raised); border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.pop h3 { margin: 0 0 10px; }
.pop .opts { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pop .opt { background: var(--panel); }

/* Takes */
.takes-strip { margin-top: 12px; }
.takes-strip ul { list-style: none; padding: 0; margin: 6px 0 0; display: flex; gap: 8px; overflow-x: auto; }
.take { flex: 0 0 auto; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #0f1217; cursor: pointer; position: relative; }
.take img { display: block; height: 84px; width: auto; }
.take[aria-pressed="true"] { border-color: var(--daylight); }
.take span { position: absolute; left: 6px; bottom: 4px; font-size: 11px; font-weight: 600; background: rgba(15, 18, 23, 0.75); padding: 1px 6px; border-radius: 4px; }
.take.pending { width: 150px; height: 88px; display: grid; place-items: center; color: var(--muted); font-size: 12px; cursor: default; border-style: dashed; border-color: var(--line); }

/* Storyboard */
.board { margin-top: 24px; }
.board-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.board-head h2 { margin: 0; }
.board-actions { margin-left: auto; display: flex; gap: 8px; }
.board-list { list-style: none; padding: 0 0 6px; margin: 12px 0 0; display: flex; gap: 10px; overflow-x: auto; }
.shot-card { flex: 0 0 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.shot-card.active { border-color: var(--daylight); }
.shot-card.playing { border-color: var(--tungsten); }
.shot-card .thumb { display: block; width: 100%; padding: 0; border: 0; background: #0f1217; cursor: pointer; }
.shot-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.shot-card .meta { padding: 8px 10px 4px; }
.shot-card .meta strong { font: 600 18px/1 var(--display); margin-right: 6px; }
.shot-card .meta span { font-size: 12px; color: var(--muted); }
.shot-card .ctrl { display: flex; gap: 4px; padding: 4px 6px 8px; }
.shot-card .ctrl button { flex: 1; min-height: 30px; border-radius: 6px; border: 1px solid var(--line); background: transparent; cursor: pointer; color: var(--muted); }
.shot-card .ctrl button:hover { color: var(--text); border-color: #566173; }

/* Move categories */
.move-groups { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.move-groups button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.move-groups button[aria-selected="true"] { color: var(--text); border-color: var(--daylight); background: #26303e; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn .short { display: none; }
.btn.primary-outline { background: transparent; border-color: var(--tungsten); color: var(--tungsten); font-weight: 600; }
.actions .row .btn { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: var(--r-sm);
  background: var(--raised); border: 1px solid var(--line); cursor: pointer; font-weight: 500;
}
.btn:hover { border-color: #566173; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--tungsten); color: #23170a; border-color: var(--tungsten); font-weight: 600; min-width: 120px; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.record .rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--tally); }
.btn.record.is-recording { border-color: var(--tally); }

.compiled { margin-top: 14px; }
.compiled summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 0; }
.compiled summary:hover { color: var(--text); }
.compiled textarea { margin-top: 8px; font-size: 13px; color: #cfd5de; }

/* Groups */
.group { border: 0; padding: 0; margin: 0 0 18px; }
.group legend { font-weight: 600; font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 8px; }
.opts { display: grid; gap: 6px; grid-template-columns: 1fr 1fr; }
.opt {
  display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 10px; cursor: pointer;
}
.opt strong { display: block; font-weight: 500; font-size: 13px; line-height: 1.25; }
.opt small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.3; margin-top: 2px; }
.opt[aria-checked="true"] { border-color: var(--daylight); background: #26303e; }
.chips .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .opt { width: auto; padding: 6px 10px; font-size: 13px; }
.select { display: block; }
.select select, .comfy-settings input {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 10px; margin-top: 4px;
}
.select.small { font-size: 13px; color: var(--muted); flex: 1; }
.comfy-settings { margin-top: 10px; display: grid; gap: 8px; font-size: 13px; color: var(--muted); }

/* Moves */
.move-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.move {
  display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 8px 6px 4px; cursor: pointer; text-align: left; min-height: 48px;
}
.move svg { width: 44px; height: 36px; }
.move svg .stage { fill: none; stroke: var(--line); stroke-width: 1.5; }
.move svg .path { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.move span { font-size: 13px; font-weight: 500; line-height: 1.2; }
.move[aria-checked="true"] { border-color: var(--daylight); background: #26303e; }
.move[aria-checked="true"] svg .path { stroke: var(--daylight); }
.sliders { display: grid; gap: 12px; margin: 16px 0; }
.slider span { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.slider output { color: var(--text); }
.slider input { width: 100%; accent-color: var(--tungsten); }
.row { display: flex; gap: 10px; }
.actions { display: grid; gap: 8px; margin-top: 16px; }
.actions .btn { width: 100%; }

/* Reel */
.reel h2 { margin-bottom: 4px; }
.reel-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.reel-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.reel-item button.thumb { display: block; width: 100%; padding: 0; border: 0; background: #0f1217; cursor: pointer; }
.reel-item img, .reel-item video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.reel-item .meta { padding: 6px 8px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.reel-item .meta a { font-weight: 600; }

/* Dialogs */
.sheet {
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 22px 22px;
}
.sheet::backdrop { background: rgba(10, 12, 15, 0.7); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 28px; }
.close { background: none; border: 0; font-size: 28px; cursor: pointer; color: var(--muted); line-height: 1; padding: 4px 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
th, td { text-align: left; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
td:last-child { color: var(--tungsten); font-weight: 600; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 16px; max-width: min(560px, calc(100vw - 32px)); font-size: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35); z-index: 20;
}
.toast.error { border-color: var(--tally); }

/* Tablet: monitor on top, panels side by side below */
@media (max-width: 1180px) {
  .studio { grid-template-columns: 1fr 1fr; grid-template-areas: "monitor monitor" "rig move" "rig finish" "reel reel"; }
  .rig { border-right: 1px solid var(--line); border-top: 1px solid var(--line); }
  .moves { border-left: 0; border-top: 1px solid var(--line); }
  .finish { border-left: 0; }
  .tagline { display: none; }
}

/* Phone: tabs switch the panel under the monitor */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar { padding: 8px 16px; gap: 8px; }
  .wordmark span { font-size: 26px; }
  .topnav .linkish { padding: 6px 6px; font-size: 13px; }
  .topnav a.linkish { display: none; }
  .studio { display: block; }
  .monitor { padding: 12px 16px 8px; }
  .viewfinder { border-radius: var(--r-sm); max-height: 56vh; }
  .hud { gap: 16px; }
  .hud-num { font-size: 28px; }
  .lens-ring { padding: 18px 6px 8px; }
  .lens-ring button { font-size: 19px; padding: 4px 4px; }
  .composer-actions { width: 100%; }
  .btn .short { display: inline; }
  .btn .long { display: none; }
  .composer-actions .btn.primary { flex: 1; }
  .chip { padding: 3px 9px; }
  .shot-card { flex-basis: 170px; }
  .tabs {
    display: flex; position: sticky; top: 0; z-index: 5; background: var(--housing);
    border-bottom: 1px solid var(--line); padding: 0 16px;
  }
  .tabs button { flex: 1; background: none; border: 0; padding: 12px 0; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
  .tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--tungsten); }
  .panel { border: 0 !important; padding: 16px; }
  .panel[hidden] { display: none; }
  .reel { padding: 18px 16px 40px; border-top: 1px solid var(--line); }
  .panel > h2 { display: none; }
  .reel-list { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
