:root {
  --bg: #f8fbf5;
  --paper: #ffffff;
  --ink: #1d2433;
  --muted: #6a7282;
  --line: #dfe7dd;
  --teal: #1f9a8a;
  --teal-deep: #0e6d63;
  --coral: #ef715d;
  --yellow: #f4bd38;
  --blue: #4385d8;
  --green: #70b55a;
  --rose: #df6d8a;
  --shadow: 0 12px 28px rgba(29, 36, 51, 0.1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(31, 154, 138, 0.35);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 16% 8%, rgba(244, 189, 56, 0.22), transparent 24rem),
    linear-gradient(180deg, #f8fbf5 0%, #eef7f4 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: calc(58px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 16px 10px;
  border-bottom: 1px solid rgba(223, 231, 221, 0.7);
  background: rgba(248, 251, 245, 0.86);
  backdrop-filter: blur(18px);
}

.brand-button,
.sound-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(29, 36, 51, 0.08);
}

.brand-button {
  gap: 9px;
  min-height: 40px;
  max-width: min(62vw, 320px);
  padding: 7px 12px 7px 8px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.sound-button,
.icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
}

.screen {
  width: min(100%, 980px);
  min-height: calc(100dvh - 142px - var(--safe-top) - var(--safe-bottom));
  margin: 0 auto;
  padding: 16px 16px calc(92px + var(--safe-bottom));
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  border-top: 1px solid rgba(223, 231, 221, 0.85);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -10px 24px rgba(29, 36, 51, 0.08);
  backdrop-filter: blur(20px);
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 58px;
  padding: 6px 4px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nav-item svg {
  width: 21px;
  height: 21px;
}

.nav-item.is-active {
  background: #e7f5ee;
  color: var(--teal-deep);
}

.hero {
  display: grid;
  gap: 14px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(31, 154, 138, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(230, 247, 242, 0.88)),
    url("./assets/learning-bridge.svg") right bottom / min(56%, 330px) auto
      no-repeat;
  box-shadow: var(--shadow);
}

.hero-copy {
  display: grid;
  gap: 8px;
  max-width: 430px;
}

.eyebrow {
  color: var(--teal-deep);
  font-size: 13px;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 12em;
  font-size: 28px;
  line-height: 1.13;
  letter-spacing: 0;
  text-wrap: balance;
}

h2 {
  font-size: 21px;
  line-height: 1.18;
}

h3 {
  font-size: 16px;
  line-height: 1.25;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.hero p {
  max-width: 24em;
  font-weight: 650;
}

.hero-actions,
.row-actions,
.quiz-actions,
.parent-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 15px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  line-height: 1.1;
  box-shadow: 0 8px 18px rgba(31, 154, 138, 0.24);
}

.button svg {
  width: 20px;
  height: 20px;
}

.button.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.button.coral {
  background: var(--coral);
  box-shadow: 0 8px 18px rgba(239, 113, 93, 0.24);
}

.button.yellow {
  background: #f0aa20;
  box-shadow: 0 8px 18px rgba(244, 189, 56, 0.22);
}

.button.blue {
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(67, 133, 216, 0.2);
}

.section {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-heading p {
  font-size: 13px;
  font-weight: 700;
}

.mission-grid,
.module-grid,
.badge-grid,
.stat-grid {
  display: grid;
  gap: 12px;
}

.mission-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.module-grid {
  grid-template-columns: 1fr;
}

.card,
.mission-card,
.module-card,
.reward-card,
.parent-panel,
.quiz-card,
.habit-row {
  border: 1px solid rgba(223, 231, 221, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 22px rgba(29, 36, 51, 0.07);
}

.mission-card,
.module-card,
.reward-card,
.parent-panel,
.quiz-card {
  padding: 14px;
}

.mission-card,
.module-card {
  display: grid;
  gap: 12px;
  min-height: 160px;
}

.card-top,
.module-top,
.reward-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.icon-tile {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #fff;
}

.icon-tile svg {
  width: 24px;
  height: 24px;
}

.tile-teal {
  background: var(--teal);
}

.tile-coral {
  background: var(--coral);
}

.tile-yellow {
  background: #e7a118;
}

.tile-blue {
  background: var(--blue);
}

.tile-green {
  background: var(--green);
}

.tile-rose {
  background: var(--rose);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf5f1;
  color: var(--teal-deep);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.done {
  background: #fff4d7;
  color: #9a6710;
}

.mission-copy {
  display: grid;
  gap: 5px;
}

.mission-copy p,
.module-card p,
.reward-card p {
  font-size: 13px;
  font-weight: 650;
}

.progress-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
}

.progress-ring {
  --progress: 0deg;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) var(--progress), #e3eadf 0deg);
}

.progress-ring span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--teal-deep);
  font-size: 20px;
  font-weight: 950;
}

