/* Subwave: the page around the canvas. The stage is a grid: the preview and the subtitle
   list side by side, the transport bar, the timeline at the bottom. The canvas fills the
   stage behind them; the preview and timeline boxes are holes the page measures and
   sends to the view (view.layout). Tokens and components are Tailwave's. */

/* ---- Tokens ------------------------------------------------------------- */

:root {
  color-scheme: light;
  --bg: #eef0f6;
  --surface: #ffffff;
  --surface-2: #f5f6fa;
  --surface-3: #e5e8f0;
  --hover: rgba(15, 23, 42, 0.05);
  --press: rgba(15, 23, 42, 0.09);
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.15);
  --text: #0f172a;
  --text-2: #4f5a70;
  --text-3: #636978;
  --accent-a: #db2777;
  --accent-b: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.1);
  --on-accent: #ffffff;
  --focus: rgba(124, 58, 237, 0.5);
  --ok: #047b56;
  --warn: #a35905;
  --danger: #dc2626;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 20px rgba(15, 23, 42, 0.05);
  --shadow-2: 0 2px 6px rgba(15, 23, 42, 0.08), 0 24px 48px rgba(15, 23, 42, 0.14);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --timeline: 176px;
  --transport: 56px;
  --list: 400px;
  --bar: 52px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0c11;
    --surface: #12151c;
    --surface-2: #171b24;
    --surface-3: #242a37;
    --hover: rgba(255, 255, 255, 0.05);
    --press: rgba(255, 255, 255, 0.09);
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.13);
    --text: #e9ecf3;
    --text-2: #a0a8bc;
    --text-3: #848b9c;
    --accent-a: #f472b6;
    --accent-b: #a78bfa;
    --accent-soft: rgba(167, 139, 250, 0.14);
    --on-accent: #0a0c11;
    --focus: rgba(167, 139, 250, 0.6);
    --ok: #34d399;
    --warn: #fbbf24;
    --danger: #f87171;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.4), 0 28px 56px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0c11;
  --surface: #12151c;
  --surface-2: #171b24;
  --surface-3: #242a37;
  --hover: rgba(255, 255, 255, 0.05);
  --press: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #e9ecf3;
  --text-2: #a0a8bc;
  --text-3: #848b9c;
  --accent-a: #f472b6;
  --accent-b: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.14);
  --on-accent: #0a0c11;
  --focus: rgba(167, 139, 250, 0.6);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.4), 0 28px 56px rgba(0, 0, 0, 0.5);
}

/* ---- Base --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  color: var(--text);
  font: 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

button, select, input { font: inherit; color: inherit; }
input { user-select: text; -webkit-user-select: text; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

svg.i {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Layout ------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-rows: var(--bar) 1fr;
  grid-template-columns: minmax(0, 1fr); /* never wider than the window */
  height: 100%;
}

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 15px;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand img { display: block; border-radius: 7px; }

.file {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text-2);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file small {
  margin-left: 10px;
  color: var(--text-3);
  font-weight: 400;
}

.bar-end { display: flex; align-items: center; gap: 6px; }

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--list);
  grid-template-rows: minmax(0, 1fr) var(--transport) var(--timeline);
  grid-template-areas: "preview side" "transport transport" "timeline timeline";
  min-height: 0;
  overflow: hidden;
}

.box-preview { grid-area: preview; pointer-events: none; }
.box-timeline { grid-area: timeline; pointer-events: none; }

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

.app[data-screen="start"] #canvas,
.app[data-screen="start"] .transport,
.app[data-screen="start"] .side,
.app[data-screen="boot"] .side,
.app[data-screen="boot"] .transport { visibility: hidden; }

/* ---- Buttons ------------------------------------------------------------ */

.icon-btn, .tool {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.icon-btn:hover:not(:disabled), .tool:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn:active:not(:disabled), .tool:active:not(:disabled) { background: var(--press); }
.tool:disabled { color: var(--text-3); opacity: 0.45; cursor: default; }

.tool.play {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: var(--on-accent);
  box-shadow: var(--shadow-1);
}

.tool.play:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: var(--on-accent);
  filter: brightness(1.08);
}

.tool.mark { color: var(--accent-b); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, filter 0.12s, transform 0.08s;
}

.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: var(--on-accent);
  box-shadow: var(--shadow-1);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  filter: brightness(1.08);
}

/* Not yet usable: a plain button with a readable label, not a faded gradient. */
.btn.primary:disabled {
  opacity: 1;
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  box-shadow: none;
}

