/* 西城初一 · 课后半小时 — 暖色童趣 UI */
:root {
  --bg: #fff8f0;
  --card: #ffffff;
  --ink: #2c3e50;
  --muted: #5d6d7e;
  --primary: #ff6b35;
  --primary-soft: #ffe8de;
  --math: #3498db;
  --math-soft: #eaf4fb;
  --chinese: #9b59b6;
  --chinese-soft: #f5eaf8;
  --fun: #1abc9c;
  --fun-soft: #e8f8f5;
  --star: #f1c40f;
  --ok: #27ae60;
  --shadow: 0 8px 24px rgba(44, 62, 80, 0.08);
  --radius: 18px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: linear-gradient(160deg, #fff8f0 0%, #ffeaa7 35%, #fab1a0 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.65;
  font-size: 16px;
}

.app { max-width: 920px; margin: 0 auto; padding: 16px 16px 96px; }

/* Header */
.site-header {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mascot {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2ecc71, #3498db);
  display: grid; place-items: center;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.35);
  animation: floaty 3s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--primary);
}
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.stats-pill {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.pill {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
}
.pill.stars { background: #fff3cd; color: #b7791f; }

/* Nav */
.nav {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.nav button {
  border: none;
  background: var(--card);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, background 0.15s;
}
.nav button:hover { transform: translateY(-2px); }
.nav button.active {
  background: var(--primary);
  color: #fff;
}

/* Views */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.35s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 1.2rem; }
.card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.muted { color: var(--muted); }
.parent-note {
  border-left: 4px solid var(--primary);
  background: #fff;
  padding: 14px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Week grid */
.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.day-tile {
  border: none;
  background: linear-gradient(145deg, #fff, #fff5eb);
  border-radius: 16px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.day-tile:hover { transform: scale(1.03); }
.day-tile.today {
  outline: 3px solid var(--primary);
  background: linear-gradient(145deg, #ffe8de, #fff);
}
.day-tile .day-num { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.day-tile .day-name { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.day-tile .progress {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--ok);
  font-weight: 600;
}
.day-tile .mini-stars { color: var(--star); letter-spacing: 1px; }

/* Section badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.badge.math { background: var(--math-soft); color: var(--math); }
.badge.chinese { background: var(--chinese-soft); color: var(--chinese); }
.badge.fun { background: var(--fun-soft); color: var(--fun); }

.problem {
  background: var(--math-soft);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.problem .statement {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin: 8px 0 12px;
  white-space: pre-wrap;
}
.steps { margin: 0; padding-left: 0; list-style: none; }
.steps li {
  background: #fff;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--math);
  font-size: 0.95rem;
}
.tip-box {
  background: #fff3cd;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 0.92rem;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}
.check-row input {
  width: 22px; height: 22px;
  accent-color: var(--ok);
  cursor: pointer;
}
.check-row.done { background: #d5f5e3; color: var(--ok); }

.word-card {
  background: var(--chinese-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.word-card .word {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--chinese);
}
.word-card .pinyin { color: var(--muted); margin-left: 8px; font-size: 0.9rem; }
.book-tip {
  background: #fef9e7;
  border-radius: 12px;
  padding: 12px;
  margin-top: 8px;
}
.video-card {
  background: var(--fun-soft);
  border-radius: 14px;
  padding: 14px 16px;
}
.video-card .kw {
  display: inline-block;
  margin-top: 8px;
  background: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 0.88rem;
  color: var(--fun);
}

.back-btn {
  border: none;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
}

/* Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.parrot-card {
  background: #fff;
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.parrot-card.locked {
  filter: grayscale(1);
  opacity: 0.55;
}
.parrot-card.unlocked {
  animation: popIn 0.45s ease;
}
@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.parrot-svg-wrap {
  width: 88px; height: 88px;
  margin: 0 auto 8px;
}
.parrot-card .name { font-weight: 800; font-size: 0.95rem; }
.parrot-card .desc { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.lock-tag { font-size: 0.75rem; color: #999; margin-top: 4px; }

/* Celebration overlay */
.celebrate {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
}
.celebrate.show { opacity: 1; }
.celebrate-bubble {
  background: rgba(255,255,255,0.95);
  border-radius: 24px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.15);
  animation: celebrateBounce 0.6s ease;
  pointer-events: none;
}
@keyframes celebrateBounce {
  0% { transform: scale(0.5) rotate(-6deg); }
  60% { transform: scale(1.1) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}
.celebrate-bubble .big { font-size: 3rem; }
.confetti {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 2px;
  animation: fall 1.2s ease-out forwards;
}
@keyframes fall {
  to { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Footer hint */
.footer-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 20px;
}

@media (max-width: 560px) {
  .brand h1 { font-size: 1.15rem; }
  .app { padding: 12px 12px 80px; }
  .card { padding: 14px; }
  .steps li { font-size: 0.9rem; }
}

/* —— 先做后讲：状态与引导 —— */
.pedagogy-note {
  background: #eaf4fb;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 0.92rem;
  color: var(--math);
}
.problem-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.problem-head h3 { margin: 0; }
.status-chip {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.st-idle { background: #ecf0f1; color: #7f8c8d; }
.st-hinting { background: #fdebd0; color: #d68910; }
.st-done { background: #d5f5e3; color: #1e8449; }
.st-unlocked { background: #d6eaf8; color: #1a5276; }

.try-first {
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0;
  border: 2px dashed #aed6f1;
}
.try-first p { margin: 0 0 10px; }
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.btn {
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover { transform: translateY(-1px); }
.btn-ok { background: #27ae60; color: #fff; }
.btn-soft { background: #ffeaa7; color: #6d4c00; }
.btn-ghost { background: #f5f6fa; color: #576574; }
.btn-parent {
  background: #34495e;
  color: #fff;
  font-size: 0.85rem;
  padding: 8px 12px;
}

.photo-note {
  background: #e8f8f5;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0;
  border-left: 4px solid var(--fun);
}
.photo-note p { margin: 0 0 6px; }
.small { font-size: 0.85rem; }

.hints-panel {
  background: linear-gradient(180deg, #fff9f0, #fff);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 12px 0;
  border: 2px solid #f5cba7;
}
.hints-panel h4 { margin: 0 0 6px; color: #d68910; }
.hint-card {
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  border-left: 3px solid #e67e22;
  animation: fadeIn 0.35s ease;
}
.hint-num {
  font-size: 0.78rem;
  font-weight: 800;
  color: #e67e22;
  margin-bottom: 4px;
}
.hint-card p { margin: 0; }
.hints-done {
  background: #d5f5e3;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  font-weight: 600;
  color: #1e8449;
}

.parent-lock {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #d5d8dc;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.solution-unlocked {
  width: 100%;
  margin-top: 8px;
  background: #eaf4fb;
  border-radius: 12px;
  padding: 12px;
}

/* —— 拍照与确认 —— */
.photo-panel {
  background: #e8f8f5;
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0;
  border: 2px solid #1abc9c;
}
.photo-panel.compact { padding: 8px; }
.photo-panel h4 { margin: 0 0 8px; color: #0e6655; }
.photo-preview-wrap {
  margin: 10px 0;
  text-align: center;
}
.photo-preview {
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  object-fit: contain;
  background: #fff;
}
.send-cta {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
  border-left: 4px solid #ff6b35;
}
.file-btn { display: inline-block; cursor: pointer; }
.file-btn input { display: none; }
.correct-banner {
  background: #d5f5e3;
  color: #1e8449;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 12px;
  margin: 10px 0;
}
.st-photo { background: #d1f2eb; color: #0e6655; }
.st-correct { background: #abebc6; color: #145a32; }

/* —— 本地最终答案检查 —— */
.answer-check-panel {
  background: #eaf4fb;
  border: 2px dashed #5dade2;
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0;
}
.answer-check-panel h4 { margin: 0 0 6px; color: #1a5276; }
.answer-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.answer-input {
  flex: 1 1 180px;
  min-width: 140px;
  padding: 11px 14px;
  border: 2px solid #aed6f1;
  border-radius: 12px;
  font-size: 1.05rem;
  font-family: inherit;
  box-sizing: border-box;
}
.answer-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}
.answer-feedback {
  margin: 10px 0 0;
  font-weight: 700;
}
.answer-feedback.wrong {
  color: #d68910;
  background: #fef9e7;
  padding: 8px 12px;
  border-radius: 10px;
}
.answer-ok-line {
  margin: 8px 0 0;
  color: #1e8449;
  font-weight: 600;
}
.photo-panel.optional-photo {
  border-style: dashed;
  opacity: 0.95;
}

/* —— 家长密码模态 —— */
#modal-root { position: relative; z-index: 2000; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
}
.modal-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-card h3 { margin: 0 0 8px; }
.pwd-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #d5d8dc;
  border-radius: 12px;
  font-size: 1.05rem;
  font-family: inherit;
  margin: 8px 0;
  box-sizing: border-box;
}
.pwd-input:focus {
  outline: none;
  border-color: var(--primary);
}
.pwd-error {
  color: #c0392b;
  font-weight: 700;
  font-size: 0.9rem;
  margin: 4px 0 8px;
}
.modal-card.shake {
  animation: shakeX 0.45s ease;
}
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* —— 摄像头拍照模态 —— */
.camera-modal .camera-modal-card {
  max-width: 520px;
}
.camera-modal .camera-video-wrap {
  margin: 10px 0;
  background: #111;
  border-radius: 14px;
  overflow: hidden;
}
.camera-modal video,
.camera-modal #camera-video {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 14px;
  background: #000;
}
