:root {
  --ink: #142018;
  --paper: #e8efe6;
  --muted: rgba(20, 32, 24, 0.62);
  --line: rgba(20, 32, 24, 0.12);
  --accent: #2f6b4f;
  --accent-soft: rgba(47, 107, 79, 0.14);
  --danger: #9b3b2e;
  --shadow: 0 18px 50px rgba(10, 20, 14, 0.18);
  --radius: 18px;
  --font-brand: "ZCOOL XiaoWei", "STKaiti", "KaiTi", "楷体", serif;
  --font-display: "Ma Shan Zheng", "STXingkai", "华文行楷", cursive;
  --font-body: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: #0f1813;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
a { color: inherit; }

.app {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 10% -10%, rgba(255,255,255,.22), transparent 50%),
    radial-gradient(90% 70% at 100% 0%, rgba(255, 214, 160, .18), transparent 45%),
    linear-gradient(165deg, #d7e6d4 0%, #b7cfc0 42%, #8eae97 100%);
  transition: background 0.8s ease;
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .35;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.35) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,.25) 0 1px, transparent 2px);
  background-size: 120px 120px, 90px 90px;
  animation: drift 28s linear infinite;
  pointer-events: none;
}
@keyframes drift {
  from { transform: translateY(0); }
  to { transform: translateY(-60px); }
}

