/* Table Read — a clear, calm casting workspace for screenwriters. */
:root {
  --desk: #f3f4ef;
  --paper: #ffffff;
  --ink: #0e0f0c;
  --ink-2: #555951;
  --ink-3: #7c8178;
  --rule: rgba(14, 15, 12, 0.09);
  --rule-2: rgba(14, 15, 12, 0.16);
  --accent: #517a36;
  --accent-strong: #173600;
  --lime: #9fe870;
  --mark: #eef6e6;
  --mark-edge: #517a36;
  --tint: #edf0e9;
  --lilac: #d9dbff;
  --peach: #f8d5c6;
  --mint: #d3eee1;
  --blue: #d5eaf7;
  --yellow: #f5e5a7;
  --pink: #eed7f0;
  --danger: #b74d45;
  --ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  /* The reading pane is set like a real screenplay page: Courier, fixed pitch. */
  --screenplay: "Courier Prime", "Courier New", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 9px;
  --r-lg: 16px;
  --pill: 9px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow-card: 0 0 0 1px rgba(14, 15, 12, 0.035), 0 18px 48px -32px rgba(23, 54, 0, 0.24);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--desk);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

::selection { background: var(--mark); color: var(--ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 5px; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--rule-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 4px;
  white-space: nowrap;
}

/* ---------- workspace shell ---------- */
.topbar-context { min-width: 0; display: grid; gap: 1px; text-align: center; }
.topbar-context span { color: var(--ink-3); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.topbar-context strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.workspace-page { min-height: calc(100vh - 72px); padding: 54px 40px 90px; background: var(--desk); }
.workspace-page-inner { width: min(1080px,100%); margin: 0 auto; }.workspace-page-inner.narrow-page { width: min(780px,100%); }
.workspace-page-head { margin-bottom: 38px; display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }.workspace-kicker { display: block; margin-bottom: 9px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }.workspace-page-head h1 { font-size: 34px; line-height: 1.1; letter-spacing: -.045em; text-wrap: balance; }.workspace-page-head p { max-width: 540px; margin-top: 10px; color: var(--ink-2); font-size: 13.5px; line-height: 1.6; text-wrap: pretty; }
.workspace-primary { min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; color: white; background: var(--accent-strong); font-family: var(--ui); font-size: 12.5px; font-weight: 650; cursor: pointer; white-space: nowrap; }.workspace-primary:hover { background: #224906; }.workspace-primary:active { transform: scale(.97); }
.project-library { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }.project-card { min-height: 190px; padding: 22px; display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow-card); }.project-card-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--accent-strong); background: #e6f2dd; }.project-card h2 { margin-top: 28px; font-size: 16px; letter-spacing: -.025em; }.project-card p { margin-top: 5px; color: var(--ink-3); font-size: 11px; }.project-card footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }.project-card footer span { color: var(--ink-3); font-size: 10px; }.project-card footer button { min-height: 36px; padding: 0 12px; border: 1px solid var(--rule-2); border-radius: 8px; background: white; font-family: var(--ui); font-size: 11px; cursor: pointer; }.project-card footer button:hover { border-color: var(--accent); color: var(--accent-strong); }
.workspace-empty { min-height: 310px; padding: 48px; display: grid; place-items: center; align-content: center; gap: 10px; border: 1px dashed var(--rule-2); border-radius: 18px; background: rgba(255,255,255,.55); text-align: center; }.workspace-empty-icon { width: 52px; height: 52px; margin-bottom: 8px; display: grid; place-items: center; border-radius: 50%; color: var(--accent-strong); background: var(--lime); font-size: 19px; }.workspace-empty h2 { font-size: 18px; letter-spacing: -.025em; }.workspace-empty p { max-width: 420px; color: var(--ink-3); font-size: 12px; line-height: 1.55; }
.character-page-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }.character-page-card { min-height: 154px; padding: 20px; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--rule); border-radius: 15px; background: var(--paper); box-shadow: var(--shadow-card); cursor: pointer; }.character-page-card:hover { border-color: color-mix(in srgb,var(--char-color) 34%,var(--rule)); transform: translateY(-2px); }.character-page-card:active { transform: scale(.98); }.character-page-card .avatar { --av: 38px; }.character-page-card h2 { margin-top: 23px; font-size: 14px; }.character-page-card p { margin-top: 4px; color: var(--ink-3); font-size: 10.5px; }
.account-settings-card { padding: 26px; border: 1px solid var(--rule); border-radius: 17px; background: var(--paper); box-shadow: var(--shadow-card); }.account-setting-row { min-height: 70px; padding: 14px 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--rule); }.account-setting-row:last-child { border-bottom: 0; }.account-setting-row div { display: grid; gap: 3px; }.account-setting-row strong { font-size: 13px; }.account-setting-row span { color: var(--ink-3); font-size: 11px; }.account-setting-row button { min-height: 38px; padding: 0 13px; border: 1px solid var(--rule-2); border-radius: 8px; background: white; font-family: var(--ui); font-size: 11px; font-weight: 600; cursor: pointer; }.account-setting-row button:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ---------- top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, auto) minmax(180px, 1fr);
  align-items: center;
  gap: 14px;
  height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.9);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-left { justify-self: start; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-brand { justify-self: start; }
.topbar-brand .brand-mark { width: 28px; height: 28px; color: var(--accent-strong); }
.topbar-right { justify-self: end; }
.reader-active .topbar-brand { display: none; }
.reader-active .account-slot { display: none; }
.reader-close-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(14,15,12,.03);
  transition: color .14s, background .14s, border-color .14s, transform .14s;
}
.reader-close-btn:hover { color: var(--ink); background: var(--tint); border-color: var(--rule-2); }
.reader-close-btn:active { transform: scale(.96); }
.reader-close-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

.reader-settings { display: none; position: relative; }
.reader-active .reader-settings { display: block; }
.reader-settings > summary { list-style: none; }
.reader-settings > summary::-webkit-details-marker { display: none; }
.reader-settings-trigger {
  min-height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .14s, background-color .14s, border-color .14s, transform .14s;
}
.reader-settings-trigger:hover,.reader-settings[open] .reader-settings-trigger { color: var(--ink); background: var(--tint); border-color: var(--rule-2); }
.reader-settings-trigger:active { transform: scale(.97); }
.reader-settings-trigger svg { width: 17px; height: 17px; fill: var(--paper); stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand:hover { opacity: 0.72; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border-radius: 0;
  flex: none;
}
.brand-mark svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wordmark { font-size: 15px; font-weight: 650; letter-spacing: -0.02em; }

/* ---------- upload stage ---------- */
#stage-upload { display: flex; justify-content: center; padding: 64px 24px 96px; }

.hero { max-width: 720px; width: 100%; text-align: center; }

.hero h1 {
  font-size: clamp(40px, 5vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.052em;
  font-weight: 650;
  text-wrap: balance;
}
.hero h1 em {
  font-family: inherit;
  font-style: normal;
  font-weight: inherit;
  letter-spacing: inherit;
  color: var(--accent);
}

.hero .sub {
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.6;
  max-width: 50ch;
  margin: 18px auto 28px;
  text-wrap: pretty;
}

.dropzone {
  display: block;
  width: 100%;
  border: 1px dashed color-mix(in srgb, var(--accent) 42%, var(--rule-2));
  border-radius: var(--r-lg);
  background: var(--paper);
  padding: 34px 28px 30px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s var(--ease);
}
.dropzone:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 0 0 4px var(--mark), var(--shadow-card); }
.dropzone.over {
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 4px var(--mark);
}

.drop-icon {
  width: 46px;
  height: 46px;
  color: var(--accent);
  background: var(--mark);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: 50%;
  padding: 12px;
  margin: 0 auto 16px;
}
.drop-title { font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.drop-sub { color: var(--ink-3); font-size: 13px; margin-top: 4px; }

.drop-cue, .drop-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin-top: 18px;
  padding: 0 20px;
  border-radius: var(--r);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
  box-shadow: 0 8px 20px -14px rgba(71, 73, 178, 0.72);
}

.formats { font-size: 11.5px; font-weight: 500; color: var(--ink-3); margin-top: 18px; letter-spacing: 0.01em; }

/* A small, tangible cast preview before the writer commits a file. */
.upload-cast-strip, .upload-cast {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 0 auto 24px;
  padding: 14px 18px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}
.upload-cast-avatars { display: flex; flex: none; padding-left: 8px; }
.upload-cast-avatar {
  width: 42px;
  height: 42px;
  margin-left: -8px;
  overflow: hidden;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--lilac);
  box-shadow: 0 0 0 1px rgba(32, 33, 42, 0.08);
}
.upload-cast-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center 24%; }
.upload-cast-avatar.tone-lilac { background: var(--lilac); }
.upload-cast-avatar.tone-peach { background: var(--peach); }
.upload-cast-avatar.tone-mint { background: var(--mint); }
.upload-cast-avatar.tone-yellow { background: var(--yellow); }
.upload-cast-avatar.tone-blue { background: var(--blue); }
.upload-cast-avatar.tone-pink { background: var(--pink); }
.upload-cast-strip p { display: grid; gap: 1px; text-align: left; }
.upload-cast-strip strong { font-size: 12.5px; font-weight: 650; }
.upload-cast-strip p span { color: var(--ink-3); font-size: 11.5px; }