.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn.big { height: 46px; padding: 0 22px; border-radius: 12px; font-size: 14.5px; }

/* ---- Start screen -------------------------------------------------------- */

.start {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(700px 400px at 20% 10%, color-mix(in srgb, var(--accent-b) 10%, transparent), transparent 70%),
    radial-gradient(700px 400px at 85% 90%, color-mix(in srgb, var(--accent-a) 9%, transparent), transparent 70%),
    var(--bg);
}

.app:not([data-screen="start"]) .start { display: none; }

.start-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  text-align: center;
}

.start-logo { border-radius: 16px; box-shadow: var(--shadow-1); }
.start h1 { margin: 6px 0 0; font-size: 30px; letter-spacing: -0.025em; }
.start-lead { margin: 0 0 8px; color: var(--text-2); font-size: 15px; line-height: 1.55; }
.hint { margin: 0; color: var(--text-3); font-size: 12.5px; }

.recent { width: 100%; margin-top: 18px; text-align: left; }
.recent h2 { margin: 0 0 6px; color: var(--text-3); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.recent ul { margin: 0; padding: 0; list-style: none; }

.recent button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  margin-bottom: 6px;
}

.recent button:hover { border-color: var(--border-strong); background: var(--surface-2); }
.recent small { color: var(--text-3); }

body.dragging .stage::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px dashed var(--accent-b);
  border-radius: 16px;
  background: var(--accent-soft);
  pointer-events: none;
}

/* ---- Loading, notice ----------------------------------------------------- */

.loading {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text-2);
}

.spin {
  width: 14px;
  height: 14px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent-a);
  border-right-color: var(--accent-b);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.notice {
  position: absolute;
  left: calc((100% - var(--list)) / 2);
  bottom: calc(var(--timeline) + var(--transport) + 16px);
  z-index: 4;
  max-width: min(620px, calc(100% - 32px));
  padding: 10px 14px;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border));
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text-2);
  text-align: center;
}

.notice.instead {
  top: calc((100% - var(--timeline) - var(--transport)) / 2);
  left: calc((100% - var(--list)) / 2);
  bottom: auto;
  transform: translate(-50%, -50%);
  padding: 18px 22px;
  font-size: 14px;
  border-color: var(--border-strong);
}

/* ---- Transport ------------------------------------------------------------ */

.transport {
  grid-area: transport;
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}

.transport::-webkit-scrollbar { display: none; }
.transport > * { flex-shrink: 0; }

.group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
}

.group:last-child { border-right: 0; }

.clock {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
  font: 600 15px var(--mono);
  font-variant-numeric: tabular-nums;
}

.clock .of, .clock #timeAll { color: var(--text-3); font-size: 12.5px; font-weight: 500; }

.timing { gap: 4px; }
.tool.hold { color: var(--accent-a); }
.tool.hold.down { background: var(--accent-a); color: var(--on-accent); }
.tool[aria-pressed="true"], .tool.on { background: var(--accent-soft); color: var(--accent-b); }

.field {
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: var(--text-3);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.time-input {
  width: 108px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font: 12.5px var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
}

.time-input:focus { border-color: var(--accent-b); outline: none; background: var(--surface); }
.time-input.bad { border-color: var(--danger); }

.vol {
  width: 84px;
  accent-color: var(--accent-b);
  cursor: pointer;
}

.length {
  min-width: 70px;
  color: var(--text-2);
  font: 12.5px var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ---- Dialogs ------------------------------------------------------------ */

.dialog {
  width: min(520px, 100vw - 32px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
}

.dialog[open] { animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.dialog::backdrop { background: rgba(5, 7, 12, 0.45); backdrop-filter: blur(2px); }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0 22px;
}

.dialog-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 22px 20px;
}

.dialog-body p { margin: 0; color: var(--text-2); }

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 18px 18px;
}

.seg {
  display: flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}

.seg input { position: absolute; opacity: 0; pointer-events: none; }

.seg label {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.seg label:hover { color: var(--text); }
.seg input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg input:focus-visible + label { outline: 2px solid var(--focus); }
.seg input:disabled + label { opacity: 0.4; cursor: default; }

.explain { min-height: 40px; line-height: 1.5; }
.explain b { color: var(--text); }
.explain .warn { color: var(--warn); }

.row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 12px;
}

.label { color: var(--text-2); font-weight: 600; }

/* (not input[type="text"]: the release build's minified page drops that default) */
.row select, .row input:not([type="checkbox"]) {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-2);
}

