:root {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --sage: #3D6B5E;
  --sage-dark: #2F5D50;
  --sage-soft: #EBF3F0;
  --slate: #3B6278;
  --slate-soft: #EBF1F5;
  --terra: #CF6F4E;
  --terra-soft: #FBEFE9;
  --ochre: #D9A14A;
  --ochre-soft: #FDF5E6;
  --ink: #232A2E;
  --muted: #636E75;
  --border: #E5DFD6;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(35, 42, 46, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

h1, h2, h3, .brand-title {
  font-family: "Nunito", "Inter", sans-serif;
  margin: 0;
}

.word-font {
  font-family: "Andika", "Nunito", sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* Top Combo Banner (auto-hidden when all unlocked) */
.combo-banner {
  background: linear-gradient(90deg, var(--sage) 0%, var(--slate) 100%);
  color: #FFFFFF;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  line-height: 1.3;
}
.combo-banner.hidden { display: none !important; }
.combo-banner a {
  background: #FFFFFF;
  color: var(--sage-dark);
  text-decoration: none;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 12px;
}

/* Install Bar */
.install-bar {
  background: var(--ochre-soft);
  border-bottom: 1px solid #EFE0C0;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--ink);
}
.install-bar.hidden { display: none !important; }
.install-actions { display: flex; gap: 6px; align-items: center; }
.btn-install {
  background: var(--sage);
  color: #FFF;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.btn-dismiss {
  color: var(--muted);
  font-size: 16px;
  padding: 2px 6px;
}

/* App Shell */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(250, 247, 242, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 10px;
}
.header-top {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(61, 107, 94, 0.2);
}
.brand-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--sage);
  line-height: 1.1;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gamify-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.pill-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
}
.pill-stat.stars { border-color: #EBD2A0; background: var(--ochre-soft); }

/* Nav Tabs */
.nav-scroll {
  max-width: 960px;
  margin: 10px auto 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.nav-scroll::-webkit-scrollbar { display: none; }
.nav-tab {
  flex: 0 0 auto;
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.nav-tab.active {
  background: var(--sage);
  color: #FFFFFF;
  border-color: var(--sage);
  box-shadow: 0 4px 12px rgba(61, 107, 94, 0.22);
}
.nav-tab.pro-tab {
  border-color: #DFC8A2;
  background: #FFFDF8;
  color: #7A5416;
}
.nav-tab.pro-tab.active {
  background: var(--ochre);
  color: #FFFFFF;
  border-color: var(--ochre);
}
.nav-tab.pro-unlocked {
  border-color: #B9D5CA;
  background: var(--sage-soft);
  color: var(--sage-dark);
}

/* Main Content */
.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

.section-intro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.section-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage-dark);
  margin-bottom: 8px;
}
.section-badge.terra { background: var(--terra-soft); color: #9F492C; }
.section-badge.slate { background: var(--slate-soft); color: var(--slate); }
.section-badge.ochre { background: var(--ochre-soft); color: #8C6018; }
.section-intro h2 {
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 6px;
}
.section-intro p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

/* Filter Chips */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.chip.active {
  background: var(--slate);
  border-color: var(--slate);
  color: #FFFFFF;
}

/* 1:1 Square Card Grid (APP-PWA-UNLOCK-001 Strict) */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 640px) {
  .cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
}
@media (min-width: 880px) {
  .cards-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.flash-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.14s ease, border-color 0.14s ease;
  text-align: center;
}
.flash-card:active { transform: scale(0.98); }
.flash-card.playing {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(61, 107, 94, 0.18);
}

.card-thumb-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #FFFFFF;
  border-radius: 13px;
  border: 1px solid #EFECE6;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.card-thumb {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
}
.card-word {
  font-family: "Andika", "Nunito", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.card-sound {
  font-size: 13px;
  font-weight: 800;
  color: var(--terra);
  margin-top: -3px;
}
.card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}
.btn-audio {
  flex: 1;
  background: var(--sage);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 12.5px;
  padding: 8px 8px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.btn-audio:hover { background: var(--sage-dark); }
.btn-zoom {
  background: var(--bg);
  color: var(--slate);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 11px;
}

/* Minimal Pairs Module */
.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.pair-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.pair-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--slate);
  margin-bottom: 10px;
}
.pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pair-card {
  background: #FFFFFF;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pair-card.left { border-color: #B7CBD7; }
.pair-card.right { border-color: #E7BEA9; }
.pair-card.correct { border-color: var(--sage); background: var(--sage-soft); }
.pair-card.wrong { border-color: var(--terra); background: var(--terra-soft); }
.hl-char { color: var(--terra); font-weight: 900; }

.quiz-box {
  background: var(--surface);
  border: 2px solid var(--slate);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.btn-primary {
  background: var(--sage);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 14.5px;
  padding: 12px 20px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.btn-primary:hover { background: var(--sage-dark); }
.btn-secondary {
  background: var(--surface);
  color: var(--sage-dark);
  border: 1.5px solid var(--sage);
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

/* Syllable Clapping Game */
.syllable-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
}
.syllable-card.done {
  border-color: var(--sage);
  background: #F4FAF7;
}
.syl-thumb {
  width: 88px;
  height: 88px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #FFFFFF;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 4px;
}
.syl-circles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 6px;
}
.syl-btn {
  min-width: 50px;
  height: 50px;
  padding: 0 12px;
  border-radius: 999px;
  border: 2px solid var(--slate);
  background: #FFFFFF;
  color: var(--ink);
  font-family: "Andika", "Nunito", sans-serif;
  font-size: 17px;
  font-weight: 700;
  transition: all 0.16s ease;
}
.syl-btn.tapped {
  background: var(--ochre);
  border-color: var(--ochre);
  color: #FFFFFF;
  transform: scale(1.06);
}

/* Routines Checklist */
.routine-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: all 0.16s ease;
}
.routine-item.checked {
  border-color: var(--sage);
  background: var(--sage-soft);
}
.routine-thumb {
  width: 64px;
  height: 64px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.routine-info { flex: 1; min-width: 0; }
.routine-step-num {
  font-size: 11px;
  font-weight: 800;
  color: var(--sage);
  text-transform: uppercase;
}
.routine-label {
  font-family: "Andika", "Nunito", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.routine-star-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #FFFFFF;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.routine-item.checked .routine-star-btn {
  background: var(--ochre);
  border-color: var(--ochre);
  color: #FFFFFF;
}

/* 10 Min Timer */
.timer-card {
  background: var(--surface);
  border: 2px solid var(--sage);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.timer-clock {
  font-family: "Nunito", sans-serif;
  font-size: 46px;
  font-weight: 900;
  color: var(--sage);
  letter-spacing: 0.03em;
  margin: 8px 0;
}
.timer-phase {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ochre-soft);
  color: #825711;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}
.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #EAE5DC;
  overflow: hidden;
  margin: 10px 0 16px;
}
.progress-fill {
  height: 100%;
  background: var(--sage);
  width: 0%;
  transition: width 0.3s linear;
}

/* A4 Sheets Gallery */
.sheets-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 640px) {
  .sheets-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.sheet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sheet-preview {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #EEE9E0;
}
.sheet-meta { font-size: 12.5px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.sheet-tag { font-size: 11px; font-weight: 700; color: var(--sage); }

/* PRO Locked Gate & Unlock Form */
.pro-gate {
  background: var(--surface);
  border: 2px solid #E5CFA7;
  border-radius: 20px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.pro-lock-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--ochre-soft);
  color: #9A6612;
  font-size: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.unlock-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}
.unlock-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.input-field {
  flex: 1;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  font-size: 14px;
  background: #FFFFFF;
  color: var(--ink);
  min-width: 0;
}
.input-field:focus { outline: none; border-color: var(--sage); }

/* Evolution Log (UP3) */
.log-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.log-entry {
  background: var(--surface);
  border-left: 4px solid var(--sage);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 30, 34, 0.72);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.hidden { display: none !important; }
.modal-card {
  background: var(--surface);
  border-radius: 22px;
  max-width: 440px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 18px;
  position: relative;
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}
.modal-img {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 14px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  margin: 8px 0 12px;
}
.modal-sheet-img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #FFFFFF;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  z-index: 200;
  box-shadow: 0 10px 28px rgba(0,0,0,0.22);
  max-width: 92vw;
  text-align: center;
}
.toast.hidden { display: none !important; }

/* Embed specific */
.embed-body {
  background: var(--bg);
  padding: 14px;
}
.embed-shell {
  max-width: 540px;
  margin: 0 auto;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.blur-zone {
  position: relative;
  margin-top: 12px;
}
.blur-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  filter: blur(5px);
  opacity: 0.65;
  pointer-events: none;
  user-select: none;
}
.blur-cta-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(250,247,242,0.15) 0%, rgba(250,247,242,0.92) 70%);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  gap: 8px;
}

@media print {
  .combo-banner, .install-bar, .app-header, .no-print { display: none !important; }
  body { background: #FFFFFF; }
  .app-main { padding: 0; max-width: 100%; }
}
