/* Taku web console. Visual language after dyna.co: ivory paper, near-black ink, lime accent, bracketed mono labels,
   serif display type. Fonts are free look-alikes (IBM Plex Sans/Mono, Source Serif 4 - the same ones Dyna's own
   replay viewer uses); Dyna's commercial fonts and logo are NOT used. */
:root {
  --bg: #f9f8f0;          /* ivory */
  --panel: #f6f5ee;       /* ivory-2 */
  --panel-hi: #fbfaf5;    /* ivory-50 */
  --stage: #efede4;
  --floor: #eae8de;
  --grid: #d8d5c7;
  --tan: #e4e2d6;
  --ink: #0d0d0d;
  --ink-80: rgba(13, 13, 13, .8);
  --ink-60: rgba(13, 13, 13, .6);
  --ink-45: rgba(13, 13, 13, .45);
  --line: rgba(13, 13, 13, .1);
  --line-strong: rgba(13, 13, 13, .16);
  --accent: #aef280;      /* lime */
  --accent-ink: #0d0d0d;
  --glass: rgba(44, 44, 44, .86);
  --glass-ink: #f9f8f0;
  --warn: #c2410c;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
  --serif: "Source Serif 4", "Iowan Old Style", Charter, Georgia, "Noto Serif CJK SC", serif;
  color-scheme: light; /* light theme only */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }

#app { display: grid; grid-template-columns: minmax(0, 1fr) 392px; height: 100vh; }

/* ------------------------------------------------------------------ stage */
#stage { position: relative; overflow: hidden; background: var(--stage); min-height: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

.stage-head { position: absolute; left: 32px; top: 28px; pointer-events: none; max-width: min(560px, 60%); }
.overline, .label { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-60); }
.bracket::before { content: "[ "; }
.bracket::after { content: " ]"; }
.stage-head h1 { font: 400 64px/1 var(--serif); letter-spacing: -.02em; margin: 14px 0 10px; }
.stage-head p { margin: 0; color: var(--ink-60); font-size: 14px; max-width: 46ch; }

.stage-tools { position: absolute; right: 20px; top: 20px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

#scene-busy { position: absolute; left: 50%; top: 20px; transform: translateX(-50%); z-index: 4; }
#scene-busy[hidden] { display: none; }
#hud { position: absolute; left: 32px; bottom: 58px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; max-width: calc(100% - 310px); }
.chip { font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 7px 9px; border-radius: 5px;
        background: color-mix(in srgb, var(--bg) 82%, transparent); border: 1px solid var(--line); color: var(--ink-80);
        backdrop-filter: blur(6px); white-space: nowrap; }
.chip b { font-weight: 500; color: var(--ink); }
.chip.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
                     margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.chip.paused::before { background: var(--warn); box-shadow: none; }

.caption { position: absolute; left: 32px; right: 290px; bottom: 22px; font: 400 12px/1.35 var(--mono); letter-spacing: .02em; color: var(--ink-45); pointer-events: none; }
.caption strong { color: var(--ink-80); font-weight: 500; }

#cams { position: absolute; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
#cams .cam { position: relative; width: 236px; aspect-ratio: 4 / 3; border-radius: 6px; border: 1px solid var(--line-strong);
             box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
#cams .cam[hidden] { display: none; }
#cams .label { position: absolute; left: 8px; top: 8px; padding: 5px 7px; border-radius: 4px; background: var(--glass); color: var(--glass-ink); letter-spacing: .1em; font-size: 10px; }

#timeline { position: absolute; left: 32px; right: 290px; bottom: 96px; display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 12px;
            padding: 10px 14px; border-radius: 8px; background: color-mix(in srgb, var(--bg) 88%, transparent); border: 1px solid var(--line);
            backdrop-filter: blur(8px); }
#timeline[hidden] { display: none; }
#timeline .ep-name { font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-60); max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#timeline output { font: 500 12px/1 var(--mono); color: var(--ink-80); min-width: 11ch; text-align: right; }

#loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--stage); z-index: 5; }
#loading[hidden] { display: none; }
#loading .box { width: min(420px, 86%); }
#loading h2 { font: 400 40px/1 var(--serif); margin: 14px 0 22px; }
#loading ol { list-style: none; margin: 0; padding: 0; font: 400 12px/1.4 var(--mono); color: var(--ink-45); }
#loading li { padding: 9px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
#loading li.active { color: var(--ink); }
#loading li.done { color: var(--ink-60); }
#loading li.done::after { content: "✓"; color: var(--ink); }
#loading .err { margin-top: 16px; color: var(--warn); font: 12px/1.45 var(--mono); white-space: pre-wrap; }

/* ------------------------------------------------------------------ panel */
#panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.p-head { padding: 22px 24px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.p-head .model { font: 400 22px/1.1 var(--serif); }
.p-head .meta { font: 500 10.5px/1.5 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-45); margin-top: 4px; }

section.sec { border-bottom: 1px solid var(--line); }
section.sec > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; cursor: pointer; user-select: none; }
section.sec > header .num { font: 500 11px/1 var(--mono); color: var(--ink-45); margin-right: 10px; }
section.sec > header .chev { font: 12px var(--mono); color: var(--ink-45); transition: transform .2s ease; }
section.sec.collapsed > header .chev { transform: rotate(-90deg); }
section.sec .body { padding: 2px 24px 20px; }
section.sec.collapsed .body { display: none; }