.upload-workflow, .upload-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 12px;
  list-style: none;
}
.upload-workflow li, .upload-flow-step {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 8px 12px;
  border-radius: 11px;
  background: var(--lilac);
  text-align: left;
}
.upload-workflow li:nth-child(2), .upload-flow-step:nth-child(2) { background: var(--peach); }
.upload-workflow li:nth-child(3), .upload-flow-step:nth-child(3) { background: var(--mint); }
.workflow-number {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  font-size: 10.5px;
  font-weight: 700;
}
.upload-workflow strong, .upload-flow-step strong { font-size: 11.5px; font-weight: 650; }

.upload-error {
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
  border-radius: var(--r);
  background: #fff4f2;
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.45;
  text-align: left;
}
.upload-error[hidden] { display: none; }
.sample-option { margin-top: 18px; }
.sample-option .ghost-btn { margin-top: 0; }
.sample-note { margin-top: 6px; color: var(--ink-3); font-size: 11px; }
.upload-trust { margin-top: 22px; color: var(--ink-3); font-size: 11px; }

/* ---------- buttons ---------- */
.ghost-btn {
  margin-top: 22px;
  background: var(--paper);
  border: 1px solid var(--rule-2);
  color: var(--ink);
  min-height: 44px;
  border-radius: var(--r);
  padding: 0 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--ui);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.ghost-btn:hover { border-color: rgba(21, 21, 21, 0.34); background: #fff; }
.ghost-btn:active { transform: scale(0.98); }
.ghost-btn.small { margin-top: 0; min-height: 40px; padding: 0 14px; font-size: 12.5px; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--ui);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 0.14s;
}
.link-btn:hover { color: var(--ink); }

.paste-details { margin-top: 22px; text-align: left; }
.paste-details summary {
  color: var(--ink-2);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  list-style: none;
}
.paste-details summary::-webkit-details-marker { display: none; }
.paste-details summary:hover { color: var(--ink); }
.paste-details textarea {
  width: 100%;
  margin-top: 16px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}
.paste-details textarea:focus { outline: none; border-color: var(--ink); }

/* ---------- loading stage ---------- */
#stage-loading { display: flex; justify-content: center; padding: 84px 24px 104px; }

.loading-card {
  max-width: 520px;
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 36px;
}

.loading-title {
  font-family: var(--ui);
  font-size: 27px;
  font-weight: 650;
  line-height: 1.16;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.loading-file {
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-3);
  letter-spacing: 0;
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  color: var(--ink-3);
  font-size: 11.5px;
}
.loading-status span:last-child { color: var(--ink-2); font-weight: 600; text-align: right; }
.loading-progress { height: 8px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: var(--tint); }
.loading-progress-fill { display: block; width: 33.333%; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.24s var(--ease); }

.steps { list-style: none; margin: 22px 0 0; }

.step {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 0;
  font-size: 13.5px;
  color: var(--ink-3);
  border-top: 1px solid var(--rule);
}
.step:first-child { border-top: 0; }

/* A ring that fills in as each stage completes. */
.step-mark {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--rule-2);
  flex-shrink: 0;
  position: relative;
}
.step.active .step-mark {
  border-color: var(--rule-2);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
.step.done .step-mark { border-color: var(--accent); background: var(--accent); }
.step.done .step-mark::after {
  content: "";
  position: absolute;
  left: 3.6px;
  top: 1.2px;
  width: 3px;
  height: 6px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.step.active { color: var(--ink); font-weight: 600; }
.step.done { color: var(--ink-2); }

.step-name { flex: 1; }
.step-detail {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.loading-note { margin-top: 18px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.loading-reassurance { margin-top: 4px; color: var(--ink-3); font-size: 11px; line-height: 1.5; }
.loading-cancel { min-height: 40px; margin-top: 18px; color: var(--ink-3); }

/* ---------- sign-in stage ---------- */
#stage-auth { display: flex; justify-content: center; padding: 92px 20px; }

.auth-body { margin-top: 18px; }

.auth-h { margin-top: 18px; font-size: 22px; font-weight: 650; letter-spacing: -0.025em; }

.auth-sub {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 8px;
  text-wrap: pretty;
}

.auth-form { display: flex; gap: 8px; margin-top: 20px; }
.auth-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.auth-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule-2);
  min-height: 48px;
  border-radius: var(--r);
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--ui);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(21, 21, 21, 0.04);
  transition: border-color 0.14s, background 0.14s, transform 0.12s;
}
.auth-google:hover { border-color: var(--ink); background: var(--tint); }
.auth-google:active { transform: scale(0.98); }
.auth-google:disabled { opacity: 0.55; cursor: wait; }
.auth-google svg { flex-shrink: 0; }

.auth-google-note {
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: center;
}

.auth-email-details { margin-top: 16px; border-top: 1px solid var(--rule); }
.auth-email-details summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  list-style: none;
  transition: color 0.14s;
}
.auth-email-details summary::-webkit-details-marker { display: none; }
.auth-email-details summary:hover { color: var(--ink); }
.auth-email-details summary svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  transition: transform 0.18s var(--ease);
}
.auth-email-details[open] summary svg { transform: rotate(180deg); }
.auth-email-panel { padding: 2px 0 4px; }

.auth-switch { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }
.auth-switch .link-btn { font-size: 12.5px; margin-left: 4px; }

.auth-input {
  flex: 1;
  min-width: 0;
  background: var(--desk);
  color: var(--ink);
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  min-height: 46px;
  padding: 0 14px;
  font-size: 14px;
  font-family: var(--ui);
}
.auth-input:focus { outline: none; border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px var(--mark); }
.auth-input.bad { border-color: #c2410c; }

.auth-submit {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
  border-radius: var(--r);
  min-height: 46px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--ui);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s;
}
.auth-submit:hover { background: #000; }
.auth-submit:disabled { opacity: 0.55; cursor: wait; }

.auth-error {
  color: #c2410c;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 10px;
  min-height: 1px;
}

.auth-skip { min-height: 40px; margin-top: 10px; font-size: 12.5px; }

/* ---------- reader layout ----------
   A full-height app shell: the script scrolls on the left, a persistent cast
   rail sits on the right, and the voice inspector slides in between them. */
#stage-reader {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px); /* fill the viewport below the sticky top bar */
  overflow: hidden;
}

.reader-shell {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 0; /* let children own their own scroll */
}

/* LEFT — the screenplay column, with its own scroll and a docked transport. */
.script-pane {
  flex: 1 1 620px;
  min-width: 620px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.script-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 32px 8px;
  scrollbar-gutter: stable;
}

