/* 云笺 · Cloudflare 小说阅读站
   Mobile-first；≥960px 切换 PC 顶栏 + 宽版式 */
:root {
  --bg: #f4efe6;
  --bg-elevated: #faf7f1;
  --bg-soft: #ebe4d6;
  --ink: #1c1917;
  --ink-2: #44403c;
  --ink-3: #78716c;
  --line: rgba(28, 25, 23, 0.12);
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --accent-ink: #115e59;
  --danger: #b91c1c;
  --shadow: 0 10px 40px rgba(28, 25, 23, 0.08);
  --radius: 16px;
  --font-serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --reader-size: 18px;
  --reader-lh: 1.7;
  --topbar-h: 60px;
  --nav-h: 64px;
  --max: 720px;
  --reader-max: 720px;
  --page-pad: 16px;
}

[data-theme="night"] {
  --bg: #0f1419;
  --bg-elevated: #171d24;
  --bg-soft: #202832;
  --ink: #e7e0d5;
  --ink-2: #c4b8a5;
  --ink-3: #8b8175;
  --line: rgba(231, 224, 213, 0.12);
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --accent-ink: #5eead4;
  --danger: #f87171;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

[data-theme="ink"] {
  --bg: #111318;
  --bg-elevated: #181b22;
  --bg-soft: #222630;
  --ink: #f3ebe2;
  --ink-2: #cfc4b5;
  --ink-3: #8f8476;
  --line: rgba(243, 235, 226, 0.1);
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.14);
  --accent-ink: #fbbf24;
  --danger: #ef4444;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100dvh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent-ink); text-decoration: none; }

.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--page-pad);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 30%, var(--accent-soft), transparent 55%),
    linear-gradient(145deg, var(--accent), #134e4a);
  box-shadow: 0 6px 18px rgba(15, 118, 110, 0.28);
  flex-shrink: 0;
}

.brand-text { min-width: 0; }

.brand-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.15;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}

.topnav {
  display: none;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.topnav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.topnav-item:hover,
.topnav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.topbar-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-ink);
  outline: none;
}

.only-mobile { display: inline-flex; }

/* 主区域 */
.main {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: var(--page-pad);
  padding-bottom: 28px;
}

.view {
  display: none;
  animation: fadeUp 0.28s ease;
}

.view.is-active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 搜索 */
.search-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}

.search-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  min-height: 44px;
}

.search-box input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  min-width: 0;
  padding: 10px 0;
}

.search-box input::placeholder { color: var(--ink-3); }

.search-clear {
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
}

.source-select {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 0 10px;
  outline: none;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.nav-btn,
.text-btn,
.seg-btn {
  border-radius: 12px;
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}

.primary-btn {
  width: 100%;
  min-height: 44px;
  background: linear-gradient(135deg, var(--accent), #0b5f59);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.25);
}

.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:active { transform: translateY(1px); }

.ghost-btn,
.danger-btn {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-2);
}

.danger-btn {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
}

/* 首页布局 */
.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.home-side { display: none; }

.side-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.side-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
}

.side-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
}

.side-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-2);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}

.text-btn {
  color: var(--accent-ink);
  font-size: 13px;
  padding: 6px 8px;
}

.history-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.history-chip {
  flex: 0 0 auto;
  max-width: 240px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  text-align: left;
}

.history-chip .name {
  display: block;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-chip .sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-3);
  text-align: center;
  font-size: 14px;
  background: color-mix(in srgb, var(--bg-elevated) 70%, transparent);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.book-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.book-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.book-cover {
  width: 72px;
  height: 96px;
  border-radius: 10px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 35%, var(--bg-soft)), var(--bg-soft));
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  padding: 6px;
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.25;
  color: var(--ink);
  text-align: center;
  overflow: hidden;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card .author {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.book-card .latest {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--accent-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
}

.book-row .book-cover {
  width: 56px;
  height: 74px;
  font-size: 11px;
}

.book-row h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.book-row .author {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.book-row .intro {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-row .tag {
  font-size: 11px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}

/* 书籍详情 */
.book-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.book-side { display: none; }

.sticky-card .primary-btn { margin-top: 12px; }

.book-hero {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, var(--accent-soft), transparent 45%),
    var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}

.book-hero .cover {
  width: 100px;
  height: 136px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.3;
  text-align: center;
  padding: 10px;
}

.book-hero .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-hero h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.3;
}

.book-hero .meta {
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

.book-hero .intro {
  margin: 12px 0 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-hero .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.book-hero .actions .primary-btn {
  width: auto;
  min-width: 120px;
  padding: 0 16px;
}

.chapter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}

.meta {
  font-size: 13px;
  color: var(--ink-3);
}

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.seg-btn {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--ink-3);
  font-size: 12px;
}

.seg-btn.is-active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chapter-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.chapter-item:hover,
.chapter-item.is-current {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
}

.chapter-item .idx {
  color: var(--ink-3);
  font-size: 12px;
  min-width: 36px;
}

.chapter-item .name {
  flex: 1;
  font-size: 14px;
  color: var(--ink);
}

/* 阅读器 */
.reader-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  max-width: var(--reader-max);
}

.reader-book {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

.reader-chapter {
  margin: 6px 0 0;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
}

.reader-body {
  width: 100%;
  max-width: var(--reader-max);
  margin: 0 auto;
  font-family: var(--font-serif);
  font-size: var(--reader-size);
  line-height: var(--reader-lh);
  color: var(--ink);
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  word-break: break-word;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg-elevated) 92%, transparent), transparent 80px),
    var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 18px 28px;
  min-height: 48vh;
  box-shadow: var(--shadow);
}

.reader-body.is-loading {
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 14px;
}