.season-spring { --accent: #2f6b4f; --paper: #e8efe6; }
.season-spring .atmosphere {
  background:
    radial-gradient(100% 70% at 80% 10%, rgba(255, 182, 193, .28), transparent 40%),
    linear-gradient(160deg, #e9f3e4, #c5dcc8 50%, #7fa88a);
}
.season-summer { --accent: #b86a1c; --paper: #f3ead9; }
.season-summer .atmosphere {
  background:
    radial-gradient(90% 60% at 15% 0%, rgba(255, 220, 120, .45), transparent 45%),
    linear-gradient(165deg, #f6e7c6, #e8c27a 48%, #c9853d);
}
.season-autumn { --accent: #8a3d24; --paper: #f0e2d2; }
.season-autumn .atmosphere {
  background:
    radial-gradient(80% 50% at 90% 20%, rgba(210, 90, 50, .28), transparent 40%),
    linear-gradient(165deg, #f0dcc4, #d9a06a 45%, #8f4d2e);
}
.season-winter { --accent: #3a5f78; --paper: #e4ecf2; }
.season-winter .atmosphere {
  background:
    radial-gradient(70% 50% at 20% 10%, rgba(255,255,255,.55), transparent 40%),
    linear-gradient(165deg, #e8eef4, #b7c7d6 50%, #6d8498);
}
.season-card { --accent: #5a3d6d; --paper: #ece6f2; }
.season-card .atmosphere {
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(180, 140, 220, .28), transparent 45%),
    linear-gradient(165deg, #e8e0f0, #c4b0d4 50%, #6e587f);
}
.season-book { --accent: #4a3b2a; --paper: #f2e8d8; }
.season-book .atmosphere {
  background:
    radial-gradient(70% 50% at 50% 0%, rgba(255,255,255,.3), transparent 40%),
    linear-gradient(165deg, #ebe0cf, #cbb896 48%, #6f5840);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,.18);
}
.brand-mini {
  font-family: var(--font-brand);
  font-size: 1.15rem;
  letter-spacing: .18em;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  display: grid;
  place-items: center;
  font-size: .95rem;
}

.view {
  min-height: calc(100dvh - 64px);
  padding: 8px 18px calc(28px + var(--safe-b));
  max-width: 480px;
  margin: 0 auto;
}

/* —— 首页 —— */
.hero {
  min-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 36px;
  animation: rise .9s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 14vw, 4.4rem);
  line-height: 1;
  margin: 0 0 12px;
  text-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.hero-line {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 28px;
  max-width: 16em;
  line-height: 1.7;
}
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--ink);
  color: #f4f7f2;
  letter-spacing: .06em;
  transition: transform .2s ease, opacity .2s ease;
}
.btn:active { transform: scale(.98); }
.btn-ghost {
  background: rgba(255,255,255,.42);
  color: var(--ink);
  border: 1px solid rgba(20,32,24,.12);
}
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* —— 表单 —— */
.panel {
  margin-top: 28px;
  padding: 28px 22px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.55);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  animation: rise .55s ease both;
}
.panel h1 {
  font-family: var(--font-brand);
  font-size: 1.8rem;
  margin: 0 0 8px;
  font-weight: 400;
}
.panel .hint {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.6;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: .82rem;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.72);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
}
.field textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.7;
}
.field input:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.switch-link {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}
.switch-link button {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* —— 四季问答 —— */
.season-head {
  padding: 18px 4px 8px;
  animation: rise .6s ease both;
}
.season-kicker {
  font-size: .78rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.season-title {
  font-family: var(--font-display);
  font-size: 2.6rem;
  margin: 0 0 6px;
  line-height: 1.1;
}
.season-sub {
  margin: 0 0 10px;
  color: var(--muted);
}
.season-guide {
  margin: 0;
  line-height: 1.75;
  font-size: .98rem;
}
.progress {
  display: flex;
  gap: 8px;
  margin: 22px 0 8px;
}
.progress span {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,.35);
  overflow: hidden;
}
.progress span i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width .4s ease;
}
.q-card {
  margin-top: 18px;
  padding: 22px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.62);
  box-shadow: var(--shadow);
  animation: rise .5s ease both;
}
.q-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: 12px;
}
.q-text {
  font-size: 1.15rem;
  line-height: 1.7;
  margin: 0 0 18px;
}
.expand-tip {
  font-size: .82rem;
  color: var(--muted);
  margin: -8px 0 14px;
}
.done-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .75rem;
}

/* —— 卡牌 —— */
.card-intro {
  text-align: center;
  padding: 12px 8px 6px;
}
.card-intro h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  margin: 0 0 10px;
}
.card-intro p {
  color: var(--muted);
  line-height: 1.7;
  margin: 0 auto 8px;
  max-width: 22em;
}
.deck {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 22px 0;
  perspective: 900px;
}
.memory-card {
  aspect-ratio: 3/4.2;
  border-radius: 14px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.8,.2,1), box-shadow .3s;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(20, 12, 30, .22);
}
.memory-card.selected {
  transform: translateY(-10px) scale(1.04);
  box-shadow: 0 18px 36px rgba(90, 40, 140, .35);
}
.memory-card.revealed { transform: rotateY(180deg); }
.memory-card .face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
}
.memory-card .back {
  background:
    linear-gradient(145deg, #5a3d6d, #2d2138);
  color: #f4ecff;
  border: 1px solid rgba(255,255,255,.18);
}
.memory-card .back .mark {
  font-family: var(--font-display);
  font-size: 2rem;
  opacity: .9;
}
.memory-card .back .tiny {
  margin-top: 8px;
  font-size: .7rem;
  letter-spacing: .2em;
  opacity: .7;
}
.memory-card .front {
  background: linear-gradient(180deg, #f7f1ff, #e7d8f5);
  color: #2a1c36;
  transform: rotateY(180deg);
  font-size: .78rem;
  line-height: 1.5;
}
.pick-bar {
  position: sticky;
  bottom: calc(12px + var(--safe-b));
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.pick-bar .count { flex: 1; color: var(--muted); font-size: .9rem; }

/* —— 书本 —— */
.book-shell {
  padding: 8px 0 24px;
}
.book-cover-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  text-align: center;
  margin: 8px 0 4px;
}
.book-sub {
  text-align: center;
  color: var(--muted);
  margin: 0 0 18px;
  font-size: .92rem;
}
.book {
  position: relative;
  height: min(68vh, 560px);
  border-radius: 8px 16px 16px 8px;
  background:
    linear-gradient(90deg, rgba(80,55,30,.18) 0 10px, transparent 10px),
    linear-gradient(180deg, #f7efdf, #e8d7bc);
  box-shadow:
    inset 8px 0 16px rgba(80,50,20,.12),
    var(--shadow);
  overflow: hidden;
  animation: bookIn .7s ease both;
}
@keyframes bookIn {
  from { opacity: 0; transform: rotateY(-12deg) translateX(-20px); }
  to { opacity: 1; transform: none; }
}
.book-page {
  height: 100%;
  padding: 28px 24px 72px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.book-page .dedication {
  font-family: var(--font-display);
  font-size: 1.4rem;
  text-align: center;
  margin: 40px 12px;
  line-height: 1.6;
  color: #5a4630;
}
.book-page .chapter-tag {
  font-size: .75rem;
  letter-spacing: .22em;
  color: #8a7355;
  margin-bottom: 10px;
}
.book-page h2 {
  font-family: var(--font-brand);
  font-size: 1.55rem;
  font-weight: 400;
  margin: 0 0 16px;
}
.book-page h3 {
  font-size: 1.05rem;
  margin: 18px 0 8px;
  color: #5c4630;
}
.book-page .body {
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: .98rem;
  color: #2c2418;
}
.book-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.book-nav .btn { flex: 1; }
.page-indicator {
  text-align: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: .82rem;
}

/* —— 我的 —— */
.mine-list { display: grid; gap: 12px; margin-top: 18px; }
.mine-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 18px 18px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.58);
  box-shadow: 0 8px 24px rgba(20,20,20,.08);
}
.mine-item strong {
  display: block;
  font-family: var(--font-brand);
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: 6px;
}
.mine-item span { color: var(--muted); font-size: .85rem; }
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  line-height: 1.7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 50;
  max-width: 86vw;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(20, 32, 24, .92);
  color: #f4f7f2;
  font-size: .9rem;
  animation: rise .25s ease both;
}
.toast[hidden],
.loading[hidden],
.topbar[hidden] {
  display: none !important;
}
.loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 18, 14, .45);
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
}
.loading-card {
  width: min(300px, 86vw);
  padding: 28px 22px;
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  text-align: center;
  box-shadow: var(--shadow);
}
.loading-card p {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.ink-spin {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(20,32,24,.12);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-swap { animation: rise .45s ease both; }