.check { display: flex; align-items: center; gap: 8px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent-b); }
.note { color: var(--text-3) !important; font-size: 12.5px; min-height: 18px; }

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--surface-3);
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b), var(--accent-a));
  background-size: 200% 100%;
  animation: sheen 1.4s linear infinite;
  transition: width 0.15s;
}

@keyframes sheen { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.done-line { display: flex; align-items: center; gap: 10px; color: var(--text) !important; font-size: 15px; font-weight: 600; }
.done-line svg.i { color: var(--ok); width: 22px; height: 22px; }

.keys { width: 100%; border-collapse: collapse; }
.keys td { padding: 5px 0; border-bottom: 1px solid var(--border); color: var(--text-2); }
.keys td:last-child { text-align: right; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font: 11.5px var(--mono);
  text-align: center;
}

.crash-details {
  max-height: 200px;
  margin: 8px 0 0;
  padding: 10px 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font: 11.5px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

/* ---- Tooltip and toasts ------------------------------------------------- */

.tip {
  position: fixed;
  z-index: 60;
  max-width: 280px;
  padding: 5px 9px;
  border-radius: 7px;
  background: #0f172a;
  color: #e9ecf3;
  font-size: 12px;
  pointer-events: none;
  box-shadow: var(--shadow-1);
}

.tip kbd { margin-left: 6px; border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: #e9ecf3; }

.toasts {
  position: fixed;
  right: 16px;
  top: calc(var(--bar) + 12px);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}

.toast.leaving { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
.toast .dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--accent-a); }
.toast.ok .dot { background: var(--ok); }
.toast.warn .dot { background: var(--warn); }
.toast.error .dot { background: var(--danger); }
.toast .btn { height: 28px; padding: 0 10px; margin-left: 4px; }

/* ---- Subwave: the side list, the edit box, menus and panels --------------- */

.side {
  grid-area: side;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.side-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 10px;
  border-bottom: 1px solid var(--border);
}

.side-find-icon { color: var(--text-3); display: grid; }
.side-head input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
}
.side-head input:focus { border-color: var(--accent-b); outline: none; background: var(--surface); }
.count { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cue-list {
  position: relative;
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  overflow-x: hidden;
  outline: none;
  contain: strict;
}

.cue-spacer { width: 1px; }

.cue-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: grid;
  grid-template-columns: 38px 86px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 6px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  cursor: default;
  will-change: transform;
}

.cue-row:hover { background: var(--hover); }
.cue-row.active { background: color-mix(in srgb, var(--accent-a) 10%, transparent); }
.cue-row.selected { background: var(--accent-soft); }
.cue-row.current { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-b) 55%, transparent); }
.cue-row.warn { border-left-color: var(--warn); }
.cue-row.bad { border-left-color: var(--danger); }
.cue-row .n { color: var(--text-3); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }
.cue-row .times { display: flex; flex-direction: column; font: 11.5px/1.35 var(--mono); font-variant-numeric: tabular-nums; }
.cue-row .times b { font-weight: 500; color: var(--text); }
.cue-row .times i { font-style: normal; color: var(--text-3); }
.cue-row .words {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
  line-height: 1.35;
  color: var(--text);
}
.cue-row .words .tag { color: var(--text-3); font-size: 0.9em; }
.cue-row .words .empty { color: var(--text-3); font-style: italic; }
.cue-row .cps { color: var(--text-3); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }
.cue-row .cps.over { color: var(--warn); font-weight: 700; }

.editbox {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.edit-row { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.edit-row .time-input { width: 104px; }
.edit-row .length { min-width: 0; padding-bottom: 6px; }
.stats { margin-left: auto; padding-bottom: 6px; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.stats .over { color: var(--warn); font-weight: 700; }

#edText {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: 15px/1.45 var(--font);
  user-select: text;
  -webkit-user-select: text;
}
#edText:focus { border-color: var(--accent-b); outline: none; }
#edText:disabled { opacity: 0.55; }

.edit-tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.edit-tools .sep { width: 1px; height: 20px; margin: 0 6px; background: var(--border-strong); }
.color-tool { position: relative; cursor: pointer; }
.color-tool input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.chip {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--accent-b); }
.chip.guessed { border-color: color-mix(in srgb, var(--warn) 60%, var(--border)); }

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--warn);
  color: #1a1203;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.badge:empty { display: none; }

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 250px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--hover); }
.menu button kbd { margin-left: auto; }
.menu hr { margin: 5px 4px; border: 0; border-top: 1px solid var(--border); }

