:root {
  --paper: #f8f6f1;
  --surface: #ffffff;
  --ink: #25211c;
  --muted: #6b6257;
  --line: #ddd6ca;
  --teal: #16766f;
  --teal-soft: #dff1ee;
  --coral: #c94f39;
  --coral-soft: #f7dfd8;
  --gold: #a87816;
  --gold-soft: #f3e7c7;
  --plum: #5b5076;
  --plum-soft: #e8e2f4;
  --shadow: 0 12px 28px rgba(37, 33, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

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

.lesson-rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--line);
  background: #fffaf2;
  padding: 24px;
}

.brand-block h1,
.top-strip h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

.brand-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow,
.progress-label,
.section-label {
  margin: 0;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.progress-panel,
.lesson-nav-button,
.lesson-card,
.reference-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.progress-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.progress-panel strong {
  display: block;
  margin-top: 2px;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e1d4;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--coral));
  transition: width 180ms ease;
}

.lesson-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.lesson-nav-button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 12px;
  color: var(--ink);
  text-align: left;
}

.lesson-nav-button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.lesson-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--surface);
  background: var(--plum);
  font-size: 13px;
  font-weight: 800;
}

.lesson-nav-button.done .lesson-number {
  background: var(--teal);
}

.lesson-nav-title {
  display: block;
  font-weight: 800;
}

.lesson-nav-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 10px;
  border: 2px solid var(--line);
  border-radius: 999px;
}

.lesson-nav-button.done .status-dot {
  border-color: var(--teal);
  background: var(--teal);
}

.lesson-main {
  min-width: 0;
  padding: 24px;
}

.top-strip {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 1180px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-action,
.secondary-action,
.ghost-action,
.choice-button {
  min-height: 42px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-action {
  color: var(--surface);
  background: var(--teal);
}

.secondary-action {
  color: var(--teal);
  background: var(--teal-soft);
}

.ghost-action,
.choice-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.primary-action:hover,
.secondary-action:hover,
.ghost-action:hover,
.speak-button:hover,
.choice-button:hover,
.lesson-nav-button:hover {
  filter: brightness(0.98);
}

.lesson-content {
  display: grid;
  max-width: 1180px;
  margin: 0 auto;
  gap: 16px;
}

.lesson-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}

.lesson-card {
  padding: 18px;
}

.lesson-summary {
  display: grid;
  align-content: start;
  gap: 14px;
}

.lesson-summary h3,
.lesson-card h3,
.reference-panel h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.lesson-summary p,
.lesson-card p,
.reference-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--gold-soft);
  color: #5b3d00;
  font-size: 13px;
  font-weight: 800;
}

.tag.alt {
  background: var(--plum-soft);
  color: var(--plum);
}

.goal-list,
.key-list,
.seed-list,
.source-list,
.mini-list,
.practice-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.goal-list li,
.key-list li,
.source-list li,
.mini-list li,
.practice-list li {
  line-height: 1.45;
}

.guide-section {
  display: grid;
  gap: 14px;
}

.guide-section h3 {
  margin: 0;
}

.guide-section h4 {
  margin: 0;
  font-size: 15px;
}

.guide-section p {
  margin: 0;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.lesson-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: #fffdfa;
}

.lesson-table th,
.lesson-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.lesson-table th {
  color: var(--ink);
  background: #f3eee4;
  font-size: 13px;
  text-transform: uppercase;
}

.lesson-table tr:last-child td {
  border-bottom: 0;
}

.speakable-cell,
.speech-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.speakable-cell {
  justify-content: space-between;
}

.speakable-cell > span,
.speech-line > :first-child {
  min-width: 0;
}

.speak-button {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--teal);
  background: var(--teal-soft);
}

.speak-button::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.guide-card-grid,
.phrase-bank-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.guide-card,
.phrase-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdfa;
}

.guide-card {
  display: grid;
  gap: 7px;
}

.guide-card strong,
.phrase-group h4 {
  color: var(--plum);
}

.guide-card p {
  color: var(--muted);
  line-height: 1.5;
}

.phrase-group {
  display: grid;
  align-content: start;
  gap: 10px;
}