.script-head {
  max-width: 666px;
  margin: 0 auto 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.meta {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* The reading surface: a clean transcript, straight on the page. */
.page { background: transparent; border: 0; padding: 0; }

/* The reading pane is a real screenplay page: Courier on a white sheet, with
   the standard slug / action / cue / dialogue / parenthetical margins. */
.script-view {
  --char-color: var(--accent);
  --reader-font: 15px;
  width: min(100%, 666px);
  margin: 0 auto;
  font-family: var(--screenplay);
  font-size: var(--reader-font);
  line-height: 1.35;
  color: var(--ink);
  background: var(--paper);
  padding: 54px 56px 76px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  box-shadow: var(--shadow-card);
  font-variant-ligatures: none;
}
/* Two-page view: flow the screenplay into two columns on a wider sheet. */
.script-view.two-page {
  width: min(100%, 1180px);
  column-count: 2;
  column-gap: 52px;
  column-rule: 1px solid var(--rule);
  padding: 48px 52px 64px;
}
.script-view.two-page .el.scene:first-child { margin-top: 0; }
.script-view.two-page .el { break-inside: avoid; }

/* A uniform hit-padding so highlights read as full-width bands; the screenplay
   indents live on the children, measured in ch (fixed-pitch, so they hold). */
.el {
  padding: 2px 8px;
  margin: 0 -8px;
  border-radius: 3px;
  transition: background 0.12s;
}
.el.playable { cursor: pointer; }
.el.playable:hover { background: var(--tint); }
.el.current {
  background: color-mix(in srgb, var(--char-color) 13%, var(--paper));
  box-shadow: inset 3px 0 0 var(--char-color);
}

/* Scene heading / slugline: caps, bold, left margin. */
.el.scene {
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink);
  margin-top: 26px;
}
.el.scene:first-child { margin-top: 0; }

/* Transition: right-aligned caps ("CUT TO:"). */
.el.transition {
  text-align: right;
  text-transform: uppercase;
  color: var(--ink);
  margin-top: 12px;
}

/* Action: full text width, blank line between blocks. */
.el.action { color: var(--ink); margin-top: 12px; }

/* Dialogue block: character cue, parenthetical, and dialogue at their standard
   screenplay indents (relative to the ~60ch action column). */
.el.block { margin-top: 12px; }
.el.block .cue {
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 0 21ch;
}
.el.block .paren {
  color: var(--ink);
  margin: 0 0 0 14ch;
  max-width: 26ch;
}
.el.block .dia {
  color: var(--ink);
  margin: 0 0 0 9ch;
  max-width: 36ch;
}

/* ---------- RIGHT: the cast rail ---------- */
.cast-dock {
  width: 252px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.62);
}
.cast-dock-head {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--rule);
}
.cast-dock-label { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cast-dock-title {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.cast-dock-help { max-width: 24ch; color: var(--ink-3); font-size: 10.5px; line-height: 1.4; }
.cast-dock-actions { display: flex; gap: 16px; }
.cast-dock-actions .link-btn { min-height: 36px; white-space: nowrap; }
.project-save-state { min-height: 36px; display: inline-flex; align-items: center; color: var(--ink-3); font-size: 10.5px; white-space: nowrap; }
.project-save-state.is-saving { color: var(--accent); }

.cast-rail {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---------- reading + view options (top-bar popover) ---------- */
.reader-tools {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 70;
  width: 304px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--rule);
  border-radius: 13px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 0 0 1px rgba(14,15,12,.025),0 18px 48px -24px rgba(14,15,12,.32);
  transform-origin: top right;
  animation: settings-in .16s var(--ease);
}
.reader-tools.hidden { display: none; }
@keyframes settings-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.rt-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 9px;
}
.rt-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 40px; font-size: 12px; font-weight: 550; color: var(--ink-2);
}
label.rt-row { cursor: pointer; }
.rt-name { white-space: nowrap; }
.rt-control { display: inline-flex; align-items: center; gap: 8px; }
.rt-speed input[type="range"] { width: 78px; accent-color: var(--accent); cursor: pointer; }
.rt-speed #speed-val { color: var(--ink-3); font-size: 10.5px; min-width: 40px; text-align: right; }
.rt-size button {
  width: 27px; height: 27px; border: 1px solid var(--rule-2); background: var(--desk);
  border-radius: 7px; color: var(--ink-2); cursor: pointer; font-family: var(--ui); font-weight: 600; line-height: 1; padding: 0;
}
.rt-size #text-smaller { font-size: 11px; }
.rt-size #text-larger { font-size: 15px; }
.rt-size button:hover { border-color: var(--ink); color: var(--ink); }
.rt-open { width: 100%; margin-top: 12px; }

.rt-switch {
  appearance: none; -webkit-appearance: none; position: relative;
  width: 34px; height: 20px; border-radius: 999px; background: var(--rule-2);
  cursor: pointer; flex: 0 0 auto; transition: background 0.16s; margin: 0;
}
.rt-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 0.16s;
}
.rt-switch:checked { background: var(--accent); }
.rt-switch:checked::after { transform: translateX(14px); }

/* ---------- collapsible cast dock ---------- */
.cast-expand { display: none; }
.cast-collapse, .cast-expand {
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; flex: 0 0 auto;
}
.cast-collapse svg, .cast-expand svg { width: 14px; height: 14px; }
.cast-collapse:hover, .cast-expand:hover { background: var(--tint); color: var(--ink); }
.cast-dock-actions { align-items: center; }

.reader-shell.cast-collapsed .cast-dock { width: 46px; }
.reader-shell.cast-collapsed .cast-dock-head,
.reader-shell.cast-collapsed .cast-rail { display: none; }
.reader-shell.cast-collapsed .cast-expand { display: grid; margin: 14px auto 0; }

/* ---------- custom voice picker (preview without committing) ---------- */
.voice-picker {
  border: 1px solid var(--rule-2); border-radius: 10px; background: var(--desk);
}
.voice-picker > summary { list-style: none; }
.voice-picker > summary::-webkit-details-marker { display: none; }
.voice-picker[open] { border-color: color-mix(in srgb,var(--accent) 55%,var(--rule-2)); box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 10%,transparent); }
.vp-trigger {
  min-height: 58px;
  padding: 9px 11px 9px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.vp-trigger:hover { background: color-mix(in srgb,var(--tint) 72%,transparent); }
.vp-trigger-copy { min-width: 0; flex: 1; display: grid; gap: 2px; }
.vp-trigger-copy strong { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.vp-trigger-copy small { overflow: hidden; color: var(--ink-3); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.vp-caret { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: var(--ink-3); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .16s var(--ease); }
.voice-picker[open] .vp-caret { transform: rotate(180deg); }
.vp-menu { border-top: 1px solid var(--rule); background: var(--paper); border-radius: 0 0 9px 9px; overflow: hidden; }
.vp-scroll { max-height: 320px; overflow-y: auto; }
.vp-group-label {
  position: sticky; top: 0; z-index: 1; background: color-mix(in srgb,var(--desk) 94%,white);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-3); padding: 10px 12px 5px;
}
.vp-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  min-height: 52px; padding: 7px 10px; border: 0; background: transparent; text-align: left;
  border-top: 1px solid color-mix(in srgb, var(--rule) 55%, transparent);
}
.vp-group-label + .vp-row { border-top: 0; }
.vp-row:hover { background: var(--tint); }
.vp-row.selected { background: color-mix(in srgb, var(--accent) 10%, var(--desk)); }
.vp-play {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; border: 1px solid var(--rule-2);
  background: #fff; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.vp-play svg { width: 11px; height: 11px; fill: currentColor; }
.vp-play:hover { border-color: var(--accent); color: var(--accent); }
.vp-play.playing { background: var(--accent); color: #fff; border-color: var(--accent); }
.vp-play.loading { opacity: 0.6; pointer-events: none; }
.vp-main { min-width: 0; flex: 1; display: flex; flex-direction: column; border: 0; background: transparent; padding: 3px 0; font-family: var(--ui); text-align: left; cursor: pointer; }
.vp-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.vp-desc { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vp-check { flex: 0 0 auto; color: var(--accent); width: 16px; display: grid; place-items: center; }
.vp-check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }

/* One character in the rail. */
.cast-row {
  --av: 36px;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-family: var(--ui);
  text-align: left;
  cursor: pointer;
  transition: background 0.14s, box-shadow 0.14s;
}
.cast-row:hover { background: var(--tint); }
.cast-row.selected {
  background: color-mix(in srgb, var(--char-color) 11%, var(--paper));
  box-shadow: inset 3px 0 0 var(--char-color), inset 0 0 0 1px color-mix(in srgb, var(--char-color) 24%, transparent);
}

.cast-row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.cast-row-name {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cast-row-sub {
  font-size: 10.75px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cast-row.selected .cast-row-name { color: var(--ink); }

.cast-row-chip {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
  padding: 2px 0;
  line-height: 1.5;
}
.cast-row.is-edited .cast-row-chip {
  color: var(--char-color);
}

/* The avatar circle — shared by the rail and the inspector header. */
.avatar {
  width: var(--av, 40px);
  height: var(--av, 40px);
  border-radius: 50%;
  border: 0;
  background: color-mix(in srgb, var(--char-color) 15%, var(--paper));
  color: var(--char-color);
  display: grid;
  place-items: center;
  font-family: var(--ui);
  font-weight: 700;
  font-size: calc(var(--av, 40px) * 0.34);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}
.avatar svg { width: 45%; height: 45%; }

/* Speaking now: the row lights up as the line plays. */
.cast-row.speaking { background: color-mix(in srgb, var(--char-color) 9%, #fff); }
.cast-row.speaking .avatar {
  background: var(--char-color);
  color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--char-color) 22%, transparent);
}
.cast-row.speaking .cast-row-name { color: var(--ink); }

.sugg-chip {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-3);
  padding: 2px 0;
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1.4;
}

/* ---------- CENTER-RIGHT: the voice inspector ---------- */
.inspector {
  width: 360px;
  flex-shrink: 0;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--rule);
  background: var(--paper);
  box-shadow: -18px 0 44px -38px rgba(32, 33, 42, 0.28);
}
.inspector[hidden] { display: none; }

.insp { --char-color: var(--ink); }

.insp-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.insp-head .avatar { --av: 40px; }
.insp-id { min-width: 0; flex: 1; }
.insp-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.015em;
  text-transform: none;
  color: var(--ink);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insp-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.insp-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--rule-2);
  background: var(--paper);
  color: var(--ink-3);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s;
}
.insp-close:hover { color: var(--ink); border-color: var(--ink); }

.insp-body { padding: 20px 20px 32px; display: flex; flex-direction: column; gap: 22px; }
.insp-section { display: flex; flex-direction: column; gap: 9px; }
.insp-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink-2);
}
.insp-reset {
  border: 0;
  background: none;
  padding: 0;
  font-family: var(--ui);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink-3);
  cursor: pointer;
}
.insp-reset:hover { color: var(--accent); }
.insp-hear { width: 100%; }

