:root {
  --paper: #F2EBDD;
  --paper-deep: #EAE1CE;
  --ink: #1F1A17;
  --ink-soft: #5C534B;
  --sienna: #C25A3A;
  --sienna-deep: #A34428;
  --forest: #2F5147;
  --rose: #D9A89A;
  --rose-pale: #EFD9D0;
  --gold: #C8964A;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Public Sans', -apple-system, sans-serif;
}
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html, body { height:100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  position: relative;
}
.screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 90px;
  display: none;
}
.screen.active { display: block; }

/* ---------- shared ---------- */
.container { padding: 0 22px; }
.eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sienna);
}
h1.display {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
h2.section {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.2;
  margin-bottom: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  padding: 14px 24px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-sienna { background: var(--sienna); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn-block { width: 100%; }

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--forest);
  background: rgba(47,81,71,0.08);
  border: 1px solid rgba(47,81,71,0.25);
  border-radius: 100px;
  padding: 5px 12px;
}
.privacy-badge svg { width: 12px; height: 12px; }

/* ---------- header ---------- */
.app-header {
  padding: 18px 22px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}
.wordmark span { color: var(--sienna); }

/* ---------- home ---------- */
.greeting-block { padding: 18px 22px 8px; }
.greeting-block .date {
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
  letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 6px;
}
.hero-card {
  margin: 14px 22px 0;
  background: var(--forest);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s ease;
}
.hero-card:active { transform: scale(0.985); }
.hero-card .hero-art { height: 190px; position: relative; overflow: hidden; }
.hero-card .hero-art svg { width: 100%; height: 100%; display: block; }
.hero-card .hero-art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.hero-card .hero-body { padding: 18px 20px 20px; }
.hero-card .hero-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--rose); margin-bottom: 6px;
}
.hero-card .hero-title {
  font-family: var(--serif); font-weight: 600; font-size: 22px;
  line-height: 1.2; color: var(--paper); margin-bottom: 4px;
}
.hero-card .hero-meta { font-size: 13px; color: rgba(242,235,221,0.75); }
.hero-card .hero-cta {
  margin-top: 14px; display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 14px; color: var(--paper);
  border-bottom: 1.5px solid var(--rose); padding-bottom: 2px;
}

.stats-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px; margin: 20px 22px 0;
}
.stat-card {
  background: #fff;
  border: 1px solid rgba(31,26,23,0.08);
  border-radius: 16px;
  padding: 14px 12px;
  text-align: center;
}
.stat-card .num {
  font-family: var(--serif); font-weight: 700; font-size: 26px;
  line-height: 1; color: var(--ink);
}
.stat-card .num small { font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.stat-card .lbl {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-soft); margin-top: 6px;
}
.stat-card.accent { background: var(--rose-pale); border-color: rgba(194,90,58,0.2); }
.stat-card.accent .num { color: var(--sienna-deep); }

