/* ============================================================
   WRITER/PERFORMER — "1C" SKIN
   ============================================================
   A pure override layer. Nothing in writer-performer.html or
   shared.css needs to change. Add TWO lines as the LAST thing
   in <head>, after the tool's own inline <style>:

     <link rel="stylesheet" href="wp-fonts-nitti.css">
     <link rel="stylesheet" href="wp-1c-skin.css">

   Type is Nitti Grotesk (Typekit kit xii1spb), in four roles:
     nitti-grotesk            interface labels, buttons, tabs
     nitti-grotesk-condensed  display — character names, headlines
     nitti-grotesk-light      long-form copy, help text
     nitti-typewriter-normal  the script page and all numeric readouts
   The family caps at 700, so display weight is condensed 700 rather
   than a black — narrower and heavier-looking at poster scale.

   It works because the app is already fully token-driven and
   already zero-radius. Three moves do most of the job:
     1. Retune the tokens (palette + type).
     2. Promote hairlines to 2px ink rules between major zones.
     3. Re-cut four pieces of chrome: header cells, tab strip,
        transport bar, active line.
   ============================================================ */

/* ---------- 1. TOKENS ---------- */

html[data-theme="light"], html[data-theme="paper"], :root {
  /* Ground cools off and loses the sepia. Ink goes near-black. */
  --bg:      #f3f2f2;
  --panel:   #f3f2f2;
  --panel-2: #eae9e9;
  --panel-3: #e0dfdf;
  --panel2:  #eae9e9;
  --panel3:  #e0dfdf;
  --ink:     #201e1d;
  --muted:   #5c5958;   /* was #7d7979 — only 3.9:1 on this ground */

  /* Rules are the structure, so they carry real weight. */
  --line: rgba(32, 30, 29, 0.4);

  --accent:      #ec3013;
  --accent-dim:  rgba(236, 48, 19, 0.10);
  --accent-glow: rgba(236, 48, 19, 0.22);
  --accent-ink:  #f3f2f2;
  --amber:       #ec3013;
  --amber-dim:   rgba(236, 48, 19, 0.10);
  --amber-glow:  rgba(236, 48, 19, 0.22);

  --sage:     #605d5d;
  --sage-dim: rgba(96, 93, 93, 0.12);

  /* Interface = Nitti Grotesk. The page = Nitti Typewriter. Never mixed. */
  --font-body:    "nitti-grotesk", system-ui, sans-serif;
  --font-mono:    "nitti-grotesk", system-ui, sans-serif;
  --font-display: "nitti-grotesk-condensed", "nitti-grotesk", sans-serif;
  --font-light:   "nitti-grotesk-light", "nitti-grotesk", sans-serif;
  --script-font:  "nitti-typewriter-normal", "Courier New", monospace;
  --ui-size: 16px;
}

html[data-theme="dark"], html[data-theme="noir"] {
  --bg:      #201e1d;
  --panel:   #201e1d;
  --panel-2: #2d2b2b;
  --panel-3: #383535;
  --panel2:  #2d2b2b;
  --panel3:  #383535;
  --ink:     #f3f2f2;
  --muted:   #b3afaf;   /* 7:1 on the dark ground */
  --line:    rgba(243, 242, 242, 0.28);
  --accent:      #ec3013;
  --accent-dim:  rgba(236, 48, 19, 0.16);
  --accent-ink:  #f3f2f2;
  --amber:       #ec3013;
  --amber-dim:   rgba(236, 48, 19, 0.16);
}

/* ---------- 2. INTERFACE TYPE ----------
   Every label in the chrome becomes small, heavy, tracked and
   uppercase. This single change is most of what reads as "1c". */

