/* Inter — Platypus Economics primary UI typeface */
@font-face {
  font-family: "Inter";
  src: url("assets/Inter.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* Platypus Economics brand palette */
  --ink: #082C32;
  --abyss: #0E4A53;
  --abyss-deep: #062227;
  --surf: #2F9E97;
  --surf-2: #5DBAB4;
  --sun: #D9A315;
  --coral: #D93A43;
  --paper: #F6F4EE;

  --panel-2: rgba(255,255,255,0.06);
  --panel-3: rgba(255,255,255,0.10);
  --text: #E7EFEF;
  --muted: #9BB4B4;
  --dimmer: #6B8688;
  --border: rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.18);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 28px rgba(0,0,0,0.35);

  /* Stata screen — exact replica; do not brand */
  --screen-font: "Lucida Console", "Consolas", "DejaVu Sans Mono", monospace;
  --screen-fontsize: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* beat author display rules (e.g. flex) */
html, body { margin: 0; height: 100%; }
body {
  --leftw: 340px;                 /* log/annotations pane width (drag the vsplit) */
  --dockh: 300px;                 /* timeline dock height    (drag the hsplit)   */
  background: var(--ink);
  color: var(--text);
  font: 14px/1.45 "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;               /* the panes scroll internally, never the body */
}

/* ---- top app bar (brand + global buttons) ---------------------------- */
.topbar {
  flex: none;
  display: flex; align-items: center;
  padding: 8px 16px;
  background: linear-gradient(180deg, var(--abyss) 0%, var(--abyss-deep) 100%);
  border-bottom: 1px solid var(--border);
}
.topbar .brandhead { margin-bottom: 0; width: 100%; }

/* ---- workspace: log/annotations | divider | preview ------------------ */
.workspace { flex: 1 1 auto; min-height: 0; display: flex; align-items: stretch; }

/* ---- left control pane (tabbed: Stata log / Annotations) ------------- */
.leftpane {
  flex: none; width: var(--leftw);
  min-width: 220px; max-width: 620px;
  background: linear-gradient(180deg, var(--abyss) 0%, var(--abyss-deep) 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.tabbar { flex: none; display: flex; gap: 2px; padding: 8px 10px 0; }
.tabbar .tab {
  flex: 1 1 0; cursor: pointer; padding: 8px 10px; font-size: 12px; font-weight: 600;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); border-radius: 6px 6px 0 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tabbar .tab:hover { color: var(--text); }
.tabbar .tab.on { color: var(--paper); border-bottom-color: var(--surf); background: var(--panel-2); }
.tab-badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--surf); color: #04211f; font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.tabpanel { display: none; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 16px 24px; }
.tabpanel.on { display: block; }
/* the log tab fills its height: the textarea grows, the guide sits under it */
#tab-log.on { display: flex; flex-direction: column; }
#tab-log .field { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin-bottom: 0; }
#tab-log textarea#src { flex: 1 1 auto; height: auto; min-height: 120px; resize: none; }
.annot-empty { color: var(--dimmer); font-size: 12px; line-height: 1.5; margin: 12px 2px; }
.annot-empty b { color: var(--muted); }
#tab-annot:not(.on) ~ * .annot-empty { display: none; }

/* ---- draggable dividers ---------------------------------------------- */
.vsplit {
  flex: none; width: 6px; margin: 0 -3px; z-index: 15;
  cursor: col-resize; background: transparent; position: relative;
}
.hsplit {
  flex: none; height: 6px; margin: -3px 0; z-index: 15;
  cursor: row-resize; background: transparent; position: relative;
}
.vsplit::after, .hsplit::after {
  content: ""; position: absolute; background: var(--border-strong);
  border-radius: 2px; transition: background .12s;
}
.vsplit::after { top: 0; bottom: 0; left: 2px; width: 2px; }
.hsplit::after { left: 0; right: 0; top: 2px; height: 2px; }
.vsplit:hover::after, .hsplit:hover::after,
body.resizing-split .vsplit::after, body.resizing-split .hsplit::after { background: var(--surf); }
body.resizing-split { user-select: none; -webkit-user-select: none; }

/* ---- bottom dock: transport + full-width timeline + controls --------- */
.dock {
  flex: none; height: var(--dockh);
  min-height: 120px;
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px 18px 14px; overflow-y: auto;
  background: linear-gradient(180deg, var(--abyss-deep) 0%, var(--ink) 100%);
  border-top: 1px solid var(--border);
}
/* in the dock, the editing chrome spans the full width instead of matching
   the preview footprint (that width coupling was for the old side-by-side) */
.dock .transport, .dock .timeline, .dock .seg-tools,
.dock .speedbar, .dock .sections { width: 100%; margin-left: 0; margin-right: 0; }
.dock .stage-sec { width: auto; min-width: 0; }

.brandhead { display: flex; gap: 11px; align-items: center; margin-bottom: 20px; }
.brandhead .brand-reset {
  display: flex; align-items: center; gap: 11px;
  background: none; border: none; font: inherit; color: inherit; text-align: left;
  cursor: pointer; padding: 5px; margin: -5px; border-radius: 11px;
  transition: background 0.12s;
}
.brandhead .brand-reset:hover { background: var(--panel-2); }
.brandhead .brand-reset:hover h1 { color: var(--surf-2); }
.brandhead .brand-reset:focus-visible { outline: 2px solid var(--surf-2); outline-offset: 1px; }
.brandhead .brandmark {
  width: 38px; height: 38px; border-radius: 9px;
  object-fit: cover; flex: none;
}
.brandhead .cog {
  margin-left: auto; align-self: flex-start; background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 5px; border-radius: 7px; display: flex;
}
.brandhead .cog:hover { color: var(--surf-2); background: var(--panel-2); }
.brandhead h1 { font-size: 16px; margin: 0; letter-spacing: -0.01em; color: var(--paper); font-weight: 700; }

/* settings & defaults modal */
.modal { position: fixed; inset: 0; background: rgba(2,12,15,0.62); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal-card { background: #0e2127; border: 1px solid var(--border-strong); border-radius: 12px; padding: 18px; width: 360px; max-width: 92vw; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--text); }
.modal-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.modal-x:hover { color: var(--coral); }
.modal-p { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 0 0 14px; }
.modal-p b { color: var(--text); }
.modal-status { color: var(--surf-2); font-size: 12px; margin-top: 12px; min-height: 15px; }

/* sessions modal */
.sess-head { color: var(--surf-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; margin: 18px 0 8px; }
.session-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow: auto; }
.session-list li { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 9px; }
.session-list .meta { flex: 1; min-width: 0; }
.session-list .nm { color: var(--text); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-list .dt { color: var(--dimmer); font-size: 11px; margin-top: 1px; }
.session-list .load { background: var(--surf); color: #04211f; border: none; border-radius: 5px; padding: 5px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.session-list .load:hover { background: var(--surf-2); }
.session-list .link { background: none; border: 1px solid var(--border); color: var(--surf-2); border-radius: 5px; padding: 5px 9px; font-size: 12px; font-weight: 600; cursor: pointer; }
.session-list .link:hover { border-color: var(--surf); color: var(--surf); }
.session-list .ico { background: none; border: none; color: var(--dimmer); cursor: pointer; font-size: 13px; padding: 0 2px; }
.session-list .ico:hover { color: var(--surf); }
.session-list .del { background: none; border: none; color: var(--dimmer); cursor: pointer; font-size: 14px; padding: 0 2px; }
.session-list .del:hover { color: var(--coral); }
.session-empty { color: var(--dimmer); font-size: 12px; }

/* enlarged log editor */
.src-card { width: 780px; max-width: 94vw; }
.src-pop {
  width: 100%; height: 62vh; resize: vertical;
  background: rgba(0,0,0,0.24); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; font-family: var(--screen-font); font-size: 13px; line-height: 1.45;
}
.src-pop:focus { outline: none; border-color: var(--surf); }

/* help / about modal */
.help-card { width: 470px; max-height: 84vh; overflow: auto; }
.help-body { color: var(--muted); font-size: 13px; line-height: 1.55; }
.help-body p { margin: 0 0 12px; }
.help-body b { color: var(--text); }
.help-body h4 { color: var(--surf-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; margin: 16px 0 6px; }
.help-body ol, .help-body ul { margin: 0 0 12px; padding-left: 20px; }
.help-body li { margin-bottom: 6px; }
.help-body code {
  background: rgba(0,0,0,0.32); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-family: var(--screen-font); font-size: 11.5px; color: var(--text);
}
.panel .sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.field { margin-bottom: 14px; }
.field > label {
  display: block; font-weight: 600; margin-bottom: 5px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--surf-2);
  white-space: normal; overflow-wrap: anywhere; line-height: 1.25;
}
.field .hint { color: var(--muted); font-size: 11px; margin-top: 4px; line-height: 1.4; }
/* label with a trailing icon button (e.g. the log popout) */
.label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.label-row > label {
  display: block; margin-bottom: 0; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--surf-2);
}
.iconbtn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 2px 4px; border-radius: 5px; display: inline-flex;
}
.iconbtn:hover { color: var(--surf-2); background: var(--panel-2); }
.field .hint b { color: var(--text); font-weight: 600; }

/* collapsible "how to annotate the log" guide under the log box */
.src-markers { margin-top: 8px; }
.src-markers > summary {
  cursor: pointer; color: var(--surf-2); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em; list-style: none;
  padding: 4px 0; user-select: none;
}
.src-markers > summary::-webkit-details-marker { display: none; }
.src-markers > summary::before { content: "▸ "; color: var(--muted); }
.src-markers[open] > summary::before { content: "▾ "; }
.src-markers ul { margin: 4px 0 2px; padding-left: 2px; list-style: none; }
.src-markers li {
  color: var(--muted); font-size: 11px; line-height: 1.45; margin-bottom: 7px;
}
.src-markers li b { color: var(--text); font-weight: 600; }
.src-markers code {
  background: rgba(0,0,0,0.28); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 4px; font-family: var(--screen-font); font-size: 11px; color: var(--text);
}

textarea {
  width: 100%; height: 190px; resize: vertical;
  background: rgba(0,0,0,0.22); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; font-family: var(--screen-font); font-size: 12px; line-height: 1.4;
}
select, input[type="number"], input[type="text"] {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 8px; font-size: 13px;
}
/* readable dropdown popups on the dark theme */
select option, select optgroup { background-color: #0e2127; color: #e7efef; }
textarea:focus, select:focus, input:focus { outline: none; border-color: var(--surf); }
textarea.droppable { border-color: var(--surf); box-shadow: 0 0 0 2px rgba(47,158,151,0.35); }
input[type="range"] { width: 100%; accent-color: var(--surf); }
input[type="color"] {
  width: 100%; height: 30px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--panel-2);
}

.row { display: flex; gap: 10px; }
.row .field { flex: 1; }

.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-row output { min-width: 56px; text-align: right; color: var(--surf-2); font-variant-numeric: tabular-nums; }

details { margin-bottom: 14px; }
details summary { cursor: pointer; font-weight: 600; font-size: 12.5px; padding: 4px 0; color: var(--surf-2); }

.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.btns button {
  flex: 1 1 auto; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 700;
  background: var(--surf); color: #04211f; border: none; font-size: 13px;
}
.btns button:hover { background: var(--surf-2); }
.btns button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong); font-weight: 600; }
.btns button.secondary:hover { background: var(--panel-3); }
.btns button.secondary.on { background: var(--sun); color: #2a2000; border-color: var(--sun); font-weight: 700; }
.btns button:disabled { opacity: 0.6; cursor: default; }

/* full-width buttons */
.btn {
  display: block; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-weight: 700; font-size: 13px; border: none;
  background: var(--surf); color: #04211f;
}
.btn:hover { background: var(--surf-2); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong); font-weight: 600; }
.btn.secondary:hover { background: var(--panel-3); }
.btn.secondary.on { background: var(--sun); color: #2a2000; border-color: var(--sun); font-weight: 700; }

/* annotations list block (adding edits lives above the window now) */
.actions { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 6px; }

/* export modal: one card per output type */
.export-card { width: 440px; }
.export-opts { display: flex; flex-direction: column; gap: 12px; }
.export-opt { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 13px; }
.export-opt-head { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; font-weight: 700; }
.export-opt-head .eo-icon { font-size: 18px; }
.eo-desc { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 6px 0 11px; }
.export-row { display: flex; gap: 10px; margin-bottom: 11px; flex-wrap: wrap; }
.export-row label {
  flex: 1 1 90px; min-width: 90px; display: flex; flex-direction: column; gap: 4px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--surf-2); font-weight: 700;
}

/* collapsible section body */
details > .sec { margin-top: 10px; }

.cli-box {
  margin-top: 10px; background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px; font-family: var(--screen-font); font-size: 11px;
  color: var(--muted); white-space: pre-wrap; word-break: break-all; user-select: all;
}

/* annotation list */
.annot-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.annot-item {
  font-size: 12px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 8px; display: flex; flex-direction: column; gap: 7px;
}
.annot-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.annot-item.selected { border-color: #ff4da6; box-shadow: 0 0 0 1px #ff4da6, 0 0 10px rgba(255,77,166,0.35); }
.annot-item.flash { animation: annflash 0.85s ease; }
@keyframes annflash { 0% { background: rgba(255,77,166,0.30); } 100% { background: var(--panel-2); } }
.annot-list .tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 4px; flex: none;
}
.annot-list .tag.highlight { background: var(--sun); color: #2a2000; }
.annot-list .tag.zoom { background: var(--surf); color: #04211f; }
.annot-list .tag.pause { background: var(--panel-3); color: var(--text); border: 1px solid var(--border-strong); }
.annot-list .tag.caption { background: var(--paper); color: #10282d; }
.annot-list .cap-text { flex: 1; font-size: 12px; padding: 4px 6px; }
.annot-list .tag.segment { background: var(--orchid); color: #fff; }
.annot-item.segment.deleted .tag.segment { background: var(--coral); }
.annot-list .snip { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--screen-font); }
.annot-list .del { flex: none; cursor: pointer; color: var(--dimmer); background: none; border: none; font-size: 14px; padding: 0 2px; }
.annot-list .del:hover { color: var(--coral); }

/* per-annotation options */
.annot-opts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatches { display: flex; gap: 4px; }
.swatches .sw {
  width: 18px; height: 18px; border-radius: 4px; padding: 0; cursor: pointer;
  border: 2px solid transparent;
}
.swatches .sw.on { border-color: var(--text); box-shadow: 0 0 0 1px var(--ink) inset; }
.annot-opts .hold-mode { width: auto; flex: 1; min-width: 92px; font-size: 12px; padding: 4px 6px; }
.dur-wrap { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); }
.annot-opts .hold-sec { width: 52px; padding: 3px 5px; font-size: 12px; }
.hold-lbl { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }

.panel-foot { margin-top: 18px; }
.link-sm { color: var(--surf-2); font-size: 11.5px; cursor: pointer; text-decoration: none; }
.link-sm:hover { color: var(--surf); text-decoration: underline; }

/* subtle "last updated" stamp at the foot of the panel */
.app-updated {
  flex: none; margin: 0; padding: 10px 16px; border-top: 1px solid var(--border);
  color: var(--dimmer); font-size: 10.5px; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* ---- preview pane (top-right of the workspace) ----------------------- */
.stage {
  position: relative;                      /* anchors the first-run card */
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 20px 24px; overflow: auto; gap: 14px;
}

/* Appearance + Pacing side by side on a laptop, stacked on a narrow screen */
.sections { display: flex; gap: 14px; width: calc(var(--win-w, 900px) * var(--fit-base, var(--fit, 1))); max-width: 96vw; align-items: flex-start; }
.sections .stage-sec { flex: 1 1 0; width: auto; min-width: 0; }
@media (max-width: 880px) { .sections { flex-direction: column; } }

/* ---- embed mode (?session=X&embed=1): a chrome-less read-only player ----
   Only the preview, the transport, and a filmstrip scrubber remain. */
body.embed .topbar,
body.embed .leftpane,
body.embed .vsplit,
body.embed .hsplit,
body.embed .annotate-bar,
body.embed .speedbar,
body.embed .sections,
body.embed .seg-tools,
body.embed #record,
body.embed #audio-clear,
body.embed .tl-gutters,
body.embed #lane-highlight, body.embed #lane-zoom, body.embed #lane-caption,
body.embed #lane-segment, body.embed #lane-steps, body.embed #lane-pauses { display: none !important; }
body.embed .dock { height: auto; }             /* just transport + filmstrip */
body.embed .stage { justify-content: center; }
body.embed .tl-lanes { cursor: pointer; }

/* the preview scales to fill the available stage width (JS sets --fit and the
   wrapper's pixel size so layout reserves exactly the scaled footprint) */
#win-fit { flex: none; position: relative; }

/* first-run guidance card, floated over the stage (the stage scrolls, so it
   sits in normal flow pulled up over the empty preview area) */
.empty-hint {
  position: absolute; left: 50%; top: clamp(70px, 18vh, 220px); transform: translateX(-50%);
  width: 460px; max-width: min(86vw, 92%);
  background: rgba(8, 33, 38, 0.96); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 20px 24px; z-index: 12; color: var(--muted); font-size: 13.5px; line-height: 1.5;
}
.empty-hint h2 { margin: 0 0 10px; font-size: 16px; color: var(--paper); letter-spacing: -0.01em; }
.empty-hint ol { margin: 0 0 14px; padding-left: 20px; }
.empty-hint li { margin-bottom: 7px; }
.empty-hint b { color: var(--text); }
.empty-hint code {
  background: rgba(0,0,0,0.32); border: 1px solid var(--border); border-radius: 4px;
  padding: 0 4px; font-family: var(--screen-font); font-size: 11.5px;
}
.empty-actions button { flex: none; padding: 8px 14px; }
body.embed .empty-hint { display: none !important; }
.window {
  position: relative;
  border-radius: 8px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(0,0,0,0.4);
  overflow: hidden;
  width: var(--win-w, 900px); flex: none;                  /* unscaled: the transform does the scaling */
  transform: scale(var(--fit, 1)); transform-origin: top left;
}
#screen { display: block; width: var(--win-w, 900px); }   /* height set inline */

/* corner grip: drag to zoom the preview in/out (logical size is unchanged;
   only the --fit display scale moves). Sits on #win-fit's scaled footprint,
   so it's outside the transform and never clipped by .window's overflow. */
.win-resize {
  position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px;
  cursor: nwse-resize; z-index: 14; touch-action: none;
}
.win-resize::after {
  content: ""; position: absolute; right: 3px; bottom: 3px; width: 11px; height: 11px;
  border-right: 2px solid var(--surf-2); border-bottom: 2px solid var(--surf-2);
  border-bottom-right-radius: 4px; opacity: 0.7; transition: opacity 0.12s;
}
.win-resize:hover::after, body.resizing-win .win-resize::after { opacity: 1; }
body.resizing-win { cursor: nwse-resize; user-select: none; -webkit-user-select: none; }
body.embed .win-resize,
.stage:fullscreen .win-resize,
.stage:-webkit-full-screen .win-resize { display: none; }

/* annotate this frame: buttons above the window */
.annotate-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.ann-bar-label { color: var(--muted); font-size: 12px; }
.ann-add {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ann-add:hover { border-color: var(--surf); }
.ann-add.hl.on { background: var(--sun); color: #2a2000; border-color: var(--sun); }
.ann-add.zoom.on { background: var(--surf); color: #04211f; border-color: var(--surf); }
.ann-bar-flex { flex: 1; }
.ann-add.export { background: var(--surf); color: #04211f; border-color: var(--surf); font-weight: 700; }
.ann-add.export:hover { background: var(--surf-2); border-color: var(--surf-2); }
.ann-bar-hint { color: var(--muted); font-size: 12px; flex-basis: 100%; }
.ann-bar-hint a { color: var(--surf-2); }

/* annotation overlay — an invisible, selectable text layer aligned over the
   live frame, so you mark exactly what's showing in the window at time t */
.annot-overlay {
  position: absolute; left: 0; right: 0; top: 32px; height: 560px;
  background: transparent; color: transparent; overflow: hidden; z-index: 20;
  cursor: text;
  box-shadow: inset 0 0 0 2px rgba(47,158,151,0.55);   /* surf ring = annotation layer is live */
  font-family: var(--screen-font); font-size: var(--screen-fontsize); line-height: 1.32;
}
.annot-overlay .aline-wrap { position: absolute; inset: 0; padding: 10px 12px; transform-origin: 0 0; }
.annot-overlay .aline { white-space: pre; min-height: 1.32em; }
.annot-overlay::selection, .annot-overlay .aline::selection { background: rgba(217,163,21,0.45); }
.annot-list-head { color: var(--surf-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; margin-top: 6px; }

/* selecting/editing an existing annotation: a glowing pink outline + handles */
.sel-edit { position: absolute; inset: 0; pointer-events: none; z-index: 26; }
.sel-box {
  position: absolute; border: 2px solid #ff4da6; border-radius: 3px;
  box-shadow: 0 0 11px 2px rgba(255,77,166,0.70), inset 0 0 7px rgba(255,77,166,0.45);
}
.sel-h {
  position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px;
  background: #ff4da6; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 7px rgba(255,77,166,0.9); pointer-events: auto;
}
.sel-h.tl, .sel-h.br { cursor: nwse-resize; }
.sel-h.tr, .sel-h.bl { cursor: nesw-resize; }

/* selection menu popover */
.sel-menu {
  position: absolute; z-index: 30; display: flex; gap: 4px;
  background: #11242a; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 5px; box-shadow: var(--shadow);
}
.sel-menu button {
  cursor: pointer; border: none; border-radius: 5px; padding: 6px 9px; font-size: 12px; font-weight: 700;
  background: var(--panel-3); color: var(--text);
}
.sel-menu button[data-type="highlight"]:hover { background: var(--sun); color: #2a2000; }
.sel-menu button[data-type="zoom"]:hover { background: var(--surf); color: #04211f; }
.sel-menu button.x { background: transparent; color: var(--muted); padding: 6px 7px; }
.sel-menu button.x:hover { color: var(--coral); }

.transport { display: flex; align-items: center; gap: 12px; width: calc(var(--win-w, 900px) * var(--fit-base, var(--fit, 1))); color: var(--muted); font-size: 12px; }
.transport button {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong); font-size: 15px;
}
.transport button:hover { background: var(--panel-3); }
.transport #record { color: var(--coral); }
.transport #record svg, .transport #audio-clear svg { display: block; }
.transport #record.recording { background: var(--coral); color: #fff; border-color: var(--coral); animation: recpulse 1.1s ease-in-out infinite; }
@keyframes recpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217,58,67,0.5); } 50% { box-shadow: 0 0 0 6px rgba(217,58,67,0); } }

/* full-size (fullscreen) view: scale the window up to fill the screen */
.stage:fullscreen { background: var(--ink); padding: 2vh 2vw; justify-content: center; }
.stage:fullscreen #win-fit { width: auto !important; height: auto !important; }
.stage:fullscreen .window { width: auto; max-width: 96vw; transform: none !important; }
.stage:fullscreen #screen { width: min(96vw, calc(90vh * var(--win-aspect, 1.52))) !important; height: auto !important; }
.stage:-webkit-full-screen { background: var(--ink); padding: 2vh 2vw; }
.stage:-webkit-full-screen #win-fit { width: auto !important; height: auto !important; }
.stage:-webkit-full-screen .window { width: auto; max-width: 96vw; transform: none !important; }
.stage:-webkit-full-screen #screen { width: min(96vw, calc(90vh * var(--win-aspect, 1.52))) !important; height: auto !important; }
.transport .time { font-variant-numeric: tabular-nums; min-width: 92px; }
.transport .tl-flex { flex: 1; }
/* timeline zoom (magnifying-glass slider) + a divider before the audio cluster */
.transport .tl-zoom { display: inline-flex; align-items: center; gap: 5px; }
.transport .tl-zoom button { width: auto; height: 26px; padding: 0 7px; border-radius: 6px; font-size: 12px; }
.transport .tl-zoom input[type="range"] { width: 96px; accent-color: var(--surf); cursor: pointer; }
.transport .transport-sep { width: 1px; height: 20px; background: var(--border-strong); flex: none; }

/* multi-track timeline (video-editor style): a ruler + stacked lanes + playhead */
.timeline { display: flex; margin: 2px 0 12px; width: calc(var(--win-w, 900px) * var(--fit-base, var(--fit, 1))); user-select: none; -webkit-user-select: none; }
.tl-gutters { flex: none; width: 92px; display: flex; flex-direction: column; }
.tl-gutter {
  height: 26px; box-sizing: border-box; display: flex; align-items: center;
  color: var(--muted); font-size: 11px; padding-right: 6px; gap: 4px;
}
.tl-gname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* per-lane "+" — inserts that kind of edit at the playhead */
.tl-add {
  flex: none; width: 16px; height: 16px; padding: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 4px; background: var(--panel-2);
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
}
.tl-add:hover { border-color: var(--surf); color: var(--text); }
.tl-add.on { background: var(--surf); color: #04211f; border-color: var(--surf); }
.tl-gutter.ruler-sp { height: 18px; }
.tl-gutter.g-video { height: 48px; }
.tl-gutter.g-audio { height: 30px; }
.tl-gutter.g-pauses { height: 24px; }
/* horizontal-scroll viewport: the lanes inside can be wider than this (zoom) */
.tl-scroll { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tl-scroll::-webkit-scrollbar { height: 8px; }
.tl-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
/* the lanes grow with --tl-zoom; % positions inside scale with them (= zoom) */
.tl-lanes { position: relative; width: calc(100% * var(--tl-zoom, 1)); min-width: 100%; cursor: ew-resize; }
.tl-lanes:active { cursor: grabbing; }
.tl-ruler { height: 18px; box-sizing: border-box; position: relative; border-bottom: 1px solid var(--border-strong); }
.tl-ruler .tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid rgba(255,255,255,0.10); }
.tl-ruler .tick > span { position: absolute; left: 3px; top: 3px; font-size: 9px; color: var(--dimmer); font-variant-numeric: tabular-nums; }
.tl-lane {
  position: relative; height: 26px; box-sizing: border-box;
  border-bottom: 1px solid rgba(255,255,255,0.05); background: rgba(255,255,255,0.022);
}
/* main visual channel: a thumbnail filmstrip */
.tl-video { height: 48px; background: #0a1418; overflow: hidden; }
.tl-video canvas.thumb { position: absolute; top: 2px; height: 44px; box-sizing: border-box; border-right: 1px solid rgba(0,0,0,0.5); image-rendering: auto; }
/* audio channel: the narration waveform as a movable clip */
.tl-audio { height: 30px; background: rgba(47,158,151,0.05); overflow: hidden; }
.audio-clip {
  position: absolute; top: 2px; bottom: 2px; border-radius: 4px; overflow: hidden;
  background: rgba(47,158,151,0.14); border: 1px solid rgba(47,158,151,0.55);
  cursor: grab; box-sizing: border-box;
}
.audio-clip:active { cursor: grabbing; }
.audio-clip canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.audio-clip .audio-trim {
  position: absolute; top: 0; right: 0; bottom: 0; width: 8px; cursor: ew-resize;
  border-right: 2px solid rgba(255,255,255,0.55); border-radius: 0 4px 4px 0;
}
.audio-clip .audio-trim:hover { border-right-color: #fff; background: rgba(255,255,255,0.12); }
/* per-sentence hover regions from the transcript (sit above the waveform;
   drag still works because mousedown bubbles to the clip) */
.audio-clip .audio-sent {
  position: absolute; top: 0; bottom: 0; box-sizing: border-box;
  border-left: 1px solid rgba(255,255,255,0.10); cursor: help;
}
.audio-clip .audio-sent:first-of-type { border-left: none; }
.audio-clip .audio-sent:hover { background: rgba(255,255,255,0.14); }
.audio-clip .audio-transcribing {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em; color: #eafffb;
  background: rgba(4,33,31,0.45); pointer-events: none;
}
/* the floating tooltip that shows the sentence text on hover */
.audio-tip {
  position: fixed; z-index: 60; max-width: 340px; pointer-events: none;
  background: #04211f; color: #eafffb; border: 1px solid var(--surf);
  border-radius: 6px; padding: 6px 9px; font-size: 12px; line-height: 1.4;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}
.transport #audio-upload { color: var(--surf-2); }
.tl-clip {
  position: absolute; top: 3px; bottom: 3px; border-radius: 4px; overflow: visible;
  white-space: nowrap; font-size: 11px; padding: 0 5px; display: flex; align-items: center;
  cursor: pointer; box-sizing: border-box; min-width: 4px;
}
/* label truncates within itself (clip is overflow:visible so the trashcan can sit above) */
.tl-clip .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tl-clip.zoom { background: rgba(47,158,151,0.30); border: 1px solid var(--surf); color: #cdeae7; }
.tl-clip.highlight { color: #eaf0f1; }                 /* bg/border set inline to the mark's colour */
.tl-clip.content { background: var(--panel-3); border: 1px solid var(--border-strong); color: var(--text); }
.tl-clip.desc { background: rgba(47,158,151,0.55); border: 1px solid var(--surf); color: #04211f; }
.tl-clip.pause { background: rgba(255,255,255,0.07); border: 1px dashed var(--border-strong); color: var(--muted); }
.tl-clip.caption { background: rgba(246,244,238,0.85); border: 1px solid var(--paper); color: #10282d; font-weight: 600; }
/* steps lane: one clip per command / desc block, grabbable on either edge to
   change how long that command plays */
.tl-lane.tl-steps { background: rgba(255,255,255,0.015); }
.tl-clip.step {
  background: rgba(120,150,165,0.14); border: 1px solid rgba(150,180,195,0.30);
  color: var(--muted); cursor: pointer;
}
.tl-clip.step.alt { background: rgba(120,150,165,0.055); }   /* alternate shade so adjacent steps read apart */
.tl-clip.step.desc { background: rgba(47,158,151,0.22); border-color: var(--surf); color: #cdeae7; }
/* Pauses lane (below Steps): every pause — after-command holds (⏱), standalone
   `// Pause` blocks, and frozen-frame pauses (⏸) */
.tl-lane.tl-pauses { height: 24px; background: rgba(246,196,84,0.035); }
.tl-clip.pause-gap, .tl-clip.pause-blk {
  top: 2px; bottom: 2px; background: rgba(246,196,84,0.12);
  border: 1px dashed rgba(246,196,84,0.5); color: rgba(246,196,84,0.9);
  font-size: 10px; cursor: pointer;
}
.tl-clip.pause-blk { background: rgba(246,196,84,0.2); border-style: solid; }
.tl-clip.pause-gap:hover, .tl-clip.pause-blk:hover { border-color: var(--sun); color: var(--sun); }
.tl-clip.step:hover { border-color: var(--surf); color: var(--text); }
.tl-clip.step.gap:hover { border-color: var(--sun); color: var(--sun); }
.tl-clip.step.here { border-color: var(--coral); color: var(--text); box-shadow: inset 0 0 0 1px var(--coral); }
/* faint full-height guides at each step boundary, so blocks line up across every lane */
.tl-blocklines { position: absolute; top: 18px; bottom: 0; left: 0; right: 0; pointer-events: none; z-index: 5; }
.tl-blocklines .bl { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(150,180,195,0.13); }
/* trashcan that pops up above a clip — on hover or while selected (Delete works too).
   Identical control on every editable row, so the clip must not clip it (overflow:visible). */
.tl-trash {
  position: absolute; left: 50%; transform: translateX(-50%); top: -17px; z-index: 7;
  width: 18px; height: 16px; padding: 0; line-height: 1; border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.35); cursor: pointer; box-sizing: border-box;
  background: var(--coral); color: #fff; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .1s;
}
.tl-clip:hover .tl-trash, .tl-clip.selected .tl-trash,
.tl-seg:hover .tl-trash, .tl-seg.selected .tl-trash { opacity: 1; pointer-events: auto; }
.tl-clip.selected { outline: 2px solid #ff4da6; box-shadow: 0 0 8px rgba(255,77,166,0.6); z-index: 4; }
/* left/right drag handles — the same grab affordance on every editable clip and speed span */
.tl-clip .tl-resize, .tl-seg .tl-resize {
  position: absolute; top: 0; right: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 6;
  border-right: 2px solid rgba(255,255,255,0.55); border-radius: 0 4px 4px 0;
}
.tl-clip .tl-resize.l, .tl-seg .tl-resize.l {
  right: auto; left: 0; border-right: none;
  border-left: 2px solid rgba(255,255,255,0.55); border-radius: 4px 0 0 4px;
}
.tl-clip .tl-resize:hover, .tl-seg .tl-resize:hover { border-color: #fff; background: rgba(255,255,255,0.12); }

/* segments (speed up / slow down / delete a span) */
.tl-seg {
  position: absolute; top: 3px; bottom: 3px; border-radius: 4px; box-sizing: border-box;
  background: rgba(142,74,160,0.28); border: 1px solid var(--orchid); color: #e8d6ef;
  font-size: 11px; padding: 0 5px; display: flex; align-items: center; overflow: visible;
  white-space: nowrap; cursor: pointer;
}
.tl-seg .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tl-seg.deleted { background: repeating-linear-gradient(45deg, rgba(217,58,67,0.30) 0 6px, rgba(217,58,67,0.12) 6px 12px); border-color: var(--coral); color: #f6cdd0; }
.tl-seg.selected { outline: 2px solid #ff4da6; box-shadow: 0 0 8px rgba(255,77,166,0.6); z-index: 5; }

.seg-tools { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; width: calc(var(--win-w, 900px) * var(--fit-base, var(--fit, 1))); flex-wrap: wrap; }
.seg-tools .seg-rate-lbl { color: var(--muted); font-size: 12px; }
.seg-tools .seg-rate-lbl b { color: var(--orchid); }
.seg-tools.deleted .seg-rate-lbl b { color: var(--coral); }
.seg-btn {
  background: var(--panel-2); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 6px; padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.seg-btn:hover { border-color: var(--surf); }
.seg-btn.danger:hover { border-color: var(--coral); color: var(--coral); }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--coral); left: calc(var(--phead, 0) * 100%); pointer-events: none; z-index: 6; }
/* a clear grab-knob at the top of the playhead so it reads as draggable */
.tl-playhead::before {
  content: ''; position: absolute; top: -3px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 14px; border-radius: 3px; background: var(--coral);
  box-shadow: 0 1px 3px rgba(0,0,0,0.55);
}
.tl-playhead::after {
  content: ''; position: absolute; top: 1px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 8px; background: rgba(255,255,255,0.8); border-radius: 1px;   /* grip line */
}

/* length / speed bar (under the scrubber), written as a formula */
.speedbar { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; padding-bottom: 10px; }
.speedbar .lbl { color: var(--surf-2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: 10px; }
.speedbar .end { font-size: 10px; color: var(--dimmer); text-transform: uppercase; letter-spacing: .05em; }
.speedbar .speed { width: 280px; max-width: 34vw; accent-color: var(--surf); display: block; }
.speed-wrap { position: relative; display: inline-flex; align-items: center; }
.speed-tick {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 18px; background: var(--surf-2); border-radius: 1px;
  pointer-events: none; z-index: 2;
}
.tick-label {
  position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%);
  font-size: 9px; font-weight: 700; color: var(--surf-2); pointer-events: none; white-space: nowrap;
}
.speedbar .formula { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.speedbar .formula .base { color: var(--text); }
.speedbar .formula .op { color: var(--dimmer); }
.speedbar .formula .final-lbl { color: var(--surf-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.speedbar .formula .spd { color: var(--surf-2); font-weight: 600; }
.speedbar .dur {
  width: 58px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 4px 6px; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums;
}
.speedbar .unit { color: var(--dimmer); margin-left: -3px; }

/* control sections that sit in the stage (Appearance above, Pacing below) */
.stage-sec { width: calc(var(--win-w, 900px) * var(--fit-base, var(--fit, 1))); min-width: 520px; max-width: 96vw; margin: 0;
  background: rgba(255,255,255,0.035); border: 1px solid var(--border); border-radius: 10px; padding: 4px 14px; }
.stage-sec > summary { padding: 7px 0; }
.stage-sec .sec.grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 20px; padding: 2px 0 12px;
}
.stage-sec .sec.grid .field { margin-bottom: 0; }
.stage-sec .span-all { grid-column: 1 / -1; }
.colors, .dims { display: flex; gap: 12px; }
.colors .field, .dims .field { flex: 1; margin-bottom: 0; min-width: 0; }
.chk { vertical-align: middle; accent-color: var(--surf); margin-right: 5px; }
.stage:fullscreen .stage-sec, .stage:-webkit-full-screen .stage-sec { display: none; }

/* annotation tool toggle */
.annot-tools { display: flex; gap: 6px; margin-top: 8px; }
.tool-btn {
  flex: 1; cursor: pointer; padding: 7px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong);
}
.tool-btn#tool-highlight.on { background: var(--sun); color: #2a2000; border-color: var(--sun); }
.tool-btn#tool-zoom.on { background: var(--surf); color: #04211f; border-color: var(--surf); }

/* zoom tool: no text selection, crosshair, live drag rectangle */
.annot-overlay.tool-zoom { cursor: crosshair; user-select: none; -webkit-user-select: none; }
.zoom-rect {
  position: absolute; z-index: 25; border: 2px dashed var(--surf);
  background: rgba(47,158,151,0.16); pointer-events: none; border-radius: 2px;
}

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #11242a; border: 1px solid var(--border-strong); color: var(--text);
  padding: 9px 14px; border-radius: 8px; font-size: 13px; opacity: 0;
  transition: opacity .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }
