/* Stella Cloud — iPad Air Safari first (≈820–1180px), warm eye-care */
:root {
  --bg: #f7f4ee;
  --bg-soft: #eef5ef;
  --card: #fffcf7;
  --card-border: #e8e0d4;
  --text: #2c3a2f;
  --text-muted: #6b7a6e;
  --accent: #5a9a78;
  --accent-soft: #d8ebe0;
  --accent-deep: #3d7a58;
  --peach: #f0b080;
  --peach-soft: #fce8d4;
  --lavender: #b8a8d4;
  --lavender-soft: #eee8f6;
  --sky: #7eb8c9;
  --sky-soft: #e4f2f6;
  --gold: #e8b84a;
  --gold-soft: #fbf0d4;
  --danger-soft: #f8e4e0;
  --shadow: 0 4px 18px rgba(60, 80, 60, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --nav-h: 72px;
  --touch: 44px;
  --font: -apple-system, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c2420;
    --bg-soft: #24302a;
    --card: #2a3530;
    --card-border: #3a4a42;
    --text: #e8efe9;
    --text-muted: #9aada0;
    --accent: #7bc49a;
    --accent-soft: #2d4a3a;
    --accent-deep: #9ad4b0;
    --peach: #e0a878;
    --peach-soft: #4a3a2a;
    --lavender: #c4b4e0;
    --lavender-soft: #3a3450;
    --sky: #8ec8d4;
    --sky-soft: #2a3a42;
    --gold: #f0c860;
    --gold-soft: #4a4020;
    --danger-soft: #4a3030;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100%;
  min-height: 100dvh;
  padding: var(--safe-top) var(--safe-right) calc(var(--nav-h) + var(--safe-bottom) + 12px) var(--safe-left);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  min-height: var(--touch);
  min-width: var(--touch);
}

img, svg { max-width: 100%; display: block; }

.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-decor svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 200px;
  opacity: 0.42;
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 20px 28px;
}

@media (min-width: 820px) and (max-width: 1180px) {
  .app { max-width: 920px; padding: 16px 28px 32px; }
  html { font-size: 19px; }
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.mascot { width: 56px; height: 56px; flex-shrink: 0; }
.header-text { flex: 1; min-width: 140px; }
.header-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tagline { color: var(--text-muted); font-size: 0.88rem; margin-top: 2px; }
.stats-row { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-pill {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 0.95rem;
}

/* Panels */
.panel { display: none; animation: fadeIn 0.25s ease; }
.panel.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
  .confetti-piece { animation: none !important; }
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1.12rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3 { font-size: 1rem; margin: 12px 0 6px; }
.muted { color: var(--text-muted); font-size: 0.92rem; }
.soft-gap { color: var(--accent-deep); font-weight: 600; } /* 可加强 — never 薄弱 */

/* Subtabs inside 成就奖励 */
.subtabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  flex: 0 0 auto;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  font-weight: 600;
  min-height: var(--touch);
  color: var(--text-muted);
}
.subtab.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  min-height: var(--touch);
  border-radius: 14px;
  font-weight: 650;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-deep); }
.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.btn-peach { background: var(--peach-soft); color: #8a5a30; }
.btn-lavender { background: var(--lavender-soft); color: #5a4a7a; }
.btn-sky { background: var(--sky-soft); color: #2a5a6a; }
.btn-gold { background: var(--gold-soft); color: #7a5a10; }
.btn-ghost {
  background: transparent;
  border-color: var(--card-border);
  color: var(--text-muted);
}
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* Forms */
.form-row { margin: 10px 0; }
.form-row label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.95rem;
}
.form-control {
  width: 100%;
  min-height: var(--touch);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--bg);
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.form-control { min-height: 96px; resize: vertical; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px;
  min-height: var(--touch);
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  font-size: 0.9rem;
}
.chip.on {
  background: var(--lavender-soft);
  border-color: var(--lavender);
  font-weight: 650;
}

/* Passage + practice */
.passage {
  background: var(--sky-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  white-space: pre-wrap;
  line-height: 1.65;
  margin: 10px 0;
  font-size: 1.02rem;
}
.problem {
  border-top: 1px dashed var(--card-border);
  padding: 14px 0 8px;
}
.problem:first-of-type { border-top: none; }
.problem-label {
  display: inline-block;
  background: var(--gold-soft);
  color: #7a5a10;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.mcq-option, .tf-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  min-height: var(--touch);
  border-radius: 12px;
  border: 1px solid var(--card-border);
  margin: 8px 0;
  background: var(--bg);
  width: 100%;
  text-align: left;
}
.mcq-option.selected, .tf-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
}
.rec-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}
.rec-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #c44; display: inline-block;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .rec-dot { animation: none; }
}

/* Radar */
.radar-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 820px) {
  .radar-wrap { grid-template-columns: 1fr 1fr; }
}
.radar-card canvas {
  width: 100%;
  max-width: 320px;
  height: auto;
  margin: 0 auto;
}
.axis-list { list-style: none; margin-top: 8px; }
.axis-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.95rem;
}
.axis-score {
  font-weight: 700;
  color: var(--accent-deep);
}