/* Interface labels — the regular cut. */
.section-title, label, .eyebrow,
nav.tabs button, .tab-btn {
  font-family: "nitti-grotesk", system-ui, sans-serif !important;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
/* Display slots — the condensed cut. The wordmark and the transport
   character name are the two biggest after the cast cards, so they must
   NOT be caught by the rule above. */
.disp, header h1, .tool-header h1 {
  font-family: var(--font-display) !important;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.section-title { font-size: 14px; color: var(--muted); letter-spacing: 0.05em; }
.disp { font-size: 15px; }
.details-label, label { font-size: 14px; font-weight: 700; letter-spacing: 0.05em; }

/* Numeric readouts stay typewriter — they belong to the script,
   not to the interface. */
.cue-counter, .status-line, #header-credits,
.ns-text .sub, .cast-card .voice-meta {
  font-family: "nitti-typewriter-normal", "Courier New", monospace !important;
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- 3. HEADER: DIVIDED CELLS, NOT SPACED ITEMS ----------
   In 1c nothing floats in the bar; each cluster is a walled cell. */

header, .tool-header {
  border-top: none;
  border-bottom: 2px solid var(--ink);
  height: 54px;   /* was 46 — 48px controls need the room */
  gap: 0;
}
.header-brand {
  display: flex;
  align-items: center;
  align-self: stretch;          /* the rule must run the full 54px */
  border-right: 2px solid var(--ink);
  padding: 0 26px 0 20px;       /* breathing room before the first tab */
  margin-right: 0;
}
/* Kill any short divider glyph the app draws next to the wordmark — the
   cell edge is the divider now. */
.header-brand::after, .header-tab-divider, .brand-divider { display: none !important; }
.header-tab-divider { display: none; }

/* Right cluster: each control is a walled cell, flush to the next.
   Icon buttons become 46px-tall full-height cells divided by hairlines,
   so the right edge reads as structure rather than floating glyphs. */
.header-right {
  border-left: 1px solid var(--line);
  padding: 0;
  gap: 0;
  align-self: stretch;
  align-items: stretch;
}
.header-project {
  display: flex;
  flex-direction: column;       /* name over timestamp, both inside 54px */
  align-items: flex-start;
  justify-content: center;
  align-self: stretch;
  gap: 1px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
  overflow: visible;
  white-space: nowrap;
}
.header-project .project-name {
  font-family: "nitti-typewriter-normal", monospace;
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
.header-project .project-status {
  font-family: "nitti-grotesk", sans-serif;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.header-right .icon-btn,
.header-right button.icon-btn {
  width: 48px;
  min-height: 0;
  height: auto;
  align-self: stretch;
  padding: 0;
  border: none;
  border-right: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
}
.header-right .icon-btn:last-child { border-right: none; }

/* The download button is wrapped in .download-menu-wrap, so the cell
   rules must apply to the WRAPPER; the button itself goes borderless. */
.header-right .download-menu-wrap {
  display: flex;
  align-self: stretch;
  border-right: 1px solid var(--line);
  position: relative;
}
.header-right .download-menu-wrap > .icon-btn { border-right: none; }
.header-right > *:last-child { border-right: none; }
.header-right .download-menu-wrap .download-menu {
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
  right: 0;
  left: auto;
}
.header-right .download-menu-wrap .download-menu button {
  border: none;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  padding: 11px 14px;
}
.header-right .download-menu-wrap .download-menu button:last-child { border-bottom: none; }
.header-right .icon-btn svg { width: 20px; height: 20px; stroke-width: 1.9; }
.header-right .icon-btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--line);
}
.header-right .icon-btn:active:not(:disabled) { background: var(--accent); color: #f3f2f2; }
.header-right .icon-btn.active {
  background: var(--accent);
  color: #f3f2f2;
  border-top: none;
}
.header-right .icon-btn:disabled { opacity: 0.5; }
.header-right .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#header-credits {
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line);
}
header h1, .tool-header h1 { font-size: 16px; letter-spacing: 0.04em; }

/* ---------- 4. TAB STRIP: THE ACTIVE TAB IS A SOLID INK BLOCK ---------- */

nav.tabs { border-bottom: none; }
nav.tabs button, .tab-btn {
  border-top: none !important;
  border-right: 1px solid var(--line);
  padding: 0 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  align-self: stretch;
}
nav.tabs button:hover:not(.active) {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
nav.tabs button.active, .tab-btn.active {
  background: var(--ink) !important;
  color: var(--bg) !important;
  font-weight: 700;
  border-top-color: transparent !important;
}

/* ---------- 5. BUTTONS: FLUSH LEFT, SQUARE, HEAVY ---------- */

button, .btn {
  font-family: "nitti-grotesk", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-color: var(--line);
  color: var(--ink);
  padding: 0.7rem 1rem;
  min-height: 40px;
}
button.small, .btn.small { font-size: 14px; min-height: 38px; }
button:hover:not(:disabled), .btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-color: var(--ink);
}
button:active:not(:disabled) { background: color-mix(in srgb, var(--ink) 14%, transparent); }
button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #f3f2f2;
}
button.primary:hover:not(:disabled) { background: #dd2b0f; opacity: 1; }
button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input, select, textarea {
  font-family: "nitti-grotesk", system-ui, sans-serif;
  font-size: 15px;   /* 16px-ish keeps iOS from zooming on focus */
  min-height: 40px;
}
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* ---------- 6. THE SCRIPT PAGE ----------
   The page itself barely changes — it was already right. The
   current line is the one place red runs as a field. */

.script-page { max-width: 620px; }
.p-line { padding: 4px 12px; }
.p-line.active-line {
  background: var(--accent-dim);
  box-shadow: inset 3px 0 0 var(--accent);
}
.p-line.active-line[data-type="Character"] .p-text { color: var(--accent); }
.p-line[data-type="Scene Heading"] { border-top-width: 2px; }
.p-line[data-type="Scene Heading"] .p-text {
  text-decoration: none;
  letter-spacing: 0.06em;
}

/* ---------- 7. SIDE PANELS: WALLED, LABELLED, RULED ---------- */

.script-area { border-right: 1px solid var(--line); }
.search-panel, .cast-drawer { background: var(--panel-2); }
.cast-drawer { border-left: 2px solid var(--ink); }
.drawer-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.section-title { border-bottom-width: 1px; }

/* ---------- 8. TRANSPORT: A SOLID INK FIELD ----------
   The one piece of chrome that inverts. Squares, not circles. */

.perf-top.perf-bottom {
  background: var(--ink);
  border-top: 2px solid var(--ink);
  padding: 14px 20px;
}
.perf-bottom .ns-text .disp {
  color: var(--bg);
  font-family: var(--font-display) !important;
  font-size: 18px;
  letter-spacing: 0.04em;
}
.perf-bottom .ns-text .sub  { color: color-mix(in srgb, var(--bg) 92%, transparent); font-size: 14px; letter-spacing: 0.04em; }
.perf-bottom .ns-photo {
  border-radius: 0;
  width: 44px; height: 44px;
  border: none;
  background: var(--accent);
  color: #f3f2f2;
}
.perf-bottom .ns-photo svg { color: #f3f2f2; }
.perf-bottom .ns-photo.speaking { border: none; outline: 2px solid var(--bg); outline-offset: -2px; }
.perf-bottom .transport button {
  border-radius: 0;
  width: 44px; height: 44px;
  min-height: 0;
  border-color: color-mix(in srgb, var(--bg) 35%, transparent);
  color: var(--bg);
}
.perf-bottom .transport button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--bg) 15%, transparent);
  border-color: var(--bg);
}
.perf-bottom .transport button.play-btn {
  width: 56px; height: 56px;
  background: var(--bg);
  border-color: var(--bg);
  color: var(--ink);
}
.perf-bottom .transport button.play-btn:hover:not(:disabled) { background: #fff; }
.perf-bottom .cue-counter { color: color-mix(in srgb, var(--bg) 88%, transparent); font-size: 15px; }
.perf-bottom .perf-actions button {
  color: var(--bg);
  border-color: color-mix(in srgb, var(--bg) 35%, transparent);
}
.perf-bottom .perf-actions button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--bg) 15%, transparent);
  border-color: var(--bg);
}
.status-line {
  background: var(--panel-2);
  border-top: 1px solid var(--line);
  font-size: 15px;
  padding: 8px 20px;
}

