:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #637083;
  --line: #d9e1ea;
  --blue: #246bfe;
  --blue-soft: #eaf1ff;
  --green: #168a55;
  --green-soft: #e8f7ef;
  --red: #d64635;
  --red-soft: #fff0ed;
  --yellow: #f4b23b;
  --yellow-soft: #fff6df;
  --violet: #7b4ed8;
  --violet-soft: #f1ecff;
  --shadow: 0 10px 26px rgba(17, 32, 51, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button {
  border: 0;
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 980px;
  margin: 0 auto 14px;
}

.brand {
  min-width: 0;
}

.brand h1,
.brand h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.12;
  letter-spacing: 0;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.icon-btn,
.text-btn,
.primary-btn,
.choice-btn,
.pill-btn {
  min-height: 56px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn {
  width: 56px;
  min-width: 56px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.text-btn {
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}

.primary-btn {
  padding: 0 18px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.pill-btn {
  padding: 0 12px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}

.hero-panel,
.module-panel,
.parent-panel {
  max-width: 980px;
  margin: 0 auto;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.module-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 168px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
}

.module-card h3 {
  margin: 0;
  font-size: 18px;
}

.module-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.module-card svg,
.visual svg {
  width: 100%;
  height: auto;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress {
  height: 8px;
  width: 54px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: var(--green);
}

.module-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.lesson-card,
.activity-card,
.summary-card,
.parent-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lesson-card {
  padding: 14px;
}

.lesson-card h3,
.activity-card h3,
.summary-card h3,
.parent-card h3 {
  margin: 0 0 8px;
  font-size: 19px;
}

.lesson-card p,
.activity-card p,
.summary-card p,
.parent-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.lesson-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.lesson-actions .primary-btn {
  grid-column: 1 / -1;
}

.step-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  max-width: 980px;
  margin: 0 auto 12px;
}

.step-tab {
  min-height: 38px;
  border-radius: 8px;
  background: #e9eef5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.step-tab.active {
  background: var(--blue);
  color: #fff;
}

.activity-card {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px;
}

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

.activity-title {
  min-width: 0;
}

.activity-title h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.18;
}

.activity-title p {
  margin: 6px 0 0;
  font-size: 14px;
}

.visual {
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.visual.compact {
  min-height: 180px;
}

.work-area {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.choices {
  display: grid;
  gap: 10px;
}

.quiz-progress {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.prompt {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
}

.choice-btn {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  line-height: 1.35;
}

.choice-btn.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.choice-btn.correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.choice-btn.wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.feedback {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--ink);
  line-height: 1.35;
}

.feedback.good {
  background: var(--green-soft);
  color: #0d6040;
}

.feedback.warn {
  background: var(--yellow-soft);
  color: #73500b;
}

.bottom-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.inline-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.drag-bank,
.drop-zone-row,
.counter-row {
  display: grid;
  gap: 10px;
}

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

.drag-item,
.drop-zone,
.counter-box {
  min-height: 58px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  font-weight: 700;
  touch-action: none;
}

.drag-item {
  cursor: grab;
  box-shadow: 0 4px 12px rgba(17, 32, 51, 0.08);
}

.drag-item.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.drag-item.dragging {
  opacity: 0.5;
}

.drop-zone.over {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.drop-zone.done {
  border-color: var(--green);
  background: var(--green-soft);
}

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

.counter-box button {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 24px;
  font-weight: 800;
}

.counter-value {
  font-size: 26px;
  margin: 4px 0;
}

.clock-wrap {
  width: min(270px, 76vw);
  aspect-ratio: 1;
  position: relative;
}

.clock-face {
  width: 100%;
  height: 100%;
  border: 8px solid #27364a;
  border-radius: 50%;
  background: #fff;
  position: relative;
}

.clock-num {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  color: #27364a;
}

.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: 50% 100%;
  border-radius: 999px;
}

.hour-hand {
  width: 9px;
  height: 28%;
  margin-left: -4.5px;
  background: #27364a;
}

.minute-hand {
  width: 6px;
  height: 39%;
  margin-left: -3px;
  background: var(--blue);
}

.hand-knob {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue);
  left: calc(50% - 17px);
  top: 10%;
  touch-action: none;
}

.clock-center {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  left: calc(50% - 9px);
  top: calc(50% - 9px);
  background: var(--yellow);
}

.time-readout {
  margin-top: 10px;
  font-size: 26px;
  font-weight: 800;
  color: var(--blue);
  text-align: center;
}

.grid-demo {
  display: grid;
  gap: 3px;
}

.cell {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--blue-soft);
  border: 1px solid #9ab5ff;
}

.edge-demo {
  width: min(300px, 82vw);
  height: 190px;
  position: relative;
  border: 8px solid var(--blue);
  background: repeating-linear-gradient(0deg, #fff, #fff 23px, #edf3fb 24px), repeating-linear-gradient(90deg, transparent, transparent 23px, #edf3fb 24px);
}

.edge-demo.fill {
  border-color: #94a3b8;
  background: repeating-linear-gradient(0deg, var(--green-soft), var(--green-soft) 23px, #b6dec9 24px), repeating-linear-gradient(90deg, transparent, transparent 23px, #b6dec9 24px);
}

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

.parent-card {
  padding: 14px;
}

@media (min-width: 720px) {
  .screen {
    padding: 24px;
  }

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

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

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

  .lesson-actions .primary-btn {
    grid-column: auto;
  }

  .work-area {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

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

@media (max-width: 390px) {
  .brand h1,
  .brand h2 {
    font-size: 23px;
  }

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

  .step-tabs {
    gap: 4px;
  }

  .step-tab {
    min-height: 34px;
    font-size: 11px;
  }

  .drag-bank {
    grid-template-columns: 1fr;
  }
}
