/* ============ Prompta — styles ============
   App chrome is always dark ("studio booth" feel).
   Prompter themes are [data-ptheme] overrides scoped to the overlay. */

@font-face {
  font-family: 'Orbitron';
  src: url('fonts/Orbitron-Variable.ttf') format('truetype-variations');
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  /* condensed editorial sans for The Newsroom theme — self-hosted, see fonts/Oswald-OFL.txt */
  font-family: 'Oswald';
  src: url('fonts/Oswald-Variable.woff2') format('woff2-variations');
  font-weight: 200 700;
  font-display: swap;
}

:root {
  --bg: #0E0E13;
  --bg-raised: #17171F;
  --line: #26262F;
  --text: #F0EFF4;
  --text-dim: #9C9AA8;
  --accent: #7C5CFF;
  --accent-soft: #2A2140;
  --danger: #FF5C7A;

  /* prompter theme tokens (studio defaults) */
  --p-bg: #0B0B0F;
  --p-text: #F2F1F6;
  --p-read: #56546A;
  --p-guide: #7C5CFF;
  --p-font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --p-weight: 600;
  --p-tracking: normal;
  --p-glow: none;
  --p-live-bg: rgba(124, 92, 255, .18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg); /* the true bottom-most paint layer, below z-index:-1 content */
}
body {
  margin: 0;
  background: transparent; /* body's own background box would otherwise sit
    above negative-z-index children in normal stacking order, hiding them */
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100dvh; }

/* fixed background layer for the library view — z-index:-1 keeps it behind
   normal in-flow content (topbar, main) without needing z-index on those.
   Explicit top/left/width/height (not just `inset:0`) so its display box is
   hard-clamped to the screen on mobile — see the sign-in background's fix. */
.lib-rings-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; }

/* ---------- top bar ----------
   Three columns so the display name sits dead-center regardless of how
   wide the brand or the right-hand actions are: brand | name | actions. */
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 14px clamp(16px, 4vw, 32px);
  border-bottom: 1px solid var(--line);
}
.brand { justify-self: start; display: flex; align-items: center; gap: 10px; }
.topbar-center { justify-self: center; position: relative; }
.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  animation: brand-pulse 5.5s ease-in-out infinite;
}
@keyframes brand-pulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(124,92,255,0)); }
  50% { filter: drop-shadow(0 0 6px rgba(124,92,255,.55)); }
}
.brand-name { font-size: 1.15rem; font-weight: 700; letter-spacing: .01em; }

