:root {
  --ink: #201812;
  --ink-soft: #4a4035;
  --muted: #7a6c5b;
  --paper: #f6ecd3;
  --paper-bright: #fff9ea;
  --line: rgba(84, 59, 31, .2);
  --jade: #315f4f;
  --jade-soft: #e3edde;
  --cinnabar: #a14a3a;
  --shadow: 0 18px 50px rgba(55, 39, 23, .18);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif CJK SC", serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --app-h: 100vh;
  --pad: clamp(14px, 3.2vw, 30px);
}
@supports (height: 100dvh) { :root { --app-h: 100dvh; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 18% 8%, rgba(255, 252, 240, .9), transparent 45%),
    radial-gradient(circle at 82% 0%, rgba(227, 237, 222, .55), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(240, 222, 190, .6), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 0 var(--pad) 40px;
  min-height: var(--app-h);
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 0 6px;
}
.topbar__brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 0 1 auto; overflow: hidden; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.brand-name { font-size: 16px; letter-spacing: .08em; color: var(--ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.topbar__avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.topbar__nav { display: flex; gap: 6px; flex: 0 0 auto; }
.topbar__nav { gap: 5px; }
.topbar__nav a, .topbar__nav button {
  border: 1px solid var(--line); background: rgba(255, 249, 234, .7);
  border-radius: 999px; padding: 6px 10px; font-size: 12.5px; color: var(--ink-soft);
  font-family: var(--sans); white-space: nowrap;
}
.topbar__nav a.active { background: var(--jade); color: #fdfaf0; border-color: var(--jade); }
.topbar__nav .nav-admin {
  background: rgba(255, 249, 234, .9); border-color: var(--line); color: var(--ink-soft);
}
.topbar__nav .nav-admin.has-pending {
  background: var(--cinnabar); border-color: var(--cinnabar); color: #fff6ef;
  box-shadow: 0 4px 12px rgba(161, 74, 58, .28);
}
.topbar__nav .who {
  flex: 0 0 32px; width: 32px; height: 32px; padding: 0; display: grid; place-items: center;
  border: 1px solid rgba(49, 95, 79, .35); background: var(--jade-soft); color: var(--jade);
  border-radius: 50%; font-size: 13px; font-family: var(--sans); overflow: hidden;
}

/* ---------- 首页 ---------- */
.hero { padding: 26px 0 18px; text-align: center; }
.hero__eyebrow {
  font-family: var(--sans); font-size: 12px; letter-spacing: .22em;
  color: var(--jade); text-transform: uppercase; margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(30px, 8vw, 46px); margin: 0 0 12px; letter-spacing: .12em; font-weight: 600;
}
.hero p { margin: 0 auto; max-width: 30em; color: var(--ink-soft); line-height: 1.9; font-size: 15px; }
.hero__seal {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  font-family: var(--sans); font-size: 12px; color: var(--cinnabar);
  border: 1px solid rgba(161, 74, 58, .45); border-radius: 999px; padding: 6px 14px;
  background: rgba(255, 249, 234, .6);
}

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 22px 0 8px;
}
.stat {
  background: rgba(255, 249, 234, .72); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 8px; text-align: center;
}
.stat b { display: block; font-size: 24px; color: var(--jade); font-variant-numeric: tabular-nums; }
.stat span { font-family: var(--sans); font-size: 11px; color: var(--muted); letter-spacing: .08em; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 30px 0 14px;
}
.section-title h2 { font-size: 19px; margin: 0; letter-spacing: .08em; font-weight: 600; }
.section-title span { font-family: var(--sans); font-size: 12px; color: var(--muted); }

.cards { display: grid; gap: 14px; }
@media (min-width: 620px) { .cards { grid-template-columns: 1fr 1fr; } }

.card {
  position: relative; border-radius: 20px; overflow: hidden; background: #e8dcc2;
  box-shadow: 0 10px 30px rgba(55, 39, 23, .12); border: 1px solid rgba(255, 255, 255, .4);
  display: block; aspect-ratio: 4 / 3;
  transition: transform .25s ease, box-shadow .25s ease;
}
.card:active { transform: scale(.985); }
.card img { width: 100%; height: 100%; object-fit: cover; }
.card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(32, 24, 18, 0) 38%, rgba(32, 24, 18, .72) 100%);
}
.card__meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 18px; z-index: 2; color: #fdf8e9;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px;
}
.card__title { font-size: 26px; letter-spacing: .16em; line-height: 1.2; }
.card__sub { font-family: var(--sans); font-size: 11.5px; opacity: .82; margin-top: 5px; letter-spacing: .06em; }
.card__theme {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  font-family: var(--sans); font-size: 11px; padding: 5px 10px; border-radius: 999px;
  background: rgba(255, 249, 234, .86); color: var(--ink-soft); backdrop-filter: blur(6px);
}
.card__badge {
  font-family: var(--sans); font-size: 10.5px; padding: 4px 9px; border-radius: 999px;
  background: rgba(49, 95, 79, .9); color: #f4f9ef; white-space: nowrap;
}
.card__badge.is-done { background: rgba(161, 74, 58, .92); color: #fff5ee; }
.card__title.is-long { font-size: 19px; letter-spacing: .04em; line-height: 1.35; }

/* 筛选 */
.filters { display: grid; gap: 10px; margin-bottom: 16px; }
.filters input {
  width: 100%; padding: 11px 14px; border-radius: 13px; border: 1px solid var(--line);
  background: rgba(255, 249, 234, .8); font-family: var(--sans); font-size: 14px; color: var(--ink);
  outline: none;
}
.filters input:focus { border-color: rgba(49, 95, 79, .5); background: #fffdf6; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line); background: rgba(255, 249, 234, .7); border-radius: 999px;
  padding: 7px 15px; font-family: var(--sans); font-size: 13px; color: var(--ink-soft);
}
.chips button.is-on { background: var(--jade); border-color: var(--jade); color: #f6fbf1; }

/* ---------- 诗页 ---------- */
.poem { padding-bottom: 132px; }
.poem__hero {
  position: relative; margin: 8px calc(var(--pad) * -1) 0; border-radius: 0 0 26px 26px;
  overflow: hidden; box-shadow: var(--shadow);
}
.poem__hero img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.poem__hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(28, 22, 16, .08) 30%, rgba(28, 22, 16, .78) 100%);
}
.poem__hero-text { position: absolute; inset: auto 0 0; padding: 18px 20px 22px; color: #fdf7e6; z-index: 2; }
.poem__theme { font-family: var(--sans); font-size: 11px; letter-spacing: .16em; opacity: .8; }
.poem__title { font-size: clamp(30px, 9vw, 42px); letter-spacing: .2em; margin: 6px 0 4px; }
.poem__by { font-size: 13px; opacity: .85; letter-spacing: .1em; }

.poem__sheet {
  position: relative; margin-top: -18px; background: rgba(255, 249, 234, .92);
  border: 1px solid rgba(255, 255, 255, .6); border-radius: 22px;
  box-shadow: 0 14px 40px rgba(55, 39, 23, .12);
  padding: 22px 18px 20px; backdrop-filter: blur(8px);
}
.lines { display: grid; gap: 20px; text-align: center; }
.line { display: grid; gap: 5px; }
.line__pinyin {
  font-family: var(--sans); font-size: 12.5px; letter-spacing: .09em; color: var(--muted);
  display: none; line-height: 1.5;
}
body.show-pinyin .line__pinyin { display: block; }
.line__text {
  font-size: clamp(23px, 6.4vw, 31px); letter-spacing: .16em; line-height: 1.7;
  color: var(--ink); transition: color .3s ease, opacity .3s ease;
}
.line.is-playing .line__text { color: var(--jade); text-shadow: 0 0 22px rgba(49, 95, 79, .18); }
.line .ch { transition: opacity .25s ease; }
.line .ch.masked {
  display: inline-block;
  min-width: 1em;
  margin: 0 .03em;
  padding: 0 1px;
  color: transparent;
  background: rgba(84, 59, 31, .06);
  border-bottom: 2px solid rgba(84, 59, 31, .3);
  border-radius: 3px;
  cursor: pointer;
}
.line .ch.masked.revealed {
  color: inherit;
  border-bottom-color: transparent;
}
.line.is-hidden .anno { border-bottom-color: transparent; }
.line.is-hidden .anno:has(.ch.revealed) { border-bottom-color: rgba(49, 95, 79, .45); }
body[data-recite="1"] .line__pinyin { opacity: .3; }
body[data-recite="2"] .line__pinyin { opacity: 0; }

.anno {
  border: 0; background: transparent; padding: 0 1px; font: inherit; color: inherit;
  border-bottom: 2px dotted rgba(49, 95, 79, .45); line-height: inherit;
}
.anno:active { background: var(--jade-soft); }

.poem__tools {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 22px 0 6px;
}
.tool {
  flex: 1 1 auto; min-width: 76px; border: 1px solid var(--line); background: rgba(255, 255, 255, .5);
  border-radius: 14px; padding: 11px 8px; font-size: 13.5px; font-family: var(--sans);
  color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tool.is-on { background: var(--jade); border-color: var(--jade); color: #f6fbf1; }
.tool--play { background: var(--jade); border-color: var(--jade); color: #f6fbf1; }
.tool--play.is-playing { background: var(--cinnabar); border-color: var(--cinnabar); }

.recite {
  margin-top: 18px; border: 1px dashed rgba(161, 74, 58, .4); border-radius: 16px;
  padding: 14px 16px; background: rgba(255, 245, 235, .7);
}
.recite__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.recite__head b { font-size: 14px; letter-spacing: .08em; }
.recite__hint { font-family: var(--sans); font-size: 11.5px; color: var(--muted); }
.recite__levels { display: flex; gap: 8px; margin-top: 12px; }
.recite__levels button {
  flex: 1; padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .6); font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft);
}
.recite__levels button.is-on { background: var(--jade); color: #f6fbf1; border-color: var(--jade); }

/* 底部操作条 */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(100%, 780px);
  padding: 10px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(246, 236, 211, 0) 0%, rgba(246, 236, 211, .96) 42%);
  display: flex; gap: 10px; z-index: 30;
}
.dock button {
  flex: 1; padding: 13px 10px; border-radius: 15px; border: 1px solid var(--line);
  background: rgba(255, 249, 234, .96); font-family: var(--sans); font-size: 13.5px;
  color: var(--ink-soft); box-shadow: 0 6px 18px rgba(55, 39, 23, .1);
}
.dock button.primary { background: var(--jade); border-color: var(--jade); color: #f6fbf1; }
.dock button.done { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff6ef; }

/* ---------- 底部抽屉 ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(28, 22, 16, .42); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.sheet-mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 102%);
  width: min(100%, 780px); max-height: 78vh; overflow: auto;
  background: var(--paper-bright); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(28px + env(safe-area-inset-bottom)); z-index: 41;
  transition: transform .3s cubic-bezier(.22, .8, .3, 1);
  box-shadow: 0 -18px 50px rgba(55, 39, 23, .22);
}
.sheet.show { transform: translate(-50%, 0); }
.sheet__grip { width: 44px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 12px; font-size: 17px; letter-spacing: .1em; }
.sheet h3 small { font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.sheet p { line-height: 1.95; color: var(--ink-soft); font-size: 15px; margin: 0 0 12px; }
.sheet .def { font-size: 14.5px; line-height: 1.9; }

/* ---------- 登录页 ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: 34px 0 20px; text-align: center; }
.auth__mark {
  width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 20px;
  display: block; object-fit: cover;
  box-shadow: 0 12px 30px rgba(120, 60, 40, .18);
}
.auth h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: .1em; }
.auth__sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; font-family: var(--sans); }
.auth__tabs {
  display: flex; gap: 6px; background: rgba(255, 249, 234, .8);
  border: 1px solid var(--line); border-radius: 14px; padding: 5px; margin-bottom: 18px;
}
.auth__tabs button {
  flex: 1; padding: 10px; border: 0; border-radius: 10px; background: transparent;
  font-family: var(--sans); font-size: 13.5px; color: var(--muted);
}
.auth__tabs button.is-on { background: var(--jade); color: #f6fbf1; }
.field { display: block; text-align: left; margin-bottom: 12px; }
.field[hidden] { display: none; }
.field > span { display: block; font-family: var(--sans); font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 13px 14px; border-radius: 13px; border: 1px solid var(--line);
  background: #fffdf6; font-family: var(--sans); font-size: 15px; color: var(--ink); outline: none;
}
.field input:focus { border-color: rgba(49, 95, 79, .55); box-shadow: 0 0 0 3px rgba(49, 95, 79, .1); }
.auth__go {
  width: 100%; margin-top: 6px; padding: 14px; border-radius: 14px; border: 0;
  background: var(--jade); color: #f6fbf1; font-family: var(--sans); font-size: 15px;
  box-shadow: 0 10px 24px rgba(49, 95, 79, .24);
}
.auth__go:disabled { opacity: .6; }
.auth__err { min-height: 20px; margin: 10px 0 0; color: var(--cinnabar); font-family: var(--sans); font-size: 13px; }
.auth__users { margin-top: 22px; }
.auth__hint { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.auth__users .chip {
  border: 1px solid var(--line); background: rgba(255, 249, 234, .8); border-radius: 999px;
  padding: 8px 15px; margin: 0 6px 8px 0; font-family: var(--sans); font-size: 13px; color: var(--ink-soft);
}
.acct { display: flex; align-items: baseline; gap: 8px; font-family: var(--sans); }
.acct b { font-family: var(--serif); font-size: 18px; letter-spacing: .06em; }
.acct span { color: var(--muted); font-size: 12.5px; }
.mrow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.mrow:last-child { border-bottom: 0; }
.mrow__who { display: grid; gap: 3px; min-width: 0; }
.mrow__who b { font-size: 15px; letter-spacing: .05em; }
.mrow__who span { font-family: var(--sans); font-size: 11.5px; color: var(--muted); }
.mrow__act { display: flex; gap: 6px; flex: 0 0 auto; }
.mini {
  border: 1px solid var(--line); background: #fffdf6; border-radius: 9px;
  padding: 7px 12px; font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft);
}
.mini.ok { background: var(--jade); border-color: var(--jade); color: #f6fbf1; }
.mini.no { color: var(--cinnabar); border-color: rgba(161, 74, 58, .4); }
.badge {
  display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 999px;
  background: var(--cinnabar); color: #fff6ef; font-family: var(--sans);
  font-size: 11px; margin-left: 6px; vertical-align: 2px;
}

.pw-form { display: grid; gap: 8px; }
.pw-form input {
  padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line);
  background: #fffdf6; font-family: var(--sans); font-size: 14px; color: var(--ink); outline: none;
}
.pw-form input:focus { border-color: rgba(49, 95, 79, .5); }
.pw-form button {
  padding: 12px; border-radius: 12px; border: 1px solid var(--jade);
  background: var(--jade); color: #f6fbf1; font-family: var(--sans); font-size: 14px;
}
.pw-form button:disabled { opacity: .6; }

/* ---------- 家长页 ---------- */
.panel {
  background: rgba(255, 249, 234, .8); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; margin-top: 16px;
}
.panel h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: .08em; }
.rows { display: grid; gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; }
.row {
  display: grid; grid-template-columns: 1.4fr .9fr .9fr .8fr; gap: 8px; align-items: center;
  background: var(--paper-bright); padding: 12px; font-family: var(--sans); font-size: 12.5px;
}
.row.head { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.row b { font-family: var(--serif); font-size: 14px; font-weight: 600; letter-spacing: .06em; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: rgba(122, 108, 91, .35); }
.dot.on { background: var(--jade); }
.dot.recited { background: var(--cinnabar); }

.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.actions button, .actions a {
  flex: 1; text-align: center; padding: 12px; border-radius: 13px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .6); font-family: var(--sans); font-size: 13px; color: var(--ink-soft);
}

.empty { text-align: center; color: var(--muted); font-family: var(--sans); font-size: 13px; padding: 30px 0; }
.footer { margin-top: 40px; text-align: center; font-family: var(--sans); font-size: 11.5px; color: var(--muted); line-height: 1.9; }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translate(-50%, 12px);
  background: rgba(32, 24, 18, .9); color: #f8f2e2; padding: 10px 18px; border-radius: 999px;
  font-family: var(--sans); font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.skeleton { height: 180px; border-radius: 18px; background: linear-gradient(90deg, #efe3c9, #f7efdd, #efe3c9); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { 0% { background-position: 0 0; } 100% { background-position: 200% 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
