/* 墨笺 · 墨砚编辑室
   Philosophy: Editorial magazine × Japanese Ma
   Cool slate paper · ink black · single jade-teal accent
   Avoid: purple gradients, cream/terracotta, Inter/Roboto, dense dashboard cards */

:root {
  /* Surfaces */
  --paper: #e4e8e6;
  --paper-2: #ecefec;
  --panel: #f4f6f4;
  --panel-raised: #fbfcfb;
  --panel-glass: rgba(244, 246, 244, 0.88);
  --panel-glass-strong: rgba(251, 252, 251, 0.96);
  /* Text */
  --ink: #14181c;
  --ink-soft: #4a5560;
  --ink-mute: #7a858f;
  /* Accent — jade ink, not purple */
  --accent: #0b4f52;
  --accent-bright: #0e6b6f;
  --accent-soft: rgba(11, 79, 82, 0.1);
  --accent-ink: #06383a;
  --accent-on: #f2f8f8;
  /* Lines / state */
  --line: #c5cdc8;
  --line-strong: #8e9a94;
  --danger: #8f3434;
  --ok: #0b4f52;
  --cover-fallback: linear-gradient(155deg, #cfd6d2 0%, #e8ece9 100%);
  --shadow: 0 1px 0 rgba(20, 24, 28, 0.05), 0 22px 48px rgba(20, 24, 28, 0.07);
  --radius: 2px;
  --font-ui: "Sora", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-brand: "Instrument Serif", "Noto Serif SC", serif;
  --font-display: "Noto Serif SC", "Songti SC", serif;
  --font-read: "Noto Serif SC", "Source Han Serif SC", serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --sidebar: 268px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --space: 8px;
  color-scheme: light;
}

html[data-ui-theme="night"] {
  --paper: #101418;
  --paper-2: #161b21;
  --panel: #1a2028;
  --panel-raised: #222a33;
  --panel-glass: rgba(22, 26, 33, 0.92);
  --panel-glass-strong: rgba(22, 26, 33, 0.97);
  --ink: #e5e9ed;
  --ink-soft: #a3adb8;
  --ink-mute: #76818d;
  --accent: #4aadb0;
  --accent-bright: #62c0c3;
  --accent-soft: rgba(74, 173, 176, 0.14);
  --accent-ink: #c5e8e9;
  --accent-on: #0b1617;
  --line: #2c3540;
  --line-strong: #4a5563;
  --danger: #d07a7a;
  --ok: #4aadb0;
  --cover-fallback: linear-gradient(155deg, #2a333d 0%, #1a2028 100%);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 24px 52px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

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

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Atmosphere: cool mist + grain — not purple glow */
.atmosphere {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(980px 560px at 0% -12%, rgba(11, 79, 82, 0.08), transparent 58%),
    radial-gradient(720px 420px at 100% 8%, rgba(20, 24, 28, 0.04), transparent 48%),
    linear-gradient(168deg, #ecefec 0%, #dde3df 100%);
}
html[data-ui-theme="night"] .atmosphere {
  background:
    radial-gradient(880px 500px at 6% -10%, rgba(74, 173, 176, 0.1), transparent 55%),
    radial-gradient(600px 380px at 100% 0%, rgba(0, 0, 0, 0.45), transparent 50%),
    linear-gradient(168deg, #13171d 0%, #0c0f13 100%);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.22;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}
html[data-ui-theme="night"] .grain {
  opacity: 0.14;
  mix-blend-mode: soft-light;
}

button, input, select {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* —— Sidebar / brand rail —— */
.sidebar {
  display: none;
  flex-direction: column;
  gap: calc(var(--space) * 2.5);
  padding: calc(var(--space) * 2.5) calc(var(--space) * 2);
  border-right: 1px solid var(--line);
  background: var(--panel-glass);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: center;
  animation: rise 0.7s var(--ease-out) both;
}
.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  background: var(--accent);
  color: var(--accent-on);
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
}
.brand-name {
  font-family: var(--font-brand);
  font-size: clamp(2rem, 2.4vw, 2.35rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  font-weight: 400;
}
.brand-sub {
  margin-top: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.brand-line {
  margin: 0;
  padding: 0 0.15rem;
  color: var(--ink-mute);
  font-family: var(--font-display);
  font-size: 0.84rem;
  line-height: 1.7;
  max-width: 18em;
  animation: rise 0.7s var(--ease-out) 0.05s both;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
  animation: rise 0.7s var(--ease-out) 0.1s both;
}
.nav-btn {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  min-height: 48px;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0.7rem 0.2rem;
  background: transparent;
  text-align: left;
  color: var(--ink-soft);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.nav-idx {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  min-width: 1.6rem;
}
.nav-label {
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}
.nav-btn:hover {
  color: var(--ink);
}
.nav-btn.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.nav-btn.active .nav-idx { color: var(--accent); }

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 0.85rem;
  animation: rise 0.7s var(--ease-out) 0.16s both;
}

.account-card {
  padding: 1rem 0 0;
  border-top: 1px solid var(--line);
  background: transparent;
}
.account-copy {
  margin: 0 0 0.85rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.55;
}
.account-cta { width: 100%; }
.account-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.85rem;
}
.account-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}
.account-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.2;
}
.account-role {
  margin-top: 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.account-logout { width: 100%; }

.status-card {
  display: grid;
  gap: 0.3rem;
  padding: 0.25rem 0 0;
}
.status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-mute);
  flex-shrink: 0;
}
.status-dot.on {
  background: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.status-dot.off { background: var(--danger); }
.hint {
  color: var(--ink-soft);
  font-size: 0.74rem;
  line-height: 1.4;
}

/* —— Buttons (approved pairs) —— */
.primary,
.ghost,
.secondary {
  min-height: 44px;
  border-radius: var(--radius);
  padding: 0.65rem 1.1rem;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-on);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.primary:hover:not(:disabled) {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}
.primary:active:not(:disabled) { transform: translateY(1px); }

.ghost,
.secondary {
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  color: var(--ink);
}
.ghost:hover:not(:disabled),
.secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.text-btn {
  min-height: 32px;
  padding: 0.2rem 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
}
.text-btn:hover { color: var(--accent-bright); text-decoration: underline; text-underline-offset: 3px; }

.linkish {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  min-height: auto;
}
.linkish:hover { color: var(--accent); }

/* —— Main —— */
.main {
  min-width: 0;
  padding: calc(var(--space) * 2) calc(var(--space) * 2) calc(5.5rem + var(--safe-bottom));
  animation: rise 0.75s var(--ease-out) 0.08s both;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.25rem;
  margin-bottom: 0;
  padding-bottom: calc(var(--space) * 2);
}
.topbar-kicker {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.55rem;
}
.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5vw, 2.65rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.15;
}
.topbar p {
  margin: 0.55rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.55;
  max-width: 28em;
}
.topbar-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.theme-toggle {
  min-width: 3.5rem;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
}
.top-user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.main-rule {
  height: 1px;
  background: var(--line);
  margin: 0 0 calc(var(--space) * 2.5);
}

.view { display: none; }
.view.active { display: block; animation: fade-in 0.4s var(--ease); }

.toolbar {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 1.15rem;
}
.toolbar.wrap { flex-wrap: wrap; }
.toolbar-end { justify-content: flex-end; }
.toolbar.grow { display: grid; grid-template-columns: 1fr auto; }
.toolbar input,
.toolbar select,
.search-bar input,
.auth-form input,
.ask-input-wrap input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.85rem;
  background: var(--panel-raised);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.toolbar input:focus,
.toolbar select:focus,
.search-bar input:focus,
.auth-form input:focus,
.ask-input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.panel-filters {
  padding: 0.85rem;
  border: 1px solid var(--line);
  background: var(--panel);
}

.section-rule {
  height: 1px;
  background: var(--line);
  margin: 1.35rem 0 1.5rem;
}

/* —— Shelf · same editorial system as results —— */
.book-grid {
  display: grid;
  gap: 0;
}
.shelf-item .shelf-progress {
  margin-top: 0.15rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.shelf-item .cache-pill {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0;
  border: 0;
  font-size: 0.7rem;
  color: var(--ink-mute);
  letter-spacing: 0.08em;
}
.shelf-item .result-actions .btn-unshelf {
  color: var(--ink-soft);
}
.shelf-item .result-actions .btn-unshelf:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.empty {
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line-strong);
  background: transparent;
  font-size: 0.95rem;
  line-height: 1.6;
}
.empty .primary {
  margin-top: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.empty-title {
  display: block;
  margin-bottom: 0.4rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--ink);
  letter-spacing: 0.06em;
}

/* —— Results · Editorial list, mobile-first —— */
.result-list {
  display: grid;
  gap: 0;
}
.result-item {
  display: grid;
  gap: 1rem;
  padding: 1.25rem 0.15rem 1.35rem;
  border-bottom: 1px solid var(--line);
  background: transparent;
  animation: rise 0.55s var(--ease-out) both;
  transition: background 0.28s var(--ease);
}
.result-main {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 0.95rem;
  align-items: start;
  min-width: 0;
}
.result-cover-wrap {
  position: relative;
  width: 76px;
}
.result-item .cover,
.result-item .cover-fallback {
  display: block;
  width: 76px;
  height: 104px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--cover-fallback);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.result-item .cover-fallback {
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 600;
}
.result-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.result-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-bottom: 0.1rem;
}
.result-idx {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
}
.result-cat {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  padding-left: 0.65rem;
  border-left: 1px solid var(--line-strong);
}
.result-item h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.35;
  color: var(--ink);
}
.result-item .meta {
  color: var(--ink-soft);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.result-item .abs {
  margin: 0.35rem 0 0;
  color: var(--ink-mute);
  font-family: var(--font-display);
  font-size: 0.84rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-item .abs.is-empty {
  display: none;
}
.result-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.15fr;
  gap: 0.45rem;
}
.result-actions .primary,
.result-actions .secondary,
.result-actions .ghost {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.4rem;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
}
.result-item.job-item {
  display: grid;
  grid-template-columns: 1fr;
}
.result-item.job-item .result-main {
  grid-template-columns: 1fr;
}
.result-item.job-item .result-actions {
  grid-template-columns: 1fr;
}

/* —— ≥600px tablet —— */
@media (min-width: 600px) {
  .result-item {
    padding: 1.45rem 0.35rem 1.55rem;
    gap: 1.1rem;
  }
  .result-main {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 1.15rem;
  }
  .result-cover-wrap,
  .result-item .cover,
  .result-item .cover-fallback {
    width: 92px;
  }
  .result-item .cover,
  .result-item .cover-fallback {
    height: 126px;
  }
  .result-item h3 {
    font-size: 1.22rem;
  }
  .result-item .abs {
    -webkit-line-clamp: 3;
    font-size: 0.88rem;
  }
  .result-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 28rem;
  }
}

/* —— ≥900px desktop: magazine row —— */
@media (min-width: 900px) {
  .result-item {
    grid-template-columns: minmax(0, 1fr) 9.5rem;
    align-items: stretch;
    gap: 1.5rem;
    padding: 1.65rem 0.5rem 1.75rem;
  }
  .result-item:hover {
    background: linear-gradient(
      90deg,
      transparent 0%,
      var(--accent-soft) 8%,
      var(--accent-soft) 92%,
      transparent 100%
    );
  }
  .result-item:hover .cover,
  .result-item:hover .cover-fallback {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(20, 24, 28, 0.12);
  }
  html[data-ui-theme="night"] .result-item:hover .cover,
  html[data-ui-theme="night"] .result-item:hover .cover-fallback {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  }
  .result-main {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 1.35rem;
  }
  .result-cover-wrap,
  .result-item .cover,
  .result-item .cover-fallback {
    width: 104px;
  }
  .result-item .cover,
  .result-item .cover-fallback {
    height: 142px;
  }
  .result-item h3 {
    font-size: 1.32rem;
    max-width: 34rem;
  }
  .result-item .abs {
    max-width: 36rem;
    -webkit-line-clamp: 3;
  }
  .result-actions {
    grid-template-columns: 1fr;
    align-content: start;
    align-self: center;
    gap: 0.5rem;
    max-width: none;
    min-width: 9.5rem;
    padding-left: 1.15rem;
    border-left: 1px solid var(--line);
  }
  .result-actions .primary,
  .result-actions .secondary,
  .result-actions .ghost {
    font-size: 0.88rem;
    padding: 0.6rem 0.75rem;
  }
}

/* —— Chips —— */
.cats-block { margin-bottom: 0.25rem; }
.cats-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0.25rem 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.cats-count {
  font-weight: 500;
  color: var(--ink-mute);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-raised);
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-on);
  font-weight: 600;
}

