:root {
  --bg: #F4F8FD;
  --panel: #FFFFFF;
  --panel-2: #E5EEF8;
  --text: #0F172A;
  --muted: #24364B;
  --border: #7F93AC;
  --primary: #0A4DB0;
  --primary-contrast: #F8FBFF;
  --secondary: #0E7C74;
  --secondary-contrast: #F8FBFF;
  --accent: #6D28D9;
  --danger: #991B1B;
  --warning-bg: #FFF2BF;
  --warning-text: #4B2E00;
  --flash-success: #DCFCE7;
  --flash-success-text: #14532D;
  --flash-error: #FEE2E2;
  --flash-error-text: #7F1D1D;
  --hero-start: #0A4DB0;
  --hero-end: #5B2CCB;
  --quote-bg: rgba(255, 255, 255, 0.97);
  --quote-text: #0F172A;
  --quote-border: rgba(255, 255, 255, 0.88);
  --soft-surface: #F2F7FD;
  --shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  --focus-ring: #D97706;
}

html[data-theme='dark'] {
  --bg: #06101A;
  --panel: #0D1D2E;
  --panel-2: #15293E;
  --text: #F8FBFF;
  --muted: #E4EDF7;
  --border: #7087A3;
  --primary: #9FD1FF;
  --primary-contrast: #04111C;
  --secondary: #84F2E3;
  --secondary-contrast: #052421;
  --accent: #E2D2FF;
  --danger: #FFB7B7;
  --warning-bg: #5A4100;
  --warning-text: #FFF1BF;
  --flash-success: #143321;
  --flash-success-text: #D1FAE5;
  --flash-error: #401515;
  --flash-error-text: #FFE1E1;
  --hero-start: #123B79;
  --hero-end: #4726A8;
  --quote-bg: #F0F7FF;
  --quote-text: #091521;
  --quote-border: #FFFFFF;
  --soft-surface: #12263A;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.48);
  --focus-ring: #FACC15;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1.78;
  letter-spacing: 0.005em;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.skip-link {
  position: absolute; left: 1rem; top: -200px; background: var(--primary); color: var(--primary-contrast);
  padding: 0.75rem 1rem; z-index: 10;
}
.skip-link:focus { top: 1rem; }
.site-header {
  display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.5rem; background: var(--panel);
  border-bottom: 1px solid var(--border); align-items: center; position: sticky; top: 0; z-index: 5;
}
.brand-wrap { display: flex; gap: 1rem; align-items: center; }
.brand-mark {
  width: 3rem; height: 3rem; border-radius: 1rem; background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; font-size: 1.5rem;
}
.brand-title { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1.15; }
.brand-subtitle { color: var(--muted); font-size: 1.02rem; }
.top-nav { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.top-nav a { font-weight: 800; font-size: 1.03rem; }
.theme-toggle {
  border: 2px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 0.75rem 1rem; font-size: 1.05rem; cursor: pointer;
}
.disclaimer-banner {
  background: var(--warning-bg); color: var(--warning-text); padding: 0.9rem 1.2rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08); font-weight: 700;
}
.page-shell { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }
.site-footer { padding: 1.4rem 1.5rem 2rem; color: var(--muted); text-align: center; }
.flash-stack { display: grid; gap: 0.8rem; margin-bottom: 1rem; }
.flash { border-radius: 1rem; padding: 1rem 1.2rem; font-weight: 700; border: 1px solid var(--border); }
.flash-success { background: var(--flash-success); color: var(--flash-success-text); }
.flash-error { background: var(--flash-error); color: var(--flash-error-text); }
.flash-warning { background: var(--warning-bg); color: var(--warning-text); }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 1.5rem; padding: 1.4rem; box-shadow: var(--shadow);
}
.panel.narrow, .auth-shell.narrow { max-width: 760px; margin: 0 auto; }
.compact-panel { padding: 1rem 1.1rem; }
.guide-panel { max-width: 1100px; margin: 0 auto; }
.panel-header { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 0.8rem; }
.panel-header.split { align-items: flex-start; }
.panel-body { display: grid; gap: 0.85rem; }
.hero { margin-bottom: 1.4rem; }
.hero-copy { min-height: 420px; }
.hero-visual { display: grid; place-items: center; min-height: 420px; }
.hero-card-stack { position: relative; width: 100%; min-height: 340px; }
.hero-card-stack .preview-card { position: absolute; width: min(260px, 80%); }
.hero-card-stack .preview-card:nth-child(1) { top: 0; left: 6%; transform: rotate(-8deg); }
.hero-card-stack .preview-card:nth-child(2) { top: 40px; right: 8%; transform: rotate(8deg); }
.hero-card-stack .preview-card:nth-child(3) { top: 160px; left: 28%; transform: rotate(-3deg); }
.dashboard-header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin: 1rem 0 1.2rem; flex-wrap: wrap; }
.dashboard-header.compact-gap { margin-top: 2rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; font-weight: 800; color: var(--accent); margin: 0 0 0.3rem; }
h1, h2, h3 { margin: 0 0 0.5rem; line-height: 1.15; }
h1 { font-size: clamp(2rem, 3vw, 3rem); }
h2 { font-size: clamp(1.4rem, 2vw, 2rem); }
.lead { font-size: 1.24rem; color: var(--muted); max-width: 68ch; line-height: 1.72; }
.grid { display: grid; gap: 1.2rem; margin-bottom: 1.2rem; }
.grid.two-up { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.wide-gap { gap: 1.6rem; }
.card-grid { display: grid; gap: 1rem; }
.library-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.compact-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.8rem; margin-top: 1rem; font-weight: 700; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border-radius: 999px; padding: 0.85rem 1.15rem; font-weight: 800; border: 2px solid transparent;
  cursor: pointer; text-decoration: none; font-size: 1.12rem;
  line-height: 1.58;
}