.continue-row { margin: 26px 0 0; }
.continue-row h2 { padding: 0 22px; }
.card-scroll {
  display: flex; gap: 12px; overflow-x: auto; padding: 4px 22px 8px;
  scrollbar-width: none;
}
.card-scroll::-webkit-scrollbar { display: none; }
.mini-card {
  flex: 0 0 200px; background: #fff;
  border: 1px solid rgba(31,26,23,0.08);
  border-radius: 16px; overflow: hidden; cursor: pointer;
  transition: transform .15s ease;
}
.mini-card:active { transform: scale(0.97); }
.mini-card .mini-art { height: 92px; }
.mini-card .mini-art svg { width:100%; height:100%; display:block; }
.mini-card .mini-art img { width:100%; height:100%; display:block; object-fit:cover; }
.mini-card .mini-body { padding: 12px 14px 14px; }
.mini-card .mini-eyebrow {
  font-size: 10px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--sienna); margin-bottom: 3px;
}
.mini-card .mini-title {
  font-family: var(--serif); font-weight: 600; font-size: 15px; line-height: 1.25;
}
.mini-card .mini-meta { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.mini-card.done { opacity: 0.55; }
.mini-card.done .mini-title::after { content: " ✓"; color: var(--forest); }

.quiet-test-link {
  margin: 24px 22px 10px;
  background: var(--paper-deep);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.quiet-test-link .t {
  font-family: var(--serif); font-weight: 600; font-size: 16px;
}
.quiet-test-link .s { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.quiet-test-link .arrow { font-size: 20px; color: var(--sienna); }

/* ---------- courses ---------- */
.course-card {
  margin: 0 22px 16px;
  background: #fff;
  border: 1px solid rgba(31,26,23,0.08);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s ease;
}
.course-card:active { transform: scale(0.985); }
.course-card .course-art { height: 130px; }
.course-card .course-art svg { width: 100%; height: 100%; display: block; }
.course-card .course-art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.course-card .course-body { padding: 16px 18px 18px; }
.course-card .course-title {
  font-family: var(--serif); font-weight: 600; font-size: 20px; margin-bottom: 4px;
}
.course-card .course-desc { font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; }
.course-card .course-progress {
  margin-top: 12px; display: flex; align-items: center; gap: 10px;
}
.progress-bar {
  flex: 1; height: 5px; background: var(--paper-deep); border-radius: 100px; overflow: hidden;
}
.progress-bar .fill { height: 100%; background: var(--sienna); border-radius: 100px; transition: width .4s ease; }
.course-progress .pct { font-size: 12px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }

/* ---------- course detail ---------- */
.detail-hero { height: 200px; position: relative; }
.detail-hero svg { width: 100%; height: 100%; display: block; }
.detail-hero img { width: 100%; height: 100%; display: block; object-fit: cover; }
.back-btn {
  position: absolute; top: 16px; left: 16px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(242,235,221,0.92); border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; color: var(--ink); z-index: 5;
}
.lesson-row {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 22px;
  border-bottom: 1px solid rgba(31,26,23,0.07);
  cursor: pointer;
  transition: background .15s ease;
}
.lesson-row:active { background: rgba(31,26,23,0.03); }
.lesson-row .lnum {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 50%; border: 1.5px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 600; font-size: 14px;
}
.lesson-row.done .lnum { background: var(--forest); border-color: var(--forest); color: var(--paper); }
.lesson-row .ltitle { font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.25; }
.lesson-row .lmeta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- lesson reader ---------- */
.lesson-hero { height: 250px; position: relative; }
.lesson-hero svg { width: 100%; height: 100%; display: block; }
.lesson-hero img { width: 100%; height: 100%; display: block; object-fit: cover; }
.lesson-content { padding: 22px 24px 30px; }
.lesson-content .eyebrow { margin-bottom: 8px; }
.lesson-content h1 {
  font-family: var(--serif); font-weight: 600; font-size: 27px;
  line-height: 1.18; margin-bottom: 6px;
}
.lesson-content .read-time { font-size: 13px; color: var(--ink-soft); margin-bottom: 22px; }
.lesson-content p {
  font-family: var(--serif); font-weight: 400; font-size: 17.5px;
  line-height: 1.62; margin-bottom: 18px; color: var(--ink);
}
.lesson-content p b { font-weight: 600; }
.key-concept {
  border-left: 3px solid var(--sienna);
  background: rgba(194,90,58,0.06);
  padding: 14px 18px; margin: 6px 0 22px;
  border-radius: 0 12px 12px 0;
}
.key-concept .kc-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--sienna); margin-bottom: 4px;
}
.key-concept .kc-body { font-size: 15px; line-height: 1.5; }
.lookup-block {
  margin: 6px 0 22px;
  padding: 16px 18px;
  background: rgba(47,81,71,0.06);
  border: 1px solid rgba(47,81,71,0.15);
  border-radius: 16px;
}
.lookup-block .lb-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--forest); margin-bottom: 6px;
}
.lookup-block .lb-sub { font-size: 13.5px; line-height: 1.5; color: var(--forest); margin-bottom: 12px; }
.lookup-block .lb-q {
  font-family: var(--serif); font-weight: 600; font-size: 15px; line-height: 1.35;
  padding: 10px 0 9px; border-top: 1px solid rgba(47,81,71,0.12);
}
.lookup-block .lb-q span {
  display: block; font-family: var(--sans); font-weight: 400;
  font-size: 12.5px; color: var(--ink-soft); margin-top: 3px;
}
.check-block { margin-top: 28px; }
.check-block h3 {
  font-family: var(--serif); font-weight: 600; font-size: 19px; margin-bottom: 4px;
}
.check-block .sub { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 16px; }