/* ---------- 9. CAST CARDS: THE NAME IS THE GRAPHIC ---------- */

.cast-card { border-color: var(--line); }
.cast-list .cast-card .cast-name .name-display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.gender-tag-inline {
  font-family: "nitti-grotesk", sans-serif;
  font-size: 15px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}
.cast-list .cast-card .photo-wrap { border-radius: 0; }
.cast-list .cast-card .photo-wrap .photo-clip { border-radius: 0; }
.cast-drawer .cast-card .photo-wrap,
.cast-drawer .cast-card .photo-wrap .photo-clip { border-radius: 0; }
select.needs-voice { border-color: var(--accent); color: var(--accent); }

/* ---------- 10. VIEW-MODE TOGGLE + PILLS ---------- */

.view-mode-btn, .pill {
  border-radius: 0;
  font-family: "nitti-grotesk", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.pill.accent { background: var(--accent-dim); border-color: var(--accent); color: #ae1800; }
::selection { background: rgba(236, 48, 19, 0.3); }
::-webkit-scrollbar-thumb { background: var(--line); }

/* ---------- 11. THE LIGHT CUT ----------
   Nitti Grotesk Light carries running copy and helper text, so the
   interface labels (regular/bold) stay clearly a different register. */

.help-text, .settings-desc, .field-hint, .empty-state p, .modal-body p,
.key-card .help-text, #settings-tab .help-text {
  font-family: var(--font-light) !important;
  font-weight: 400;
  font-size: 16px !important;
  line-height: 1.65;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  max-width: 70ch;
  text-wrap: pretty;
}

/* Tracking scales inversely with size: the bigger the label, the less it
   needs. Nitti Grotesk is also wider than Archivo, so nothing here goes
   past 0.08em. */
.disp, .section-title, .details-label, label,
nav.tabs button, .tab-btn, button, .btn {
  letter-spacing: 0.05em;
}
.header-project .project-status { letter-spacing: 0.05em; }

/* Display headlines use the condensed cut everywhere. Section 2 already
   claims .disp and header h1 with !important; these are the rest. */
h2, h3, .display-lg {
  font-family: var(--font-display);
  font-weight: 700;
}

/* ---------- 12. ACCESSIBILITY FLOOR ----------
   The poster logic stays; the interface stops shouting in 10px caps.
   - Nothing in the chrome below 12.5px; body and help copy at 14.5px.
   - Interactive targets at least 40px, icon-only ones 44-48px.
   - --muted darkened to clear 4.5:1 on both grounds.
   - Uppercase tracking eased from .14em to .07-.08em, since heavy
     tracking at small sizes is what made it hard to read as much as
     the size itself.
   - Respect the user's own preferences rather than overriding them. */

/* App classes the skin doesn't otherwise size get an explicit value.
   (Not a `max(…, 1em)` floor — `1em` resolves against the inherited
   size, so it would flatten every label to the parent's 16px.) */
.tag, .chip, .badge, .drawer-head,
.ve-sidebar-section-title, .appearance-row span {
  font-size: 14px;
}

/* Hit targets — but only on buttons that carry a label. An icon-only
   button given a min-height and no matching width turns into an oval,
   so those get an equal width/height and no radius instead. */
button, .btn, select, [role="button"], .tab-btn {
  min-height: 40px;
}
/* Icon-only buttons, by explicit class. Deliberately NOT
   `button:has(> svg:only-child)` — `:only-child` counts element children
   only, so a button holding an icon AND a text label matches it too and
   gets crushed into a square (this is what broke "Remove from cast"). */
.icon-btn, .test-btn.icon-only, .close-btn, .modal-close {
  border-radius: 0 !important;
  min-height: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* Nothing in this system is round. */
.avatar, .photo-wrap, .photo-clip, .ns-photo, .dot, .swatch,
.line-play-gutter .play-here-btn,
.line-take-btn, .line-skip-btn, .line-note-btn {
  border-radius: 0 !important;
}

/* ---- The per-line margin pins ----
   The app positions these absolutely at a 26px pitch (take +14, skip +40,
   note +66) sized 20x20. Squaring them at 28px means the pitch has to be
   re-derived or they overlap; 28 + 8 gap = 36px pitch. */
.line-take-btn, .line-skip-btn, .line-note-btn {
  width: 28px;
  height: 28px;
  min-height: 0;
  top: -8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.line-take-btn { left: calc(100% + 20px) !important; }
.line-skip-btn { left: calc(100% + 56px) !important; }
.line-note-btn { left: calc(100% + 92px) !important; }
.line-take-btn svg, .line-skip-btn svg, .line-note-btn svg {
  width: 14px;
  height: 14px;
}
.line-take-btn:hover, .line-skip-btn:hover, .line-note-btn:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.p-line.has-note .line-note-btn,
.p-line.line-skipped .line-skip-btn {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #ae1800;
}
/* The note box is absolute inside .p-line, so it takes the offset.
   .line-take-box is position:fixed and gets its left from JS at runtime —
   setting left here would resolve 100% against the viewport and throw it
   off-screen. Leave it alone. */
.line-note-box { left: calc(100% + 128px) !important; }

/* The gutter play button matches the pins in size and squareness. */
.line-play-gutter { left: -44px !important; }
.line-play-gutter .play-here-btn {
  width: 28px;
  height: 28px;
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.line-play-gutter .play-here-btn:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.p-line.active-line .line-play-gutter .play-here-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #f3f2f2;
}

/* Focus is visible on every ground, including inside the ink transport. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.perf-bottom :focus-visible {
  outline: 2px solid var(--bg);
  outline-offset: 2px;
}

/* Disabled stays legible rather than dissolving. */
button:disabled, .btn:disabled, select:disabled, input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* The user's OS settings win. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
@media (prefers-contrast: more) {
  :root { --line: var(--ink); --muted: var(--ink); }
  button, .btn, input:not([type="range"]), select { border-color: var(--ink); }
}

/* Small viewports: the chrome gets bigger, not smaller. */
@media (max-width: 860px) {
  nav.tabs button, .tab-btn { font-size: 15px; padding: 0 16px; }
  .header-right .icon-btn { width: 52px; }
  .perf-bottom .transport button { width: 48px; height: 48px; }
  .perf-bottom .transport button.play-btn { width: 60px; height: 60px; }
}

/* ---------- 13. ALIGNMENT ----------
   One control height, one row rhythm, one edge. Most of what read as
   "wonky" was rows mixing 36/40/44px controls and buttons sized by their
   own padding instead of a shared baseline. */

/* A single interactive height, so anything sharing a row lines up. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select, textarea, button, .btn, .test-btn, .voice-sel {
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
  vertical-align: top;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; }
button.small, .btn.small, .test-btn.small { height: 36px; min-height: 36px; }

/* Modernist: button labels are flush left, never centered — a button wider
   than its label starts the text at the left padding edge. Icon-only
   buttons are the exception and stay centered. */
button, .btn { justify-content: flex-start; text-align: left; }
.icon-btn, .test-btn.icon-only, .close-btn, .modal-close,
.line-take-btn, .line-skip-btn, .line-note-btn,
.line-play-gutter .play-here-btn, .transport button {
  justify-content: center !important;
  text-align: center;
}

/* Rows: align on the control baseline, never on text. */
.toolbar-row, .cast-card-actions, .modal-actions, .dialog-actions,
.appearance-row, .field-row, .cast-card-main, .details-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.field, .field-col { display: flex; flex-direction: column; gap: 6px; }

/* Labels sit tight to the control they name, not floating mid-gap. */
label, .details-label { display: block; margin: 0 0 6px; }

/* Modal footer: the destructive action anchors left, confirmations right,
   both on the same 40px line, with a rule above rather than a gap. */
.modal-actions, .dialog-actions, .modal-footer {
  justify-content: flex-end;
  padding-top: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
}
.cast-edit-delete-btn, #cast-edit-delete-btn,
.modal-actions .danger, .dialog-actions .danger,
.modal-footer .danger, .remove-btn {
  justify-content: flex-start;
  margin-right: auto;
  width: auto !important;
  min-width: 0;
  height: 40px;
  padding: 0 16px;
  white-space: nowrap;
  border: 1px solid #ae1800;
  color: #ae1800;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cast-edit-delete-btn:hover, #cast-edit-delete-btn:hover,
.modal-actions .danger:hover, .remove-btn:hover {
  background: #ae1800;
  border-color: #ae1800;
  color: #f3f2f2;
}

/* Range inputs: same height as their row, square thumb, ink track. */
input[type="range"] {
  height: 40px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none !important;   /* the app's shared input border applies here too */
  padding: 0;
  margin: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 20px;
  margin-top: -9px;
  border-radius: 0;
  background: var(--accent);
  border: none;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 20px; border-radius: 0;
  background: var(--accent); border: none;
}

/* Panels: one padding value, edges that meet. */
.card, .panel-box, .settings-group, .assigned-voice {
  padding: 16px;
  box-sizing: border-box;
}
.assigned-voice { border: 2px solid var(--ink); }

/* Modals: square, ruled, flush-left content. */
.modal, .dialog, .modal-content {
  border-radius: 0;
  border: 2px solid var(--ink);
  box-shadow: none;
}
.modal-head, .dialog-title, .modal-header {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

/* Section rules: 2px, full width, consistent air above and below. */
.section-title, .settings-section-title {
  padding-bottom: 10px;
  margin: 0 0 20px;
  border-bottom: 2px solid var(--ink);
}

/* ---------- 14. THE PLACES THE FIRST PASS MISSED ----------
   Three specific regressions and two things that stayed too small. */

/* 1. TEST overflowing its box.
   The app sets `.cast-btn-row .test-btn { flex: 1; min-width: 0 }`, so the
   button shrinks below its label — and section 13's flush-left 16px padding
   pushed the text straight out the right edge. In a shrinking flex row the
   label centers and the box never goes narrower than its content. */
.cast-btn-row { gap: 8px; }
.cast-btn-row .test-btn,
.cast-btn-row .cast-clear-voice-btn {
  flex: 1 1 auto;
  min-width: max-content !important;
  padding: 0 12px;
  justify-content: center !important;
  text-align: center;
  white-space: nowrap;
  height: 40px;
}
.cast-btn-row .cast-no-synth-btn {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center !important;
}
/* No button anywhere clips its own label. */
button, .btn { white-space: nowrap; overflow: visible; }

/* 2. Library: the two primary actions are the point of the screen. */
#new-workspace-btn, #new-workspace-btn-tab,
#library-import-script-btn, #library-import-script-btn-tab {
  height: 48px !important;
  min-height: 48px;
  padding: 0 22px !important;
  font-size: 15px !important;
  letter-spacing: 0.05em;
}
#library-open-shared-btn, #library-open-shared-btn-tab {
  width: 48px !important;
  height: 48px !important;
  padding: 0 !important;
  justify-content: center !important;
}
#library-open-shared-btn svg, #library-open-shared-btn-tab svg {
  width: 20px !important;
  height: 20px !important;
}

/* 3. The sort control carries inline font-size:11px (select) and 10px
   (label), so only !important reaches it. */
#library-sort-select, #library-sort-select-tab {
  font-size: 15px !important;
  height: 40px !important;
  min-height: 40px;
  padding: 0 10px !important;
  border: 1px solid var(--line) !important;
  border-radius: 0 !important;
  background: var(--bg) !important;
  color: var(--ink) !important;
  font-family: "nitti-grotesk", sans-serif !important;
}
#library-sort-select-tab + *, .library-sort-label,
#library-sort-select ~ span {
  font-size: 14px !important;
}
/* The "Sort" caption sits on inline styles too. */
[id^="library-sort-select"] {
  vertical-align: middle;
}
#new-workspace-btn ~ * span, .library-actions span,
.library-toolbar span, .lib-head span {
  font-size: 14px !important;
  letter-spacing: 0.05em;
}