.phrase-row {
  display: grid;
  gap: 3px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.phrase-row:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.phrase-row strong {
  font-size: 17px;
}

.phrase-row span {
  color: var(--muted);
  line-height: 1.35;
}

.phrase-row em {
  color: var(--gold);
  font-size: 13px;
  font-style: normal;
  font-weight: 750;
}

.dialog-list {
  display: grid;
  gap: 10px;
}

.dialog-line {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdfa;
}

.dialog-line > span {
  color: var(--teal);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.dialog-line strong {
  display: block;
  font-size: 18px;
  line-height: 1.35;
}

.dialog-line p {
  margin-top: 5px;
  color: var(--muted);
}

.practice-list {
  counter-reset: practice;
  list-style: none;
  padding-left: 0;
}

.practice-list li {
  position: relative;
  min-height: 42px;
  padding: 10px 12px 10px 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.practice-list li::before {
  counter-increment: practice;
  content: counter(practice);
  position: absolute;
  left: 12px;
  top: 10px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 8px;
  color: var(--surface);
  background: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.callout {
  border-left: 4px solid var(--coral);
  padding: 10px 12px;
  background: var(--coral-soft);
  color: var(--ink) !important;
  font-weight: 700;
}

.example-grid,
.drill-grid,
.seed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.example,
.drill,
.seed {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdfa;
}

.tagalog {
  margin: 0;
  font-size: 20px;
  font-weight: 850;
  line-height: 1.25;
}

.english {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.note {
  margin: 10px 0 0;
  color: var(--gold);
  font-size: 14px;
  font-weight: 750;
}

.visual-board {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(22, 118, 111, 0.12), rgba(201, 79, 57, 0.10)),
    var(--surface);
  padding: 16px;
}

.visual-title {
  margin: 0 0 12px;
  font-weight: 850;
}

.letter-strip,
.number-board,
.marker-board,
.linker-board,
.aspect-board,
.phrase-board,
.plan-board,
.sentence-board {
  display: grid;
  gap: 10px;
}

.letter-strip {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.letter-tile,
.number-tile,
.marker-tile,
.aspect-tile,
.plan-tile,
.sentence-part {
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.letter-tile {
  min-height: 48px;
  text-align: center;
  font-weight: 900;
}

.letter-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.phrase-board {
  grid-template-columns: 1fr;
}

.bubble {
  width: fit-content;
  max-width: 85%;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.bubble:nth-child(even) {
  justify-self: end;
  background: var(--teal-soft);
}

.number-board {
  grid-template-columns: repeat(3, 1fr);
}

.number-tile strong,
.marker-tile strong,
.aspect-tile strong,
.plan-tile strong,
.sentence-part strong {
  display: block;
  margin-bottom: 4px;
}

.sentence-board {
  grid-template-columns: repeat(3, 1fr);
}

.sentence-part {
  min-height: 110px;
}

.sentence-part:nth-child(1) {
  border-top: 6px solid var(--coral);
}

.sentence-part:nth-child(2) {
  border-top: 6px solid var(--teal);
}

.sentence-part:nth-child(3) {
  border-top: 6px solid var(--gold);
}

.marker-board {
  grid-template-columns: repeat(3, 1fr);
}

.marker-tile:nth-child(1) {
  background: var(--teal-soft);
}

.marker-tile:nth-child(2) {
  background: var(--coral-soft);
}

.marker-tile:nth-child(3) {
  background: var(--gold-soft);
}

.linker-board,
.aspect-board,
.plan-board {
  grid-template-columns: repeat(2, 1fr);
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.choice-button.selected {
  color: var(--surface);
  background: var(--plum);
}

.choice-button.correct {
  color: var(--surface);
  background: var(--teal);
}

.choice-button.incorrect {
  color: var(--surface);
  background: var(--coral);
}

.feedback {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.seed {
  display: grid;
  gap: 5px;
}

.seed span {
  color: var(--muted);
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.reference-panel {
  padding: 18px;
}

.reference-panel a {
  color: var(--teal);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--surface);
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .lesson-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lesson-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .lesson-hero,
  .example-grid,
  .drill-grid,
  .seed-grid,
  .guide-card-grid,
  .phrase-bank-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .lesson-rail,
  .lesson-main {
    padding: 16px;
  }

  .brand-block h1,
  .top-strip h2 {
    font-size: 28px;
  }

  .top-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button,
  .secondary-action {
    flex: 1 1 auto;
  }

  .lesson-list,
  .letter-strip,
  .number-board,
  .marker-board,
  .linker-board,
  .aspect-board,
  .plan-board,
  .sentence-board {
    grid-template-columns: 1fr;
  }

  .dialog-line {
    grid-template-columns: 1fr;
  }
}