/* ---------- quiz ---------- */
.quiz-top { padding: 18px 22px 4px; display: flex; justify-content: space-between; align-items: center; }
.quiz-progress { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.quiz-exit { background: none; border: none; font-size: 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.quiz-q {
  font-family: var(--serif); font-weight: 500; font-size: 23px;
  line-height: 1.3; padding: 18px 24px 8px;
}
.quiz-tag { padding: 0 24px; font-size: 12px; color: var(--ink-soft); margin-bottom: 14px; }
.answers { padding: 6px 22px; display: flex; flex-direction: column; gap: 10px; }
.answer-btn {
  text-align: left; font-family: var(--sans); font-size: 15.5px; font-weight: 500;
  line-height: 1.4; padding: 15px 18px; border-radius: 14px;
  background: #fff; border: 1.5px solid rgba(31,26,23,0.12);
  cursor: pointer; transition: all .15s ease; color: var(--ink);
}
.answer-btn:active { transform: scale(0.98); }
.answer-btn.correct { background: rgba(47,81,71,0.1); border-color: var(--forest); color: var(--forest); font-weight: 600; }
.answer-btn.wrong { background: rgba(194,90,58,0.08); border-color: var(--sienna); color: var(--sienna-deep); }
.answer-btn:disabled { cursor: default; }
.quiz-feedback {
  margin: 16px 22px 0; padding: 14px 18px; border-radius: 14px;
  font-size: 14.5px; line-height: 1.5; display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.good { background: rgba(47,81,71,0.08); color: var(--forest); }
.quiz-feedback.bad { background: rgba(194,90,58,0.07); color: var(--sienna-deep); }
.quiz-next-wrap { padding: 18px 22px; }

/* results */
.results-wrap { padding: 40px 26px 20px; text-align: center; }
.results-num {
  font-family: var(--serif); font-weight: 700; font-size: 64px; line-height: 1;
  color: var(--ink);
}
.results-num small { font-size: 26px; color: var(--ink-soft); font-weight: 500; }
.results-msg {
  font-family: var(--serif); font-size: 20px; font-weight: 500;
  margin: 14px 0 8px; line-height: 1.3;
}
.results-sub { font-size: 14.5px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 28px; }

/* ---------- you ---------- */
.you-header { padding: 24px 22px 10px; }
.big-stat {
  margin: 8px 22px 14px; background: #fff;
  border: 1px solid rgba(31,26,23,0.08); border-radius: 20px;
  padding: 22px;
}
.big-stat .bs-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 8px;
}
.big-stat .bs-num {
  font-family: var(--serif); font-weight: 700; font-size: 40px; line-height: 1;
}
.big-stat .bs-num small { font-size: 20px; color: var(--ink-soft); font-weight: 500; }
.big-stat .progress-bar { margin-top: 14px; height: 7px; }
.you-note {
  margin: 20px 22px; padding: 16px 18px;
  background: rgba(47,81,71,0.06); border: 1px solid rgba(47,81,71,0.15);
  border-radius: 16px; font-size: 13.5px; line-height: 1.55; color: var(--forest);
}
.you-note b { display: block; margin-bottom: 4px; font-size: 14px; }
.reset-link {
  display: block; margin: 8px auto 0; background: none; border: none;
  font-size: 13px; color: var(--ink-soft); text-decoration: underline; cursor: pointer;
}
.about-row {
  margin: 4px 22px 18px;
  padding: 14px 4px;
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid rgba(31,26,23,0.08);
  font-size: 14.5px; font-weight: 600; color: var(--ink);
  cursor: pointer;
}
.about-row .arrow { font-size: 16px; color: var(--sienna); }

/* ---------- about ---------- */
.about-feedback { margin-top: 8px; }
.about-feedback p {
  font-family: var(--sans); font-weight: 400; font-size: 14px;
  line-height: 1.5; color: var(--ink-soft); margin-bottom: 10px;
}
.about-feedback-link {
  display: block; font-size: 14.5px; font-weight: 600;
  color: var(--sienna); text-decoration: underline; margin-bottom: 6px;
}
.about-credit {
  margin-top: 26px; font-size: 12px; color: var(--ink-soft); line-height: 1.5;
}

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(242,235,221,0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(31,26,23,0.1);
  display: flex;
  padding: 8px 0 max(14px, env(safe-area-inset-bottom));
  z-index: 50;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  color: var(--ink-soft); letter-spacing: 0.02em;
}
.nav-item svg { width: 22px; height: 22px; stroke: var(--ink-soft); fill: none; stroke-width: 1.7; }
.nav-item[data-nav="quiz"] svg { stroke-width: 2.1; }
.nav-item.active { color: var(--sienna); }
.nav-item.active svg { stroke: var(--sienna); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ==================================================================
   BETA GATE — private-beta password overlay, wraps the whole app
   ================================================================== */
.gate-screen {
  position: fixed; inset: 0; z-index: 999;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.gate-screen.gate-unlocked-instant { display: none; }
.gate-card {
  width: 100%; max-width: 380px;
  background: var(--paper-deep);
  border: 1px solid rgba(31,26,23,0.1);
  border-radius: 20px;
  padding: 30px 26px 26px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(31,26,23,0.04);
}
.gate-quill-wrap { margin-bottom: 10px; display: flex; justify-content: center; }
.gate-quill-svg { display: block; overflow: visible; }
.gate-sign-line {
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
}
.gate-quill-icon { opacity: 0; }
.gate-screen.gate-unlocking .gate-sign-line {
  animation: gateDrawLine 1.4s ease forwards;
}
.gate-screen.gate-unlocking .gate-quill-icon {
  opacity: 1;
  transition: opacity .2s ease;
}
.gate-screen.gate-unrolling {
  animation: gateUnroll .5s ease forwards;
}
.gate-screen.gate-fade-out {
  transition: opacity .3s ease;
  opacity: 0;
}
.gate-headline {
  font-family: var(--serif); font-weight: 600; font-size: 25px;
  line-height: 1.2; margin: 8px 0 6px;
}
.gate-sub { font-size: 14px; color: var(--ink-soft); line-height: 1.45; margin-bottom: 22px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; }
.gate-input {
  font-family: var(--sans); font-size: 15.5px; font-weight: 500;
  padding: 14px 16px; border-radius: 14px;
  background: #fff; border: 1.5px solid rgba(31,26,23,0.15);
  color: var(--ink); text-align: center;
  outline: none; transition: border-color .15s ease;
}
.gate-input::placeholder { color: var(--ink-soft); }
.gate-input:focus { border-color: var(--sienna); }
.gate-input.gate-shake { animation: gateShake .3s ease; }
.gate-hint { font-size: 12px; color: var(--ink-soft); margin-top: -2px; }
.gate-message {
  font-size: 13px; font-weight: 600; color: var(--sienna-deep);
  min-height: 0; opacity: 0; transition: opacity .3s ease;
}
.gate-message.show { opacity: 1; }
.gate-form .btn-primary { margin-top: 4px; }

@keyframes gateDrawLine {
  from { stroke-dashoffset: 320; }
  to { stroke-dashoffset: 0; }
}
@keyframes gateShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
@keyframes gateUnroll {
  0% { opacity: 1; transform: scaleY(1) translateY(0); }
  100% { opacity: 0; transform: scaleY(0.9) translateY(-14px); }
}

@media (prefers-reduced-motion: reduce) {
  .gate-screen.gate-unlocking .gate-sign-line,
  .gate-screen.gate-unrolling,
  .gate-input.gate-shake {
    animation: none !important;
  }
}
