:root {
  color-scheme: light;
  --navy: #173653;
  --navy-2: #0e263d;
  --blue: #2c6fa8;
  --orange: #e97817;
  --orange-soft: #fff0e1;
  --mint: #dff1e9;
  --mint-strong: #177c69;
  --paper: #fffefa;
  --canvas: #f4f1eb;
  --ink: #152635;
  --muted: #60717f;
  --line: #d9e0e5;
  --white: #ffffff;
  --shadow: 0 18px 60px rgba(23, 54, 83, 0.11);
  --radius-lg: 28px;
  --radius-md: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Avenir Next", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

html[data-text-size="large"] { font-size: 17px; }
html[data-text-size="xlarge"] { font-size: 19px; }
.dark-mode { --paper:#172838; --canvas:#0d1c29; --ink:#edf4f7; --muted:#a8bac7; --line:#344858; --white:#203444; color-scheme:dark; }
.dark-mode .topbar { background:rgba(13,28,41,.9); }
.dark-mode .phrase-row, .dark-mode .choice, .dark-mode .field input, .dark-mode .field textarea, .dark-mode .letter-button { background:#1b2d3d; }
.dark-mode #ink-pad { filter:brightness(.85); }

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 28px 22px 24px;
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--orange);
  color: var(--white);
  font-size: 20px;
  font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -0.02em; }
.brand small { color: #b9cad7; margin-top: 2px; font-size: 12px; }

.progress-card {
  margin: 28px 0 20px;
  padding: 17px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.07);
}

.primary-nav { display:grid; gap:5px; margin-top:22px; }
.primary-nav a { min-height:42px; padding:10px 12px; display:flex; align-items:center; gap:10px; border-radius:12px; color:#dce7ee; text-decoration:none; font-size:13px; font-weight:800; }
.primary-nav a:hover, .primary-nav a.active { background:rgba(255,255,255,.11); color:white; }
.primary-nav a b { margin-left:auto; min-width:23px; padding:3px 6px; border-radius:99px; background:var(--orange); text-align:center; font-size:9px; }

.progress-copy { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.progress-copy span { color: #c1d0dc; }
.progress-track { height: 7px; margin: 12px 0 10px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.12); }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--orange); transition: width .3s ease; }
.progress-card p { margin: 0; color: #afc2cf; font-size: 11px; line-height: 1.45; }

.day-nav { display: grid; gap: 5px; }
.week-nav { margin-bottom: 10px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.week-link { min-height: 34px; padding: 5px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: transparent; color: #9fb5c5; cursor: pointer; font-size: 10px; font-weight: 900; }
.week-link.active { border-color: rgba(255,255,255,.24); background: var(--orange); color: white; }
.day-link {
  border: 0;
  width: 100%;
  min-height: 52px;
  padding: 7px 10px;
  border-radius: 14px;
  display: grid;
  grid-template-columns: 36px 1fr 22px;
  align-items: center;
  gap: 9px;
  background: transparent;
  color: #dce7ee;
  cursor: pointer;
  text-align: left;
}
.day-link:hover { background: rgba(255,255,255,.07); }
.day-link.active { color: var(--white); background: rgba(255,255,255,.12); }
.day-link .day-num { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.08); font-weight: 800; }
.day-link.active .day-num { background: var(--orange); }
.day-link span:nth-child(2) strong, .day-link span:nth-child(2) small { display: block; }
.day-link span:nth-child(2) strong { font-size: 13px; }
.day-link span:nth-child(2) small { color: #9fb5c5; margin-top: 2px; font-size: 10px; }
.day-link .day-check { color: #92d1c2; font-size: 16px; }

.sidebar-actions { margin-top: auto; padding-top: 20px; display: grid; gap: 5px; }
.quiet-button {
  min-height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #c6d5df;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
}
.quiet-button:hover { background: rgba(255,255,255,.07); color: white; }

.main-area { min-width: 0; }
.topbar {
  min-height: 82px;
  padding: 16px clamp(24px, 5vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-bottom: 1px solid rgba(23,54,83,.08);
  background: rgba(244, 241, 235, .88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar strong { display: block; color: var(--navy); font-size: 18px; }
.week-select { min-height:40px; padding:7px 30px 7px 11px; border:1px solid var(--line); border-radius:12px; background:var(--paper); color:var(--navy); font-size:11px; font-weight:800; }
.eyebrow { display: block; margin-bottom: 2px; color: var(--orange); text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.top-icon-button { min-height:42px; padding:9px 13px; border:1px solid var(--line); border-radius:13px; background:var(--paper); color:var(--navy); cursor:pointer; font-size:11px; font-weight:800; }
.mobile-more-button { display: none; }
.helper-toggle { min-height: 44px; padding: 7px 12px; display: flex; align-items: center; gap: 9px; border-radius: 14px; color: var(--navy); background: var(--white); box-shadow: 0 4px 15px rgba(23,54,83,.06); cursor: pointer; font-size: 12px; font-weight: 700; }
.helper-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 37px; height: 22px; padding: 3px; border-radius: 99px; background: #bac5cd; transition: background .2s ease; }
.toggle-track span { display: block; width: 16px; height: 16px; border-radius: 50%; background: white; transition: transform .2s ease; box-shadow: 0 1px 5px rgba(0,0,0,.18); }
.helper-toggle input:checked + .toggle-track { background: var(--mint-strong); }
.helper-toggle input:checked + .toggle-track span { transform: translateX(15px); }
.install-button, .primary-button, .complete-button {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--navy);
  color: var(--white);
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 7px 18px rgba(23,54,83,.15);
}
.install-button:hover, .primary-button:hover { background: var(--navy-2); }

.lesson { width: min(100%, 990px); margin: 0 auto; padding: 34px clamp(24px, 5vw, 64px) 100px; }
.lesson-hero {
  position: relative;
  overflow: hidden;
  min-height: 215px;
  padding: clamp(24px, 4vw, 42px);
  border-radius: var(--radius-lg);
  background: var(--navy);
  color: var(--white);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 30px;
}
.bookmark-button { position:absolute; z-index:2; top:20px; right:20px; width:44px; height:44px; border:1px solid rgba(255,255,255,.2); border-radius:14px; background:rgba(255,255,255,.08); color:white; cursor:pointer; font-size:23px; }
.bookmark-button.saved { background:var(--orange); border-color:var(--orange); }
.lesson-hero::after {
  content: "";
  position: absolute;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  right: -120px;
  top: -150px;
  border: 55px solid rgba(255,255,255,.045);
}
.lesson-hero .day-label { color: #f9b77c; text-transform: uppercase; font-size: 11px; font-weight: 900; letter-spacing: .13em; }
.lesson-hero h1 { margin: 8px 0 5px; font-size: clamp(34px, 5vw, 60px); line-height: .98; letter-spacing: -.045em; }
.lesson-hero .translation { color: #c4d6e2; font-size: 15px; }
.lesson-hero p { max-width: 590px; margin: 25px 0 0; color: #e5eef3; font-size: 16px; line-height: 1.55; }
.hero-count { align-self: end; min-width: 92px; padding: 14px; border-radius: 18px; background: var(--orange); color: white; text-align: center; }
.hero-count strong { display: block; font-size: 33px; line-height: 1; }
.hero-count span { display: block; margin-top: 6px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

.lesson-flow { display: grid; gap: 20px; margin-top: 28px; }
.card {
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid rgba(23,54,83,.08);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: 0 9px 30px rgba(23,54,83,.055);
}
.card-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-kicker { display: block; margin-bottom: 5px; color: var(--mint-strong); font-size: 10px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.card h2 { margin: 0; color: var(--navy); font-size: clamp(21px, 3vw, 29px); letter-spacing: -.025em; }
.card p { color: var(--muted); line-height: 1.55; }
.mini-note { max-width: 250px; margin: 0 !important; font-size: 11px; text-align: right; }

.alphabet-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.letter-button {
  min-height: 91px;
  padding: 10px 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fafb;
  cursor: pointer;
  text-align: center;
}
.letter-button:active { transform: scale(.98); }
.letter-button strong { display: block; color: var(--navy); font-size: 25px; }
.letter-button span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.letter-button small { display: block; margin-top: 3px; color: var(--orange); font-size: 9px; font-weight: 800; }

.phrase-list { display: grid; gap: 9px; }
.phrase-row {
  min-height: 64px;
  padding: 10px 12px 10px 16px;
  display: grid;
  grid-template-columns: minmax(145px, .8fr) 48px minmax(180px, 1.2fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfc;
}
.phrase-row .greek { color: var(--navy); font-size: 18px; font-weight: 800; }
.phrase-row .english { color: var(--muted); font-size: 12px; }
.reveal-helper summary { cursor:pointer; color:var(--orange); font-size:11px; font-weight:800; }
.reveal-helper span { display:block; margin-top:5px; }
.phrase-row .cue { display: block; margin-top: 2px; color: var(--orange); font-size: 9px; font-weight: 800; letter-spacing: .02em; }
.speak-button, .icon-button {
  width: 42px;
  height: 42px;
  padding: 10px;
  border: 0;
  border-radius: 13px;
  background: var(--mint);
  color: var(--mint-strong);
  cursor: pointer;
}
.speak-button svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.speak-button.speaking { background: var(--orange-soft); color: var(--orange); }

.sound-grid, .mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.sound-card { padding: 16px; border-radius: 16px; background: #f6f8f9; border: 1px solid var(--line); }
.sound-card strong { display: block; color: var(--navy); font-size: 23px; }
.sound-card span { color: var(--orange); font-size: 12px; font-weight: 800; }
.sound-card small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.35; }

.dialogue { padding: 20px; border-radius: 18px; background: #eff5f8; }
.dialogue-line { display: flex; gap: 12px; margin: 10px 0; align-items: start; }
.dialogue-line b { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: var(--navy); color: white; font-size: 11px; }
.dialogue-line span { padding-top: 3px; color: var(--navy); font-size: 17px; font-weight: 700; }

.quiz-list { display: grid; gap: 16px; }
.question { padding: 18px; border: 1px solid var(--line); border-radius: 18px; }
.question h3 { margin: 0 0 13px; color: var(--navy); font-size: 15px; line-height: 1.4; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  min-height: 45px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.choice:hover { border-color: var(--blue); }
.choice.selected { border-color: var(--blue); background: #e9f3fa; color: var(--navy); }
.choice.correct { border-color: #5aae94; background: var(--mint); color: #0e6857; }
.choice.wrong { border-color: #e69b79; background: var(--orange-soft); color: #9e4316; }
.feedback { margin: 10px 0 0 !important; font-size: 12px; font-weight: 700; }
.feedback.correct { color: var(--mint-strong); }
.feedback.wrong { color: #b35323; }

.helper-panel { padding: 16px 18px; border-left: 4px solid var(--orange); border-radius: 0 14px 14px 0; background: var(--orange-soft); }
.helper-panel strong { color: #a64513; }
.helper-content { transition: opacity .2s ease; }
.hide-helpers .helper-content { display: none !important; }

.writing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--navy); font-size: 12px; font-weight: 800; }
.field input, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcfc;
  color: var(--ink);
  outline: none;
}
.field textarea { min-height: 112px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44,111,168,.11); }

.ink-wrap { margin-top: 16px; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: white; }
.ink-toolbar { min-height: 46px; padding: 7px 10px 7px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: #f7f8f8; }
.ink-toolbar span { color: var(--muted); font-size: 11px; font-weight: 700; }
.clear-ink { min-height: 34px; padding: 6px 10px; border: 0; border-radius: 10px; background: white; color: var(--navy); cursor: pointer; font-size: 11px; font-weight: 800; }
#ink-pad { display: block; width: 100%; height: 190px; background: repeating-linear-gradient(white 0, white 37px, #e7ecef 38px); touch-action: none; }

.verb-table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; }
.verb-table th, .verb-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
.verb-table th { background: var(--navy); color: white; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.verb-table tr:last-child td { border-bottom: 0; }
.verb-table td:nth-child(2) { color: var(--navy); font-weight: 800; }

.lesson-footer { margin-top: 20px; padding: 22px; border-radius: var(--radius-lg); background: var(--mint); display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.lesson-footer h3 { margin: 0 0 4px; color: var(--navy); }
.lesson-footer p { margin: 0; color: var(--muted); font-size: 12px; }
.complete-button { min-width: 190px; background: var(--mint-strong); }
.complete-button.completed { background: var(--navy); }
.footer-actions { display:grid; gap:9px; min-width:220px; }
.lesson-pager { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
.lesson-pager button { min-height:38px; border:1px solid rgba(23,54,83,.15); border-radius:11px; background:rgba(255,255,255,.5); color:var(--navy); cursor:pointer; font-size:10px; font-weight:800; }
.lesson-pager button:disabled { opacity:.35; }

.checkpoint-score { padding: 25px; border-radius: 20px; background: var(--navy); color: white; text-align: center; }
.checkpoint-score strong { display: block; font-size: 50px; line-height: 1; }
.checkpoint-score span { display: block; margin-top: 8px; color: #bfd0dc; }

.mobile-day-nav { display: none; }
.nonlesson-view .mobile-day-nav { display:none !important; }

.dashboard, .review-page { display:grid; gap:22px; }
.dashboard-hero { min-height:210px; padding:36px; display:flex; align-items:center; justify-content:space-between; gap:28px; border-radius:var(--radius-lg); background:linear-gradient(135deg,var(--navy),#245b7c); color:white; box-shadow:var(--shadow); }
.dashboard-hero h1 { margin:6px 0; font-size:clamp(38px,6vw,66px); letter-spacing:-.05em; }
.dashboard-hero p { margin:0; color:#d8e5ec; }
.streak-orb { width:116px; height:116px; display:grid; place-content:center; flex:0 0 auto; border:12px solid rgba(255,255,255,.12); border-top-color:var(--orange); border-radius:50%; text-align:center; }
.streak-orb strong { font-size:34px; line-height:1; }
.streak-orb span { margin-top:5px; color:#d8e5ec; font-size:9px; font-weight:800; text-transform:uppercase; }
.dashboard-grid { display:grid; grid-template-columns:1.5fr 1fr; gap:18px; }
.dashboard-card { padding:26px; border:1px solid var(--line); border-radius:24px; background:var(--paper); box-shadow:0 9px 30px rgba(23,54,83,.055); }
.dashboard-card h2 { margin:5px 0 9px; color:var(--navy); }
.dashboard-card p { color:var(--muted); line-height:1.5; }
.dashboard-actions { display:flex; align-items:center; gap:14px; margin-top:20px; }
.dashboard-actions span { color:var(--muted); font-size:11px; }
.review-summary > strong { display:block; color:var(--orange); font-size:54px; line-height:1; }
.course-stat strong { color:var(--navy); font-size:52px; }
.course-stat span { margin-left:8px; color:var(--muted); }
.mastery-ring { width:105px; height:105px; display:grid; place-items:center; border-radius:50%; background:conic-gradient(var(--mint-strong) var(--mastery),var(--line) 0); position:relative; }
.mastery-ring::after { content:""; position:absolute; inset:10px; border-radius:50%; background:var(--paper); }
.mastery-ring strong { z-index:1; color:var(--navy); }
.bookmark-list { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
.bookmark-list button { padding:14px; border:1px solid var(--line); border-radius:14px; background:var(--canvas); text-align:left; cursor:pointer; }
.bookmark-list span,.bookmark-list strong { display:block; }
.bookmark-list span { color:var(--orange); font-size:9px; font-weight:800; }
.bookmark-list strong { margin-top:3px; color:var(--navy); }
.empty-state { min-height:60vh; display:grid; place-items:center; align-content:center; text-align:center; }
.empty-state .empty-icon { width:82px; height:82px; display:grid; place-items:center; border-radius:50%; background:var(--mint); color:var(--mint-strong); font-size:37px; }
.empty-state h1 { margin:18px 0 4px; color:var(--navy); }
.empty-state p { max-width:430px; color:var(--muted); }
.review-page header h1 { color:var(--navy); }
.review-card { min-height:390px; padding:42px; display:grid; place-items:center; align-content:center; gap:18px; border-radius:30px; background:var(--navy); color:white; text-align:center; box-shadow:var(--shadow); }
.review-card > span { color:#bcd0dc; font-size:10px; font-weight:900; text-transform:uppercase; }
.review-card > strong { font-size:clamp(32px,6vw,62px); }
.review-card details { width:100%; margin-top:10px; }
.review-card summary { cursor:pointer; color:#ffd1aa; font-weight:800; }
.review-card details p { font-size:20px; }
.review-ratings { display:flex; justify-content:center; gap:9px; }
.review-ratings button,.small-action { min-height:42px; padding:9px 14px; border:1px solid var(--line); border-radius:12px; background:var(--paper); color:var(--navy); cursor:pointer; font-size:11px; font-weight:800; }

.match-grid { display:grid; grid-template-columns:1fr 1fr; gap:9px; }
.match-grid button,.order-bank button { min-height:44px; padding:10px; border:1px solid var(--line); border-radius:12px; background:var(--white); cursor:pointer; }
.match-grid button.selected { outline:3px solid rgba(44,111,168,.2); }
.match-grid button.correct,.order-answer.correct { background:var(--mint); color:var(--mint-strong); }
.match-grid button.wrong,.order-answer.wrong { background:var(--orange-soft); color:#9e4316; }
.order-bank { display:flex; flex-wrap:wrap; gap:7px; }
.order-answer { min-height:58px; margin:12px 0; padding:15px; border:2px dashed var(--line); border-radius:13px; color:var(--navy); font-weight:800; }
.mission-card { padding:20px; border-radius:18px; background:var(--mint); }
.mission-card label { display:flex; align-items:center; gap:9px; color:var(--navy); font-weight:800; }
.dictation-box,.gap-box { display:grid; gap:12px; }
.recorder-panel { padding:18px; display:grid; grid-template-columns:1fr auto; gap:14px; align-items:center; border-radius:18px; background:#eff5f8; }
.recorder-panel p { margin:3px 0; font-size:11px; }
.recorder-actions { display:flex; gap:8px; }
.recorder-panel audio,.recorder-panel [data-record-status] { grid-column:1/-1; width:100%; }
.recorder-panel [data-record-status] { color:var(--muted); font-size:11px; }

.settings-list { padding:18px 24px; display:grid; gap:8px; }
.settings-list label { min-height:62px; padding:12px; display:flex; align-items:center; justify-content:space-between; gap:20px; border:1px solid var(--line); border-radius:14px; }
.settings-list strong,.settings-list small { display:block; }
.settings-list small { margin-top:3px; color:var(--muted); }
.settings-list select { min-height:40px; border:1px solid var(--line); border-radius:10px; background:var(--paper); color:var(--ink); }
.stacked-actions { display:grid; gap:7px; }
.stacked-actions .quiet-button { color:var(--navy); border:1px solid var(--line); }
.stacked-actions .danger { color:#9e4316; }
.auth-form,.signed-in-panel { padding:24px; display:grid; gap:14px; }
.auth-form label { display:grid; gap:6px; color:var(--navy); font-size:12px; font-weight:800; }
.auth-form input { min-height:48px; padding:12px; border:1px solid var(--line); border-radius:12px; background:var(--paper); color:var(--ink); }
.text-button { border:0; background:transparent; color:var(--blue); cursor:pointer; font-weight:800; }
.form-message { min-height:18px; margin:0; color:var(--orange); font-size:11px; }
.auth-preview-note { margin:18px 24px 0; padding:14px; border-radius:13px; background:var(--orange-soft); color:#8c451c; font-size:12px; line-height:1.5; }
.auth-gate { position:fixed; z-index:100; inset:0; display:grid; place-items:center; padding:22px; background:linear-gradient(145deg,var(--navy-2),var(--navy)); }
.auth-gate[hidden] { display:none; }
.auth-gate-card { width:min(430px,100%); padding:40px; border-radius:28px; background:var(--paper); text-align:center; box-shadow:0 30px 90px rgba(0,0,0,.3); }
.auth-gate-card .brand-mark { margin:0 auto 22px; }
.auth-gate-card h1 { margin:8px 0; color:var(--navy); font-size:44px; }
.auth-gate-card p { color:var(--muted); line-height:1.55; }
.auth-gate-card button { display:block; width:100%; margin-top:10px; }
.legal-page { width:min(760px,calc(100% - 36px)); margin:50px auto; padding:36px; border-radius:28px; background:var(--paper); box-shadow:var(--shadow); }
.legal-page h1,.legal-page h2 { color:var(--navy); }
.legal-page p { color:var(--muted); line-height:1.7; }

dialog {
  width: min(620px, calc(100% - 34px));
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(14,38,61,.28);
}
dialog::backdrop { background: rgba(8,24,38,.55); backdrop-filter: blur(5px); }
.dialog-head { padding: 24px; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; color: var(--navy); }
.icon-button { color: var(--navy); font-size: 21px; line-height: 1; }
.resource-list { padding: 14px; display: grid; gap: 7px; }
.resource-list a { padding: 14px; border-radius: 14px; color: var(--navy); text-decoration: none; background: #f4f7f8; }
.resource-list strong, .resource-list span { display: block; }
.resource-list span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.dialog-note { margin: 0; padding: 0 26px 25px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.dialog-actions { padding: 0 24px 24px; }
.reset-button { min-height: 42px; padding: 9px 13px; border: 1px solid #e5b79f; border-radius: 12px; background: var(--orange-soft); color: #9e4316; cursor: pointer; font-size: 11px; font-weight: 800; }
.install-steps { margin: 0; padding: 24px 48px; display: grid; gap: 12px; color: var(--navy); }

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 236px minmax(0, 1fr); }
  .sidebar { padding-inline: 16px; }
  .alphabet-grid { grid-template-columns: repeat(4, 1fr); }
  .lesson { padding-inline: 30px; }
  .topbar { padding-inline: 30px; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { min-height: 72px; padding: 10px 18px; top: 0; }
  .topbar .eyebrow { display: none; }
  .course-heading { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .course-heading strong { white-space: nowrap; font-size: 15px; }
  .week-select { display: block; min-height: 40px; padding: 7px 25px 7px 9px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--navy); font-size: 11px; font-weight: 800; }
  .topbar-actions { gap: 7px; }
  .mobile-more-button { width: 42px; min-width: 42px; height: 42px; padding: 0 0 7px; display: block; border: 0; border-radius: 13px; background: white; color: var(--navy); cursor: pointer; font-size: 18px; font-weight: 900; letter-spacing: 1px; box-shadow: 0 4px 15px rgba(23,54,83,.06); }
  .helper-toggle { padding-inline: 9px; }
  .helper-toggle > span:last-child { display: none; }
  .install-button { padding-inline: 12px; font-size: 11px; }
  .top-icon-button { display:none; }
  .lesson { padding: 20px 18px calc(100px + var(--safe-bottom)); }
  .lesson-hero { min-height: 190px; padding: 25px; }
  .lesson-hero h1 { font-size: 42px; }
  .lesson-hero p { margin-top: 18px; font-size: 14px; }
  .hero-count { display: none; }
  .alphabet-grid { grid-template-columns: repeat(4, 1fr); }
  .sound-grid, .mini-grid { grid-template-columns: repeat(2, 1fr); }
  .phrase-row { grid-template-columns: 1fr 48px; }
  .phrase-row .english { grid-column: 1 / -1; padding-bottom: 4px; }
  .writing-grid { grid-template-columns: 1fr; }
  .lesson-footer { align-items: stretch; flex-direction: column; }
  .complete-button { width: 100%; }
  .dashboard-grid { grid-template-columns:1fr; }
  .dashboard-hero { padding:26px; }
  .dashboard-hero h1 { font-size:44px; }
  .streak-orb { width:92px; height:92px; border-width:9px; }
  .bookmark-list { grid-template-columns:1fr; }
  .recorder-panel { grid-template-columns:1fr; }
  .recorder-actions,.recorder-panel audio,.recorder-panel [data-record-status] { grid-column:1; }
  .mobile-day-nav {
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: calc(70px + var(--safe-bottom));
    padding: 8px 12px var(--safe-bottom);
    display: flex;
    gap: 7px;
    overflow-x: auto;
    background: rgba(255,255,255,.92);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(18px);
  }
  .mobile-day-nav .mobile-day {
    flex: 1 0 64px;
    min-width: 64px;
    min-height: 52px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    font-weight: 800;
  }
  .mobile-day span { display: block; margin-bottom: 2px; font-size: 17px; }
  .mobile-day.active { color: white; background: var(--navy); }
  .mobile-day.completed:not(.active) { color: var(--mint-strong); background: var(--mint); }
}

@media (max-width: 520px) {
  .course-heading strong { display: none; }
  .alphabet-grid { grid-template-columns: repeat(3, 1fr); }
  .card { padding: 18px; border-radius: 22px; }
  .card-head { display: block; }
  .mini-note { max-width: none; margin-top: 7px !important; text-align: left; }
  .sound-grid, .mini-grid { grid-template-columns: 1fr; }
  .lesson-hero { border-radius: 22px; }
  .dashboard-hero { align-items:flex-start; }
  .streak-orb { width:78px; height:78px; }
  .streak-orb strong { font-size:25px; }
  .match-grid { grid-template-columns:1fr; }
  .settings-list label { align-items:flex-start; flex-direction:column; }
}

@media print {
  .sidebar, .topbar, .mobile-day-nav, .speak-button, .lesson-footer, dialog { display: none !important; }
  .app-shell { display: block; }
  .lesson { width: 100%; padding: 0; }
  .card, .lesson-hero { box-shadow: none; break-inside: avoid; }
}