/* 4. The cast toolbar row: one height, one gap, labels not clipped. */
.cast-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cast-toolbar > * { height: 40px; min-height: 40px; }
#cast-sort-select, #cast-sort-select-drawer {
  font-size: 14px;
  padding: 0 12px;
}

/* 5. Settings: link colour in the light cut, and the card rhythm. */
.help-text a { color: #ae1800; text-decoration: underline; }
.key-card { padding: 18px; }
.key-card .disp { margin-bottom: 10px; }
.key-card .help-text { margin-top: 10px; }

/* ---------- 15. THE BUTTON AUDIT ----------
   "Buttons buttons who's got the button." Every control the app sizes with
   `font-size: var(--ui-size)` and its own padding, brought onto the shared
   scale — plus three alignment fixes. */

/* 1. Cast & Voices: names and the role line flush left, like everything else. */
.cast-list .cast-card .cast-card-main { align-items: stretch; text-align: left; }
.cast-list .cast-card .cast-name {
  align-items: flex-start;
  text-align: left;
  flex-direction: column;
  gap: 3px;
}
.cast-list .cast-card .cast-name .name-display { line-height: 0.95; }
.cast-list .cast-card .char-role,
.cast-list .cast-card .cast-role,
.cast-list .cast-card .cast-card-main > .muted,
.cast-list .cast-card .cast-meta {
  text-align: left !important;
  font-family: "nitti-grotesk", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* 2. Tag Genders: the M/F/N/O hint was escaping the button because the
   shared 40px height clamped a two-line column. These are stacked
   buttons, so they size to content. */
.gender-tag-grid { gap: 10px; }
.gender-tag-btn {
  height: auto !important;
  min-height: 68px;
  padding: 14px 8px !important;
  flex-direction: column;
  justify-content: center !important;
  align-items: center;
  gap: 6px;
  font-size: 14px !important;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  white-space: normal;
  line-height: 1.15;
  background: var(--panel-2);
}
.gender-tag-btn .key-hint {
  font-family: "nitti-typewriter-normal", monospace;
  font-size: 14px !important;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}
.gender-tag-btn.active { border-color: var(--accent); border-width: 2px; background: var(--accent-dim); color: #ae1800; }
.gender-tag-btn.active .key-hint { color: #ae1800; }
.gender-tag-nav { margin-top: 18px; gap: 10px; }
.gender-tag-nav button { justify-content: center !important; }
.gender-tag-name { font-family: var(--font-display); font-size: 34px; letter-spacing: -0.01em; text-transform: uppercase; margin: 8px 0 2px; }
.gender-tag-progress, .gender-tag-role, .gender-tag-current { font-size: 15px !important; }
.gender-tag-panel .help-text { font-size: 16px !important; }

/* 3. The header project chip: name and timestamp on consecutive lines.
   The project name is a <button class="breadcrumb-project"> nested two
   levels down (.header-project > .breadcrumb-wrap > .breadcrumb > button),
   so the shared 40px control height made a 24px label 40px tall and pushed
   the timestamp out of the cell. It is a label, not a control. */
.header-project { justify-content: center !important; gap: 2px !important; }
.header-project > * { line-height: 1.15 !important; margin: 0 !important; padding: 0 !important; }
.header-project .breadcrumb-wrap,
.header-project .breadcrumb {
  height: auto !important;
  min-height: 0 !important;
  line-height: 1.15 !important;
  gap: 6px;
}
.header-project .breadcrumb-project,
.header-project button.breadcrumb-project {
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  font-family: "nitti-typewriter-normal", monospace !important;
  font-size: 15px !important;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.15 !important;
  color: var(--ink) !important;
  opacity: 1 !important;
  cursor: default;
}
.header-project .breadcrumb-project:not(:disabled) { cursor: pointer; }
.header-project .breadcrumb-project:not(:disabled):hover { color: var(--accent) !important; }
.header-project .file-switcher { height: auto !important; min-height: 0 !important; }
.header-project .project-status { font-size: 13px !important; }

/* 4. Takes: the ‹ › nav were single glyphs in 40px flush-left boxes. */
.line-take-box, .line-note-box { padding: 12px; border: 2px solid var(--ink); background: var(--panel-2); }
.note-box-head .note-label {
  font-family: "nitti-grotesk", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.take-row { gap: 8px; margin-top: 8px; }
.take-row button.take-prev, .take-row button.take-next {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  justify-content: center !important;
  text-align: center;
}
.take-count {
  font-family: "nitti-typewriter-normal", monospace;
  font-size: 15px !important;
  color: var(--ink);
  text-align: center;
}
.take-row button.small {
  flex: 1 1 auto;
  height: 34px !important;
  min-height: 34px;
  padding: 0 10px !important;
  font-size: 14px !important;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  justify-content: center !important;
  min-width: max-content;
}

/* 5. EDITING / REHEARSING. */
.view-mode-toggle { gap: 10px; padding: 10px 24px 0; }
.view-mode-btn {
  font-family: "nitti-grotesk", sans-serif !important;
  font-size: 14px !important;
  font-weight: 700;
  letter-spacing: 0.05em;
  height: 40px;
  min-height: 40px;
  padding: 0 14px !important;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.view-mode-btn.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* 6. "Executive plan renews…" is account information, not fine print. */
#license-credits-detail {
  font-family: var(--font-light) !important;
  font-size: 15px !important;
  line-height: 1.6;
  color: var(--ink) !important;
  margin-top: 10px;
}

/* 7. Light / Dark in Settings → Appearance: the label was falling out of
   the swatch because the shared 40px height cropped a stacked button. */
.theme-swatches { gap: 12px; }
.theme-swatch {
  height: auto !important;
  min-height: 0;
  padding: 12px 14px !important;
  flex-direction: column;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 10px;
  font-size: 14px !important;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.2;
  color: var(--muted);
}
.theme-swatch .swatch-preview {
  width: 64px;
  height: 40px;
  border: 1px solid var(--line);
  padding: 5px;
  border-radius: 0;
}
.theme-swatch .swatch-preview i { width: 10px; height: 10px; }
/* The swatch colours are inline in the markup and still the pre-skin sepia,
   so the one control whose job is to show what each theme looks like was
   advertising a palette the app no longer uses. Inline styles need !important. */
#day-mode-btn .swatch-preview,
.theme-swatch[data-theme="light"] .swatch-preview,
.theme-swatch[data-theme="paper"] .swatch-preview { background: #f3f2f2 !important; }
#day-mode-btn .swatch-preview i,
.theme-swatch[data-theme="light"] .swatch-preview i,
.theme-swatch[data-theme="paper"] .swatch-preview i { background: #201e1d !important; }
#night-mode-btn .swatch-preview,
.theme-swatch[data-theme="dark"] .swatch-preview,
.theme-swatch[data-theme="noir"] .swatch-preview { background: #201e1d !important; }
#night-mode-btn .swatch-preview i,
.theme-swatch[data-theme="dark"] .swatch-preview i,
.theme-swatch[data-theme="noir"] .swatch-preview i { background: #f3f2f2 !important; }
.theme-swatch.active {
  border-color: var(--ink);
  border-width: 2px;
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}
.appearance-row { gap: 20px; align-items: flex-end; }
.appearance-row label { gap: 6px; font-size: 14px; }