.insp-advanced { gap: 12px; }
.insp-foot { display: flex; gap: 16px; }

.insp-disclosure {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.insp-disclosure + .insp-disclosure { margin-top: -25px; border-top: 0; }
.insp-disclosure summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  list-style: none;
}
.insp-disclosure summary::-webkit-details-marker { display: none; }
.insp-disclosure summary::after { content: "+"; color: var(--ink-3); font-size: 17px; font-weight: 400; }
.insp-disclosure[open] summary::after { content: "−"; }
.insp-disclosure-body { padding: 2px 0 20px; }

.pop-inner { display: flex; flex-direction: column; gap: 8px; padding: 16px; }

.pop-head { display: flex; align-items: flex-start; gap: 9px; }
.pop-id { min-width: 0; flex: 1; }
.pop-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--char-color, var(--ink));
  line-height: 1.2;
}
.pop-sub { color: var(--ink-3); font-size: 11.5px; margin-top: 3px; }

.pop-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 2px;
}

.pop-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--rule);
  padding-top: 10px;
  margin-top: 1px;
}

.pop-more {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--ui);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.14s;
}
.pop-more:hover { color: var(--ink); }
.pop-more.is-open { color: var(--ink); }
.pop-more:disabled { opacity: 0.5; cursor: wait; }

.voice-select {
  appearance: none;
  width: 100%;
  background: var(--desk) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23787b8a' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  background-size: 9px 5.4px;
  color: var(--ink);
  border: 1px solid var(--rule-2);
  min-height: 44px;
  border-radius: var(--r);
  padding: 0 34px 0 13px;
  font-size: 13px;
  font-family: var(--ui);
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.14s;
}
.voice-select:hover, .voice-select:focus { border-color: var(--ink); outline: none; }

.voice-desc { color: var(--ink-3); font-size: 11.5px; line-height: 1.45; min-height: 16px; }

.preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--rule-2);
  color: var(--ink-2);
  min-height: 44px;
  border-radius: var(--r);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--ui);
  padding: 0 12px;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s;
}
.preview-btn:hover { color: var(--ink); border-color: var(--ink); }
.preview-btn:disabled { opacity: 0.5; cursor: wait; }
.preview-btn svg { width: 10px; height: 10px; fill: currentColor; flex-shrink: 0; }

.btn-row { display: flex; gap: 6px; }
.btn-row .preview-btn { flex: 1; padding: 8px 6px; }

.use-btn { background: var(--ink); border-color: var(--ink); color: #fff; }
.use-btn:hover { background: #000; border-color: #000; color: #fff; }

/* ---------- tuning ---------- */
.tune-panel {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--desk);
}
.tune-panel.open { display: flex; }

.tune-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.tune-label { font-size: 11.5px; font-weight: 500; color: var(--ink-2); width: 62px; flex-shrink: 0; }
.tune-row input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 0; }
.tune-val {
  font-size: 10.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* ---------- direction box ---------- */
.design-prompt {
  width: 100%;
  background: var(--desk);
  color: var(--ink);
  border: 1px solid var(--rule-2);
  min-height: 104px;
  border-radius: var(--r);
  padding: 12px 13px;
  font-size: 13px;
  font-family: var(--ui);
  line-height: 1.5;
  resize: vertical;
}
.design-prompt:focus { outline: none; border-color: var(--ink); background: var(--paper); }
.design-prompt::placeholder { color: var(--ink-3); }

/* ---------- performance direction ---------- */
.booth {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.booth-row { padding: 7px 2px; border-radius: 8px; transition: background 0.14s; }
.booth-row:hover { background: var(--desk); }
.booth-track {
  display: grid;
  grid-template-columns: 78px 1fr 78px;
  align-items: center;
  gap: 11px;
  cursor: pointer;
}
.booth-end {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-3);
  transition: color 0.14s, font-weight 0.14s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.booth-end.lo { text-align: right; }
.booth-end.hi { text-align: left; }
/* The end the slider leans toward reads solid; the other stays quiet. */
.booth-row.moved.lean-lo .booth-end.lo,
.booth-row.moved.lean-hi .booth-end.hi { color: var(--ink); font-weight: 700; }

.booth-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--rule-2);
  outline: none;
  cursor: pointer;
}
.booth-row.moved .booth-range { background: color-mix(in srgb, var(--accent) 30%, var(--rule-2)); }
.booth-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--rule-2);
  box-shadow: 0 1px 3px rgba(20, 19, 16, 0.18);
  transition: transform 0.1s, background 0.14s, border-color 0.14s;
}
.booth-row.moved .booth-range::-webkit-slider-thumb { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--mark); }
.booth-range::-webkit-slider-thumb:active { transform: scale(1.15); }
.booth-range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--rule-2);
  cursor: pointer;
}
.booth-row.moved .booth-range::-moz-range-thumb { background: var(--accent); border-color: var(--accent); }

/* Apply Direction — the inspector's primary action. */
.insp-apply { flex: 1; background: var(--ink); border-color: var(--ink); color: #fff; }
.insp-apply:hover { background: #2a2a2a; border-color: #2a2a2a; color: #fff; }

.booth-rationale {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-2);
  font-style: normal;
  padding: 9px 10px;
  border-radius: var(--r);
  background: var(--mark);
}

.booth-build {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--rule-2);
  color: var(--ink-3);
  font-size: 11.5px;
  padding: 8px;
}
.booth-build:hover { color: var(--ink-2); border-color: var(--ink-3); }

/* ---------- reading options, in the nav ---------- */
.nav-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.nav-opt input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.nav-opt > span { cursor: pointer; }

.nav-speed { padding-left: 18px; border-left: 1px solid var(--rule); }
.nav-opt-label { color: var(--ink-3); }
.nav-speed input[type="range"] { width: 84px; accent-color: var(--accent); cursor: pointer; }
#speed-val { color: var(--ink-3); font-size: 11px; min-width: 42px; text-align: right; }

