:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #e3ded5;
  --accent: #8a3b1f;
  --mark: #f6e3a1;
  --error: #b42318;
  color-scheme: light dark;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --surface: #242320;
    --text: #ece8e1;
    --muted: #a39d93;
    --border: #3a3833;
    --accent: #e39a72;
    --mark: #6b5418;
    --error: #f97066;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px;
}

.brand {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

a { color: var(--accent); }

input, select, button {
  font: inherit;
  color: inherit;
}

input, select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
}

button:disabled { opacity: 0.6; cursor: default; }

.link-button {
  background: none;
  color: var(--accent);
  padding: 0;
  font-size: 0.875rem;
  white-space: nowrap;
}

.muted { color: var(--muted); font-size: 0.875rem; }
.error { color: var(--error); }

/* 登录 */
.login { max-width: 360px; margin: 12vh auto 0; }
.login h1 { font-size: 1.4rem; margin: 0 0 4px; }
.login form { display: flex; gap: 8px; margin-top: 16px; }
.login input { flex: 1; letter-spacing: 0.1em; text-transform: uppercase; }

/* 搜索 */
.search-form { display: grid; gap: 10px; }
.search-form input[type="search"] { width: 100%; font-size: 1.05rem; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters label { display: grid; gap: 4px; font-size: 0.8125rem; color: var(--muted); flex: 1 1 140px; }
.filters button { flex: 0 0 auto; }

.results { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 12px; }

.result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.result .quote {
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
  display: block;
}

.result .quote:hover { color: var(--accent); }

.result .meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* 阅读 */
.reader-nav {
  position: sticky;
  top: 0;
  background: var(--bg);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.reader-title { color: var(--muted); }

.passage {
  font-family: "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  font-size: 1.1rem;
  line-height: 1.95;
}

.passage p { text-indent: 2em; margin: 0 0 1em; }

mark {
  background: var(--mark);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.pager {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pager .disabled { visibility: hidden; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }
.chip {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.875rem;
}
.chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.result .tag { margin: 0 0 6px; font-size: 0.8125rem; color: var(--accent); }
.list-title { font-size: 1rem; margin: 18px 0 10px; }
.list-title .muted { font-weight: normal; }

[hidden] { display: none !important; }