/* centered display-name button + its dropdown menu */
.account-btn {
  max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* .btn-ghost (same specificity, declared later) otherwise wins the cascade
   and leaves this transparent — double the class so it always wins */
.account-btn.btn-ghost { border-color: var(--line); background: var(--bg-raised); }
.account-btn.btn-ghost:hover { border-color: var(--accent); }
.account-menu {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  z-index: 40; min-width: 210px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 2px;
}
.account-menu-email {
  margin: 4px 8px 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  font-size: .78rem; color: var(--text-dim); word-break: break-all;
}
.account-menu-item {
  font: inherit; font-size: .9rem; text-align: left; cursor: pointer;
  background: transparent; border: none; color: var(--text);
  padding: 9px 10px; border-radius: 8px;
}
.account-menu-item:hover { background: var(--accent-soft); }
.account-menu-danger { color: var(--danger); }

/* display-name modal */
.namemodal {
  position: fixed; inset: 0; z-index: 75; overflow-y: auto;
  display: grid; place-items: center; padding: 24px;
}
.namemodal-backdrop { position: fixed; inset: 0; background: rgba(7,7,10,.86); backdrop-filter: blur(3px); }
.namemodal-card {
  position: relative; z-index: 1; width: 100%; max-width: 360px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 20px;
  padding: 30px 26px 24px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.namemodal-card h2 { margin: 0 0 10px; font-size: 1.25rem; }
.namemodal-sub { margin: 0 0 22px; color: var(--text-dim); font-size: .86rem; line-height: 1.55; }
.namemodal-input {
  width: 100%; font: inherit; font-size: 1.05rem; text-align: center;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 20px;
}
.namemodal-input:focus { outline: none; border-color: var(--accent); }
.namemodal-actions { display: flex; gap: 10px; justify-content: center; }
.namemodal-actions .btn { flex: 1; }

/* portrait phones: the three columns can't sit side-by-side comfortably,
   so stack the right-hand actions and tighten spacing. Landscape phones
   are wide enough to keep the roomy desktop layout. */
@media (max-width: 600px) {
  .topbar { gap: 6px; padding: 12px 14px; }
  .topbar-actions { flex-direction: column; align-items: flex-end; gap: 5px; }
  .topbar-actions .btn { padding: 6px 10px; font-size: .82rem; }
  .account-btn { max-width: 36vw; }
  .brand-name { font-size: 1rem; }
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--bg-raised); color: var(--text);
  padding: 10px 16px; border-radius: 10px;
  transition: background .15s ease, border-color .15s ease;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: transparent; }

/* ---------- views ---------- */
.view { padding: clamp(16px, 4vw, 32px); max-width: 900px; margin: 0 auto; }
.view-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.view-head h1 { font-size: 1.5rem; margin: 0; }
.view-head-actions { display: flex; align-items: center; gap: 8px; }

/* library — scripts lead the page; the theme picker sits below as a compact
   horizontal strip (swipe/scroll sideways) so it never buries the scripts. */
.lib-theme-row { margin: 34px 0 0; padding-top: 26px; border-top: 1px solid var(--line); }
.lib-theme-label { display: block; color: var(--text-dim); font-size: .8rem; margin: 0 0 12px 2px; }
.lib-theme-grid {
  display: flex; gap: 12px; overflow-x: auto;
  padding: 10px 2px 12px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.lib-theme-grid::-webkit-scrollbar { height: 6px; }
.lib-theme-grid::-webkit-scrollbar-track { background: transparent; }
.lib-theme-grid::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.lib-theme-grid::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.lib-theme-tile {
  position: relative; flex: 0 0 auto; width: 132px; aspect-ratio: 1 / 1; padding: 0;
  scroll-snap-align: start;
  border-radius: 14px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line);
  background-size: cover; background-position: center;
  transform: translateY(0) scale(1);
  transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease, border-color .22s ease;
}
.lib-theme-tile::before {
  /* scrim so the label stays legible over any photo or gradient */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 38%, rgba(0,0,0,.8) 100%);
}
.lib-theme-tile:hover { transform: translateY(-4px) scale(1.045); box-shadow: 0 12px 30px rgba(0,0,0,.5); border-color: var(--accent); }
.lib-theme-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lib-theme-tile.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 10px 28px rgba(124,92,255,.4); }
.lib-theme-tile.ltt-tapped { animation: lttPop .32s cubic-bezier(.34,1.56,.64,1); }
@keyframes lttPop {
  0%   { transform: scale(1) translateY(0); }
  55%  { transform: scale(1.1) translateY(-4px); }
  100% { transform: scale(1) translateY(0); }
}
.ltt-label {
  position: absolute; left: 9px; bottom: 7px; z-index: 1;
  font-size: .78rem; font-weight: 700; color: #fff; letter-spacing: .01em;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
.ltt-check {
  position: absolute; top: 6px; right: 6px; z-index: 1;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .62rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(.5);
  transition: opacity .18s ease, transform .18s ease;
}
.lib-theme-tile.active .ltt-check { opacity: 1; transform: scale(1); }

/* Grand per-theme art. First layer is a real photo John drops at that exact
   path (images/themes/<name>.jpg) — until it exists the layer just fails to
   paint and the gradient beneath shows instead, so no code changes needed
   later to "go live" with real artwork. */
.lib-theme-tile[data-lib-theme-pick="studio"] {
  background-image: url('images/themes/studio.webp'),
    radial-gradient(circle at 50% 22%, #A78BFA 0%, #4C2889 42%, #0B0B0F 100%);
}
.lib-theme-tile[data-lib-theme-pick="broadcast"] {
  background-image: url('images/themes/broadcast.webp'),
    radial-gradient(circle at 62% 18%, #7FD8FF 0%, #0b3f66 40%, #04101c 100%);
}
.lib-theme-tile[data-lib-theme-pick="matrix"] {
  background-image: url('images/themes/matrix.webp'),
    radial-gradient(circle at 50% 12%, #22FF66 0%, #063313 36%, #000 100%);
}
.lib-theme-tile[data-lib-theme-pick="noir"] {
  background-image: url('images/themes/noir.webp'),
    radial-gradient(circle at 50% 18%, #E8C97A 0%, #3a2c12 36%, #0A0908 100%);
}
.lib-theme-tile[data-lib-theme-pick="synthwave"] {
  background-image: url('images/themes/synthwave.webp'),
    linear-gradient(160deg, #FF7EDB 0%, #34005B 45%, #170032 100%);
}
.lib-theme-tile[data-lib-theme-pick="contrast"] {
  background-image: url('images/themes/contrast.webp'),
    radial-gradient(circle at 50% 28%, #FFE600 0%, #3a3300 40%, #000 100%);
}
.lib-theme-tile[data-lib-theme-pick="cosmo"] {
  background-image: url('images/themes/cosmo.webp'),
    radial-gradient(circle at 50% 20%, #8A79FF 0%, #1a1442 44%, #050511 100%);
}
.lib-theme-tile[data-lib-theme-pick="spotlight"] {
  background-image: url('images/themes/spotlight.webp'),
    radial-gradient(circle at 50% 24%, #A9283D 0%, #2a0d13 44%, #090807 100%);
}
.lib-theme-tile[data-lib-theme-pick="sunlit"] {
  background-image: url('images/themes/sunlit.webp'),
    radial-gradient(circle at 50% 26%, #F0D9B8 0%, #C75D42 55%, #8a3d29 100%);
}
.lib-theme-tile[data-lib-theme-pick="arcade"] {
  background-image: url('images/themes/arcade.webp'),
    radial-gradient(circle at 50% 18%, #38E8FF 0%, #241a5e 44%, #08070D 100%);
}

.script-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.script-card {
  text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s ease, transform .15s ease, box-shadow .2s ease;
}
.script-card:hover {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124,92,255,.25);
}
.script-card h3 { margin: 0; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-card p { margin: 0; color: var(--text-dim); font-size: .85rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.script-card .card-meta { color: var(--text-dim); font-size: .75rem; margin-top: auto; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card-actions .btn { padding: 6px 10px; font-size: .8rem; }
.empty-note { color: var(--text-dim); text-align: center; margin-top: 48px; }

/* small themed waveform accent at the top of each script card — the four
   bars echo the Prompta brand mark, tinted with the card's own theme accent
   (via the data-ptheme attribute renderLibrary sets on every card). */
.card-banner { display: flex; align-items: flex-end; gap: 4px; height: 20px; margin-bottom: 2px; }
.card-banner .cb-el { width: 5px; border-radius: 3px; background: var(--card-accent, var(--accent)); opacity: .9; }
.card-banner .cb-el:nth-child(1) { height: 40%; }
.card-banner .cb-el:nth-child(2) { height: 72%; }
.card-banner .cb-el:nth-child(3) { height: 100%; }
.card-banner .cb-el:nth-child(4) { height: 58%; }
.script-card[data-ptheme="studio"]    { --card-accent: #7C5CFF; }
.script-card[data-ptheme="broadcast"] { --card-accent: #A6192E; }
.script-card[data-ptheme="matrix"]    { --card-accent: #22FF66; }
.script-card[data-ptheme="noir"]      { --card-accent: #C9A24B; }
.script-card[data-ptheme="synthwave"] { --card-accent: #FF7EDB; }
.script-card[data-ptheme="contrast"]  { --card-accent: #FFE600; }
.script-card[data-ptheme="cosmo"]     { --card-accent: #8A79FF; }
.script-card[data-ptheme="spotlight"] { --card-accent: #A9283D; }
.script-card[data-ptheme="sunlit"]    { --card-accent: #C75D42; }
.script-card[data-ptheme="arcade"]    { --card-accent: #38E8FF; }

/* library footer — legal + support links (also required to be reachable by
   Stripe and the app stores). */
.lib-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--line);
  color: var(--text-dim); font-size: .8rem;
}
.lib-footer nav { display: flex; gap: 18px; }
.lib-footer a { color: var(--text-dim); text-decoration: none; }
.lib-footer a:hover { color: var(--text); }

/* editor */
.editor-title {
  width: 100%; font: inherit; font-size: 1.3rem; font-weight: 700;
  background: transparent; border: none; border-bottom: 1px solid var(--line);
  color: var(--text); padding: 10px 2px; margin-bottom: 14px;
}
.editor-title:focus { outline: none; border-bottom-color: var(--accent); }
.editor-body {
  width: 100%; min-height: 50dvh; resize: vertical;
  font: inherit; font-size: 1.05rem; line-height: 1.7;
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.editor-body:focus { outline: none; border-color: var(--accent); }
.editor-meta { color: var(--text-dim); font-size: .85rem; }

/* help */
.help-copy { line-height: 1.7; color: var(--text); max-width: 65ch; }
.help-copy h2 { font-size: 1.05rem; margin: 24px 0 6px; color: var(--accent); }
.help-copy p { margin: 0 0 10px; color: var(--text-dim); }
.help-copy strong { color: var(--text); }

/* ---------- prompter overlay ---------- */
.prompter {
  position: fixed; inset: 0; z-index: 50;
  background: var(--p-bg); color: var(--p-text);
  display: flex; flex-direction: column;
  font-family: var(--p-font);
}

.matrix-rain { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.prompter[data-ptheme="matrix"] .matrix-rain { opacity: .28; }

/* full-bleed photographed set — off by default; a [data-ptheme] block above
   turns it on and points it at that theme's scene image */
.prompter-bg-photo {
  position: absolute; inset: 0; z-index: 0; opacity: 0; pointer-events: none;
  background-size: cover; background-position: center 38%;
}
/* soft charcoal vignette, feathered so the set stays visible at the edges —
   sits behind the text (negative z-index inside .prompter-scroll's own
   stacking context) but above the photo, per John's "don't cover the
   newsroom with an obvious panel" note */
.prompter[data-ptheme="broadcast"] .prompter-scroll::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 70% 55% at 50% 45%,
    rgba(10, 9, 8, .55) 0%, rgba(10, 9, 8, .3) 55%, rgba(10, 9, 8, 0) 78%);
}

.prompter-top {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
}
.prompter-top .btn-ghost { color: var(--p-text); opacity: .6; }
.prompter-top .btn-ghost:hover { opacity: 1; }
.prompter-progress { flex: 1; height: 4px; border-radius: 2px; background: rgba(128,128,128,.25); overflow: hidden; }
.prompter-progress-fill { height: 100%; width: 0%; background: var(--p-guide); transition: width .3s linear; }
.prompter-clock { font-variant-numeric: tabular-nums; opacity: .7; font-size: .9rem; }

.prompter-scroll {
  position: relative; z-index: 2; flex: 1;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none;
}
.prompter-scroll::-webkit-scrollbar { display: none; }

.prompter-text {
  padding: 45dvh clamp(16px, var(--p-margin, 6vw), 20vw) 60dvh;
  font-size: var(--p-fontsize, 42px);
  font-weight: var(--p-weight);
  letter-spacing: var(--p-tracking);
  line-height: 1.55;
  text-shadow: var(--p-glow);
}
.prompter-text p { margin: 0 0 1.2em; }

/* custom cursor over tappable words — real pointer devices only (web); on
   touch, browsers ignore `cursor` entirely, so no separate gate is needed
   there, but this keeps intent explicit and skips hybrid touch+mouse rigs. */
@media (hover: hover) and (pointer: fine) {
  .prompter[data-mode="voice"] .prompter-text .w {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 64 64'%3E%3Cg fill='%237C5CFF'%3E%3Crect x='14' y='30' width='5' height='10' rx='2.5'/%3E%3Crect x='22' y='22' width='5' height='26' rx='2.5'/%3E%3Crect x='30' y='14' width='5' height='42' rx='2.5'/%3E%3Crect x='38' y='24' width='5' height='22' rx='2.5'/%3E%3C/g%3E%3Cpath d='M43 14a12 12 0 0 1 0 24' stroke='%237C5CFF' stroke-width='5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") 4 4, pointer;
  }
}

/* tap-to-jump feedback flash — color follows the active reading theme via
   --p-guide, so it always reads correctly against that theme's palette    */
@keyframes word-tap-pulse {
  0%   { text-shadow: 0 0 0 transparent; transform: scale(1); }
  35%  { text-shadow: 0 0 14px var(--p-guide); transform: scale(1.08); }
  100% { text-shadow: 0 0 0 transparent; transform: scale(1); }
}
.w-tapped { display: inline-block; color: var(--p-guide); animation: word-tap-pulse .45s ease-out; }

/* sentence spotlight — three layers of focus, voice mode only:
   past = read and released · live = being spoken · rest = readable ahead */
.prompter-text .s {
  border-radius: .25em;
  padding: .04em .12em;
  margin: 0 -.12em;
  transition: opacity .18s ease-out, background-color .18s ease-out, color .18s ease-out;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.prompter[data-mode="voice"] .prompter-text .s { opacity: .78; }
.prompter[data-mode="voice"] .prompter-text .s.past { opacity: .32; }
.prompter[data-mode="voice"] .prompter-text .s.live {
  opacity: 1;
  background-color: var(--p-live-bg);
  color: var(--p-live-fg, inherit);
  text-shadow: var(--p-live-glow, var(--p-glow));
}
.prompter.mirrored .prompter-scroll { transform: scaleX(-1); }

.guide-line {
  position: absolute; z-index: 1; left: 0; right: 0; top: 38dvh; height: 0;
  border-top: 2px solid var(--p-guide); opacity: .28; pointer-events: none;
}

.prompter-countdown {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: var(--p-bg);
}

/* fires once, right as the countdown ends — a visible marker for syncing
   camera footage in post, same moment the "Sync flash" audio tone plays  */
.clap-flash {
  position: absolute; inset: 0; z-index: 8;
  background: #fff; opacity: 0; pointer-events: none;
}
.clap-flash.flash { animation: clapFlash .28s ease-out; }
@keyframes clapFlash {
  0% { opacity: .95; }
  100% { opacity: 0; }
}
.prompter-countdown span { font-size: 20vmin; font-weight: 800; color: var(--p-guide); }

.prompter-paused, .voice-status {
  position: absolute; z-index: 4; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.65); color: #fff; backdrop-filter: blur(6px);
  padding: 8px 18px; border-radius: 999px; font-size: .9rem; white-space: nowrap;
}
.prompter-paused { top: 16dvh; }
.voice-status { bottom: 110px; }

.prompter-bottom {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 10px 14px max(14px, env(safe-area-inset-bottom));
  flex-wrap: wrap;
}
.mode-seg { display: flex; border: 1px solid rgba(128,128,128,.35); border-radius: 999px; overflow: hidden; }
.seg {
  font: inherit; font-size: .85rem; cursor: pointer;
  background: transparent; color: var(--p-text); opacity: .55;
  border: none; padding: 8px 16px;
}
.seg.active { opacity: 1; background: var(--p-guide); color: var(--p-bg); font-weight: 700; }
.btn-play {
  font: inherit; font-size: 1.3rem; cursor: pointer;
  width: 58px; height: 58px; border-radius: 50%;
  border: none; background: var(--p-guide); color: var(--p-bg);
  display: flex; align-items: center; justify-content: center;
}
.speed-ctl { display: flex; align-items: center; gap: 4px; }
.speed-ctl .btn { color: var(--p-text); font-size: 1.1rem; padding: 8px 12px; }
.speed-val { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; opacity: .8; }
.prompter-bottom .btn-ghost { color: var(--p-text); font-size: 1.2rem; }

/* controls fade while playing */
.prompter.playing .prompter-top,
.prompter.playing .prompter-bottom { opacity: 0; pointer-events: none; transition: opacity .4s ease .8s; }
.prompter .prompter-top, .prompter .prompter-bottom { transition: opacity .25s ease; }

/* ---------- settings sheet ---------- */
.sheet {
  position: absolute; inset: 0; z-index: 7;
  background: rgba(0,0,0,.5); display: flex; align-items: flex-end;
}
.sheet-inner {
  width: 100%; max-height: 75dvh; overflow-y: auto;
  background: var(--bg-raised); color: var(--text);
  border-radius: 20px 20px 0 0; padding: 18px 20px max(20px, env(safe-area-inset-bottom));
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2, .sheet-subhead { font-size: 1rem; margin: 0; }
.sheet-subhead { margin: 20px 0 10px; }
.sheet-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.sheet-row span small { color: var(--text-dim); }
.sheet-row input[type="range"] { flex: 1; max-width: 55%; accent-color: var(--accent); }
.sheet-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }

/* library-page display settings (gear icon) — same bottom-sheet recipe as
   .sheet above (reuses .sheet-inner/.sheet-head/.sheet-row as-is), but
   position:fixed instead of absolute since there's no .prompter-equivalent
   positioned wrapper around it on the library page.                      */
.lib-sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.5); display: flex; align-items: flex-end;
}

/* voice language picker — editor pills + in-prompter settings chips */
.editor-lang { margin: 2px 0 14px; }
.editor-lang-label { display: block; font-size: .8rem; color: var(--text-dim); margin-bottom: 8px; }
.lang-pills { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.lang-pill {
  font: inherit; font-size: .85rem; cursor: pointer; color: var(--text);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px;
}
.lang-pill.active { border-color: var(--accent); background: var(--accent-soft); }
.editor-lang-help, .sheet-lang-help {
  display: block; margin-top: 8px; color: var(--text-dim); min-height: 1em; font-size: .8rem;
}
.lang-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lang-chip {
  font: inherit; font-size: .85rem; cursor: pointer; color: var(--text);
  background: transparent; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 8px; text-align: center;
}
.lang-chip.active { border-color: var(--accent); background: var(--accent-soft); }

.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-chip {
  font: inherit; font-size: .8rem; cursor: pointer; color: var(--text);
  background: transparent; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.theme-chip.active { border-color: var(--accent); background: var(--accent-soft); }
.chip-preview {
  width: 100%; border-radius: 8px; padding: 10px 0; text-align: center;
  font-size: 1.1rem; font-weight: 700;
}
.chip-studio    { background: #0B0B0F; color: #F2F1F6; }
.chip-broadcast { background: #14100D; color: #D8DDE3; font-family: 'Oswald', sans-serif; font-weight: 700; letter-spacing: .01em; }
.chip-matrix    { background: #000; color: #22FF66; font-family: "Courier New", monospace; }
.chip-noir      { background: #0A0908; color: #F4E9D4; font-family: Georgia, serif; }
.chip-synthwave { background: linear-gradient(160deg, #170032, #34005B); color: #FFB3EC; }
.chip-contrast  { background: #000; color: #FFE600; }
.chip-cosmo     { background: radial-gradient(circle at 50% 25%, #211a52, #050511 75%); color: #CFC7FF; }
.chip-spotlight { background: linear-gradient(160deg, #2a0d13, #090807); color: #FFF0D2; }
.chip-sunlit    { background: #F5F0E6; color: #C75D42; }
.chip-arcade    { background: #08070D; color: #38E8FF; font-family: ui-monospace, "Consolas", monospace; }

/* ---------- prompter themes ---------- */
/* The Newsroom — heroic early-2000s newsroom: mature crimson/royal-blue/silver,
   never neon. Regular text is metallic silver with a faint warm-white shimmer;
   the active sentence turns crimson with a royal-blue depth shadow and a thin
   silver edge/glow so it stays legible over the photographed newsroom set. */
.prompter[data-ptheme="broadcast"] {
  --p-bg: #14100D; --p-text: #D8DDE3; --p-read: #6B6F76; --p-guide: #A6192E;
  --p-font: 'Oswald', 'Arial Narrow', 'Helvetica Neue Condensed', sans-serif;
  --p-weight: 700; --p-tracking: .01em;
  /* dark halo layered under the original faint warm shimmer — the ahead/past
     sentences have no background chip (only .live does), so over the photo
     they leaned entirely on the center-weighted vignette for contrast and
     went unreadable near the edges/margins where the vignette fades out */
  --p-glow: 0 1px 3px rgba(0, 0, 0, .7), 0 0 6px rgba(0, 0, 0, .4), 0 0 1px rgba(255, 250, 240, .4);
  --p-live-bg: rgba(166, 25, 46, .16);
  --p-live-fg: #A6192E;
  --p-live-edge: #C7CDD4;
  --p-live-glow:
    1px 2px 2px rgba(23, 52, 95, .8),
    0 0 8px rgba(199, 205, 212, .45);
}
/* thin metallic-silver stroke, crisper than a stacked text-shadow outline
   (which read as a muddy blur at this font size) */
.prompter[data-ptheme="broadcast"] .prompter-text .s.live {
  -webkit-text-stroke: .6px var(--p-live-edge);
}
.prompter[data-ptheme="broadcast"] .prompter-bg-photo {
  opacity: 1;
  background-image: url('images/themes/broadcast-scene.webp');
}
.prompter[data-ptheme="matrix"] {
  --p-bg: #000; --p-text: #22FF66; --p-read: #0C5A26; --p-guide: #A8FFC4;
  --p-font: "Courier New", ui-monospace, monospace; --p-weight: 700;
  --p-glow: 0 0 12px rgba(34,255,102,.45);
  --p-live-bg: rgba(34, 255, 102, .12);
  --p-live-glow: 0 0 18px rgba(34, 255, 102, .65);
}
.prompter[data-ptheme="noir"] {
  --p-bg: #0A0908; --p-text: #F4E9D4; --p-read: #6B6152; --p-guide: #C9A24B;
  --p-font: Georgia, "Times New Roman", serif; --p-weight: 500;
  --p-live-bg: rgba(201, 162, 75, .15);
}
.prompter[data-ptheme="synthwave"] {
  --p-bg: #170032; --p-text: #FFD9F5; --p-read: #6B3E7E; --p-guide: #FF7EDB;
  --p-weight: 700; --p-glow: 0 0 14px rgba(255,126,219,.5);
  --p-live-bg: rgba(255, 126, 219, .16);
  --p-live-glow: 0 0 18px rgba(255, 126, 219, .65);
}
.prompter[data-ptheme="contrast"] {
  --p-bg: #000; --p-text: #FFE600; --p-read: #5C5300; --p-guide: #FFF;
  --p-weight: 800;
  --p-live-bg: #FFE600;
  --p-live-fg: #000;
  --p-live-glow: none;
}

/* Cosmo — presenting from the edge of the universe: starlight text on deep
   space black, cosmic-violet accent, a controlled violet halo on the live
   sentence. Nebulae are pushed to the corners so the reading center stays
   dark and quiet. */
.prompter[data-ptheme="cosmo"] {
  --p-bg: #050511; --p-text: #F0EEFF; --p-read: #4A4770; --p-guide: #8A79FF;
  --p-weight: 600;
  --p-glow: none;
  --p-live-bg: rgba(138, 121, 255, .14);
  --p-live-glow: 0 0 16px rgba(138, 121, 255, .5);
}
.prompter[data-ptheme="cosmo"]::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1.5px 1.5px at 12% 16%, rgba(240,238,255,.9) 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 82% 11%, rgba(240,238,255,.75) 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 68% 28%, rgba(200,196,255,.7) 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 24% 74%, rgba(240,238,255,.8) 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 91% 66%, rgba(210,205,255,.7) 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 44% 88%, rgba(240,238,255,.65) 0, transparent 60%),
    radial-gradient(1px 1px at 55% 40%, rgba(240,238,255,.55) 0, transparent 60%),
    radial-gradient(1px 1px at 8% 46%, rgba(220,216,255,.6) 0, transparent 60%),
    radial-gradient(60% 48% at 10% 4%, rgba(96, 74, 190, .34) 0, transparent 62%),
    radial-gradient(58% 46% at 92% 96%, rgba(58, 40, 150, .3) 0, transparent 62%);
}

/* Spotlight — a single warm stage light. Deep theater black, stage-ivory
   text, burgundy focus band; progress + countdown carry an amber footlight
   tint, and a soft warm pool sits at the reading anchor. No neon, no glow. */
.prompter[data-ptheme="spotlight"] {
  --p-bg: #090807; --p-text: #FFF0D2; --p-read: #6A5F52; --p-guide: #A9283D;
  --p-weight: 700;
  --p-glow: none;
  --p-live-bg: rgba(169, 40, 61, .26);
  --p-live-glow: none;
}
.prompter[data-ptheme="spotlight"]::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(72% 44% at 50% 42%,
    rgba(227, 168, 87, .13) 0%, rgba(169, 40, 61, .05) 46%, transparent 72%);
}
.prompter[data-ptheme="spotlight"] .prompter-progress-fill { background: #E3A857; }
.prompter[data-ptheme="spotlight"] .prompter-countdown span { color: #E3A857; }

/* Sunlit Paper — the calm daytime option. Paper-ivory page, charcoal text,
   muted-terracotta accent, a soft terracotta band on the live sentence.
   A whisper of paper grain textures the page; the reading area stays clean. */
.prompter[data-ptheme="sunlit"] {
  --p-bg: #F5F0E6; --p-text: #191816; --p-read: #7A7264; --p-guide: #C75D42;
  --p-weight: 600;
  --p-glow: none;
  --p-live-bg: rgba(199, 93, 66, .18);
  --p-live-fg: #191816;
  --p-live-glow: none;
}
.prompter[data-ptheme="sunlit"]::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  opacity: .5; mix-blend-mode: multiply;
  background:
    radial-gradient(125% 95% at 50% 38%, transparent 56%, rgba(120, 92, 60, .07) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  background-size: cover, 120px 120px;
}

/* Arcade — every script is the next mission. Arcade black, lavender-white
   monospace, electric-cyan accent. The live sentence sits in a crisp cyan
   selection box over dark-indigo shading; the progress bar reads as a
   segmented game-status meter. Subtle scanlines + restrained purple/magenta
   corner glow decorate the frame, but the script itself stays smooth. */
.prompter[data-ptheme="arcade"] {
  --p-bg: #08070D; --p-text: #F5E9FF; --p-read: #4B4470; --p-guide: #38E8FF;
  --p-font: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
  --p-weight: 700;
  /* same photo-legibility fix as The Newsroom — ahead/past text had no
     shadow at all here and could sit directly on the pixel-art photo */
  --p-glow: 0 1px 3px rgba(0, 0, 0, .75), 0 0 8px rgba(0, 0, 0, .5);
  --p-live-bg: rgba(23, 20, 58, .92);
  --p-live-fg: #F5E9FF;
  --p-live-glow: none;
}
.prompter[data-ptheme="arcade"] .prompter-bg-photo {
  opacity: 1;
  background-image: url('images/themes/arcade-scene.webp');
}
/* scanlines + a center-weighted vignette so the busy cabinet-screen colors
   in the photo don't fight the script text — same layering trick as The
   Newsroom's scrim: sits inside .prompter-scroll's stacking context
   (z-index 2) at local z-index -1, so it paints above the bg photo
   (z-index 0 on .prompter) but below .prompter-text. */
.prompter[data-ptheme="arcade"] .prompter-scroll::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse 68% 58% at 50% 46%,
      rgba(8, 7, 13, .64) 0%, rgba(8, 7, 13, .4) 55%, rgba(8, 7, 13, .1) 80%);
}
.prompter[data-ptheme="arcade"] .prompter-text .s.live {
  box-shadow: 0 0 0 2px #38E8FF, 0 0 16px rgba(56, 232, 255, .45);
}
.prompter[data-ptheme="arcade"] .prompter-progress { background: rgba(56, 232, 255, .12); }
.prompter[data-ptheme="arcade"] .prompter-progress-fill {
  background: repeating-linear-gradient(90deg, #38E8FF 0 12px, rgba(8,7,13,.85) 12px 15px);
  box-shadow: 0 0 8px rgba(56, 232, 255, .55);
}

/* ---------- sign-in overlay ---------- */
.auth {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: #07070a;
}
/* explicit top/left + width/height (not just the `inset` shorthand) so the
   canvas's DISPLAY box is clamped to the screen on every mobile browser —
   otherwise the canvas can render at its drawing-buffer size and overflow,
   pushing the animation off-center. Identical to `inset:0` on desktop. */
.auth-scroll-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; }
.auth-vignette {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center,
    rgba(7,7,10,.95) 0%, rgba(7,7,10,.8) 38%, rgba(7,7,10,.35) 70%, rgba(7,7,10,0) 100%);
}
.auth-grain {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.auth-close {
  position: absolute; z-index: 3; top: max(16px, env(safe-area-inset-top)); right: 16px;
  font: inherit; font-size: 1.1rem; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
}
.auth-close:hover { color: var(--text); border-color: var(--accent); }

.auth-skip {
  position: absolute; z-index: 3; bottom: max(28px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  font: inherit; font-size: .82rem; cursor: pointer;
  background: none; border: none; color: var(--text-dim);
  letter-spacing: .02em; padding: 8px;
}
.auth-skip:hover { color: var(--text); }

.auth[data-auth-mode="modal"] .auth-skip { display: none; }
.auth[data-auth-mode="gate"] .auth-close { display: none; }

.auth-card {
  position: relative; z-index: 3;
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.auth-mark {
  width: 88px; height: 88px; margin-bottom: 32px;
  filter: drop-shadow(0 0 0 rgba(124,92,255,0));
  animation: auth-pulse 4.5s ease-in-out infinite;
}
@keyframes auth-pulse {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(124,92,255,.3)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 30px rgba(124,92,255,.7)); transform: scale(1.035); }
}
.auth-kicker {
  margin: 0 0 40px; color: var(--text-dim);
  font-family: 'Orbitron', -apple-system, "Segoe UI", sans-serif;
  font-size: .78rem; font-weight: 700; letter-spacing: .22em;
}
.auth-note {
  margin: -24px 0 30px; max-width: 290px;
  color: var(--accent); font-size: .84rem; line-height: 1.55; font-weight: 500;
}
.auth-step { display: flex; flex-direction: column; align-items: center; width: 100%; }
.auth-sub { margin: 22px 0 0; color: #5c5a68; font-size: .8rem; line-height: 1.6; }
.auth-sub strong { color: var(--text-dim); font-weight: 600; }

.auth-input {
  width: 100%; font: inherit; font-size: 1.1rem; text-align: center;
  background: transparent; color: var(--text);
  border: none; border-bottom: 1px solid var(--line);
  padding: 4px 4px 16px; margin-bottom: 34px;
  letter-spacing: .02em;
  transition: border-color .2s ease;
}
.auth-input::placeholder { color: #4a4854; font-weight: 300; }
.auth-input:focus { outline: none; border-bottom-color: var(--accent); }
.auth-input-code { font-size: 1.7rem; letter-spacing: .4em; font-variant-numeric: tabular-nums; padding-left: 22px; }

.auth-submit {
  font: inherit; cursor: pointer;
  background: transparent; color: var(--text);
  border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  padding: 12px 40px; font-size: .88rem; letter-spacing: .04em;
  transition: border-color .2s ease, background .2s ease, color .2s ease;
}
.auth-submit:hover { border-color: var(--accent); background: rgba(124,92,255,.08); color: #fff; }
.auth-submit:disabled { opacity: .4; pointer-events: none; }

.auth-error {
  color: var(--danger); font-size: .82rem; margin: 14px 0 0; min-height: 1.2em;
}
.auth-links { display: flex; gap: 22px; margin-top: 26px; }
.auth-link {
  font: inherit; font-size: .78rem; cursor: pointer;
  background: none; border: none; color: #4a4854;
  letter-spacing: .02em; padding: 4px;
}
.auth-link:hover { color: var(--text-dim); }

.account-btn.account-btn-signed-in { color: var(--accent); border-color: var(--accent-soft); }

@media (prefers-reduced-motion: reduce) {
  .auth-mark { animation: none; filter: drop-shadow(0 0 10px rgba(124,92,255,.5)); }
  .auth-scroll-bg { display: none; }
}

/* ---------- upgrade / manage plan overlay ---------- */
.btn-upgrade {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  font-weight: 600;
}
.btn-upgrade:hover { background: var(--accent); color: #fff; }

.upgrade {
  position: fixed; inset: 0; z-index: 70; overflow-y: auto;
  display: grid; place-items: center; padding: 24px;
}
.upgrade-backdrop {
  position: fixed; inset: 0; background: rgba(7,7,10,.86); backdrop-filter: blur(3px);
}
.upgrade-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 20px;
  padding: 36px 28px 28px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.upgrade-close {
  position: absolute; top: 14px; right: 14px;
  font: inherit; font-size: 1rem; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
}
.upgrade-close:hover { color: var(--text); border-color: var(--accent); }
.upgrade-mark { width: 52px; height: 52px; margin-bottom: 18px; }
.upgrade-card h2 { margin: 0 0 10px; font-size: 1.3rem; }
.upgrade-sub { margin: 0 0 26px; color: var(--text-dim); font-size: .88rem; line-height: 1.6; }

.upgrade-plans { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.upgrade-plan {
  font: inherit; cursor: pointer; text-align: left;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 4px;
  position: relative; transition: border-color .15s ease, background .15s ease;
}
.upgrade-plan:hover { border-color: var(--accent); background: var(--accent-soft); }
.upgrade-plan-best { border-color: var(--accent); }
.up-price { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.up-price small { font-size: .7rem; font-weight: 500; color: var(--text-dim); }
.up-note { font-size: .76rem; color: var(--text-dim); }
.up-badge {
  position: absolute; top: -9px; right: 14px;
  background: var(--accent); color: #fff; font-size: .65rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
}
.upgrade-fine { margin: 0; color: #5c5a68; font-size: .74rem; line-height: 1.5; }
.upgrade-fine a { color: var(--text-dim); }
.upgrade-fine a:hover { color: var(--accent); }

/* ---------- resume choice (opening a script with a saved position) ---------- */
.resume {
  position: fixed; inset: 0; z-index: 65; overflow-y: auto;
  display: grid; place-items: center; padding: 24px;
}
.resume-backdrop {
  position: fixed; inset: 0; background: rgba(7,7,10,.82); backdrop-filter: blur(4px);
}
.resume-card {
  position: relative; z-index: 1; width: 100%; max-width: 360px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px;
  padding: 30px 24px 26px; text-align: center;
  box-shadow: 0 26px 64px rgba(0,0,0,.55);
  animation: themepickIn .38s cubic-bezier(.34,1.56,.64,1);
}
.resume-close {
  position: absolute; top: 12px; right: 12px;
  font: inherit; font-size: .9rem; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
}
.resume-close:hover { color: var(--text); border-color: var(--accent); }
.resume-kicker {
  margin: 0 0 8px; color: var(--accent);
  font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.resume-sub { margin: 0 0 22px; color: var(--text-dim); font-size: .88rem; line-height: 1.5; }
.resume-actions { display: flex; flex-direction: column; gap: 10px; }
.resume-actions .btn { width: 100%; padding: 13px; }

/* ---------- theme action popup (tap a library theme tile) ----------
   Entrance uses a slight scale-overshoot ("back out" easing) so the card
   visibly pops forward and enlarges as it lands — same easing curve as
   .ltt-tapped above, so the tile's tap-feedback and the popup's arrival
   read as one continuous motion. */
.themepick {
  position: fixed; inset: 0; z-index: 65; overflow-y: auto;
  display: grid; place-items: center; padding: 24px;
}
.themepick-backdrop {
  position: fixed; inset: 0; background: rgba(7,7,10,.82); backdrop-filter: blur(4px);
}
.themepick-card {
  position: relative; z-index: 1; width: 100%; max-width: 360px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px;
  padding: 24px 24px 26px; text-align: center;
  box-shadow: 0 26px 64px rgba(0,0,0,.55);
  animation: themepickIn .38s cubic-bezier(.34,1.56,.64,1);
}
@keyframes themepickIn {
  0%   { opacity: 0; transform: scale(.82) translateY(24px); }
  60%  { opacity: 1; transform: scale(1.035) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.themepick-close {
  position: absolute; top: 12px; right: 12px;
  font: inherit; font-size: .9rem; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
}
.themepick-close:hover { color: var(--text); border-color: var(--accent); }
.themepick-art {
  /* source images are square (1254x1254) — 1/1 shows the full photo with
     zero cropping, same fix already used for .lib-theme-tile (which was
     16/10 originally too, and had the exact same "heads cropped off" bug). */
  width: 100%; aspect-ratio: 1 / 1; border-radius: 14px;
  background-size: cover; background-position: center;
  margin-bottom: 18px; box-shadow: 0 10px 26px rgba(0,0,0,.4);
}
.themepick-card h2 { margin: 0 0 20px; font-size: 1.25rem; }
.themepick-actions { display: flex; flex-direction: column; gap: 10px; }
.themepick-actions .btn { width: 100%; padding: 13px; font-size: .92rem; }

/* lock badges — non-Studio themes on the free plan */
.ltt-lock {
  position: absolute; top: 6px; right: 6px; z-index: 1;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.6); font-size: .68rem;
  display: none; align-items: center; justify-content: center;
}
.lib-theme-tile.locked .ltt-lock { display: flex; }
.lib-theme-tile.locked { filter: grayscale(.4) brightness(.75); }
.lib-theme-tile.locked .ltt-check { display: none; }

.chip-lock { display: none; margin-left: 4px; font-size: .7rem; vertical-align: middle; }
.theme-chip.locked .chip-lock, .sheet-row.locked .chip-lock { display: inline; }
.theme-chip.locked { opacity: .55; }
.sheet-row.locked { opacity: .5; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 90; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--text);
  padding: 10px 20px; border-radius: 999px; font-size: .9rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); white-space: nowrap;
  display: flex; align-items: center; gap: 14px;
}
.toast-action {
  font: inherit; font-weight: 700; font-size: .86rem; letter-spacing: .01em;
  cursor: pointer; background: none; border: none; color: var(--accent); padding: 0;
}
.toast-action:hover { color: #fff; }

/* ---------- session recap ---------- */
.recap {
  position: fixed; inset: 0; z-index: 65; overflow-y: auto;
  display: grid; place-items: center; padding: 24px;
}
.recap-backdrop {
  position: fixed; inset: 0; background: rgba(7,7,10,.82); backdrop-filter: blur(4px);
}
.recap-card {
  position: relative; z-index: 1; width: 100%; max-width: 360px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 20px;
  padding: 30px 24px 26px; text-align: center;
  box-shadow: 0 26px 64px rgba(0,0,0,.55);
  animation: themepickIn .38s cubic-bezier(.34,1.56,.64,1);
}
.recap-close {
  position: absolute; top: 12px; right: 12px;
  font: inherit; font-size: .9rem; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
}
.recap-close:hover { color: var(--text); border-color: var(--accent); }
.recap-kicker {
  margin: 0 0 22px; color: var(--accent);
  font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.recap-stats { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 26px; }
.recap-stat { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.recap-num { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.recap-label { font-size: .72rem; color: var(--text-dim); letter-spacing: .01em; }
.recap-card .btn { width: 100%; padding: 13px; }

/* phone-landscape: short screens starve the reader of upcoming lines —
   ride the current line higher and cap text height so the next words
   are always on screen. (Guide top matches anchorFrac() in prompter.js.) */
@media (orientation: landscape) and (max-height: 500px) {
  .guide-line { top: 26dvh; }
  .prompter-text {
    padding-top: 30dvh;
    padding-bottom: 70dvh;
    font-size: min(var(--p-fontsize, 42px), 8.5vh);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .prompter[data-ptheme="matrix"] .matrix-rain { display: none; }
}
