/* Table Read — app. Modern minimal: Inter, soft cards, one signal-orange
   accent. The script renders as a clean transcript, not a screenplay page. */
:root {
  --desk: #fbfaf8;
  --paper: #ffffff;
  --ink: #141310;
  --ink-2: #605d55;
  --ink-3: #9b988f;
  --rule: #edebe5;
  --rule-2: #dddad2;
  --accent: #ff4d1f;
  --mark: #fff0e9;        /* accent tint — the reading highlight */
  --mark-edge: #ff4d1f;
  --tint: #f5f4f0;
  --grad: linear-gradient(90deg, #ff4d1f, #ffab2e);
  --ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --r: 12px;
  --r-lg: 22px;
  --pill: 999px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --shadow-card: 0 1px 2px rgba(20, 19, 16, 0.04), 0 24px 60px -30px rgba(20, 19, 16, 0.18);
}

* { 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; }

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

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

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;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 60px;
  padding: 0 22px;
  border-bottom: 1px solid var(--rule);
  background: rgba(251, 250, 248, 0.85);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand:hover { opacity: 0.8; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: var(--ink);
  border-radius: 9px;
  flex: none;
}
.brand-mark svg { width: 17px; height: 17px; fill: var(--accent); }
.wordmark { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }

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

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

.hero h1 {
  font-size: clamp(30px, 4.2vw, 44px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  font-weight: 750;
  text-wrap: balance;
}
.hero h1 em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.hero .sub {
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.6;
  max-width: 42ch;
  margin: 14px auto 36px;
  text-wrap: pretty;
}

.dropzone {
  border: 1.5px dashed var(--rule-2);
  border-radius: var(--r-lg);
  background: var(--paper);
  padding: 52px 24px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s var(--ease);
}
.dropzone:hover { border-color: var(--accent); transform: translateY(-1px); }
.dropzone.over {
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 4px var(--mark);
}

.drop-icon {
  width: 56px;
  height: 56px;
  color: var(--accent);
  background: var(--mark);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 16px;
}
.drop-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.drop-sub { color: var(--ink-3); font-size: 13px; margin-top: 3px; }

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

/* ---------- buttons ---------- */
.ghost-btn {
  margin-top: 22px;
  background: var(--paper);
  border: 1px solid var(--rule-2);
  color: var(--ink);
  border-radius: var(--pill);
  padding: 10px 20px;
  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: var(--ink); }
.ghost-btn.small { margin-top: 0; padding: 7px 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: 30px; text-align: left; }
.paste-details summary {
  color: var(--ink-3);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  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: 14px;
  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: 96px 20px; }

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

.loading-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.loading-file {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-top: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.step {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 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: 16px; font-size: 12px; color: var(--ink-3); line-height: 1.55; }

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

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

.auth-h { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }

.auth-sub {
  color: var(--ink-2);
  font-size: 13.5px;
  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);
  border-radius: var(--pill);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--ui);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.auth-google:hover { border-color: var(--ink); background: var(--tint); }
.auth-google:disabled { opacity: 0.55; cursor: wait; }
.auth-google svg { flex-shrink: 0; }

.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 4px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.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);
  padding: 11px 14px;
  font-size: 14px;
  font-family: var(--ui);
}
.auth-input:focus { outline: none; border-color: var(--ink); background: var(--paper); }
.auth-input.bad { border-color: #c2410c; }

.auth-submit {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
  border-radius: var(--r);
  padding: 11px 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 { margin-top: 18px; font-size: 12px; }

/* ---------- reader layout ---------- */
#stage-reader { padding-bottom: 150px; }

.reader-layout {
  max-width: 760px;
  margin: 0 auto;
  padding: 30px 24px 0;
}

.script-pane { min-width: 0; }

.script-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.script-head h2 { font-size: 21px; font-weight: 750; letter-spacing: -0.025em; }
.meta {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-top: 6px;
}

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

.script-view {
  max-width: 660px;
  margin: 0 auto;
  font-family: var(--ui);
  font-size: 15.5px;
  line-height: 1.6;
}

.el {
  margin: 0 0 6px;
  padding: 12px 16px;
  border-radius: 14px;
  transition: background 0.14s;
}
.el.playable { cursor: pointer; }
.el.playable:hover { background: var(--tint); }
.el.current { background: var(--mark); box-shadow: inset 3px 0 0 var(--accent); }

/* Scene headings become quiet section dividers. */
.el.scene {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-top: 36px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.el.scene::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.el.scene:first-child { margin-top: 0; }

.el.transition {
  text-align: right;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.el.action { color: var(--ink-2); font-size: 15px; }

/* Dialogue: a colored speaker label over a clean paragraph. */
.el.block .cue {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--char-color, var(--ink));
  margin: 0 0 4px;
}
.el.block .paren {
  color: var(--ink-3);
  font-style: italic;
  font-size: 13.5px;
  margin: 2px 0;
  max-width: none;
}
.el.block .dia { margin: 0; max-width: 58ch; color: var(--ink); }

/* ---------- the table: pinned cast strip ---------- */
.cast-bar {
  position: sticky;
  top: 60px; /* directly under the top bar */
  z-index: 18;
  background: rgba(251, 250, 248, 0.9);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.cast-bar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.cast-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px;
}

/* Lines up with the first row of avatars however many rows there end up being. */
.cast-bar-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; padding-top: 15px; }

/* One avatar card. --av is the dial that keeps a big cast on screen. */
.avatar-card {
  --av: 44px;
  width: calc(var(--av) + 24px);
  padding: 5px 2px 6px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-family: var(--ui);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: background 0.14s;
}
.cast-strip.dense .avatar-card { --av: 36px; }
.cast-strip.denser .avatar-card { --av: 30px; }

.avatar-card:hover, .avatar-card.open { background: var(--tint); }

.avatar {
  width: var(--av);
  height: var(--av);
  border-radius: 50%;
  border: 0;
  background: color-mix(in srgb, var(--char-color) 13%, #fff);
  color: var(--char-color);
  display: grid;
  place-items: center;
  font-family: var(--ui);
  font-weight: 700;
  font-size: calc(var(--av) * 0.32);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  transition: background 0.16s, color 0.16s, box-shadow 0.16s, transform 0.16s;
}
.avatar svg { width: 45%; height: 45%; }

.avatar-name {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.16s;
}
.cast-strip.denser .avatar-name { font-size: 8.5px; }

/* Speaking now: the character lights up as their line plays. */
.avatar-card.speaking .avatar {
  background: var(--char-color);
  color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--char-color) 20%, transparent);
  transform: translateY(-1px);
}
.avatar-card.speaking .avatar-name { color: var(--char-color); }

/* A hand-edited character keeps a mark, so Recast's scope is legible. */
.avatar-card.edited .avatar::after {
  content: "";
  position: absolute;
  transform: translate(calc(var(--av) * 0.36), calc(var(--av) * -0.36));
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--char-color);
  border: 2px solid #fff;
}
.avatar-card.edited .avatar { position: relative; }

