:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --panel: #fffdf8;
  --ink: #2f342f;
  --muted: #6b7067;
  --line: #ded6c8;
  --green: #557a5d;
  --green-soft: #dfe9dc;
  --red: #b96c5b;
  --gold: #d49b45;
  --blue: #6d8ca3;
  --shadow: 0 18px 50px rgba(80, 65, 45, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button, input, select { font: inherit; }

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  background: #ede4d4;
  border-right: 1px solid var(--line);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff9ee;
  font-size: 30px;
  font-weight: 800;
}

.brand h1, .brand p, .topbar h2, .eyebrow, h3, p { margin: 0; }

.brand h1 { font-size: 28px; line-height: 1.1; }
.brand p { color: var(--muted); margin-top: 8px; line-height: 1.4; }

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

.nav-item, .plan-row, .primary, .sound-card {
  min-height: 56px;
  border-radius: 8px;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.nav-item {
  text-align: left;
  padding: 0 18px;
  background: transparent;
  color: var(--ink);
  font-size: 19px;
}

.nav-item.active, .nav-item:hover {
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(80, 65, 45, 0.08);
}

.care-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.55;
  background: rgba(255,255,255,.45);
}

.care-note strong {
  display: block;
  color: var(--ink);
  margin-bottom: 8px;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--green);
  font-weight: 700;
  margin-bottom: 8px;
}

.topbar h2 {
  font-size: 34px;
  line-height: 1.15;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pills span {
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}

.view { display: none; }
.view.active { display: block; }

.training-board {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(340px, 520px);
  gap: 22px;
  align-items: stretch;
}

.today-panel, .memory-photo, .metric, .game-head, .settings-panel, .log-panel, .reference-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.today-panel {
  padding: 24px;
}

.section-head, .game-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.section-head h3, .game-head h3 {
  font-size: 26px;
}

.section-head span, .game-head p {
  color: var(--muted);
  margin-top: 8px;
}

.plan-list {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.plan-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  text-align: left;
  background: #f1eadf;
  color: var(--ink);
}

.plan-row:hover, .sound-card:hover, .primary:hover { transform: translateY(-1px); }

.plan-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}

.plan-row strong, .plan-row small { display: block; }
.plan-row small { color: var(--muted); margin-top: 6px; }

.memory-photo, .mini-scene {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  background: linear-gradient(#a9c8cf 0 46%, #dccb96 46% 64%, #7fa173 64%);
}

.sun {
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #f3c85b;
  right: 13%;
  top: 14%;
}

.mountain {
  position: absolute;
  width: 54%;
  height: 42%;
  bottom: 30%;
  background: #6d8b7a;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.mountain.back { left: 5%; opacity: .72; }
.mountain.front { right: 0; background: #587764; }

.river {
  position: absolute;
  width: 46%;
  height: 45%;
  left: 20%;
  bottom: -8%;
  background: #6d9fc0;
  transform: skewX(-18deg);
  border-radius: 50% 50% 0 0;
}

.house {
  position: absolute;
  left: 11%;
  bottom: 18%;
  width: 120px;
  height: 100px;
}

.roof {
  width: 128px;
  height: 58px;
  background: var(--red);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.house .body {
  width: 96px;
  height: 62px;
  margin-left: 16px;
  background: #f2dfb8;
  border: 5px solid #8a6b4b;
}

.photo-caption {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(255,253,248,.88);
  font-weight: 700;
  font-size: 20px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.metric {
  padding: 22px;
}

.metric strong {
  display: block;
  font-size: 32px;
  color: var(--green);
}

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

.game-head {
  padding: 20px 22px;
  margin-bottom: 18px;
}

.primary {
  background: var(--green);
  color: #fff;
  padding: 0 22px;
  font-size: 18px;
  min-width: 120px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 14px;
}

.card {
  min-height: 132px;
  border-radius: 8px;
  background: #d9cbb8;
  border: 2px solid #c5b69f;
  color: transparent;
  font-size: 42px;
  display: grid;
  place-items: center;
}

.card.open, .card.done {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--green);
}

.sort-layout, .family-grid, .puzzle-wrap {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 18px;
}

.item-bank, .category-grid, .sound-grid {
  display: grid;
  gap: 14px;
}

.item-chip {
  min-height: 62px;
  border-radius: 8px;
  background: var(--panel);
  border: 2px solid var(--line);
  font-size: 20px;
}

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

.category {
  min-height: 190px;
  padding: 16px;
  border-radius: 8px;
  background: var(--panel);
  border: 2px dashed #c9bda9;
}

.category h4, .log-panel h4 {
  margin: 0 0 12px;
  font-size: 22px;
}

.category.filled { border-color: var(--green); background: var(--green-soft); }

.puzzle-wrap {
  grid-template-columns: minmax(320px, 560px) 240px;
  align-items: start;
}

.puzzle-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  aspect-ratio: 1;
  border: 8px solid var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tile {
  min-width: 0;
  border: 1px solid rgba(255,255,255,.72);
  background-image: linear-gradient(#a9c8cf 0 46%, #dccb96 46% 64%, #7fa173 64%);
  background-size: 300% 300%;
}

.tile.selected { outline: 5px solid var(--gold); outline-offset: -5px; }

.reference-panel {
  padding: 14px;
}

.mini-scene {
  min-height: 170px;
  border-radius: 8px;
}

.mini-scene .house { transform: scale(.58); transform-origin: left bottom; }
.reference-panel p { text-align: center; color: var(--muted); margin-top: 10px; }

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

.sound-card {
  min-height: 180px;
  padding: 24px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.sound-card strong {
  display: block;
  font-size: 25px;
}

.sound-card span {
  display: block;
  color: var(--muted);
  margin-top: 10px;
}

.settings-panel, .log-panel {
  padding: 20px;
}

.settings-panel label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
}

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

#uploadedPhoto {
  display: none;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-top: 8px;
}

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

.log-item {
  padding: 12px;
  border-radius: 8px;
  background: #f1eadf;
  color: var(--muted);
}

.log-item strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; padding: 18px; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 18px; }
  .topbar, .section-head, .game-head { align-items: flex-start; flex-direction: column; }
  .training-board, .sort-layout, .family-grid, .puzzle-wrap { grid-template-columns: 1fr; }
  .metric-grid, .sound-grid { grid-template-columns: 1fr; }
  .memory-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 520px) {
  .brand h1 { font-size: 24px; }
  .topbar h2 { font-size: 28px; }
  .nav { grid-template-columns: 1fr; }
  .memory-grid { grid-template-columns: repeat(2, 1fr); }
  .category-grid { grid-template-columns: 1fr; }
  .card { min-height: 112px; }
}