/* —— Modal / Auth —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(10, 14, 18, 0.52);
  backdrop-filter: blur(6px);
  animation: fade-in 0.22s var(--ease);
}
#askModal { z-index: 55; }
#bookModal { z-index: 54; }
.modal-panel {
  width: min(480px, 100%);
  max-height: 82vh;
  overflow: auto;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.32s var(--ease-out);
}
.book-panel {
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}
.book-modal-hero {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 1rem;
  padding: 1.15rem 1.15rem 0.85rem;
  align-items: start;
}
.book-modal-cover {
  width: 88px;
  height: 120px;
  border: 1px solid var(--line);
  background: var(--cover-fallback);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.5rem;
}
.book-modal-meta h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.35;
}
.book-modal-author {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.book-modal-cat {
  margin: 0.45rem 0 0;
  color: var(--ink-mute);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}
.book-modal-section {
  padding: 0.35rem 1.15rem 1rem;
  border-top: 1px solid var(--line);
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.book-modal-label {
  display: block;
  margin-bottom: 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.book-modal-abs {
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.book-modal-abs.is-empty {
  color: var(--ink-mute);
  font-style: italic;
}
.book-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  padding: 0.85rem 1.15rem calc(0.95rem + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel-raised);
  position: sticky;
  bottom: 0;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel-raised);
  z-index: 1;
}
.modal-head strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.auth-panel { width: min(400px, 100%); }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}
.auth-tab {
  min-height: 48px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: -1px;
}
.auth-tab.active {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
}
.auth-hint {
  margin: 0;
  padding: 0.95rem 1.1rem 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.55;
  font-family: var(--font-display);
}
.auth-form {
  display: grid;
  gap: 0.9rem;
  padding: 1rem 1.1rem 1.25rem;
}
.auth-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.auth-submit { width: 100%; margin-top: 0.2rem; }

.ask-panel { width: min(380px, 100%); }
.ask-msg {
  margin: 0;
  padding: 1.1rem 1.15rem 0.4rem;
  color: var(--ink-soft);
  font-size: 0.94rem;
  line-height: 1.6;
  font-family: var(--font-display);
}
.ask-input-wrap { padding: 0.6rem 1.15rem 0; }
.ask-input-wrap label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}
.ask-input-wrap input { width: 100%; }
.ask-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  padding: 1.1rem 1.15rem 1.2rem;
}
.ask-actions .primary.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.toc-panel { width: min(520px, 100%); }
.toc-meta {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--ink-mute);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.toc-toolbar {
  padding: 0.55rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.toc-list { max-height: 58vh; overflow: auto; }
.toc-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  border: 0;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0.85rem 1.1rem;
  text-align: left;
  color: var(--ink);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.toc-title { font-size: 0.9rem; line-height: 1.4; }
.toc-flag {
  flex-shrink: 0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.toc-item.cached .toc-flag { color: var(--accent); }
.toc-item.missing { opacity: 0.72; }
.toc-item:hover,
.toc-item.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.35rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 400px);
  padding: 0.75rem 1.15rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
  animation: toast-in 0.28s var(--ease-out);
}
html[data-ui-theme="night"] .toast {
  background: var(--panel-raised);
  color: var(--ink);
  border: 1px solid var(--line);
}

/* —— Loading —— */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(12, 16, 20, 0.4);
  backdrop-filter: blur(7px);
  animation: fade-in 0.22s var(--ease);
}
.loading-card {
  width: min(320px, 92vw);
  padding: 1.85rem 1.45rem 1.4rem;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  box-shadow: var(--shadow);
  text-align: center;
}
.loading-mark {
  position: relative;
  width: 56px;
  height: 56px;
  margin: 0 auto 1.1rem;
  display: grid;
  place-items: center;
}
.loading-ring {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.loading-ink {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--accent-ink);
  font-weight: 600;
}
.loading-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.loading-msg {
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.5;
  min-height: 1.4em;
  transition: opacity 0.25s var(--ease);
}
.loading-msg.is-swap { opacity: 0.35; }
.loading-bar {
  margin: 1.1rem auto 0.7rem;
  width: 100%;
  height: 2px;
  background: var(--line);
  overflow: hidden;
}
.loading-bar-fill {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--accent);
  animation: bar-slide 1.35s var(--ease) infinite;
}
.loading-hint {
  color: var(--ink-mute);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

body.is-loading #app { filter: blur(1.5px); }

/* —— Mobile nav —— */
.mobile-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 0.3rem 0.2rem calc(0.3rem + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel-glass-strong);
  backdrop-filter: blur(14px);
}
.mobile-nav .nav-btn {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.15rem;
  min-height: 52px;
  border: 0;
  border-bottom: 0;
  padding: 0.35rem 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}
.mobile-nav .nav-idx {
  font-size: 0.58rem;
  min-width: 0;
}
.mobile-nav .nav-btn.active {
  border-bottom: 0;
  background: var(--accent-soft);
}

/* —— Desktop —— */
@media (min-width: 900px) {
  #app {
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
  }
  .sidebar {
    display: flex;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
  }
  .mobile-nav { display: none; }
  .main {
    padding: calc(var(--space) * 3.5) calc(var(--space) * 4.5) calc(var(--space) * 4);
    max-width: 920px;
  }
  .book-panel {
    width: min(560px, 100%);
  }
  .book-modal-hero {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 1.25rem;
    padding: 1.35rem 1.35rem 1rem;
  }
  .book-modal-cover {
    width: 108px;
    height: 146px;
  }
  .book-modal-meta h2 {
    font-size: 1.45rem;
  }
  .book-modal-section {
    padding: 0.5rem 1.35rem 1.15rem;
  }
  .book-modal-actions {
    padding: 1rem 1.35rem 1.15rem;
  }
}

@media (min-width: 1200px) {
  .main { max-width: 980px; }
  .topbar h1 { font-size: 2.85rem; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bar-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