.button:hover { text-decoration: none; transform: translateY(-1px); }
.button.small { padding: 0.65rem 0.95rem; font-size: 1rem; }
.button.primary { background: var(--primary); color: var(--primary-contrast); }
.button.secondary { background: var(--secondary); color: var(--secondary-contrast); }
.button.ghost { border-color: var(--border); color: var(--text); background: transparent; }
.inline-actions, .inline-form { display: flex; gap: 0.8rem; align-items: center; }
.wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 1rem; }
.stack-form { display: grid; gap: 1rem; }
.stack-form label { display: grid; gap: 0.45rem; font-weight: 700; }
input, textarea, select {
  width: 100%; border-radius: 1rem; border: 2px solid var(--border); background: var(--panel);
  color: var(--text); padding: 0.85rem 1rem; font-size: 1.14rem;
  line-height: 1.5;
}

textarea { resize: vertical; }
.checkbox-row { display: flex !important; align-items: center; gap: 0.7rem; }
.checkbox-row input { width: auto; }
.pill-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.pill-row { display: flex; gap: 0.5rem; flex-wrap: wrap; row-gap: 0.55rem; min-width: 0; }
.pill {
  background: rgba(10, 77, 176, 0.14); color: var(--primary);
  border-radius: 999px; padding: 0.5rem 0.86rem; font-weight: 800; font-size: 1.02rem;
  border: 1px solid rgba(10, 77, 176, 0.22); overflow-wrap: anywhere; max-width: 100%;
}
.pill.alt { background: rgba(14, 124, 116, 0.16); color: var(--secondary); }
.cover-art { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 1rem; border: 1px solid var(--border); background: var(--panel-2); }
.cover-art.small { aspect-ratio: 4 / 3; min-width: 0; }
.cover-art.detail { min-height: 320px; object-fit: cover; }
.game-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.game-card .panel-body { padding-top: 0.9rem; min-width: 0; flex: 1; }
.mini-card { display: grid; gap: 0.72rem; align-content: start; border: 1px solid var(--border); border-radius: 1rem; padding: 0.95rem; background: var(--soft-surface); min-width: 0; overflow: hidden; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.8rem; min-width: 0; }
.stat-grid.compact { min-width: 0; width: min(100%, 760px); }
.stat-card { background: var(--soft-surface); border: 1px solid var(--border); border-radius: 1rem; padding: 1.05rem; display: grid; gap: 0.35rem; min-width: 0; overflow: hidden; }
.stat-card span { color: var(--muted); font-weight: 800; font-size: 1.02rem; line-height: 1.45; overflow-wrap: anywhere; }
.stat-card strong { font-size: 1.88rem; line-height: 1.08; }
.clean-list { margin: 0; padding-left: 1.1rem; }
.clean-list.spaced li { margin-bottom: 0.9rem; overflow-wrap: anywhere; line-height: 1.58; }
.mini-list { margin: 0; padding-left: 1rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 0.85rem 0.75rem; text-align: left; vertical-align: top; }
th { font-size: 1rem; font-weight: 800; }
.auth-shell { max-width: 600px; margin: 1rem auto; }
.instruction-strip { margin-bottom: 1rem; padding: 1rem 1.1rem; border-radius: 1rem; background: rgba(124, 58, 237, 0.12); color: var(--text); font-weight: 700; }
.hint-box { min-height: 3.4rem; border: 2px dashed var(--border); border-radius: 1rem; padding: 0.9rem; margin-bottom: 1rem; font-weight: 700; color: var(--muted); }
.note-feed { display: grid; gap: 0.8rem; max-height: 260px; overflow: auto; padding-right: 0.4rem; }
.note-card { border: 1px solid var(--border); border-radius: 1rem; padding: 0.85rem; background: rgba(255,255,255,0.03); }
.note-card small { color: var(--muted); }
.memory-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}
.memory-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
}
.memory-card {
  position: relative; aspect-ratio: 5 / 6; border-radius: 1.4rem;
  background: transparent; border: none; padding: 0; perspective: 1000px; cursor: pointer;
}
.preview-card { cursor: default; }
.card-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.38s ease; }
.live-card.open .card-inner, .live-card.matched .card-inner, .preview-card.front .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; border-radius: 1.4rem; backface-visibility: hidden; border: 3px solid var(--accent, var(--primary));
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 0.8rem; box-shadow: var(--shadow);
}
.card-front { background: var(--panel); color: var(--text); transform: rotateY(180deg); }
.card-back { background: linear-gradient(145deg, var(--accent, var(--primary)), var(--primary)); color: #fff; }
.live-card .card-back { background: linear-gradient(145deg, var(--accent, var(--primary)), #0F172A); }
.memory-card.matched .card-front, .matched-preview .card-face { box-shadow: 0 0 0 4px rgba(34,197,94,0.35), var(--shadow); }
.card-emoji { font-size: clamp(2.4rem, 4vw, 4.2rem); margin-bottom: 0.6rem; }
.card-label { font-size: 1.05rem; font-weight: 800; }
.card-photo { width: 78%; max-height: 58%; object-fit: cover; border-radius: 1rem; border: 1px solid var(--border); margin-bottom: 0.6rem; }
.guide-content { font-size: 1.16rem; line-height: 1.8; }
.guide-content h1, .guide-content h2, .guide-content h3 { margin-top: 1.2rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
@media (max-width: 980px) {
  .site-header { position: static; }
  .stat-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
@media (max-width: 640px) {
  .page-shell, .site-header { padding: 1rem; }
  .top-nav { justify-content: flex-start; }
  .memory-board { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

.conversation-hero-card { display:grid; gap:1rem; width:min(560px, 100%); padding:1.55rem; border-radius:1.6rem; background:linear-gradient(145deg, var(--hero-start), var(--hero-end)); color:#fff; border:1px solid rgba(255,255,255,0.18); box-shadow:var(--shadow); }
.conversation-wave { font-size:3rem; letter-spacing:0.2rem; text-shadow: 0 2px 10px rgba(0,0,0,0.18); }
.conversation-snippet { font-size:1.42rem; font-weight:800; line-height:1.56; background:var(--quote-bg); color:var(--quote-text); padding:1.15rem 1.2rem; border-radius:1rem; border:2px solid var(--quote-border); box-shadow:0 10px 24px rgba(15,23,42,0.18); overflow-wrap:anywhere; }
.conversation-pills { display:flex; gap:0.6rem; flex-wrap:wrap; }
.conversation-preview-list { display:grid; gap:0.8rem; }
.conversation-bubble { border:1px solid var(--border); border-radius:1rem; padding:0.9rem 1rem; background:rgba(255,255,255,0.03); }
.audio-control-panel { display:grid; gap:1rem; margin-bottom:1rem; }
.audio-control-panel input[type="range"] { padding:0; }
.question-board { display:grid; grid-template-columns:repeat(auto-fit, minmax(280px, 1fr)); gap:1rem; }
.question-card { border:1px solid var(--border); border-radius:1.2rem; padding:1rem; background:var(--panel); box-shadow:var(--shadow); display:grid; gap:0.8rem; }
.option-list { display:grid; gap:0.7rem; }
.option-button { text-align:left; border-radius:1rem; border:2px solid var(--border); background:var(--panel); color:var(--text); padding:0.85rem 1rem; font-size:1rem; cursor:pointer; }
.option-button.selected { border-color:var(--secondary); background:rgba(15,118,110,0.10); }
.muted { color:var(--muted); }
@media (max-width: 640px) { .question-board { grid-template-columns:1fr; } }


.premium-audio-grid { gap: 1rem; }
.assist-toolbar { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.chip-button {
  border-radius: 999px; border: 2px solid var(--border); background: var(--panel);
  color: var(--text); padding: 0.65rem 0.95rem; font-weight: 800; cursor: pointer;
}
.chip-button.active { background: rgba(15, 118, 110, 0.12); border-color: var(--secondary); color: var(--secondary); }
.compact-audio-settings { margin-top: 0.4rem; }
.support-strip {
  background: rgba(15, 61, 145, 0.08); border: 1px solid var(--border); border-radius: 1rem;
  padding: 0.9rem 1rem; font-weight: 700;
}
.session-mini-card { min-width: 140px; }
.transcript-panel .conversation-bubble { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.large-captions .transcript-panel .conversation-bubble,
.large-captions .question-card,
.large-captions .option-button {
  font-size: 1.15rem;
}
.focus-mode .question-card { opacity: 0.92; }
.focus-mode .question-card:hover,
.focus-mode .question-card:focus-within { opacity: 1; box-shadow: 0 0 0 3px rgba(15,118,110,0.22), var(--shadow); }
.mb-1 { margin-bottom: 1rem; }
@media (max-width: 640px) {
  .assist-toolbar { flex-direction: column; }
}

.toolbar-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(255,255,255,0.03);
}
.compact-header h3 { margin-bottom: 0.2rem; }
.compact-lead { font-size: 0.98rem; max-width: 56ch; }
.small-support { font-size: 0.96rem; }
.align-end { align-items: end; }
.active-filter { border-color: var(--secondary) !important; color: var(--secondary) !important; background: rgba(15,118,110,0.12) !important; }
.question-card-top { display:flex; gap:0.8rem; justify-content:space-between; align-items:flex-start; }
.review-badge {
  display:inline-flex; align-items:center; gap:0.35rem; white-space:nowrap;
  border-radius:999px; padding:0.35rem 0.7rem; font-size:0.86rem; font-weight:800;
  background:rgba(124,58,237,0.14); color:var(--accent); border:1px solid rgba(124,58,237,0.25);
}
.question-card-active { box-shadow: 0 0 0 3px rgba(15,118,110,0.22), var(--shadow); }
.filtered-out { display:none !important; }
.transcript-hit { box-shadow: 0 0 0 3px rgba(15,118,110,0.18), var(--shadow); }
@media print {
  .site-header, .site-footer, .theme-toggle, .top-nav, .disclaimer-banner, .inline-actions { display:none !important; }
  .page-shell { max-width: none; padding: 0; }
  .panel, .stat-card { box-shadow: none; background: white; color: black; }
}


/* v4 accessibility and premium legibility upgrades */
html { font-size: 18px; }
body, p, li, td, th, label, input, textarea, select, .lead, .muted, .brand-title, .brand-subtitle, .pill, .support-strip, .conversation-bubble, .option-button, .note-card, .flash, .stat-card span, .guide-content, .instruction-strip {
  overflow-wrap: anywhere;
  word-break: normal;
}
a, button, input, select, textarea { transition: box-shadow 0.16s ease, transform 0.12s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus-ring) 25%, transparent);
}
.site-header { padding: 1.25rem 1.6rem; }
.disclaimer-banner { font-size: 1rem; line-height: 1.5; }
.page-shell { padding: 1.6rem; }
.panel { border-radius: 1.55rem; }
.panel-body, .stack-form, .conversation-preview-list, .clean-list.spaced { gap: 1rem; }
.dashboard-header h1, .panel h2, .panel h3, .question-card h3, .game-card h3 { overflow-wrap: anywhere; }
.game-card { display: grid; grid-template-rows: auto 1fr; min-height: 100%; }
.game-card .panel-body { display: grid; align-content: start; gap: 0.95rem; min-height: 100%; }
.game-card h3 { font-size: 1.32rem; line-height: 1.28; }
.game-card p { font-size: 1.03rem; line-height: 1.65; margin: 0; }
.library-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: stretch; }
.cover-art { border-radius: 1.15rem; }
.cover-art, .cover-art.detail { object-position: center; }
.inline-form label, .stack-form label { font-size: 1.04rem; }
.inline-form select, .inline-form input { min-height: 3rem; }
.stat-card { padding: 1.05rem; }
.stat-card strong { font-size: 1.72rem; line-height: 1.1; }
.question-card { border-width: 2px; }
.option-button { font-size: 1.08rem; padding: 0.95rem 1rem; line-height: 1.5; }
.option-button:hover { border-color: var(--secondary); }
.support-strip, .instruction-strip, .hint-box { font-size: 1.02rem; line-height: 1.6; }
.table-wrap table { table-layout: fixed; }
th, td { font-size: 1.02rem; line-height: 1.55; overflow-wrap: anywhere; }
.guide-panel .button { min-width: 10rem; }
.voice-button, .chip-button { font-size: 1rem; }
.transcript-panel .conversation-bubble { font-size: 1.06rem; line-height: 1.7; }
.compact-header h3 { font-size: 1.22rem; }
.small-support { font-size: 1rem; }
.button.primary { background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 72%, var(--accent))); }
.button.secondary { background: linear-gradient(135deg, var(--secondary), color-mix(in srgb, var(--secondary) 72%, var(--primary))); }
.button.ghost { background: color-mix(in srgb, var(--panel) 80%, transparent); }
.button.ghost:hover, .chip-button:hover, .theme-toggle:hover { border-color: var(--primary); }
.pill-row { align-items: flex-start; }
.pill { line-height: 1.35; max-width: 100%; }
.library-card-meta, .conversation-card-title, .conversation-card-description { overflow-wrap: anywhere; }

h3 { font-size: 1.34rem; }
label { font-size: 1.06rem; }
.top-nav a, .brand-subtitle, .clean-list li, .mini-card, .stat-card, .game-card, .panel-body, .dashboard-header > div, .inline-actions, .pill-row {
  min-width: 0;
}
.mini-card strong,
.mini-card div,
.game-card h3,
.game-card p,
.clean-list li strong,
.clean-list li div,
.stat-card strong,
.stat-card span,
.conversation-card-title,
.conversation-card-description,
.hero-copy,
.hero-visual {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.mini-card strong {
  display: block;
  font-size: 1.18rem;
  line-height: 1.42;
}
.mini-card div {
  font-size: 1.06rem;
  line-height: 1.55;
}
.library-card-meta { align-items: flex-start; }
.conversation-card-title {
  font-size: 1.3rem;
  line-height: 1.38;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.conversation-card-description {
  font-size: 1.08rem;
  line-height: 1.68;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clean-list li { padding-right: 0.2rem; }
.disclaimer-banner, .flash, .instruction-strip, .hint-box { font-size: 1.06rem; line-height: 1.6; }

@media (max-width: 980px) {
  html { font-size: 17px; }
  .dashboard-header { align-items: stretch; }
  .library-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .compact-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}
@media (max-width: 640px) {
  html { font-size: 16px; }
  .brand-title { font-size: 1.5rem; }
  .brand-subtitle { font-size: 0.98rem; }
  .page-shell, .site-header { padding: 1rem; }
  .button, .theme-toggle { width: 100%; justify-content: center; }
  .top-nav { width: 100%; }
  .top-nav a { font-size: 1rem; }
}