/* Panels (find, problems) stay open beside the work: not modal, above the page. */
.dialog.panel {
  position: fixed;
  inset: auto 16px calc(var(--timeline) + var(--transport) + 12px) auto;
  z-index: 50;
  margin: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - var(--bar) - var(--timeline) - var(--transport) - 40px);
  overflow: auto;
}

.field.wide { flex: 1; }
.field.wide input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  text-transform: none;
  letter-spacing: 0;
}
.dialog-body .field.wide { margin-bottom: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.grid2 input {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
}
.inline { display: flex; gap: 6px; }
.sync-point { display: grid; grid-template-columns: 1fr auto auto; align-items: end; gap: 6px 10px; }
.sync-point .label { grid-column: 1 / -1; }
.sync-point select { height: 32px; min-width: 0; }

.enc-preview {
  max-height: 180px;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: 13px/1.5 var(--font);
  white-space: pre-wrap;
  user-select: text;
}

.report, .tidy { margin: 0; padding: 0; list-style: none; }
.report li { padding: 7px 0; border-bottom: 1px solid var(--border); color: var(--text-2); }
.report li b { color: var(--text); }
.tidy li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.tidy li span { color: var(--text-2); }
.tidy li small { display: block; color: var(--text-3); }

.problems { display: flex; flex-direction: column; gap: 10px; max-height: min(60vh, 520px); overflow: auto; }
.problems .kind { border: 1px solid var(--border); border-radius: 10px; }
.problems .kind header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 10px; }
.problems .kind header b { flex: 1 1 auto; min-width: 140px; }
.problems .kind header .btn { height: 28px; padding: 0 10px; font-size: 12px; }
.problems .kind ul { margin: 0; padding: 0 0 6px; list-style: none; max-height: 160px; overflow: auto; }
.problems .kind li button {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 5px 10px;
  border: 0;
  background: none;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
}
.problems .kind li button:hover { background: var(--hover); color: var(--text); }
.problems .kind li .t { font: 11.5px var(--mono); color: var(--text-3); flex: none; }
.problems .kind li .w { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.problems .none { color: var(--text-3); }

.start-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---- Narrow windows and touch -------------------------------------------- */

@media (max-width: 1100px) {
  :root { --list: 340px; }
  .cue-row { grid-template-columns: 30px 80px minmax(0, 1fr) 34px; gap: 6px; }
}

/* Narrow: the list under the preview. */
@media (max-width: 860px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(140px, 38%) minmax(0, 1fr) auto var(--timeline);
    grid-template-areas: "preview" "side" "transport" "timeline";
  }
  .side { border-left: 0; border-top: 1px solid var(--border); }
  .notice, .notice.instead { left: 50%; }
  .bar { gap: 8px; padding: 0 8px 0 10px; }
  .bar .label, .brand b, .file small { display: none; }
  .bar .btn { padding: 0 10px; }
}

/* Phones: the edit box first, a short list; the transport on two rows. */
@media (max-width: 640px) {
  :root { --timeline: 150px; }
  .stage { grid-template-rows: minmax(120px, 30%) minmax(0, 1fr) auto var(--timeline); }
  .side { flex-direction: column-reverse; }
  .side-head { display: none; }
  .editbox { border-top: 0; border-bottom: 1px solid var(--border); }
  .edit-row .time-input { width: 92px; }
  .stats { display: none; }
  .transport {
    flex-wrap: wrap;
    align-content: center;
    row-gap: 4px;
    column-gap: 8px;
    padding: 4px 8px;
    overflow-x: hidden;
  }
  .transport .group { padding-right: 4px; border-right: 0; }
  .transport [data-cmd="redo"], .transport [data-cmd^="view."], .transport #stripBtn,
  .transport .group:has(#volume) { display: none; }
  .clock { border-right: 0; padding-right: 4px; font-size: 14px; }
  .clock .of, .clock #timeAll { display: none; }
  .field span { display: none; }
  #keysBtn, #encBtn { display: none; }
  .cue-row { grid-template-columns: 26px 74px minmax(0, 1fr); }
  .cue-row .cps { display: none; }
}

@media (pointer: coarse) {
  .icon-btn, .tool { width: 42px; height: 42px; }
  .btn { height: 42px; }
  .seg label { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .spin, .progress i { animation: none; }
  .dialog[open], .toast { animation: none; }
}
