:root {
  --bg: #f4f0e6;
  --bg2: #ece6d8;
  --card: #fffdf7;
  --ink: #211f1a;
  --muted: #7c7568;
  --line: #e2dacb;
  --accent: #9a3a2c;
  --accent-soft: #f3e3dc;
  --green: #33544b;
  --gold: #a97c34;
  --shadow: 0 6px 24px rgba(70, 55, 35, .08);
  --r: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC",
    "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, #efe6d2 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #eee7d8 0%, transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-weight: 600;
  letter-spacing: .01em;
}
h2 { font-size: 1.05rem; margin: 0 0 10px; }
h3 { font-size: .95rem; margin: 10px 0 8px; }
p { margin: 8px 0; }
a { color: var(--accent); }

.hint { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.mt { margin-top: 16px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.hidden, [hidden] { display: none !important; }

/* ── 登录 ─────────────────────────────── */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
}
.auth-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 30px 26px 24px;
  text-align: center;
}
.auth-card h1 { font-size: 1.45rem; margin: 12px 0 4px; }
.auth-card .sub { color: var(--muted); font-size: .86rem; margin: 0 0 18px; }
.auth form { text-align: left; }
.auth .hint { text-align: center; margin-top: 14px; }

.seal {
  width: 54px; height: 54px; margin: 0 auto;
  display: grid; place-items: center;
  background: var(--accent); color: #fff8ee;
  font-family: "Noto Serif SC", serif;
  font-size: 28px; border-radius: 12px;
  box-shadow: inset 0 0 0 2px rgba(255, 240, 220, .35);
  transform: rotate(-3deg);
}
.seal.sm {
  width: 26px; height: 26px; font-size: 15px; border-radius: 7px;
  display: inline-grid; margin: 0;
  transform: rotate(-4deg);
}