.btn { font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 9px 11px; border-radius: 5px;
       border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); cursor: pointer; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.btn:hover { background: var(--panel-hi); border-color: var(--ink-45); }
.btn:active { transform: translateY(1px); }
.btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(.96); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 7px 9px; font-size: 10.5px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg { flex-shrink: 0; display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px; gap: 2px; background: var(--bg); }
.seg button { border: 0; background: transparent; font: 500 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 7px 9px; border-radius: 4px; cursor: pointer; color: var(--ink-60); white-space: nowrap; }
.seg button.on { background: var(--ink); color: var(--bg); }
.hint { font: 400 12px/1.5 var(--sans); color: var(--ink-60); margin: 10px 0 0; }
kbd { font: 500 10.5px/1 var(--mono); padding: 2px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--bg); color: var(--ink-80); }
.sub { font: 500 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-45); margin: 16px 0 6px; }

/* drive pad */
.drive { display: grid; grid-template-columns: 148px 1fr; gap: 18px; align-items: start; }
.pad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 6px; }
.pad button { border: 1px solid var(--line-strong); background: var(--bg); border-radius: 6px; cursor: pointer; font: 400 16px/1 var(--sans); color: var(--ink);
              display: grid; place-items: center; position: relative; touch-action: none; }
.pad button small { position: absolute; right: 4px; bottom: 3px; font: 500 8.5px/1 var(--mono); color: var(--ink-45); }
.pad button.active { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.pad button.stop { font-size: 11px; }
.drive .speeds { display: grid; gap: 12px; }

/* joint sliders */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 12px; }
.tabs button { border: 0; background: none; padding: 9px 8px 10px; font: 500 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-45); cursor: pointer;
               border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.jrow { display: grid; grid-template-columns: 92px minmax(0, 1fr) 54px; gap: 10px; align-items: center; margin: 9px 0; }
.jrow label { font-size: 12.5px; color: var(--ink-80); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jrow output { font: 500 11px/1 var(--mono); text-align: right; color: var(--ink-80); }
.slider { position: relative; height: 20px; }
.slider .act { position: absolute; top: 15px; width: 2px; height: 6px; background: var(--ink); border-radius: 1px; transform: translateX(-1px); pointer-events: none; opacity: .65; }
.rng { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; margin: 0; cursor: pointer; }
.rng:disabled { cursor: default; }
.rng::-webkit-slider-runnable-track { height: 2px; background: var(--line-strong); border-radius: 1px; }
.rng::-moz-range-track { height: 2px; background: var(--line-strong); border-radius: 1px; }
.rng::-moz-range-progress { height: 2px; background: var(--ink-60); }
.rng::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--ink); border: 2px solid var(--panel); margin-top: -5.5px; box-shadow: 0 0 0 1px var(--ink); }
.rng::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: var(--ink); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--ink); }
.rng:disabled::-webkit-slider-thumb { background: var(--ink-45); box-shadow: 0 0 0 1px var(--ink-45); }
.rng:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* lists / status */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font: 400 12px/1.3 var(--mono); }
.kv dt { color: var(--ink-45); text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; padding-top: 1px; }
.kv dd { margin: 0; text-align: right; color: var(--ink); }
select.sel { width: 100%; padding: 9px 10px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--bg); font: 400 13px/1.2 var(--sans); }
.tag { display: inline-block; font: 500 9.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 4px 6px; border-radius: 4px; background: var(--tan); color: var(--ink-80); }
.tag.real { background: var(--accent); color: var(--accent-ink); }
.tag.ours { background: var(--ink); color: var(--paper, #fff); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-80); cursor: pointer; }
.check input { accent-color: var(--ink); width: 15px; height: 15px; }
.foot { padding: 18px 24px 26px; font: 400 11px/1.55 var(--mono); color: var(--ink-45); }
.foot b { color: var(--ink-60); font-weight: 500; }

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 920px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 64vh auto; height: auto; min-height: 100vh; }
  #panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .stage-head { left: 16px; top: 16px; max-width: 70%; }
  .stage-head h1 { font-size: 40px; margin: 10px 0 6px; }
  .stage-head p { display: none; }
  .stage-tools { right: 12px; top: 12px; }
  #hud { left: 16px; bottom: 16px; max-width: calc(100% - 32px); }
  #hud .chip:nth-child(n+4) { display: none; }
  .caption { display: none; }
  #cams { right: 12px; bottom: 56px; }
  #cams .cam { width: 120px; }
  #cams .cam:not(:first-child) { display: none; }
  #timeline { left: 12px; right: 12px; bottom: 56px; grid-template-columns: auto 1fr auto; }
  #timeline .ep-name { display: none; }
  section.sec .body, section.sec > header, .p-head, .foot { padding-left: 16px; padding-right: 16px; }
}
.seg button[hidden] { display: none; }
/* scene choices carry long labels ("Laundry room (aligned with the dryer episode)"): let them wrap in a narrow panel */
#scene-seg { flex-shrink: 1; max-width: 100%; }
#scene-seg button { white-space: normal; line-height: 1.25; text-align: left; }
