:root {
  --paper: #f3f0e8;
  --surface: #fffefa;
  --ink: #1d2730;
  --muted: #4a555c;
  --navy: #1e2c39;
  --sage: #4e6859;
  --sage-soft: #e7eee8;
  --gold: #a9722f;
  --gold-soft: #f4e8d3;
  --line: #c5c9c7;
  --success: #355c47;
  --radius: 7px;
  --shadow: 0 14px 36px rgba(29, 39, 48, 0.09);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Arial, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); scroll-behavior: smooth; }
body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.34), transparent 250px),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 19px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { touch-action: manipulation; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 9px max(20px, env(safe-area-inset-right)) 9px max(20px, env(safe-area-inset-left));
  background: rgba(243, 240, 232, 0.96);
  backdrop-filter: blur(12px);
}
.brand { text-align: left; text-decoration: none; }
.brand-name { display: block; color: var(--navy); font-family: var(--serif); font-size: 17px; font-weight: 700; line-height: 1.1; }
.brand-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 750; line-height: 1.1; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.exit-action { border: 1px solid var(--line); background: transparent; color: var(--navy); }
.save-action { border: 1px solid var(--sage); background: var(--sage); color: #fff; }
.save-notice {
  position: fixed;
  top: 80px;
  left: 50%;
  z-index: 35;
  width: max-content;
  max-width: calc(100% - 30px);
  transform: translateX(-50%);
  border: 1px solid #8ca494;
  border-radius: var(--radius);
  padding: 11px 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--success);
  font-size: 15px;
  font-weight: 850;
  text-align: center;
}

main { width: 100%; flex: 1; }
.screen { width: min(720px, 100%); margin: 0 auto; padding: 24px 20px 52px; }
.lesson-top { margin-bottom: 24px; }
.lesson-toolbar { min-height: 48px; display: flex; align-items: center; margin-bottom: 8px; }
.step-back {
  min-height: 48px;
  border: 0;
  padding: 6px 10px 6px 0;
  background: transparent;
  color: var(--sage);
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
}
.lesson-progress { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; color: var(--muted); font-size: 16px; font-weight: 750; }
.progress-track { height: 10px; overflow: hidden; border-radius: 5px; background: #d9ded9; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--sage); transition: width 220ms ease; }

.lesson-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 25px 21px; box-shadow: 0 12px 32px rgba(29, 39, 48, 0.075); }
.intro-card { padding-top: 0; overflow: hidden; }
.sol-intro {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin: 0 -21px 26px;
  border-bottom: 1px solid var(--line);
  padding: 18px 21px;
  background: #e8e4d9;
}
.sol-intro img { width: 86px; height: 86px; border-radius: 50%; object-fit: cover; object-position: center 27%; }
.sol-intro p { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.5; }

.method-label { margin: 0 0 8px; color: var(--gold); font-size: 14px; font-weight: 850; line-height: 1.3; text-transform: uppercase; letter-spacing: 0; }
h1, h2, h3 { margin-top: 0; color: var(--navy); font-family: var(--serif); font-weight: 600; letter-spacing: 0; }
h1 { margin-bottom: 18px; font-size: clamp(37px, 10vw, 53px); line-height: 1.12; }
h2 { margin-bottom: 15px; font-size: clamp(31px, 8vw, 43px); line-height: 1.16; }
h3 { margin-bottom: 7px; font-size: 23px; line-height: 1.25; }
p { margin: 0 0 18px; }
.lead { color: var(--muted); font-size: 21px; line-height: 1.62; }
.principle { margin: 24px 0; border-left: 4px solid var(--sage); padding: 3px 0 3px 16px; color: var(--navy); font-size: 21px; font-weight: 800; }
.quiet { color: var(--muted); font-size: 17px; }
.english-word { direction: ltr; display: inline-block; font-weight: 800; }

