/* pro-speak-stories.css — [Batch 40 g108 hygiene 2026-04-24] Orphan `}` removed (legacy artifact). */
/* pro-speak-stories.css — 042026.1.69 */
/* [g69 Session 65 — Batch 9 Part A] Brand-palette restoration. Local
   :root shadows shared --text-3 back to pro-speak-stories' pre-g60 brand
   hex (#7d8590) so HC-off tertiary text matches the canonical JHACAL look
   (D30/D31). g60 L11-3 lightened shared --text-3 from #7d8590 → #98a1ac
   for WCAG AA across white-bg apps, but pro-speak-stories sits on a dark
   JHACAL surface where the original #7d8590 meets AA and matches brand.
   Other surface tokens (--bg-1/2/3, --text-1/2) already match shared
   defaults so no override needed there. Shared body.jhacal-high-contrast
   (specificity 0,1,1) beats local :root (0,1,0) — HC-on still flips. */
/* [g67 Session 63 — Batch 7 Part D] L10-2 Phase 2 token migration.
   Replaced hard-coded text/bg hex values with shared design-token
   references (~30 swaps in total across colour literals for text-1,
   text-2, text-3, and the card bg) so HC mode flips automatically
   via the token-swap layer in jhacal-design-tokens.css. No new
   !important rules introduced. Curated brand accents (gold variants,
   orange practice, green success, purple subset gradients) are
   intentionally retained as literals — those are UX highlights, not
   theme-responsive surfaces. Scope limited to text/bg surfaces;
   decorative backgrounds (rgba whites/blacks used for overlay/hover
   tints) deferred to Phase 3+ because flipping them would require a
   matching --surface-tint-hc token that we do not have yet. */
/* =====================================================
   PRO-SPEAK v4 — Application Styles
   JHACAL Dark Theme
   Centred max-width layout  ·  No-scroll  ·  Cross-platform
   ===================================================== */

:root {
  --ps-primary-font-scale: 1;
  --ps-interface-font-scale: 1;

  /* [g69 Part A] Brand-palette restoration — only --text-3 drifted when
     g60 L11-3 lightened shared --text-3 for white-bg AA compliance.
     Shadow it back here to ps's pre-g60 brand hex; shared HC block still
     wins on HC-on via cascade specificity (0,1,1 > 0,1,0). */
  --text-3: #7d8590;
}

/* Interface font scale — applied to controls, labels, buttons, status */
.ps-ctrl-btn    { font-size: calc(1em * var(--ps-interface-font-scale, 1)); }
.ps-ico         { font-size: calc(1.1em * var(--ps-interface-font-scale, 1)); }
.ps-topbar      { font-size: calc(1em * var(--ps-interface-font-scale, 1)); }
.ps-status-bar  { font-size: calc(1em * var(--ps-interface-font-scale, 1)); }
.ps-controls    { gap: calc(6px * var(--ps-interface-font-scale, 1)); }
.ps-btn         { font-size: calc(13px * var(--ps-interface-font-scale, 1)); }
.ps-speed-row   { font-size: calc(1em * var(--ps-interface-font-scale, 1)); }

/* ── Reset ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
html {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1a1d22;        /* outer page bg */
  color: var(--text-1);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* iOS safe areas */
  padding-top:    env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left:   env(safe-area-inset-left);
  padding-right:  env(safe-area-inset-right);
  display: flex;
  align-items: center;
  justify-content: center;
}
body *:not(input):not(textarea):not(select) {
  user-select: none;
  -webkit-user-select: none;
}

/* ── Outer wrapper: centres the card on large screens ─ */
.ps-outer {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  /* App renders under the launch facade — no hide/reveal needed */
}

/* ── App card ────────────────────────────────────────
   On large screens this is a centred column with a
   max-width, giving a more focused experience and
   avoiding the blowout the user was seeing.
   On small/medium screens it fills the viewport.       */