/* ---------- transport: docked at the foot of the script column ---------- */
.transport {
  flex-shrink: 0;
  align-self: center;
  width: min(720px, calc(100% - 40px));
  margin: 6px auto 16px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--rule);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 0 0 1px rgba(32, 33, 42, 0.025), 0 18px 44px -28px rgba(32, 33, 42, 0.38);
  z-index: 30;
}
.transport-inner {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.t-buttons { display: flex; align-items: center; gap: 4px; }
.t-buttons button {
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  color: var(--ink-2);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.t-buttons button svg { width: 15px; height: 15px; fill: currentColor; }
.t-buttons button:hover { background: var(--tint); color: var(--ink); }

.t-buttons .play {
  position: relative;
  width: 46px;
  height: 46px;
  margin: 0 6px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px var(--mark), 0 8px 18px -13px rgba(71, 73, 178, 0.86);
}
.t-buttons .play::after {
  content: "";
  position: absolute;
  inset: -5px;
  pointer-events: none;
  border-width: 2px;
  border-style: solid;
  border-color: var(--lilac) var(--mint) var(--blue) var(--peach);
  border-radius: 50%;
}
.t-buttons .play:hover { background: var(--accent-strong); color: #fff; }
.t-buttons .play.is-playing { background: var(--ink); }
.t-buttons .play svg { width: 16px; height: 16px; }
.t-buttons .play .i-play { transform: translateX(1px); }
.play .i-pause { display: none; }
.play.is-playing .i-play { display: none; }
.play.is-playing .i-pause { display: block; }
.play-label { display: none; }

.t-info { flex: 1; min-width: 0; }

.now-playing { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 7px; }
.np-char { font-size: 10.5px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; margin-right: 10px; }
.np-text { color: var(--ink-2); }
.np-idle { color: var(--ink-3); }

.progress-wrap { display: flex; align-items: center; gap: 12px; }
.progress-bar { flex: 1; height: 4px; background: var(--rule); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }
.progress-label { color: var(--ink-3); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }

.loading-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  flex-shrink: 0;
}
.loading-dot.on {
  border-color: var(--rule-2);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--r);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 70;
  max-width: min(90vw, 460px);
  text-align: center;
  box-shadow: 0 8px 24px -8px rgba(20, 19, 16, 0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
.inspector-backdrop { display: none; }

/* Preserve the screenplay at laptop widths. Voice settings lift above the
   reader instead of taking a permanent 380px bite out of the page. */
@media (max-width: 1240px) {
  .script-scroll { padding: 26px 24px 8px; }
  .inspector-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 72px 0 0;
    border: 0;
    background: rgba(32, 33, 42, 0.12);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    cursor: default;
    z-index: 44;
  }
  .inspector {
    position: fixed;
    inset: 72px 0 0 auto;
    width: min(414px, calc(100vw - 32px));
    z-index: 45;
    border-left: 1px solid var(--rule);
    box-shadow: -28px 0 70px -30px rgba(32, 33, 42, 0.42), -2px 0 0 rgba(32, 33, 42, 0.04);
  }
}

/* Narrow: stack. The page scrolls normally, the cast becomes a sticky top
   strip, and the inspector slides up as a bottom sheet. */
@media (max-width: 860px) {
  #stage-reader { display: block; height: auto; overflow: visible; padding-bottom: calc(130px + env(safe-area-inset-bottom)); }
  .reader-shell { flex-direction: column; }
  .script-pane { min-width: 0; min-height: 0; }
  .script-scroll { overflow: visible; padding: 20px 16px 8px; scrollbar-gutter: auto; }

  .cast-dock {
    order: -1;
    width: auto;
    border-left: 0;
    border-bottom: 1px solid var(--rule);
    position: sticky;
    top: 72px;
    z-index: 18;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  .cast-dock-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-bottom: 0;
    padding: 10px 14px 7px;
  }
  .cast-dock-label { gap: 1px; }
  .cast-dock-help { display: block; max-width: 38ch; font-size: 9.5px; }
  .cast-dock-actions { gap: 12px; }
  .cast-rail { flex-direction: row; overflow-x: auto; overflow-y: hidden; gap: 7px; padding: 0 12px 11px; scrollbar-width: none; }
  .cast-rail::-webkit-scrollbar { display: none; }
  .cast-row { width: auto; min-height: 52px; flex-shrink: 0; padding: 8px 10px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--rule); }
  .cast-row-main { max-width: 124px; }

  /* collapse is a desktop affordance; on mobile keep the dock open */
  .cast-expand, .cast-collapse { display: none !important; }
  .reader-shell.cast-collapsed .cast-dock { width: auto; }
  .reader-shell.cast-collapsed .cast-dock-head,
  .reader-shell.cast-collapsed .cast-rail { display: flex; }
  /* two-page view is impractical on a phone */
  .script-view.two-page { column-count: 1; width: min(100%, 666px); }

  .inspector {
    position: fixed;
    inset: auto 0 0 0;
    width: auto;
    max-height: 82vh;
    border-left: 0;
    border-top: 1px solid var(--rule);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -22px 64px -28px rgba(32, 33, 42, 0.48), 0 -1px 0 rgba(32, 33, 42, 0.05);
    z-index: 50;
  }
  .inspector .insp-body { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

  .transport {
    position: fixed;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    width: min(720px, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }
  .toast { bottom: calc(126px + env(safe-area-inset-bottom)); }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    height: 64px;
    gap: 10px;
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }
  .topbar-brand .wordmark { display: none; }
  .topbar-context { text-align: left; }
  .topbar-context strong { max-width: 38vw; }
  .topbar-right { gap: 8px; }
  .reader-settings-trigger { width: 40px; padding: 0; justify-content: center; }
  .reader-settings-trigger span { display: none; }
  .reader-tools { position: fixed; top: 58px; right: max(10px,env(safe-area-inset-right)); width: min(304px,calc(100vw - 20px)); }
  .cast-dock { top: 64px; }
  .inspector-backdrop:not([hidden]) { top: 64px; }
  .nav-speed { display: none; } /* speed also lives on each character's Pace */
  .nav-opt span { display: none; }
  .transport-inner { flex-direction: column; gap: 10px; align-items: stretch; }
  .t-buttons { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 10px; align-items: center; }
  .t-buttons #btn-stop { display: none; }
  .t-buttons .play {
    width: 100%;
    height: 48px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
  }
  .t-buttons .play::after { border-radius: 15px; }
  .play-label { display: inline; font-size: 0; font-weight: 650; }
  .play-label::after { content: "Play table read"; font-size: 13px; }
  .play.is-playing .play-label::after { content: "Pause"; }
}

/* ---------- revision tools: line notes, draft versions, focused voice edit ---------- */
.nav-tools { display: flex; align-items: center; }
.reader-active .topbar-right { display: flex; visibility: visible; }
.reader-active .account-slot { display: none; }
.reader-view-dock[hidden] { display: none !important; }
.script-view:focus { outline: none; }
.reader-settings > summary {
  min-height: 40px; padding: 0 13px; display: flex; align-items: center;
  border: 1px solid var(--rule); border-radius: 9px; background: var(--paper);
  color: var(--ink-2); font-size: 12px; font-weight: 650; cursor: pointer;
}
.reader-settings[open] > summary,.reader-settings > summary:hover { background: var(--tint); color: var(--ink); }
.reader-settings-popover {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 80; width: 330px;
  padding: 16px; border: 1px solid var(--rule); border-radius: 14px; background: var(--paper);
  box-shadow: 0 20px 52px -28px rgba(14,15,12,.38); display: grid; gap: 4px;
}
.settings-popover-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 2px 12px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.settings-popover-head span { color: var(--ink-3); font-size: 10px; font-weight: 550; }
.settings-toggle,.settings-row,.settings-action { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 4px; }
.settings-toggle span,.settings-row > span,.settings-action > span:first-child { display: grid; gap: 3px; text-align: left; }
.settings-toggle strong,.settings-row strong,.settings-action strong { font-size: 12px; font-weight: 620; color: var(--ink); }
.settings-toggle small,.settings-row small,.settings-action small { font-size: 10.5px; color: var(--ink-3); }
.settings-toggle input { accent-color: var(--accent); width: 34px; height: 20px; }
.text-stepper { display: flex; gap: 4px; }
.text-stepper button { width: 34px; height: 32px; border: 1px solid var(--rule-2); border-radius: 7px; background: var(--desk); color: var(--ink-2); cursor: pointer; }
.settings-action { width: 100%; margin-top: 4px; border: 0; border-top: 1px solid var(--rule); background: transparent; font-family: var(--ui); cursor: pointer; color: var(--ink-3); }
.settings-action:hover { color: var(--accent); }

.source-page-number {
  position: relative; margin: 42px 0 22px; padding-top: 18px; border-top: 1px solid #d9d8d2;
  color: #7c7b75; font-family: var(--ui); font-size: 10px !important; font-weight: 650;
  letter-spacing: .08em; text-align: right; text-transform: uppercase; user-select: none;
}
.source-page-number:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.el { position: relative; border-radius: 5px; }
.el.playable { cursor: text; }
.el.line-selected { background: color-mix(in srgb,var(--lime) 24%,transparent); box-shadow: 0 0 0 5px color-mix(in srgb,var(--lime) 24%,transparent); }
.script-note-marker {
  position: absolute; right: -44px; top: 0; min-width: 27px; height: 25px; padding: 0 7px;
  border: 1px solid #d8c96c; border-radius: 13px 13px 13px 4px; background: #fff8b8;
  color: #665b18; font: 650 10px/1 var(--ui); cursor: pointer; box-shadow: 0 3px 10px -8px rgba(14,15,12,.45);
}
.script-note-highlight { background: #fff1a6; color: inherit; border-radius: 2px; box-shadow: 0 0 0 1px rgba(169,145,34,.08); }
.line-toolbar {
  position: fixed; z-index: 95; display: flex; gap: 3px; padding: 5px;
  border: 1px solid var(--rule-2); border-radius: 10px; background: var(--ink); color: #fff;
  box-shadow: 0 14px 35px -18px rgba(14,15,12,.72);
}
.line-toolbar[hidden] { display: none; }
.line-toolbar button { min-height: 34px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: inherit; font: 600 11px/1 var(--ui); cursor: pointer; }
.line-toolbar button:hover { background: rgba(255,255,255,.13); }
.line-toolbar svg { width: 14px; height: 14px; fill: currentColor; }

.editor-dialog { position: fixed; inset: 0; width: min(580px,calc(100vw - 28px)); height: max-content; max-height: calc(100vh - 28px); margin: auto; padding: 0; border: 0; border-radius: 16px; background: transparent; color: var(--ink); }
.editor-dialog::backdrop { background: rgba(24,24,20,.35); backdrop-filter: blur(2px); }
.editor-dialog-card { padding: 22px; border: 1px solid var(--rule); border-radius: 16px; background: var(--paper); box-shadow: 0 32px 90px -40px rgba(14,15,12,.72); }
.editor-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog-kicker { color: var(--accent); font-size: 9.5px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.editor-dialog h2 { margin: 4px 0 0; font-size: 21px; letter-spacing: -.025em; }
.dialog-close { width: 38px; height: 38px; border: 1px solid var(--rule); border-radius: 9px; background: transparent; color: var(--ink-3); font-size: 20px; cursor: pointer; }
.editor-dialog blockquote { margin: 18px 0; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--desk); border-radius: 0 8px 8px 0; color: var(--ink-2); font: 400 13px/1.55 var(--script); }
.dialog-field { display: grid; gap: 8px; color: var(--ink-2); font-size: 12px; font-weight: 650; }
.dialog-field textarea { resize: vertical; width: 100%; padding: 12px; border: 1px solid var(--rule-2); border-radius: 9px; background: #fff; color: var(--ink); font: 400 13px/1.5 var(--ui); }
.dialog-help { margin: 9px 0 0; color: var(--ink-3); font-size: 10.5px; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.dialog-spacer { flex: 1; }
.primary-btn,.secondary-btn,.danger-link { min-height: 40px; padding: 0 14px; border-radius: 9px; font: 650 11.5px/1 var(--ui); cursor: pointer; }
.primary-btn { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.secondary-btn { border: 1px solid var(--rule-2); background: var(--paper); color: var(--ink-2); }
.danger-link { border: 0; background: transparent; color: #a04739; padding-left: 0; }

/* Voice editing is a modal task; it no longer compresses the screenplay. */
.inspector-backdrop:not([hidden]) { display: block; position: fixed; inset: 72px 0 0; z-index: 84; border: 0; background: rgba(24,24,20,.34); backdrop-filter: blur(2px); }
.inspector {
  position: fixed; inset: 50% auto auto 50%; z-index: 85; width: min(620px,calc(100vw - 32px)); max-height: min(760px,calc(100vh - 104px));
  min-height: 0; overflow-y: auto; transform: translate(-50%,-50%); border: 1px solid var(--rule); border-radius: 16px;
  background: var(--paper); box-shadow: 0 34px 100px -44px rgba(14,15,12,.78);
}
.cast-row { cursor: default; }
.cast-edit-btn { flex: 0 0 auto; min-height: 30px; padding: 0 9px; border: 1px solid var(--rule-2); border-radius: 7px; background: var(--paper); color: var(--ink-2); font: 650 10.5px/1 var(--ui); cursor: pointer; }
.cast-edit-btn:hover { border-color: var(--accent); color: var(--accent); }
.voice-quick-actions { display: flex; gap: 8px; margin-top: 2px; }
.voice-quick-actions button { flex: 1; min-height: 40px; }

@media (max-width: 860px) {
  .reader-settings-popover { position: fixed; top: 66px; right: 10px; width: min(330px,calc(100vw - 20px)); }
  .script-note-marker { right: -18px; }
  .inspector { inset: auto 8px 8px; width: auto; max-height: min(82vh,720px); transform: none; border-radius: 16px; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .primary-btn { flex: 1; }
}

@media (max-width: 700px) {
  #stage-upload {
    padding: 38px max(16px, env(safe-area-inset-right)) 72px max(16px, env(safe-area-inset-left));
  }
  .hero { text-align: left; }
  .hero h1 { font-size: clamp(38px, 11vw, 44px); }
  .hero .sub { font-size: 15.5px; }
  .hero .sub { margin-right: 0; margin-left: 0; }
  .upload-cast-strip, .upload-cast { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 20px; }
  .upload-cast-avatar { width: 40px; height: 40px; }
  .upload-workflow, .upload-flow { gap: 6px; }
  .upload-workflow li, .upload-flow-step { align-items: flex-start; flex-direction: column; gap: 5px; min-height: 78px; padding: 10px; }
  .dropzone { padding: 28px 20px 24px; text-align: left; }
  .drop-icon { margin-right: 0; margin-left: 0; }
  .drop-cue, .drop-action { width: 100%; }
  .sample-option .ghost-btn, .paste-details .ghost-btn { width: 100%; }
  .sample-option, .sample-note, .upload-trust { text-align: left; }
  .paste-details summary { text-align: left; }
  #stage-loading, #stage-auth {
    padding: 40px max(16px, env(safe-area-inset-right)) 72px max(16px, env(safe-area-inset-left));
  }
  .loading-card { padding: 24px 20px; }
  .loading-title { font-size: 24px; }
  .loading-status { align-items: flex-start; flex-direction: column; gap: 2px; }
  .loading-status span:last-child { text-align: left; }
  .loading-cancel, .auth-skip { width: 100%; }
  /* Scale the whole screenplay page down together so the ch-based indents and
     the fixed pitch stay in proportion. */
  .script-view { font-size: 13px; padding: 32px 22px 48px; }
}

/* ---------- account control + billing ---------- */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right .nav-tools { margin-left: 0; }
.account-slot { display: flex; align-items: center; gap: 9px; }
.account-slot.auth-active { visibility: hidden; }
.account-loading {
  width: 88px;
  height: 40px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--tint);
  animation: account-loading 1.2s ease-in-out infinite alternate;
}
@keyframes account-loading { from { opacity: 0.52; } to { opacity: 1; } }

.solid-btn {
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  min-height: 44px; border-radius: var(--r); padding: 0 18px; font-size: 13px; font-weight: 600;
  font-family: var(--ui); cursor: pointer; white-space: nowrap;
  transition: background 0.14s, box-shadow 0.14s;
}
.solid-btn:hover { background: #000; box-shadow: 0 6px 18px -10px rgba(20, 19, 16, 0.6); }
.solid-btn.small { min-height: 40px; padding: 0 14px; font-size: 12.5px; }

.account-signin {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--ink);
  border-radius: var(--r);
  background: var(--ink);
  color: #fff;
  font-family: var(--ui);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, transform 0.12s;
}
.account-signin:hover { background: #000; }
.account-signin:active { transform: scale(0.97); }

.account-menu { position: relative; }
.account-menu > summary { list-style: none; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 5px 9px 5px 6px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.14s, background 0.14s;
}
.account-trigger:hover, .account-menu[open] .account-trigger { border-color: rgba(21, 21, 21, 0.34); background: #fff; }
.account-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 7px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--ui);
  font-size: 15px;
  font-weight: 600;
}
.account-trigger-copy { display: grid; gap: 1px; min-width: 0; text-align: left; }
.account-trigger-plan { font-size: 11.5px; font-weight: 700; line-height: 1.2; }
.account-trigger-usage { color: var(--ink-3); font-size: 10.5px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.account-trigger-caret { width: 14px; height: 14px; fill: none; stroke: var(--ink-3); stroke-width: 1.5; transition: transform 0.18s var(--ease); }
.account-menu[open] .account-trigger-caret { transform: rotate(180deg); }

.account-popover {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  width: 292px;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(21, 21, 21, 0.03), 0 18px 46px -24px rgba(21, 21, 21, 0.38);
  transform-origin: top right;
  animation: account-pop 0.16s var(--ease);
}
@keyframes account-pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.account-popover-head { display: grid; gap: 2px; padding: 10px 10px 12px; }
.account-popover-email { overflow: hidden; color: var(--ink); font-size: 12.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.account-popover-plan { color: var(--ink-3); font-size: 11px; }
.account-usage { padding: 11px 10px 12px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.account-usage-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--ink-3); font-size: 10.5px; }
.account-usage-line strong { color: var(--ink-2); font-weight: 650; font-variant-numeric: tabular-nums; }
.account-usage-track { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: var(--tint); }
.account-usage-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.account-menu-actions { display: grid; gap: 2px; padding-top: 6px; }
.account-menu-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--ui);
  font-size: 12.5px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: color 0.14s, background 0.14s;
}
.account-menu-action:hover { background: var(--tint); color: var(--ink); }
.account-menu-action.signout { color: #9a3f25; }
.account-menu-action.signout:hover { background: #f8eee9; color: #7c2f1b; }
.account-menu-action span:last-child { color: var(--ink-3); font-size: 11px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .account-loading { opacity: 0.8; }
}

@media (max-width: 760px) {
  .account-trigger-copy { display: none; }
  .account-trigger { width: 40px; padding: 6px; }
  .account-trigger-caret { display: none; }
  .account-popover { position: fixed; top: 58px; right: 12px; width: min(292px, calc(100vw - 24px)); }
  .account-loading { width: 40px; }
}

/* modal */
body.modal-open { overflow: hidden; }
.bill-modal { position: fixed; inset: 0; z-index: 80; display: none; }
.bill-modal.show { display: flex; align-items: center; justify-content: center; padding: 20px; }
.bill-backdrop { position: absolute; inset: 0; background: rgba(20, 19, 16, 0.5); backdrop-filter: blur(4px); animation: fadein 0.15s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.bill-card {
  position: relative; z-index: 1; width: min(720px, 100%); max-height: 90vh; overflow: auto;
  background: var(--desk); border: 1px solid var(--rule); border-radius: 14px;
  padding: 32px 30px 26px; box-shadow: 0 40px 80px -40px rgba(20, 19, 16, 0.6);
  animation: popin 0.18s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes popin { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.bill-x {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border: 0;
  background: none; font-size: 24px; line-height: 1; color: var(--ink-3); cursor: pointer; border-radius: var(--r);
}
.bill-x:hover { color: var(--ink); background: var(--tint); }
.bill-head { text-align: center; max-width: 460px; margin: 0 auto 22px; }
.bill-kicker { font-family: var(--ui); font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.bill-head h3 { font-size: 24px; font-weight: 650; letter-spacing: -0.03em; }
.bill-head p { color: var(--ink-2); font-size: 14px; margin-top: 8px; }
.bill-toggle { display: inline-flex; gap: 4px; margin-top: 18px; padding: 4px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); }
.bt-opt { min-height: 38px; font-family: var(--ui); font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 0 15px; border: 0; background: transparent; border-radius: 5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.bt-opt.is-on { background: var(--ink); color: #fff; }
.bt-opt span { font-size: 9px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }
.bt-opt.is-on span { color: var(--lilac); }
.bill-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.bill-tier { position: relative; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 22px 18px; text-align: center; }
.bill-tier.pop { border-color: var(--ink); box-shadow: var(--shadow-card); }
.bt-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: #fff; background: var(--accent); padding: 4px 10px; border-radius: 4px; white-space: nowrap; }
.bt-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-2); }
.bt-price { font-size: 30px; font-weight: 800; letter-spacing: -0.04em; margin-top: 6px; }
.bt-price span { font-size: 12px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.bt-annual { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.bt-pages { font-size: 12px; color: var(--ink-2); margin: 12px 0 14px; min-height: 30px; }
.bt-buy { width: 100%; }
.bill-full { display: block; text-align: center; margin-top: 20px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.bill-full:hover { color: var(--ink); }
@media (max-width: 620px) {
  .bill-tiers { grid-template-columns: 1fr; }
  .bill-card { padding: 26px 18px 20px; }
  .acct-left, .acct-meter { display: none; }
}

@media (max-width: 1080px) {
  .project-library,.character-page-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 860px) {
  .workspace-page { min-height: calc(100vh - 64px); padding: 40px 24px 72px; }
}

@media (max-width: 620px) {
  .workspace-page { padding: 32px 16px 64px; }.workspace-page-head { margin-bottom: 28px; align-items: flex-start; flex-direction: column; }.workspace-page-head h1 { font-size: 29px; }.workspace-page-head .workspace-primary { width: 100%; }
  .project-library,.character-page-list { grid-template-columns: 1fr; }.workspace-empty { min-height: 280px; padding: 34px 22px; }.account-settings-card { padding: 18px; }.account-setting-row { align-items: flex-start; flex-direction: column; }.account-setting-row button { width: 100%; }
}

/* Shared interaction contract. Keep a visible keyboard location even for
   controls whose component-level focus style removes the native outline. */
:where(button, a, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 3px;
}
.dropzone:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--mark), var(--shadow-card); }
:where(button, .dropzone):active { transform: scale(0.98); }
:where(button, input, textarea, select):disabled { opacity: 0.52; cursor: not-allowed; }

/* ---------- focused reader refinement ----------
   The script title, transport, progress, pace, and type size now read as one
   compact instrument in the top navigation. */
.topbar-center {
  min-width: 0;
  justify-self: center;
}

.reader-transport { display: none; }

.reader-active .topbar {
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 12px;
  padding: 0 18px;
}

.reader-active .topbar-center {
  width: min(940px, 100%);
  height: 56px;
  padding: 4px 6px 4px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 2px rgba(14, 15, 12, 0.035), 0 8px 24px -22px rgba(14, 15, 12, 0.36);
}

.reader-active .topbar-context {
  width: 190px;
  flex: 0 1 190px;
  gap: 0;
  text-align: left;
}

.reader-active .topbar-context span { font-size: 8px; }
.reader-active .topbar-context strong { font-size: 12px; }

.reader-active .reader-transport {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.reader-transport .t-buttons { flex: 0 0 auto; gap: 1px; }
.reader-transport .t-buttons button {
  width: 32px;
  height: 32px;
}
.reader-transport .t-buttons button svg { width: 13px; height: 13px; }
.reader-transport .t-buttons .play {
  width: 36px;
  height: 36px;
  margin: 0 2px;
  background: var(--accent);
  box-shadow: none;
}
.reader-transport .t-buttons .play::after { display: none; }
.reader-transport .t-buttons .play:hover { background: var(--accent-strong); }

.reader-progress {
  min-width: 100px;
  flex: 1;
}
.reader-progress .now-playing {
  margin-bottom: 4px;
  color: var(--ink-3);
  font-size: 9.5px;
}
.reader-progress .np-char { font-size: 9px; }
.reader-progress .progress-wrap { gap: 8px; }
.reader-progress .progress-label { font-size: 9.5px; }

.reader-transport .reader-settings { flex: 0 0 auto; }
.reader-transport .reader-settings-trigger {
  min-height: 36px;
  padding: 0 10px;
  border-color: transparent;
}

/* The cast is navigation only: no dashboard header or account-state chrome. */
.cast-collapse-rail {
  align-self: flex-end;
  margin: 10px 10px 0;
}
.cast-rail { padding-top: 2px; }
.reader-shell:not(.cast-collapsed) .cast-expand { display: none; }
.reader-shell.cast-collapsed .cast-collapse-rail { display: none; }

/* Editable script understanding precedes casting controls. */
.character-description {
  width: 100%;
  min-height: 132px;
  padding: 12px 13px;
  resize: vertical;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--desk);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 12.5px;
  line-height: 1.55;
}
.character-description:focus {
  border-color: var(--accent);
  background: var(--paper);
}
.insp-help {
  color: var(--ink-3);
  font-size: 10.5px;
  line-height: 1.45;
  text-wrap: pretty;
}

/* Voice options are anonymous descriptions. Hovering or focusing reveals a
   denser audition overlay without changing the row's hit targets. */
.vp-trigger {
  min-height: 72px;
  align-items: flex-start;
  padding-top: 11px;
  padding-bottom: 11px;
}
.vp-trigger-copy strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.vp-trigger-copy small { margin-top: 2px; }
.vp-caret { margin-top: 14px; }

.vp-row {
  position: relative;
  min-height: 72px;
  overflow: hidden;
}
.vp-main { gap: 3px; }
.vp-name {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1.35;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.vp-desc {
  font-size: 9.5px;
  letter-spacing: 0.015em;
  text-transform: none;
}
.vp-detail-overlay {
  position: absolute;
  inset: 5px 27px 5px 51px;
  z-index: 2;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  border-radius: 7px;
  background: rgba(14, 15, 12, 0.94);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
}
.vp-detail-overlay strong,
.vp-detail-overlay small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
}
.vp-detail-overlay strong {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.3;
  -webkit-line-clamp: 2;
}
.vp-detail-overlay small {
  color: rgba(255, 255, 255, 0.66);
  font-size: 8.5px;
  line-height: 1.3;
  -webkit-line-clamp: 2;
}
.vp-row:hover .vp-detail-overlay,
.vp-row:focus-within .vp-detail-overlay {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  .cast-collapse-rail { display: none; }
  .cast-rail { padding-top: 10px; }
}

@media (max-width: 760px) {
  .reader-active .topbar {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 8px;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }
  .reader-active .topbar-center {
    height: 52px;
    padding: 3px 5px 3px 10px;
    gap: 7px;
  }
  .reader-active .topbar-context {
    width: min(31vw, 132px);
    flex-basis: min(31vw, 132px);
  }
  .reader-active .topbar-context span { display: none; }
  .reader-active .topbar-context strong { max-width: none; font-size: 10.5px; }
  .reader-active .topbar-right { display: none; }
  .reader-active .reader-transport { gap: 5px; }
  .reader-transport .t-buttons {
    display: flex;
    grid-template-columns: none;
    gap: 0;
  }
  .reader-transport .t-buttons button { width: 28px; height: 32px; }
  .reader-transport .t-buttons #btn-stop { display: none; }
  .reader-transport .t-buttons .play {
    width: 34px;
    height: 34px;
    margin: 0;
    border-radius: 50%;
  }
  .reader-transport .play-label { display: none; }
  .reader-progress { display: none; }
  .reader-transport .reader-settings-trigger { width: 34px; min-height: 34px; }
  .reader-tools { top: 58px; }
}

@media (max-width: 430px) {
  .reader-transport .t-buttons #btn-prev,
  .reader-transport .t-buttons #btn-next { display: none; }
  .reader-active .topbar-context {
    width: min(44vw, 154px);
    flex-basis: min(44vw, 154px);
  }
}

/* ---------- floating reader instruments ---------- */
.reader-active .topbar {
  position: fixed;
  inset: 0 0 auto;
  width: 100%;
  border-bottom: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.reader-active #stage-reader {
  height: 100vh;
  padding-top: 72px;
}

.reader-active .topbar-right { visibility: hidden; }

.reader-active .topbar-center {
  box-shadow:
    0 0 0 1px rgba(14, 15, 12, 0.035),
    0 2px 5px -3px rgba(14, 15, 12, 0.16),
    0 14px 34px -26px rgba(14, 15, 12, 0.42);
}

.player-speed {
  position: relative;
  width: 52px;
  height: 40px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink-2);
  background: var(--tint);
  transition: color 0.14s, background-color 0.14s, transform 0.12s;
}
.player-speed::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  pointer-events: none;
  transform: translateY(-68%) rotate(45deg);
}
.player-speed:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 10%, var(--desk));
}
.player-speed:active { transform: scale(0.97); }
.player-speed select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 100%;
  padding: 0 18px 0 9px;
  border: 0;
  border-radius: inherit;
  outline: 0;
  color: inherit;
  background: transparent;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.reader-view-dock {
  position: fixed;
  left: 24px;
  bottom: 20px;
  z-index: 40;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 0 0 1px rgba(14, 15, 12, 0.08),
    0 2px 5px -3px rgba(14, 15, 12, 0.18),
    0 14px 34px -24px rgba(14, 15, 12, 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.reader-view-control {
  position: relative;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--ui);
  cursor: pointer;
  transition: color 0.14s, background-color 0.14s, transform 0.12s;
}
.reader-view-control:hover,
.reader-view-control:focus-within {
  color: var(--ink);
  background: var(--tint);
}
.reader-view-control:active { transform: scale(0.97); }

.reader-view-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  transition: color 0.14s, background-color 0.14s;
}
.reader-view-icon svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.reader-view-control input:checked + .reader-view-icon {
  color: var(--accent-strong);
  background: var(--mark);
}
.page-double { display: none; }
.reader-view-control input:checked + .reader-view-icon .page-single { display: none; }
.reader-view-control input:checked + .reader-view-icon .page-double { display: inline; }

.text-size-mark {
  color: currentColor;
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}
.text-size-mark sup {
  position: relative;
  top: -0.12em;
  margin-left: 1px;
  font-size: 9px;
  font-weight: 700;
}

.control-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  z-index: 2;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(14, 15, 12, 0.94);
  color: var(--paper);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
}
.reader-view-control:hover .control-tooltip,
.reader-view-control:focus-visible .control-tooltip,
.reader-view-control:focus-within .control-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}
.reader-view-control:first-child .control-tooltip {
  left: 0;
  transform: translate(0, 4px);
}
.reader-view-control:first-child:hover .control-tooltip,
.reader-view-control:first-child:focus-within .control-tooltip {
  transform: translate(0, 0);
}
.tooltip-on { display: none; }
.reader-view-control input:checked ~ .tooltip-off { display: none; }
.reader-view-control input:checked ~ .tooltip-on { display: block; }

.reader-active .toast { bottom: 80px; }

@media (max-width: 860px) {
  .reader-active #stage-reader {
    height: auto;
    min-height: 100vh;
    padding-top: 64px;
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
  .reader-view-dock {
    left: max(10px, env(safe-area-inset-left));
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .reader-active .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media (max-width: 760px) {
  .player-speed {
    width: 46px;
    height: 34px;
    flex-basis: 46px;
  }
  .player-speed select { padding-left: 7px; font-size: 10px; }
}

/* The revision controls are part of the floating reader header. These final
   overrides intentionally follow the legacy floating-instrument rules. */
.reader-active .topbar-right { display: flex; visibility: visible; }
.reader-active .topbar-right .account-slot { display: none; }
.reader-active .script-view:focus,
.reader-active .script-view:focus-visible { outline: none !important; }
.reader-view-dock[hidden] { display: none !important; }

@media (max-width: 760px) {
  .reader-active .topbar-right { display: flex; position: fixed; top: 61px; left: 10px; z-index: 31; }
  .reader-active .cast-dock { padding-left: 58px; }
  .reader-settings > summary { width: 38px; justify-content: center; padding: 0; font-size: 0; }
  .reader-settings > summary::after { content: "•••"; font-size: 11px; letter-spacing: 1px; }
}