.primary-button,
.secondary-button,
.choice-button {
  width: 100%;
  min-height: 58px;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-weight: 850;
  line-height: 1.3;
  cursor: pointer;
}
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  text-align: center;
  text-decoration: none;
}
.primary-button:hover { background: #2a3c4e; }
.primary-button:disabled { border-color: #8c969c; background: #8c969c; cursor: default; }
.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.primary-button:focus-visible,
.secondary-button:focus-visible,
.choice-button:focus-visible,
.header-action:focus-visible,
.step-back:focus-visible,
input:focus-visible,
textarea:focus-visible { outline: 3px solid rgba(169, 114, 47, 0.45); outline-offset: 2px; }
.button-space { margin-top: 28px; }
.checkout-trust {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 750;
  text-align: center;
}
.restore-access-link {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 8px 4px;
  color: var(--sage);
  font-size: 17px;
  font-weight: 850;
  line-height: 1.4;
  text-align: center;
  text-underline-offset: 4px;
}

.steps { display: grid; gap: 14px; margin: 25px 0; counter-reset: step; }
.step { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 13px; align-items: start; border-top: 1px solid var(--line); padding-top: 14px; }
.step-number { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-soft); color: var(--navy); font-weight: 900; }
.step p { margin: 4px 0 0; color: var(--muted); }

.example-box { margin: 24px 0; border: 1px solid #b8c4ba; border-radius: var(--radius); padding: 20px; background: var(--sage-soft); }
.example-box p:last-child { margin-bottom: 0; }
.visual-scene { margin: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 22px 0; color: var(--navy); font-size: 22px; }

.practice-list { display: grid; gap: 14px; margin: 22px 0; }
.practice-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: #faf9f5; }
.practice-item.done { border-color: #8ca494; background: var(--sage-soft); }
.practice-item p { margin-bottom: 12px; }
.practice-item .secondary-button { min-height: 52px; font-size: 17px; }
.practice-item.done .secondary-button { border-color: var(--sage); color: var(--success); }

.question { margin: 22px 0 28px; border-bottom: 1px solid var(--line); padding-bottom: 24px; }
.question:last-of-type { border-bottom: 0; }
.question p { margin-bottom: 12px; color: var(--navy); font-weight: 850; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-button { min-height: 52px; border: 1px solid #a7afb1; background: #fff; color: var(--ink); padding-inline: 8px; }
.choice-button.selected { border: 2px solid var(--navy); background: var(--gold-soft); }
.choice-button.correct { border-color: var(--success); background: var(--sage-soft); color: var(--success); }
.choice-button.incorrect { border-color: #9d5c50; background: #f5e8e4; color: #753c33; }

.result-box { margin: 22px 0; border: 1px solid var(--gold); border-radius: var(--radius); padding: 21px; background: var(--gold-soft); text-align: center; }
.result-number { display: block; color: var(--navy); font-size: 38px; font-weight: 900; line-height: 1.1; }
.result-box p { margin: 9px 0 0; }

.field { margin: 20px 0; }
.field label { display: block; margin-bottom: 8px; color: var(--navy); font-weight: 850; }
.field .help { display: block; margin-top: -4px; margin-bottom: 8px; color: var(--muted); font-size: 17px; }
.field input,
.field textarea {
  width: 100%;
  min-height: 56px;
  border: 1px solid #909a9e;
  border-radius: var(--radius);
  padding: 13px 14px;
  background: #fff;
  color: var(--ink);
  font-size: 19px;
}
.field textarea { min-height: 112px; resize: vertical; }
.field-error { margin-top: 8px; color: #793d34; font-size: 15px; font-weight: 700; }

.cue-card { margin: 24px 0; border: 1px solid var(--gold); border-radius: var(--radius); padding: 22px; background: linear-gradient(145deg, #fffaf0, var(--gold-soft)); }
.cue-card h3 { margin-bottom: 16px; }
.cue-row { border-top: 1px solid rgba(169,114,47,0.35); padding: 12px 0; }
.cue-row:first-of-type { border-top: 0; }
.cue-row span { display: block; color: var(--muted); font-size: 16px; font-weight: 800; }
.cue-row strong { display: block; margin-top: 4px; color: var(--navy); font-size: 20px; }

.complete-message { text-align: center; }
.complete-mark { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; background: var(--sage); color: #fff; font-size: 34px; font-weight: 900; }
.mantra { margin: 25px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 20px 0; color: var(--navy); font-size: 26px; font-weight: 900; }
.session-progress { margin: 24px 0; color: var(--success); font-weight: 850; }
.completion-section {
  margin: 27px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 21px;
  text-align: left;
}
.completion-section h3 { margin-bottom: 8px; }
.completion-section p:last-child { margin-bottom: 0; }
.memory-rule-card {
  margin: 28px 0;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 22px 20px;
  background: var(--gold-soft);
  text-align: left;
}
.memory-rule-card h3 { margin-bottom: 13px; font-size: 24px; }
.memory-rule-card blockquote {
  margin: 0;
  border-left: 4px solid var(--sage);
  padding-left: 15px;
  color: var(--navy);
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 650;
  line-height: 1.48;
}
.optional-label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}
.plain-steps {
  margin: 22px 0;
  padding-left: 26px;
}
.plain-steps li { margin: 11px 0; padding-left: 5px; }
.revealed-answer {
  border-left: 4px solid var(--sage);
  padding: 10px 0 10px 14px;
  color: var(--success);
  font-weight: 850;
}

.group-key {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 22px 0 8px;
}
.group-key span {
  border: 1px solid #b8c4ba;
  border-radius: var(--radius);
  padding: 9px 6px;
  background: var(--sage-soft);
  color: var(--navy);
  font-size: 15px;
  font-weight: 850;
  text-align: center;
}
.compact-question { margin: 12px 0; padding-bottom: 14px; }
.compact-question > p { margin-bottom: 8px; }

.organized-groups { display: grid; gap: 12px; margin: 22px 0; }
.organized-groups section {
  border: 1px solid #b8c4ba;
  border-radius: var(--radius);
  padding: 17px;
  background: var(--sage-soft);
}
.organized-groups h3 { margin-bottom: 4px; font-size: 21px; }
.organized-groups p { margin: 0; }
.comparison-box { margin: 24px 0; border-top: 1px solid var(--line); padding-top: 22px; }

.tool-list,
.combined-plan { display: grid; gap: 14px; margin: 24px 0; }
.tool-list section,
.combined-plan section {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px;
  background: #faf9f5;
}
.tool-list section > span,
.combined-plan section > span {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--navy);
  font-weight: 900;
}
.tool-list h3,
.combined-plan h3 { margin-bottom: 4px; font-size: 21px; }
.tool-list p,
.combined-plan p { margin: 0; color: var(--muted); }
.tool-question { margin: 24px 0; border-bottom: 1px solid var(--line); padding-bottom: 24px; }
.tool-question > p:first-child { color: var(--navy); font-weight: 850; }
.tool-options { display: grid; gap: 8px; }
.tool-reason { margin: 14px 0 0; border-left: 4px solid var(--sage); padding-left: 13px; }

.field select {
  width: 100%;
  min-height: 56px;
  border: 1px solid #909a9e;
  border-radius: var(--radius);
  padding: 13px 14px;
  background: #fff;
  color: var(--ink);
  font-size: 19px;
}

.unlock-card {
  margin: 28px 0 8px;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 24px 20px;
  background: linear-gradient(145deg, #fffaf0, var(--gold-soft));
  text-align: left;
}
.unlock-card h3 { font-size: 27px; }
.unlock-card ul { margin: 18px 0 24px; padding-left: 23px; }
.unlock-card li { margin: 8px 0; }
.unlock-card .quiet { margin: 12px 0 0; text-align: center; }
.text-action {
  display: inline-block;
  margin-top: 24px;
  color: var(--navy);
  font-weight: 800;
}

.source-list,
.passage-box,
.selected-sequence {
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 19px;
  background: #faf9f5;
}
.source-list p,
.passage-box p,
.selected-sequence p { margin: 0 0 11px; }
.source-list p:last-child,
.passage-box p:last-child,
.selected-sequence p:last-child { margin-bottom: 0; }

.route-grid { display: grid; gap: 9px; margin: 22px 0; }
.route-grid > div {
  display: grid;
  grid-template-columns: 38px minmax(0, 0.9fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.route-grid > div > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--navy);
  font-weight: 900;
}
.route-grid strong { color: var(--navy); font-size: 16px; }
.route-grid p { margin: 0; font-weight: 800; }

.word-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
}
.word-strip span {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #b8c4ba;
  border-radius: var(--radius);
  padding: 10px;
  background: var(--sage-soft);
  color: var(--navy);
  font-weight: 850;
  text-align: center;
}

.people-grid { display: grid; gap: 12px; margin: 22px 0; }
.people-grid section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px;
  background: #faf9f5;
}
.people-grid h3 { margin-bottom: 4px; }
.people-grid p { margin: 0 0 8px; color: var(--muted); }
.people-grid strong { color: var(--navy); }

.number-practice {
  margin: 24px 0;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 23px 19px;
  background: var(--gold-soft);
  text-align: center;
}
.number-practice p:last-child { margin-bottom: 0; }
.number-value {
  display: block;
  margin: 5px 0 17px;
  color: var(--navy);
  font-family: var(--serif);
  font-size: clamp(42px, 13vw, 62px);
  letter-spacing: 0.08em;
  line-height: 1;
}

.peg-grid { display: grid; gap: 10px; margin: 22px 0; }
.peg-grid > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #b8c4ba;
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--sage-soft);
}
.peg-grid strong { color: var(--navy); }
.peg-grid span { font-weight: 850; text-align: right; }

.future-grid { display: grid; gap: 12px; margin: 22px 0; }
.future-grid section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: #faf9f5;
}
.future-grid section p:last-child { margin-bottom: 0; }

.drawing-wrap { margin: 22px 0; }
#drawingPad {
  width: 100%;
  height: 260px;
  display: block;
  border: 2px solid #8e999a;
  border-radius: var(--radius);
  background:
    linear-gradient(#e8e3d8 1px, transparent 1px),
    linear-gradient(90deg, #e8e3d8 1px, transparent 1px),
    #fff;
  background-size: 28px 28px;
  touch-action: none;
}
.drawing-clear { min-height: 48px; margin-top: 10px; }

.sequence-buttons { display: grid; gap: 9px; margin: 20px 0; }
.sequence-buttons .choice-button { min-height: 58px; }
.sequence-buttons .choice-button:disabled { opacity: 0.45; }
.continuation-card { text-align: left; }

.memory-rules-sheet {
  margin: 30px 0 22px;
  border-top: 3px solid var(--navy);
  border-bottom: 3px solid var(--navy);
  padding: 27px 0 14px;
  text-align: left;
}
.memory-rules-sheet h3 { margin-bottom: 20px; font-size: 28px; }
.memory-rules-sheet ol { margin: 0; padding: 0; list-style: none; }
.memory-rules-sheet li {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 13px;
  border-top: 1px solid var(--line);
  padding: 15px 0;
}
.memory-rules-sheet li:first-child { border-top: 0; }
.memory-rules-sheet li span {
  color: var(--gold);
  font-size: 14px;
  font-weight: 850;
  text-transform: uppercase;
}
.memory-rules-sheet li strong {
  color: var(--navy);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.45;
}
.print-rules-button { margin-bottom: 14px; }

.app-footer { border-top: 1px solid var(--line); padding: 22px max(20px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); color: var(--muted); font-size: 14px; text-align: center; }
.app-footer p { max-width: 720px; margin: 0 auto; }

@media (min-width: 700px) {
  .screen { padding-top: 42px; }
  .lesson-card { padding: 34px; }
  .intro-card { padding-top: 0; }
  .sol-intro { margin-inline: -34px; padding-inline: 34px; }
}

@media (max-width: 390px) {
  body { font-size: 18px; }
  .screen { padding-inline: 15px; }
  .lesson-card { padding-inline: 17px; }
  .intro-card { padding-top: 0; }
  .sol-intro { grid-template-columns: 72px minmax(0, 1fr); margin-inline: -17px; padding-inline: 17px; }
  .sol-intro img { width: 72px; height: 72px; }
  .choices { gap: 6px; }
  .choice-button { font-size: 17px; }
  .compact-question .choice-button { font-size: 16px; padding-inline: 4px; }
  .route-grid > div { grid-template-columns: 34px minmax(0, 1fr); }
  .route-grid p { grid-column: 2; }
  .brand-name { font-size: 15px; }
  .brand-subtitle { font-size: 11px; }
  .header-actions { gap: 5px; }
  .header-action { min-height: 48px; padding: 7px 9px; font-size: 13px; }
  .memory-rules-sheet li { grid-template-columns: 1fr; gap: 4px; }
  .memory-rule-card blockquote { font-size: 21px; }
}

@media print {
  @page { margin: 16mm; }
  body { background: #fff; color: #111; font-size: 12pt; }
  .app-header,
  .app-footer,
  .lesson-top,
  .complete-message > * { display: none !important; }
  .screen { width: 100%; padding: 0; }
  .lesson-card { border: 0; padding: 0; box-shadow: none; }
  .complete-message > .memory-rules-sheet { display: block !important; margin: 0; border-color: #111; }
  .memory-rules-sheet li { break-inside: avoid; padding: 8px 0; }
  .memory-rules-sheet li strong { color: #111; font-size: 12pt; }
}

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