.ps-app {
  width: 100%;
  max-width: 900px;           /* ← centred card on tablets/desktop */
  height: 100%;               /* ← must be set so flex children can fill vertically */
  padding: 8px 14px calc(38px + env(safe-area-inset-bottom)) 14px;
  padding-top: calc(8px + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--bg-1);        /* card bg — [g67 L10-2 Phase 2] tokenised for HC flip */
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

/* ── Top bar ─────────────────────────────────────── */
.ps-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 52px;
}
.ps-topbar-left  { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ps-topbar-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.ps-brand-img {
  height: 38px; width: auto;
  border-radius: 6px;
  display: block; flex-shrink: 0;
  transition: transform 0.2s;
  cursor: pointer;
}
.ps-brand-img:hover { transform: scale(1.06); }

.ps-title-block { line-height: 1.15; min-width: 0; }
.ps-app-title {
  margin: 0;
  font-size: clamp(14px, 2.2vw, 22px);
  font-weight: 900;
  background: linear-gradient(135deg, #f6c177, #ff9800);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}
.ps-app-sub {
  margin: 0;
  font-size: 10px; color: var(--text-3); font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ps-btn-top {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text-2); font-size: calc(12px * var(--ps-interface-font-scale, 1)); font-weight: 700;
  cursor: pointer; min-height: 40px;
  touch-action: manipulation; transition: all 0.18s; white-space: nowrap;
}
.ps-btn-top:hover { background: rgba(255,255,255,0.1); color: var(--text-1); }
.ps-btn-choose   { border-color: rgba(91,141,87,0.4);  color: #8bc34a; }
.ps-btn-choose:hover  { background: rgba(91,141,87,0.15); border-color: #5B8D57; }
.ps-btn-settings { border-color: rgba(255,152,0,0.3);  color: #ff9800; }
.ps-btn-settings:hover { background: rgba(255,152,0,0.1); border-color: #ff9800; }

.ps-btn-tutorial {
  background: none;
  border: 1px solid rgba(246,193,119,.45);
  color: #f6c177;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 1rem; font-weight: 900;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  min-width: 36px; min-height: 34px;
  touch-action: manipulation; transition: border-color .15s, color .15s; flex-shrink: 0;
  letter-spacing: .5px;
}
.ps-btn-tutorial:hover { border-color: #f6c177; color: #fff; }

/* ── Status / sound-reference bar ───────────────── */
.ps-status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 12px; gap: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px; flex-shrink: 0;
}
/* Single centred status message — word count + set info combined */
.ps-status-primary {
  flex: 1; text-align: center;
  font-size: clamp(11px, 1.5vw, 13px); font-weight: 600;
  color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* subsetLine hidden — info merged into topLine */
.ps-status-count { display: none; }

/* Sound reference pill — sits at right of status bar */
.ps-sound-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center;
  background: rgba(246,193,119,0.1);
  border: 1px solid rgba(246,193,119,0.28);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: clamp(10px, 1.4vw, 12px);
  font-weight: 700;
  color: #f6c177;
  letter-spacing: 0.2px;
  max-width: 240px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity 0.25s ease;
  pointer-events: none;
}
.ps-sound-pill:not(:empty) { opacity: 1; pointer-events: auto; }
/* Old sound-ref below word — kept for compatibility but unused */
.ps-sound-ref { display: none; }

/* ── Main content area ──────────────────────────── */
.ps-main {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 12px 14px;
  align-items: center;
  overflow: hidden;
}

.ps-stage {
  flex: 1; min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  overflow: hidden;
}

/* ── Big word display ───────────────────────────── */
.ps-word-display {
  font-size: calc(clamp(36px, 8vw, 110px) * var(--ps-primary-font-scale, 1));
  font-weight: 900;
  color: var(--text-1);
  line-height: 1.1;
  letter-spacing: 0.5px;
  word-break: break-word;
  max-width: 100%;
  transition: font-size 0.12s ease;
}
.ps-word-display.ps-phrase {
  font-size: calc(clamp(22px, 5vw, 70px) * var(--ps-primary-font-scale, 1));
}

/* ── Sound reference / subset descriptor ───────────
   Shows the IPA / phonetic context beneath the word:
   e.g. "Short Vowels — /æ/" or "Stops — /p/"         */
.ps-sound-ref {
  font-size: clamp(12px, 1.8vw, 17px);
  font-weight: 600;
  color: #f6c177;             /* gold — prominent but not competing with word */
  background: rgba(246,193,119,0.1);
  border: 1px solid rgba(246,193,119,0.2);
  border-radius: 8px;
  padding: 5px 14px;
  letter-spacing: 0.3px;
  text-align: center;
  min-height: 30px;
  display: flex; align-items: center; justify-content: center;
  /* Hidden until a word is playing */
  opacity: 0;
  transition: opacity 0.25s ease;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ps-sound-ref.ps-visible { opacity: 1; }
.ps-sound-ref:empty { opacity: 0; border-color: transparent; background: transparent; }

/* ── Progress rail ─────────────────────────────── */
.ps-rail {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 6px 8px;
  border-left: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.ps-meter-group { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.ps-meter-label { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.ps-meter {
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.3);
  position: relative; overflow: hidden;
  height: clamp(70px, 12vh, 130px);
  width: 20px;
}
.ps-meter-fill {
  position: absolute; bottom: 0; left: 0; width: 100%; height: 0%;
  background: linear-gradient(180deg, #5B8D57, #2e5c2b);
  transition: height 0.3s ease;
}
.ps-meter-sub .ps-meter-fill { background: linear-gradient(180deg, #6fa8dc, #2c5e9c); }
.ps-counter {
  font-size: 10px; font-weight: 800; color: var(--text-2);
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px; padding: 2px 4px; text-align: center; white-space: nowrap;
}

/* ── Controls ──────────────────────────────────── */
.ps-controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px; padding: 8px 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px; flex-shrink: 0;
}
.ps-ctrl-btn {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: var(--text-1); cursor: pointer;
  width:  clamp(50px, 7vw, 64px);
  height: clamp(50px, 7vw, 64px);
  display: flex; align-items: center; justify-content: center;
  position: relative; touch-action: manipulation; transition: all 0.16s;
  -webkit-transform: translateZ(0);
}
.ps-ctrl-btn:hover  { transform: scale(1.06) translateZ(0); border-color: rgba(255,255,255,0.22); }
.ps-ctrl-btn:active { transform: scale(0.95) translateZ(0); }

.ps-ico {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(18px, 3vw, 26px); pointer-events: none;
}

.ps-ctrl-go    { background: rgba(91,141,87,0.28);  border-color: rgba(91,141,87,0.5); }
.ps-ctrl-go:hover  { background: rgba(91,141,87,0.42); border-color: #5B8D57; }
.ps-ctrl-nav   { background: rgba(255,152,0,0.1); border-color: rgba(255,152,0,0.22); }
.ps-ctrl-nav:hover { background: rgba(255,152,0,0.2); border-color: rgba(255,152,0,0.45); }
/* Subset jump buttons - same size as other nav */
.ps-ctrl-subset { }
/* Word step buttons - slightly smaller */
.ps-ctrl-word {
  width:  clamp(42px, 5.5vw, 52px) !important;
  height: clamp(42px, 5.5vw, 52px) !important;
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
}
.ps-ctrl-word:hover { background: rgba(255,255,255,0.09); }
/* Main play/stop — slightly larger, more prominent */
.ps-ctrl-main {
  width:  clamp(60px, 8.5vw, 72px) !important;
  height: clamp(60px, 8.5vw, 72px) !important;
  border-width: 3px;
}
/* Small icon variant for ◀◀ ▶▶ */
.ps-ico-sm { font-size: clamp(10px, 1.8vw, 14px); letter-spacing: -2px; }
.ps-ctrl-reset { background: rgba(199,166,74,0.2);  border-color: rgba(199,166,74,0.35); }
.ps-ctrl-reset:hover { background: rgba(199,166,74,0.35); }
.ps-ctrl-rec   { background: rgba(180,80,80,0.25);  border-color: rgba(180,80,80,0.4); }
.ps-ctrl-rec:hover   { background: rgba(180,80,80,0.4); }
.ps-ctrl-rec.ps-recording {
  border-color: #dc3545; background: rgba(220,53,69,0.35);
  animation: psRecPulse 1.2s ease-in-out infinite;
}
@keyframes psRecPulse {
  0%,100% { box-shadow: 0 0 6px rgba(220,53,69,0.3); }
  50%      { box-shadow: 0 0 18px rgba(220,53,69,0.7); }
}

/* ── Speed bar ─────────────────────────────────── */
.ps-speed-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 6px 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px; flex-shrink: 0; flex-wrap: wrap;
}
.ps-mute-label {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px; padding: 6px 10px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer; min-height: 36px; touch-action: manipulation;
}
.ps-speed-lever { display: flex; align-items: center; gap: 8px; }
.ps-speed-btn {
  border-radius: 50%; border: 2px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05); color: var(--text-1); font-weight: 900;
  cursor: pointer; width: 40px; height: 40px; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; transition: all 0.16s;
}
.ps-speed-btn:hover { background: rgba(255,255,255,0.1); transform: scale(1.06); }
.ps-speed-val {
  min-width: 52px; text-align: center; font-weight: 900; font-size: 16px; color: #f6c177;
  background: rgba(0,0,0,0.25); border: 2px solid rgba(255,152,0,0.2);
  border-radius: 8px; padding: 4px 8px;
}
.ps-speed-unit { color: var(--text-3); font-size: 11px; font-weight: 600; }

/* ── Modal, dialog and word-set selector styles ──────────────────────────────
   Moved to /shared/css/jhacal-wordset-selector.css (shared with Pro Speak).
   ─────────────────────────────────────────────────────────────────────────── */


/* ── Recording modal ────────────────────────────── */
.ps-rec-block {
  border: 1px solid rgba(255,255,255,0.08); border-radius: 9px;
  padding: 12px 14px; margin: 6px 16px;
  background: rgba(255,255,255,0.02);
}
.ps-rec-head { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: #ff9800; }
.ps-rec-row  { display: flex; gap: 7px; flex-wrap: wrap; }
.ps-word-list-preview {
  max-height: 180px; overflow-y: auto;
  background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 7px; padding: 10px; font-size: 12px; color: var(--text-2); line-height: 1.7;
}

/* Word grid inside the preview */
.rec-word-grid {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px;
}
.rec-word {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
/* Played — bold, gold star, green tint */
.rec-word--played {
  background: rgba(74,222,128,0.15);
  border: 1px solid rgba(74,222,128,0.4);
  color: #4ade80;
  font-weight: 700;
}
/* Not yet reached — muted */
.rec-word--unplayed {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  color: #6b7280;
}
/* Legend row */
.rec-word-legend {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 10px; color: var(--text-3); margin-bottom: 4px; align-items: center;
}
.rec-word-legend .rec-word {
  font-size: 10px; padding: 1px 7px; pointer-events: none;
}
/* Summary line */
.rec-word-summary {
  margin-top: 8px; font-size: 10px; color: var(--text-3); font-style: italic;
}
.ps-spanel        { display: none; }
.ps-spanel.active { display: block; }
.ps-spanel-intro  { font-size: 13px; color: #9ca3af; line-height: 1.55; margin: 0 0 14px; padding: 10px 12px; background: rgba(255,152,0,0.06); border-radius: 8px; border-left: 3px solid rgba(255,152,0,0.3); }
.ps-shead { font-size: 13px; font-weight: 700; color: #ff9800; margin: 20px 0 10px; padding-bottom: 7px; border-bottom: 1px solid rgba(255,152,0,0.2); }
.ps-shead:first-child { margin-top: 0; }
.ps-srow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 13px 14px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px; margin-bottom: 8px;
}
.ps-sinfo { flex: 1; }
.ps-slabel { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 2px; }
.ps-sdesc  { font-size: 11px; color: var(--text-3); line-height: 1.4; }
.ps-sctrl  { min-width: 180px; }

.ps-select, .ps-input {
  width: 100%; padding: 9px 10px;
  background: rgba(0,0,0,0.35); border: 2px solid rgba(255,255,255,0.1);
  border-radius: 7px; color: var(--text-1); font-size: 13px; font-family: inherit;
  appearance: none; cursor: pointer; transition: border-color 0.18s;
}
.ps-select:focus, .ps-input:focus { outline: none; border-color: #ff9800; }

.ps-slider-row { display: flex; align-items: center; gap: 8px; }
.ps-slider     { flex: 1; height: 5px; accent-color: #ff9800; cursor: pointer; }
.ps-slider-val { font-weight: 800; color: #f6c177; min-width: 36px; text-align: right; font-size: 13px; }

.ps-tog { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ps-tog input { display: none; }
.ps-tog-track {
  width: 46px; height: 24px; background: rgba(255,255,255,0.1); border-radius: 12px;
  position: relative; transition: background 0.3s; flex-shrink: 0;
}
.ps-tog-track::after {
  content:''; position:absolute; top:3px; left:3px;
  width:18px; height:18px; border-radius:50%;
  background:#7d8590; transition: all 0.3s;
}
.ps-tog input:checked ~ .ps-tog-track { background: rgba(255,152,0,0.38); }
.ps-tog input:checked ~ .ps-tog-track::after { transform: translateX(22px); background: #ff9800; }
.ps-tog-lbl { font-size: 12px; color: var(--text-2); font-weight: 600; }

.ps-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.ps-stat-card  { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 14px; text-align: center; }
.ps-stat-ico   { font-size: 22px; margin-bottom: 5px; }
.ps-stat-val   { font-size: 26px; font-weight: 900; color: #f6c177; line-height: 1; margin-bottom: 3px; }
.ps-stat-lbl   { font-size: 11px; color: var(--text-3); font-weight: 600; }

.ps-ach-list { display: flex; flex-direction: column; gap: 7px; }
.ps-ach-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07); border-radius: 9px;
}
.ps-ach-item.unlocked { background: rgba(255,152,0,0.07); border-color: rgba(255,152,0,0.2); }
.ps-ach-item-ico  { font-size: 20px; filter: grayscale(1) opacity(0.35); flex-shrink:0; }
.ps-ach-item.unlocked .ps-ach-item-ico { filter: none; }
.ps-ach-item-info { flex: 1; }
.ps-ach-item-title { font-size: 13px; font-weight: 700; color: #d1d5db; }
.ps-ach-item.unlocked .ps-ach-item-title { color: #f6c177; }
.ps-ach-item-desc  { font-size: 11px; color: var(--text-3); }
.ps-ach-item-badge {
  font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 999px;
  background: rgba(255,255,255,0.07); color: var(--text-3);
}
.ps-ach-item.unlocked .ps-ach-item-badge { background: rgba(255,152,0,0.18); color: #ff9800; }

.ps-rec-history { display: flex; flex-direction: column; gap: 7px; min-height: 60px; }
.ps-rec-entry   { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07); border-radius: 8px; }
.ps-rec-entry-date { font-size: 11px; color: var(--text-3); flex-shrink:0; }
.ps-rec-entry-info { flex:1; font-size: 12px; color: var(--text-2); }

.ps-badge { background: rgba(255,152,0,0.14); color: #ff9800; border: 1px solid rgba(255,152,0,0.28); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700; }
.ps-info-card { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07); border-radius: 10px; overflow:hidden; }
.ps-info-row  { display:flex; justify-content:space-between; padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 12px; color: var(--text-2); }
.ps-info-row:last-child { border-bottom: none; }
.ps-info-row strong { color: #f6c177; }
.ps-feature-list { display:flex; flex-direction:column; gap:5px; }
.ps-feature-item { font-size: 12px; color: var(--text-2); padding: 7px 10px; background: rgba(255,255,255,0.02); border-radius: 7px; border-left: 3px solid rgba(255,152,0,0.25); }

/* ── Achievement popup ─────────────────────────── */
.ps-ach-popup {
  position: fixed; top:50%; left:50%;
  transform: translate(-50%,-50%) scale(0);
  background: linear-gradient(135deg,#ffd700,#ffed4e); color: #111;
  padding: 24px 32px; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  z-index: 2100; text-align: center;
  transition: transform 0.4s cubic-bezier(0.68,-0.55,0.265,1.55);
  pointer-events: none; max-width: 300px; width: 88vw;
}
.ps-ach-popup.show { transform: translate(-50%,-50%) scale(1); }
.ps-ach-popup-ico   { font-size: 54px; margin-bottom: 8px; }
.ps-ach-popup-title { font-size: 18px; font-weight: 900; margin-bottom: 5px; }
.ps-ach-popup-desc  { font-size: 12px; opacity: 0.75; }

/* ── Toast ─────────────────────────────────────── */
.ps-toast {
  position: fixed; right: 14px;
  bottom: calc(40px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,0.88); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-weight: 700; font-size: 13px;
  opacity: 0; transform: translateY(8px);
  transition: all 0.22s ease; z-index: 1600;
  pointer-events: none; max-width: 280px;
  border: 1px solid rgba(255,255,255,0.1);
}
.ps-toast.show { opacity: 1; transform: translateY(0); }

/* ── Respect OS reduced motion preference ────────── */
/* [Batch 40 g108] Stray orphan brace removed (legacy artifact). */

/* ── Focus (keyboard) ──────────────────────────── */
@media (pointer: fine) {
  .ps-ctrl-btn:focus-visible, .ps-btn:focus-visible, .ps-btn-top:focus-visible {
    outline: 3px solid #ff9800; outline-offset: 2px;
  }
  * { scrollbar-width: thin; scrollbar-color: rgba(255,152,0,0.25) rgba(255,255,255,0.04); }
}


/* ── Edit button on subset tiles ────────────────── */
.ps-sub-edit-btn {
  flex-shrink: 0; margin-left: auto;
  background: none;
  border: 1px solid rgba(255,152,0,0.35);
  border-radius: 5px; color: rgba(255,152,0,0.7);
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; cursor: pointer; transition: all 0.15s;
  line-height: 1.5; white-space: nowrap;
  opacity: 0;  /* hidden by default on desktop */
  pointer-events: none;
  touch-action: manipulation;
}
/* Show on hover of the parent tile */
.ps-sub-item:hover .ps-sub-edit-btn,
.ps-sub-item:focus-within .ps-sub-edit-btn { opacity: 1; pointer-events: auto; }
.ps-sub-edit-btn:hover { background: rgba(255,152,0,0.15); border-color: #ff9800; color: #ff9800; }
/* Touch devices: always show at FULL opacity and ensure pointer-events enabled */
@media (hover: none) {
  .ps-sub-edit-btn { opacity: 1; pointer-events: auto; }
  /* Also show edit button when parent item has focus-within on touch */
  .ps-sub-item:focus-within .ps-sub-edit-btn { opacity: 1; pointer-events: auto; }
}

/* ── Word editor modal ───────────────────────────── */
.ps-edit-dialog {
  max-width: 540px;
  max-height: min(90vh, 700px);
  display: flex; flex-direction: column;
}
.ps-edit-header-content { flex: 1; min-width: 0; }
.ps-edit-breadcrumb { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.ps-edit-cat-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
  color: #ff9800; background: rgba(255,152,0,0.12);
  border: 1px solid rgba(255,152,0,0.3); border-radius: 4px; padding: 1px 6px;
}
.ps-edit-subset-name { font-size: 13px; font-weight: 700; color: var(--text-1); }
.ps-edit-body {
  flex: 1; display: flex; flex-direction: column; gap: 10px;
  padding: 14px 18px; min-height: 0; overflow: hidden;
}
.ps-edit-instructions {
  font-size: 12px; color: #9ca3af; line-height: 1.6;
  padding: 8px 12px; background: rgba(255,152,0,0.06);
  border-radius: 7px; border-left: 3px solid rgba(255,152,0,0.35);
  flex-shrink: 0;
}
.ps-edit-instructions strong { color: #ff9800; }
.ps-edit-textarea {
  flex: 1; min-height: 220px;
  background: rgba(0,0,0,0.35); border: 2px solid rgba(255,255,255,0.1);
  border-radius: 9px; color: var(--text-1); font-size: 14px; font-family: inherit;
  padding: 12px 14px; resize: none; line-height: 1.8;
  user-select: text; -webkit-user-select: text;
  transition: border-color 0.18s;
}
.ps-edit-textarea:focus { outline: none; border-color: rgba(255,152,0,0.55); }
.ps-edit-stats {
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.ps-edit-word-count { font-size: 12px; font-weight: 800; color: #ff9800; }
.ps-edit-hint       { font-size: 11px; color: var(--text-3); }
.ps-edit-footer { justify-content: space-between; }
.ps-edit-footer-right { display: flex; gap: 8px; }

/* ══════════════════════════════════════════════════
   RESPONSIVE — ensure the centred card stays within
   viewport on every device without scrolling
   ══════════════════════════════════════════════════ */

/* Phone portrait ≤ 480px: fill viewport, compact gaps */
@media (max-width: 480px) {
  .ps-app { padding: 5px 8px calc(34px + env(safe-area-inset-bottom)) 8px; gap: 4px; max-width: 100%; padding-top: calc(5px + env(safe-area-inset-top)); }
  .ps-topbar { padding: 5px 7px; min-height: 46px; }
  .ps-brand-img { height: 30px; }
  .ps-btn-top { padding: 5px 9px; font-size: 11px; min-height: 36px; }
  .ps-btn-tutorial { width: 28px; height: 28px; font-size: 14px; }
  .ps-ctrl-btn { width: clamp(44px, 12vw, 54px); height: clamp(44px, 12vw, 54px); }
  .ps-ico { font-size: clamp(16px, 4.5vw, 22px); }
  .ps-speed-btn { width: 36px; height: 36px; font-size: 18px; }
  .ps-sound-ref { font-size: 11px; padding: 4px 10px; }
  .ps-sub-grid  { grid-template-columns: repeat(2,1fr); }
  .ps-srow { flex-direction: column; align-items: stretch; gap: 8px; }
  .ps-sctrl { min-width: unset; }
  .ps-stab { padding: 10px 12px; font-size: 11px; }
}

/* Tablet portrait 481–767px: start limiting width */
@media (min-width: 481px) and (max-width: 767px) {
  .ps-app { max-width: 100%; gap: 5px; }
}

/* Tablet 768–1024px: centred card, appropriate meter height */
@media (min-width: 768px) and (max-width: 1024px) {
  .ps-app { gap: 7px; padding: 10px 16px calc(40px + env(safe-area-inset-bottom)) 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .ps-brand-img { height: 40px; }
  .ps-ctrl-btn  { width: 58px; height: 58px; }
  .ps-meter     { height: clamp(80px, 14vh, 130px); width: 22px; }
  .ps-sub-grid  { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* Desktop > 1024px: fixed card, centred */
@media (min-width: 1025px) {
  body { background: #111418; }           /* darker outer page */
  .ps-app {
    border-left:  1px solid rgba(255,255,255,0.06);
    border-right: 1px solid rgba(255,255,255,0.06);
  }
}

/* Landscape / short screen */
@media (max-height: 600px) and (orientation: landscape) {
  .ps-app { gap: 4px; padding-top: calc(4px + env(safe-area-inset-top)); }
  .ps-topbar { min-height: 42px; padding: 4px 8px; }
  .ps-brand-img { height: 28px; }
  .ps-app-sub   { display: none; }
  .ps-status-bar { padding: 3px 8px; }
  .ps-ctrl-btn  { width: 44px; height: 44px; }
  .ps-ico       { font-size: 18px; }
  .ps-meter     { height: clamp(50px, 10vh, 80px); }
  .ps-speed-bar { padding: 4px 8px; }
  .ps-speed-btn { width: 34px; height: 34px; font-size: 17px; }
  .ps-sound-ref { font-size: 11px; padding: 3px 8px; min-height: 24px; }
}

/* iPad Pro landscape (1024 wide, ~768 tall) */
@media (min-width: 1024px) and (max-height: 800px) {
  .ps-app { gap: 5px; }
  .ps-meter { height: clamp(70px, 11vh, 100px); }
}

/* ═══════════════════════════════════════════════════════════
   RSVP — Flash Reading Mode
   One word at a time; focal character always at horizontal centre.

   IP design notes (documented for audit):
   • RSVP is a 1970s academic technique — public domain.
   • Focal character held at a FIXED HORIZONTAL POSITION via a
     CSS grid layout (1fr | auto | 1fr), NOT by repositioning the
     word element.  Three separate <span> elements fill the grid
     columns — the focal span is always the centre column.
   • Our focal index uses Math.round((len-1)*0.28) — a percentage
     formula, distinct from the character-count lookup table in
     Spritz US 8,832,552.
   • Visual design: background-box on the focal character (not
     Spritz's red-letter / grey–black colour-split approach).
   • Focal-column marker: two small dots above/below the reading
     channel (not Spritz's bracket-and-crosshair "Redicle" marks).
   ═══════════════════════════════════════════════════════════ */

/* ── Settings panel: WPM stepper ── */
.rsvp-wpm-ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rsvp-wpm-val {
  min-width: 76px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1, #e6edf3);
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 6px 10px;
  letter-spacing: 0.02em;
}

/* ── Story stage: RSVP launch button ── */
.story-rsvp-btn {
  padding: 3px 11px;
  border-radius: 12px;
  border: 1px solid rgba(255,152,0,0.4);
  background: rgba(255,152,0,0.10);
  color: #ff9800;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.6;
}
.story-rsvp-btn:hover  { background: rgba(255,152,0,0.22); }
.story-rsvp-btn:active { background: rgba(255,152,0,0.35); }

/* Story-stage mute button in status bar */
.story-mute-btn {
  width: 28px; height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.18s, background 0.18s;
  flex-shrink: 0;
}
.story-mute-btn:hover { background: rgba(255,255,255,0.12); }

/* ── Full-screen RSVP overlay ── */
/* z-index beats the legal footer bar (2147483000) and its modal (2147483600);
   capped at max safe int (2147483647). JS also hides the footer on launch. */
.rsvp-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  background: #080b0e;      /* near-black for maximum contrast */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-top:    env(safe-area-inset-top,    0px);
  padding-right:  env(safe-area-inset-right,  0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left:   env(safe-area-inset-left,   0px);
}
.rsvp-overlay[hidden] { display: none; }

/* ── Chapter title bar — passive strip, no interactive elements ── */
.rsvp-ch-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 16px;
  flex-shrink: 0;
}
.rsvp-ch-title {
  font-size: 11px;
  color: rgba(255,255,255,0.22);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(420px, 90vw);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Word stage — fills remaining vertical space ── */
.rsvp-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  padding: 0 12px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

/* ── Reading channel ─────────────────────────────────────────────────
   Fixed-width container that constrains the word display to a
   consistent horizontal zone.  The focal-column marker dots
   (::before / ::after) sit exactly at the horizontal centre of this
   container — visually anchoring the reader's gaze point.
   ─────────────────────────────────────────────────────────────────── */
.rsvp-reading-channel {
  width: min(540px, 96vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
}

/* Focal-column markers: small dots centred above and below the word.
   These are simple geometric indicators, not Spritz's bracket/crosshair
   "Redicle" design. */
.rsvp-reading-channel::before,
.rsvp-reading-channel::after {
  content: '';
  display: block;
  margin: 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,152,0,0.55);
  flex-shrink: 0;
}

/* Guide lines: solid horizontal lines within the reading channel.
   They run the full channel width, reinforcing the reading zone. */
.rsvp-guide-line {
  width: 100%;
  height: 1px;
  background: rgba(255,152,0,0.20);
  margin: 6px 0;
  flex-shrink: 0;
}

/* ── Three-column word grid ──────────────────────────────────────────
   grid-template-columns: 1fr auto 1fr
   The middle (auto) column holds exactly one focal character and is
   always at the horizontal centre of the channel.  The left column
   (1fr, right-aligned) and right column (1fr, left-aligned) expand
   outward.  This CSS layout is what keeps the focal character stable —
   not word repositioning.
   ─────────────────────────────────────────────────────────────────── */
.rsvp-word-wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  /* overflow: visible — words must never be clipped mid-character.
     Long words scale down via --rsvp-word-scale (set by JS in _render). */
  overflow: visible;
  line-height: 1.2;
  min-height: 1.2em;
}

.rsvp-word-wrap span {
  font-family: 'Atkinson Hyperlegible', 'Arial', system-ui, sans-serif;
  /* --rsvp-word-scale is set by _render() in rsvp-engine.js — shrinks long words
     so they fit without clipping (1.0 for ≤6 chars, down to 0.5 for 13+ chars). */
  font-size: calc(clamp(44px, 11vw, 88px) * var(--ps-primary-font-scale, 1) * var(--rsvp-word-scale, 1));
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Pre-focal text: right-aligned, muted.
   Opacity 0.55 (was 0.40) — WCAG AA compliant on #080B0E background (~4.7:1 contrast). */
.rsvp-before {
  text-align: right;
  color: rgba(255,255,255,0.55);
  overflow: visible;
  min-width: 0;
}

/* Post-focal text: left-aligned, muted. */
.rsvp-after {
  text-align: left;
  color: rgba(255,255,255,0.55);
  overflow: visible;
  min-width: 0;
}

/* Focal character: JHACAL orange colour — no background box.
   Colour-only approach: distinct from Spritz's red-letter + background split.
   Practice words use a brighter orange to flag therapeutic words. */
.rsvp-focal {
  text-align: center;
  color: #ff9800;
  background: none;
  border-radius: 0;
  padding: 0;
}

/* Practice-word: brighter focal to flag therapeutic words */
.rsvp-word-wrap.is-practice .rsvp-focal {
  color: #ffb340;
  background: none;
  outline: none;
}

/* Sentence boundary: both side spans hidden, focal shows a dash */
.rsvp-word-wrap.is-boundary .rsvp-before,
.rsvp-word-wrap.is-boundary .rsvp-after { visibility: hidden; }
.rsvp-word-wrap.is-boundary .rsvp-focal {
  display: block;
  width: 24px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 0 auto;
  align-self: center;
  font-size: 0;
  padding: 0;
}

/* Paused state indicator */
.rsvp-stage.is-paused::after {
  content: '⏸  Paused — tap to resume';
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.28);
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

/* ── Progress track ── */
.rsvp-progress-track {
  height: 3px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  flex-shrink: 0;
}
.rsvp-progress-fill {
  height: 100%;
  background: #ff9800;
  transition: width 0.15s linear;
}

/* ── Status line ── */
.rsvp-status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.28);
  flex-shrink: 0;
}
.rsvp-pause-hint { font-style: italic; }

/* ── Bottom controls — lifted by ~1 text-line above the screen edge ── */
.rsvp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.rsvp-ctrl-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.75);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rsvp-ctrl-btn:hover  { background: rgba(255,255,255,0.13); }
.rsvp-ctrl-btn:active { background: rgba(255,255,255,0.22); }

/* Play/pause — larger, orange accent */
.rsvp-play-btn {
  width: 62px;
  height: 62px;
  font-size: 24px;
  border-color: rgba(255,152,0,0.5);
  background: rgba(255,152,0,0.13);
  color: #ff9800;
}
.rsvp-play-btn:hover { background: rgba(255,152,0,0.27); }

/* Exit — red accent, signals destructive action */
.rsvp-exit-btn {
  border-color: rgba(192,57,43,0.35);
  color: rgba(255,110,90,0.70);
}
.rsvp-exit-btn:hover { background: rgba(192,57,43,0.28); border-color: rgba(192,57,43,0.65); color: #e74c3c; }

/* Mute — orange tint when voice is active (overrides shared green border) */
.rsvp-mute-btn.voice-on {
  background: rgba(255,152,0,0.18);
  border-color: rgba(255,152,0,0.50) !important;
  color: #ff9800;
}
/* Override shared mute border colour for RSVP unmuted state */
.rsvp-mute-btn:not(.muted) {
  border-color: rgba(255,152,0,0.50);
}

.rsvp-wpm-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 58px;
}
#rsvpWpmDisplay {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}
.rsvp-wpm-label {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-top: 2px;
}