/* ── 布局 ─────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px max(16px, env(safe-area-inset-left)) 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 1rem; }
.brand b { font-family: "Noto Serif SC", serif; letter-spacing: .04em; }
.who { font-size: .82rem; color: var(--muted); }

main {
  max-width: 720px; margin: 0 auto;
  padding: 14px 16px calc(84px + env(safe-area-inset-bottom));
}
.page { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }

.nav-bottom {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 30;
  width: min(560px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(60, 44, 24, .12);
  padding: 6px;
}
.nav-bottom button {
  position: relative;
  appearance: none; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0 5px; border-radius: 14px; color: var(--muted);
  font-size: .68rem; font-family: inherit;
}
.nav-bottom button i {
  font-style: normal; font-family: "Noto Serif SC", serif;
  font-size: 1rem; width: 30px; height: 26px; display: grid; place-items: center;
  border-radius: 9px;
}
.nav-bottom button.on { color: var(--accent); }
.nav-bottom .dot { position: absolute; top: 6px; right: calc(50% - 16px); width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--card); }
.nav-bottom button.on i { background: var(--accent-soft); }

/* ── 卡片 / 表格 ──────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset;
}
.card.flush { padding: 4px 16px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 12px 0 18px;
}
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 13px; padding: 10px 8px; text-align: center;
}
.stat b { display: block; font-size: 1.18rem; font-family: "Noto Serif SC", serif; }
.stat span { font-size: .68rem; color: var(--muted); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 8px; }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

/* ── 表单 ─────────────────────────────── */
.field { display: block; margin: 9px 0; }
.field > span { display: block; font-size: .76rem; color: var(--muted); margin-bottom: 4px; }
.field.inline { flex: 1; min-width: 90px; margin: 0; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #fffdf9; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.err { color: var(--accent); background: var(--accent-soft); border-radius: 9px; padding: 8px 10px; font-size: .82rem; margin: 8px 0; }

/* ── 按钮 ─────────────────────────────── */
.btn {
  appearance: none; font: inherit; font-size: .86rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; line-height: 1.2;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff9f0; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: .8rem; }
.btn.block { width: 100%; margin-top: 8px; }
.btn.danger { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.btn:disabled { opacity: .5; cursor: default; }

.seg {
  display: inline-flex; background: var(--bg2); border-radius: 10px; padding: 3px; gap: 2px;
  margin-bottom: 12px;
}
.seg button {
  appearance: none; border: 0; background: none; font: inherit; font-size: .82rem;
  color: var(--muted); padding: 6px 14px; border-radius: 8px; cursor: pointer;
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.seg.sm button { padding: 5px 10px; font-size: .78rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chip {
  border: 1px solid var(--line); background: #fffdf9; color: var(--ink);
  font-size: .78rem; padding: 5px 10px; border-radius: 999px; cursor: pointer;
}
.chip.on { background: var(--green); border-color: var(--green); color: #f6f3ea; }
.chip b { font-weight: 600; opacity: .65; margin-left: 4px; font-size: .72rem; }

/* ── 列表 ─────────────────────────────── */
.log-item {
  border-left: 3px solid var(--accent-soft);
  padding: 2px 0 2px 12px; margin: 12px 0;
}
.log-item .meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.log-item .meta b { font-weight: 600; }
.log-item .meta time { color: var(--muted); font-size: .76rem; }
.log-item p { margin: 5px 0 0; font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.log-item .pills { margin-top: 6px; }

.pill {
  display: inline-block; font-size: .72rem; color: var(--muted);
  background: var(--bg2); border-radius: 999px; padding: 2px 8px; margin: 2px 4px 0 0;
}
.pill.red { background: var(--accent-soft); color: var(--accent); }
.pill.green { background: #e3ece8; color: var(--green); }
.pill.gold { background: #f4ead6; color: var(--gold); }

.empty { text-align: center; color: var(--muted); font-size: .86rem; padding: 26px 0; }

/* ── 刷题 ─────────────────────────────── */
.qmeta { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin: 4px 2px 8px; }
.qcard .stem { font-size: 1rem; line-height: 1.75; white-space: pre-wrap; }
.qcard .options { display: grid; gap: 7px; margin-top: 12px; }
.option {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); background: #fffdf9; border-radius: 11px;
  padding: 9px 11px; cursor: pointer; font-size: .92rem;
}
.option .k {
  flex: 0 0 22px; height: 22px; border-radius: 6px; background: var(--bg2);
  display: grid; place-items: center; font-size: .76rem; font-weight: 600;
}
.option.on { border-color: var(--green); background: #eef4f0; }
.option.on .k { background: var(--green); color: #fff; }
.option.right { border-color: #4c7c63; background: #e6f1ea; }
.option.wrong { border-color: var(--accent); background: #f9eae5; }
.result { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: .9rem; }
.result .tag { font-family: "Noto Serif SC", serif; font-size: 1rem; }
.result .tag.ok { color: #2f6b4f; }
.result .tag.no { color: var(--accent); }
.analysis { white-space: pre-wrap; color: #4a463d; font-size: .88rem; margin-top: 8px; }

/* ── 条形图 ───────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 96px; padding-top: 6px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bars .b i { display: block; width: 100%; background: linear-gradient(180deg, #b4654f, #9a3a2c); border-radius: 4px 4px 2px 2px; min-height: 2px; }
.bars .b span { font-size: .6rem; color: var(--muted); }
.bars .b.zero i { background: var(--line); }

.mrow { display: grid; grid-template-columns: 92px 1fr 46px; gap: 8px; align-items: center; font-size: .8rem; margin: 6px 0; }
.track { background: var(--bg2); height: 8px; border-radius: 999px; overflow: hidden; }
.dimrow .track { height: 7px; }
.mrow .track { height: 8px; }
.track i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.mrow em { font-style: normal; text-align: right; color: var(--muted); font-size: .76rem; }

/* ── 申论 ─────────────────────────────── */
.essay-item { padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.essay-item:last-child { border-bottom: 0; }
.essay-item .t { display: flex; justify-content: space-between; gap: 8px; }
.essay-item .t b { font-weight: 600; font-size: .94rem; }
.essay-item .score { font-family: "Noto Serif SC", serif; color: var(--accent); font-size: 1.05rem; }
.checks { display: grid; gap: 6px; }
.check { display: flex; gap: 8px; font-size: .84rem; align-items: baseline; }
.check i { font-style: normal; width: 16px; }
.check.ok i { color: #2f6b4f; }
.check.no i { color: var(--accent); }
.check span { color: var(--muted); font-size: .78rem; }
.dimrow { display: grid; grid-template-columns: 92px 1fr 42px; gap: 8px; align-items: center; font-size: .82rem; margin: 7px 0; }
.dimrow input[type=range] { padding: 0; accent-color: var(--accent); }
.essay-text { white-space: pre-wrap; font-size: .92rem; line-height: 1.8; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 74px; height: 74px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* ── 弹层 ─────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(35, 28, 18, .38);
  display: grid; place-items: end center;
  backdrop-filter: blur(2px);
}
.modal-box {
  width: min(640px, 100%); max-height: 90vh; overflow: auto;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  animation: sheet .22s ease;
}
@keyframes sheet { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .modal { place-items: center; }
  .modal-box { border-radius: 20px; }
}

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: #f7f1e6;
  padding: 9px 16px; border-radius: 999px; font-size: .84rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
}

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

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid.six { grid-template-columns: repeat(3, 1fr); }
  .stat b { font-size: 1.1rem; }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171613; --bg2: #23211c; --card: #201e1a; --ink: #ece5d7;
    --muted: #a49b8a; --line: #36322a; --accent: #d08063; --accent-soft: #3a2a22;
    --green: #7fa793; --gold: #c9a05a;
  }
  body { background: radial-gradient(900px 500px at 90% -10%, #242019 0%, transparent 60%), var(--bg); }
  .btn, input, select, textarea, .option, .chip { background: #262319; }
  .modal-box { background: var(--card); }
}

/* ── 番茄钟 ───────────────────────────── */
.timer-card { text-align: center; }
.timer-wrap { position: relative; width: min(250px, 66vw); margin: 4px auto 10px; }
.ring { width: 100%; display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--bg2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 552.92;
  stroke-dashoffset: 0; transition: stroke-dashoffset .3s linear; }
.timer-face { position: absolute; inset: 0; display: grid; place-content: center; gap: 2px; }
#pomo-time { font-family: "Noto Serif SC", serif; font-size: 2.5rem;
  font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.chips.center { justify-content: center; }
.checkline { display: flex; gap: 8px; align-items: center; justify-content: center;
  font-size: .8rem; color: var(--muted); margin: 8px 0; }
.checkline input { width: auto; }
.center { text-align: center; }

/* ── 练习入口 ─────────────────────────── */
.hub { display: grid; gap: 10px; margin: 10px 0 14px; }
.hub-card { display: grid; grid-template-columns: 46px 1fr; grid-template-rows: auto auto;
  gap: 2px 12px; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px; font: inherit; color: var(--ink); cursor: pointer; }
.hub-card:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.hub-ico { grid-row: 1 / 3; width: 46px; height: 46px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
  font-family: "Noto Serif SC", serif; font-size: 1.2rem; }
.hub-card b { font-size: .98rem; }
.hub-card span:last-child { color: var(--muted); font-size: .78rem; }

/* ── 社区 ─────────────────────────────── */
.feed-item { padding: 13px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-head { display: flex; gap: 9px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--green);
  color: #f7f3e8; display: grid; place-items: center; font-size: .85rem; flex: 0 0 34px;
  font-family: "Noto Serif SC", serif; }
.avatar.me { background: var(--accent); }
.feed-head .n { font-size: .86rem; font-weight: 600; }
.feed-head time { font-size: .7rem; color: var(--muted); margin-left: auto; }
.feed-title { font-family: "Noto Serif SC", serif; font-size: 1rem; margin: 8px 0 3px; }
.feed-body { font-size: .9rem; white-space: pre-wrap; word-break: break-word;
  color: color-mix(in srgb, var(--ink) 84%, var(--muted)); }
.feed-imgs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.feed-imgs img { width: 84px; height: 84px; object-fit: cover; border-radius: 9px;
  border: 1px solid var(--line); }
.feed-actions { display: flex; gap: 16px; margin-top: 9px; font-size: .8rem; color: var(--muted); }
.feed-actions button { border: 0; background: none; font: inherit; color: inherit;
  cursor: pointer; padding: 0; display: inline-flex; gap: 4px; align-items: center; }
.feed-actions button.on { color: var(--accent); }
.tag-kind { font-size: .66rem; padding: 1px 7px; border-radius: 999px;
  background: var(--bg2); color: var(--muted); margin-left: 6px; font-weight: 400; }
.comment { display: flex; gap: 9px; padding: 10px 0; border-top: 1px solid var(--line);
  font-size: .86rem; }
.comment .c-body { flex: 1; }
.comment .c-body b { font-size: .8rem; }
.comment time { color: var(--muted); font-size: .7rem; margin-left: 6px; }
.comment p { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }
.comment .del { font-size: .7rem; color: var(--muted); background: none; border: 0;
  cursor: pointer; padding: 0; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 6px 0;
  font-size: .86rem; }
.rank-row .no { width: 18px; color: var(--muted); font-family: "Noto Serif SC", serif; }
.rank-row .m { margin-left: auto; color: var(--muted); font-size: .78rem; }

/* ── 个人主页 ─────────────────────────── */
.profile-head { display: flex; gap: 14px; align-items: center; }
.profile-head .avatar { width: 58px; height: 58px; flex-basis: 58px; font-size: 1.35rem; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.badge { font-size: .66rem; background: var(--accent-soft); color: var(--accent);
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; font-weight: 400; }

@media (prefers-color-scheme: dark) {
  .feed-body { color: #d8d0c0; }
  .avatar { color: #1b1915; }
}
