:root {
  color-scheme: light;
  --bg: #f5f7f5;
  --surface: #ffffff;
  --surface-muted: #edf1ee;
  --text: #202622;
  --muted: #69726c;
  --line: #d7ded9;
  --accent: #9f352e;
  --accent-strong: #7e2722;
  --support: #2f6d5f;
  --shadow: 0 4px 16px rgba(27, 36, 30, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Noto Sans CJK SC", system-ui, sans-serif;
  letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
button, select { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(47, 109, 95, 0.28);
  outline-offset: 2px;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.header-inner, .page-shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}
.header-inner {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
h1 {
  margin: 0;
  font-family: "Noto Serif CJK SC", "Source Han Serif SC", "STSong", serif;
  font-size: 32px;
  line-height: 1.25;
  font-weight: 700;
}
.library-total { margin: 7px 0 0; color: var(--muted); }
.library-total strong { color: var(--support); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-link { display: inline-flex; align-items: center; justify-content: center; color: var(--text); text-decoration: none; }
.page-shell { padding: 26px 0 72px; }

.recent {
  padding: 0 0 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.section-heading h2 { margin: 0; font-size: 18px; }
.recent-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.recent-link {
  min-width: 0;
  display: block;
  padding: 12px 14px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.recent-link:hover { border-color: var(--support); }
.recent-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.recent-meta { display: flex; align-items: center; gap: 8px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.recent-progress { flex: 1; height: 4px; overflow: hidden; background: var(--surface-muted); border-radius: 2px; }
.recent-progress span { display: block; height: 100%; background: var(--support); }

.sticky-tools {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 0;
  background: rgba(245, 247, 245, 0.96);
  border-bottom: 1px solid transparent;
}
.sticky-tools.is-stuck { border-bottom-color: var(--line); }
.primary-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.search-field { position: relative; min-width: 0; }
.search-field input {
  width: 100%;
  min-height: 48px;
  padding: 11px 48px 11px 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.search-field input::placeholder { color: #89918c; }
.icon-button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 24px;
  cursor: pointer;
}
.command-button {
  min-height: 44px;
  padding: 9px 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.command-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); }
.command-button:disabled { opacity: 0.45; cursor: default; }
.filter-button { min-height: 48px; min-width: 92px; }
.filter-button[aria-expanded="true"] { color: #fff; background: var(--support); border-color: var(--support); }
.text-button {
  min-height: 36px;
  padding: 5px 8px;
  color: var(--accent);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.filters[hidden] { display: none; }
.filters label { min-width: 0; color: var(--muted); font-size: 12px; }
.filters select, .sort-label select {
  width: 100%;
  min-height: 42px;
  margin-top: 5px;
  padding: 7px 30px 7px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.reset-button { align-self: end; justify-self: start; }

.result-bar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
}
.count { margin: 0; color: var(--muted); font-size: 14px; }
.sort-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.sort-label select { width: 112px; min-height: 38px; margin: 0; }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.book-card {
  min-width: 0;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  padding: 14px 15px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.book-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.book-title {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: "Noto Serif CJK SC", "Source Han Serif SC", "STSong", serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.book-meta { margin-top: auto; padding-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.tag-row { display: flex; gap: 6px; min-width: 0; margin-bottom: 5px; overflow: hidden; }
.tag {
  max-width: 50%;
  padding: 2px 6px;
  overflow: hidden;
  color: #425048;
  background: var(--surface-muted);
  border-radius: 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.review-tag { color: #7a4d0d; background: #f5e8ce; }
.empty { padding: 56px 16px; color: var(--muted); text-align: center; border: 1px dashed var(--line); }
.pager { display: grid; grid-template-columns: 120px minmax(100px, auto) 120px; justify-content: center; align-items: center; gap: 14px; margin-top: 24px; }
.page-status { color: var(--muted); text-align: center; font-size: 14px; }
.noscript { padding: 24px; text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 820px) {
  .header-inner, .page-shell { width: min(100% - 28px, 720px); }
  .recent-list, .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .header-inner, .page-shell { width: calc(100% - 24px); }
  .header-inner { min-height: 92px; gap: 12px; }
  h1 { font-size: 25px; }
  .library-total { margin-top: 4px; font-size: 13px; }
  .header-actions { flex-direction: column; gap: 6px; }
  .header-actions .command-button { min-height: 36px; padding: 6px 10px; font-size: 13px; }
  .page-shell { padding-top: 14px; }
  .recent-list, .book-grid { grid-template-columns: minmax(0, 1fr); }
  .recent-list { gap: 8px; }
  .sticky-tools { margin-inline: -12px; padding: 9px 12px; }
  .primary-tools { grid-template-columns: minmax(0, 1fr) 76px; }
  .filter-button { min-width: 0; padding-inline: 10px; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 10px; }
  .result-bar { align-items: center; }
  .sort-label > span { display: none; }
  .sort-label select { width: 96px; }
  .book-card { min-height: 106px; }
  .pager { grid-template-columns: 96px minmax(74px, auto) 96px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