.sugg-chip {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  border: 1px solid var(--rule-2);
  border-radius: var(--pill);
  padding: 2px 8px;
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1.4;
}

/* ---------- voice popover ---------- */
.voice-pop {
  position: fixed;
  z-index: 60;
  width: 324px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 18px;
  box-shadow: 0 2px 6px rgba(20, 19, 16, 0.05), 0 24px 56px -16px rgba(20, 19, 16, 0.25);
}
.voice-pop[hidden] { display: none; }

.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='%239b988f' 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);
  border-radius: 10px;
  padding: 9px 30px 9px 12px;
  font-size: 12.5px;
  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: 11px; line-height: 1.45; min-height: 15px; }

.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);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--ui);
  padding: 8px 10px;
  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);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  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); }

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

.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: 14px; height: 14px; 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 { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 11px; width: 42px; text-align: right; }

/* ---------- transport: a floating player ---------- */
.transport {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 20px));
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--rule);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 10px rgba(20, 19, 16, 0.05), 0 28px 60px -24px rgba(20, 19, 16, 0.35);
  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: 34px;
  height: 34px;
  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 {
  width: 44px;
  height: 44px;
  margin: 0 6px;
  background: var(--ink);
  color: #fff;
}
.t-buttons .play:hover { background: #000; color: #fff; }
.t-buttons .play.is-playing { background: var(--accent); }
.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; }

.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(--grad); 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(--pill);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 40;
  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 ---------- */
@media (max-width: 940px) {
  .reader-layout { padding-top: 22px; }
  .cast-bar-inner { padding: 10px 16px; gap: 12px; }
  .transport-inner { flex-direction: column; gap: 10px; align-items: stretch; }
  .t-buttons { justify-content: center; }
  #stage-reader { padding-bottom: 190px; }
}

@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 0 16px; }
  .nav-speed { display: none; } /* speed also lives on each character's Pace */
  .cast-bar-inner { flex-direction: column; align-items: stretch; gap: 8px; }
  .cast-bar-actions { justify-content: flex-end; padding-top: 0; }
  .voice-pop { width: min(324px, calc(100vw - 20px)); }
}

@media (max-width: 700px) {
  #stage-upload { padding-top: 44px; }
  .script-view { font-size: 14.5px; }
  .el { padding: 10px 12px; }
}

/* ---------- account pill + billing ---------- */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar-right .nav-tools { margin-left: 0; }
.account-slot { display: flex; align-items: center; gap: 9px; }

.solid-btn {
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  border-radius: var(--pill); padding: 10px 20px; 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 { padding: 7px 14px; font-size: 12.5px; }

.acct-link { font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; text-decoration: none; }
.acct-link:hover { color: var(--ink); }

.acct-pill {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px 6px 13px; border: 1px solid var(--rule-2);
  border-radius: var(--pill); background: var(--paper); white-space: nowrap;
}
.acct-plan { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.acct-meter { width: 44px; height: 5px; background: var(--tint); border-radius: 3px; overflow: hidden; }
.acct-meter i { display: block; height: 100%; background: var(--grad); border-radius: 3px; transition: width 0.3s; }
.acct-left { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding-right: 4px; }
.acct-pill.low { border-color: #f0b28c; background: #fdf3ec; }
.acct-pill.low .acct-meter i { background: #c2410c; }
.acct-pill.low .acct-left { color: #b4531a; }

/* 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: 24px;
  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: 14px; right: 16px; width: 32px; height: 32px; border: 0;
  background: none; font-size: 24px; line-height: 1; color: var(--ink-3); cursor: pointer; border-radius: 50%;
}
.bill-x:hover { color: var(--ink); background: var(--tint); }
.bill-head { text-align: center; max-width: 460px; margin: 0 auto 22px; }
.bill-kicker { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin-bottom: 10px; }
.bill-head h3 { font-size: 23px; font-weight: 750; letter-spacing: -0.025em; }
.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(--pill); }
.bt-opt { font-family: var(--ui); font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 8px 15px; border: 0; background: transparent; border-radius: var(--pill); 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: #ffb59d; }
.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: 18px; 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 11px; border-radius: var(--pill); 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; }
}