/* Progress */
.progress {
  height: 12px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--sky));
  border-radius: 999px;
  transition: width 0.35s ease;
}
@media (prefers-reduced-motion: reduce) {
  .progress > span { transition: none; }
}

/* Reward overview hero (成就奖励 first screen) */
.reward-overview {
  background: linear-gradient(160deg, var(--gold-soft) 0%, var(--card) 42%, var(--accent-soft) 100%);
  border-color: rgba(90, 154, 120, 0.35);
}
.ov-hero { margin-bottom: 14px; }
.ov-kicker {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.ov-big {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 4px 0 10px;
  line-height: 1.15;
}
.ov-yen {
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent-deep);
}
.ov-budget {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text-muted);
}
.progress-hero {
  height: 16px;
  margin: 6px 0 10px;
}
.progress-hero > span {
  background: linear-gradient(90deg, var(--gold), var(--accent));
}
.progress-gold > span {
  background: linear-gradient(90deg, var(--peach), var(--gold));
}
.ov-subline {
  font-size: 0.95rem;
  color: var(--text);
}
.ov-twin {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 4px;
}
@media (min-width: 820px) {
  .ov-twin { grid-template-columns: 1fr 1fr; gap: 14px; }
}
.ov-quest {
  background: rgba(255, 252, 247, 0.72);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
@media (prefers-color-scheme: dark) {
  .ov-quest { background: rgba(28, 36, 32, 0.45); }
}
.ov-quest-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.ov-quest-title { font-weight: 700; font-size: 0.98rem; }
.ov-quest-meta {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--accent-deep);
}
.ov-hint { margin-top: 6px; font-size: 0.86rem; }
.btn-sm {
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.9rem;
  margin-top: 8px;
}
.today-quest .today-pack {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

/* Ledger */
.ledger-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--card-border);
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.badge-pending { background: var(--gold-soft); color: #7a5a10; }
.badge-paid { background: var(--accent-soft); color: var(--accent-deep); }

/* Fun cards */
.fun-card {
  background: linear-gradient(145deg, var(--lavender-soft), var(--card));
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--card-border);
  min-height: 200px;
}
.fun-tag {
  display: inline-block;
  background: var(--peach-soft);
  color: #8a5a30;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 650;
  margin-bottom: 10px;
}
.fun-en { margin-top: 12px; color: var(--text-muted); font-style: italic; }

/* Achievement grid */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.ach-item {
  text-align: center;
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  opacity: 0.45;
}
.ach-item.unlocked {
  opacity: 1;
  background: var(--gold-soft);
  border-color: var(--gold);
}
.ach-emoji { font-size: 1.6rem; }
.ach-name { font-weight: 700; font-size: 0.9rem; margin-top: 4px; }
.ach-desc { font-size: 0.78rem; color: var(--text-muted); }

/* Bottom nav — 3 tabs */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: rgba(255, 252, 247, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--card-border);
  padding: 6px var(--safe-right) calc(6px + var(--safe-bottom)) var(--safe-left);
}
@media (prefers-color-scheme: dark) {
  .bottom-nav { background: rgba(42, 53, 48, 0.94); }
}
.nav-inner {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  min-height: var(--nav-h);
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 650;
}
.nav-btn .nav-ico { font-size: 1.35rem; line-height: 1; }
.nav-btn.active {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

/* Toast + confetti */
.toast-host {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(90vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--card);
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 650;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
.confetti-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: fall 1.6s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(420deg); opacity: 0; }
}

/* Fold settings */
details.settings {
  margin-top: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  padding: 8px 12px;
  background: var(--bg-soft);
}
details.settings summary {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
details.settings summary::-webkit-details-marker { display: none; }

.site-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
}

.hidden { display: none !important; }