.reader-nav {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
  max-width: var(--reader-max);
  margin-left: auto;
  margin-right: auto;
}

.nav-btn {
  min-height: 44px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 14px;
}

.nav-btn-mid { color: var(--accent-ink); }

.nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 底部导航（移动端） */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 12px;
  color: var(--ink-3);
  font-size: 11px;
}

.nav-item.is-active {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

/* 抽屉 / 模态 */
.drawer,
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.drawer[hidden],
.modal[hidden],
.toast[hidden] { display: none !important; }

.drawer-mask,
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 14, 12, 0.45);
  backdrop-filter: blur(2px);
}

.drawer-panel,
.modal-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(100%, 420px);
  background: var(--bg-elevated);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s ease;
}

.modal-panel {
  left: 50%;
  right: auto;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(92vw, 640px);
  max-height: min(80vh, 720px);
  border-radius: 18px;
  border: 1px solid var(--line);
  animation: popIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(18px); opacity: 0.4; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes popIn {
  from { transform: translate(-50%, -48%); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
}

.drawer-body,
.modal-body {
  padding: 16px;
  overflow: auto;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.source-item {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.source-item.is-active {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: var(--accent-soft);
}

.source-item .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.source-item h4 {
  margin: 0;
  font-size: 14px;
}

.source-item p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
  word-break: break-all;
}

.pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
  white-space: nowrap;
}

.pill.ok {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}

.field span {
  font-size: 13px;
  color: var(--ink-2);
}

.field em {
  font-style: normal;
  color: var(--accent-ink);
  font-weight: 600;
}

.drawer-body input[type="text"],
.drawer-body textarea,
.drawer-body select,
.field input[type="text"],
.field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 10px 12px;
  outline: none;
}

.drawer-body textarea {
  resize: vertical;
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 24px);
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(90vw, 420px);
  padding: 12px 16px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  color: var(--bg);
  font-size: 13px;
  box-shadow: var(--shadow);
  text-align: center;
}

/* ========== 平板 ========== */
@media (min-width: 720px) {
  :root {
    --max: 840px;
    --page-pad: 20px;
    --reader-max: 760px;
  }

  .search-toolbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .search-box {
    flex: 1 1 240px;
  }

  .source-select {
    width: auto;
    min-width: 140px;
  }

  .search-submit {
    width: auto;
    min-width: 112px;
    padding: 0 18px;
    flex: 0 0 auto;
  }

  .book-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  .book-card {
    grid-template-columns: 64px 1fr;
  }

  .book-card .book-cover {
    width: 64px;
    height: 88px;
  }

  .book-hero {
    grid-template-columns: 120px 1fr;
  }

  .book-hero .cover {
    width: 120px;
    height: 160px;
    font-size: 18px;
  }

  .book-hero h2 {
    font-size: 26px;
  }

  .reader-chapter {
    font-size: 24px;
  }

  .reader-body {
    padding: 28px 28px 36px;
  }
}

/* ========== PC ========== */
@media (min-width: 960px) {
  :root {
    --topbar-h: 68px;
    --max: 1180px;
    --reader-max: 820px;
    --page-pad: 28px;
    --nav-h: 0px;
  }

  .app {
    padding-bottom: 0;
  }

  .topbar {
    gap: 16px;
    padding: 0 28px;
  }

  .brand-title {
    font-size: 22px;
  }

  .brand-sub {
    font-size: 12px;
  }

  .topnav {
    display: flex;
  }

  .only-mobile { display: none !important; }

  .bottom-nav {
    display: none !important;
  }

  .main {
    padding-top: 24px;
    padding-bottom: 48px;
  }

  .home-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    align-items: start;
  }

  .home-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: calc(var(--topbar-h) + 16px);
  }

  .search-card {
    padding: 18px 20px;
  }

  .book-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .book-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 20px;
    align-items: start;
  }

  .book-side {
    display: block;
  }

  .sticky-card {
    position: sticky;
    top: calc(var(--topbar-h) + 16px);
  }

  .book-hero {
    padding: 22px;
    gap: 20px;
  }

  .book-hero .intro {
    -webkit-line-clamp: 6;
  }

  .chapter-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .drawer-panel {
    width: min(460px, 42vw);
  }

  .modal-panel {
    width: min(720px, 70vw);
  }

  .toast {
    bottom: 32px;
  }

  /* 阅读器导航可固定在底部但不遮挡 */
  .reader-nav {
    position: sticky;
    bottom: 20px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    padding: 10px;
    border-radius: 16px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    margin-top: 20px;
  }
}

@media (min-width: 1280px) {
  :root {
    --max: 1240px;
  }

  .home-grid {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .book-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .book-card {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .book-card .book-cover {
    width: 100%;
    height: 180px;
    font-size: 18px;
  }

  .chapter-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .drawer-panel {
    width: 480px;
  }
}

@media (max-width: 420px) {
  .brand-sub { display: none; }
  .brand-title { font-size: 17px; }
  .book-grid { grid-template-columns: 1fr; }
  .book-card { grid-template-columns: 72px 1fr; }
}

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
  .view,
  .drawer-panel,
  .modal-panel {
    animation: none;
  }

  .book-card:hover {
    transform: none;
  }
}

/* Õ˺Å / ÔĶÁ3.0 */
.auth-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-btn:hover,
.auth-btn:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent-ink);
  background: var(--accent-soft);
  outline: none;
}

.auth-panel {
  width: min(92vw, 420px);
}

.auth-panel .auth-tabs {
  width: 100%;
  margin: 8px 0 4px;
}

.auth-panel .auth-tabs .seg-btn {
  flex: 1;
}

.auth-form .primary-btn {
  flex: 1;
}

@media (min-width: 960px) {
  .auth-btn {
    min-width: 72px;
  }
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