.progress-text {
  display: grid;
  gap: 4px;
}

.progress-text strong {
  font-size: 18px;
}

.activity-shell {
  display: grid;
  gap: 14px;
}

.activity-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.activity-title {
  display: grid;
  gap: 5px;
}

.quiz-card {
  display: grid;
  gap: 16px;
}

.big-prompt {
  display: grid;
  place-items: center;
  min-height: 154px;
  border-radius: 8px;
  background: linear-gradient(145deg, #fff7e1, #e9f6ff);
  color: var(--ink);
  text-align: center;
  font-size: 72px;
  font-weight: 950;
  line-height: 1;
}

.big-prompt.small {
  padding: 24px;
  font-size: 34px;
  line-height: 1.18;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-button {
  min-height: 62px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 22px;
  font-weight: 950;
  line-height: 1.15;
  word-break: break-word;
}

.choice-button.is-correct {
  border-color: rgba(112, 181, 90, 0.7);
  background: #edf8e9;
}

.choice-button.is-wrong {
  border-color: rgba(239, 113, 93, 0.7);
  background: #fff0ed;
}

.feedback {
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #f4f7f3;
  color: var(--muted);
  font-weight: 800;
}

.feedback.good {
  background: #eaf7e8;
  color: #457835;
}

.feedback.try {
  background: #fff1ed;
  color: #b84d3b;
}

.write-board {
  display: grid;
  gap: 12px;
}

.trace-canvas {
  width: 100%;
  min-height: 270px;
  border: 2px dashed rgba(31, 154, 138, 0.3);
  border-radius: 8px;
  background: #ffffff;
  touch-action: none;
}

.writing-models {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.model-button {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
}

.model-button.is-active {
  border-color: var(--teal);
  background: #e8f6f1;
  color: var(--teal-deep);
}

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

.habit-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px;
}

.habit-check {
  width: 38px;
  height: 38px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: transparent;
}

.habit-row.is-done .habit-check {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.habit-copy {
  display: grid;
  gap: 3px;
}

.habit-copy p {
  font-size: 13px;
  font-weight: 650;
}

.star-jar {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 7px;
  padding: 14px;
  border-radius: 8px;
  background: linear-gradient(160deg, #fff8df, #ecf8ef);
}

.star-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(244, 189, 56, 0.3);
}

.star-cell.filled {
  background: #f4bd38;
  box-shadow: inset 0 -3px 0 rgba(154, 103, 16, 0.16);
}

.badge-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.badge {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.badge.is-locked {
  opacity: 0.55;
}

.badge strong {
  font-size: 15px;
}

.badge span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.stat-card strong {
  font-size: 24px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segment {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.segment.is-active {
  border-color: var(--teal);
  background: #e8f6f1;
  color: var(--teal-deep);
}

.note-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.note-list li {
  padding: 10px 11px;
  border-radius: 8px;
  background: #f7faf6;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px dashed rgba(31, 154, 138, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 680px) {
  .screen {
    padding-top: 22px;
  }

  .hero {
    min-height: 260px;
    align-content: center;
    padding: 26px;
  }

  h1 {
    font-size: 42px;
  }

  .mission-grid,
  .module-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quiz-card {
    padding: 18px;
  }

  .big-prompt {
    min-height: 220px;
    font-size: 96px;
  }

  .choice-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .badge-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .screen {
    padding-right: 12px;
    padding-left: 12px;
  }

  .hero {
    padding-bottom: 118px;
    background-size: 245px auto;
  }

  h1 {
    max-width: 13em;
    font-size: 25px;
    line-height: 1.16;
  }

  .mission-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

  .big-prompt {
    font-size: 60px;
  }
}
