:root {
  color-scheme: dark;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --bg: #101010;
  --panel: #181818;
  --panel-2: #242424;
  --field: #0f0f0f;
  --input: var(--field);
  --surface: #141414;
  --elevated: #242424;
  --chapter-bg: #181818;
  --spotlight-start: #242424;
  --spotlight-end: #101010;
  --spotlight-wash: rgba(239, 68, 68, 0.2);
  --spotlight-art-start: #15181b;
  --spotlight-art-end: #2f363c;
  --spotlight-art-wash: rgba(96, 210, 164, 0.28);
  --text: #f3f4f6;
  --muted: #b8b8b8;
  --muted-2: #6b7280;
  --line: #343434;
  --accent: #ef4444;
  --accent-strong: #ff6b6b;
  --accent-soft: rgba(239, 68, 68, 0.14);
  --accent-line: rgba(255, 107, 107, 0.34);
  --accent-2: #10b981;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ff6b6b;
  --error: #ff6b6b;
  --focus: #ff8a8a;
  --ink: #171717;
  --on-accent: #fff;
  --topbar-bg: rgba(16, 16, 16, 0.94);
  --overlay: rgba(0, 0, 0, 0.72);
  --soft-panel: rgba(255, 255, 255, 0.03);
  --cover-shelf: #101010;
  --shadow: rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 28px 80px var(--shadow);
  font-family: var(--font-sans);
}

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

:root[data-theme="light"],
body.light-theme {
  color-scheme: light;
  --bg: #f4f1ea;
  --panel: #fffaf0;
  --panel-2: #f0e8d8;
  --field: #fffdf8;
  --input: var(--field);
  --surface: #eee6d8;
  --elevated: #fffdf8;
  --chapter-bg: #fffdf8;
  --spotlight-start: #f5ead2;
  --spotlight-end: #fffaf0;
  --spotlight-wash: rgba(56, 129, 112, 0.18);
  --spotlight-art-start: #e8decf;
  --spotlight-art-end: #d7c7ad;
  --spotlight-art-wash: rgba(169, 71, 47, 0.16);
  --text: #211f1b;
  --muted: #6b6257;
  --muted-2: #786f64;
  --line: #d5c9b7;
  --accent: #a9472f;
  --accent-strong: #8e3827;
  --accent-soft: rgba(169, 71, 47, 0.12);
  --accent-line: rgba(169, 71, 47, 0.32);
  --accent-2: #247b63;
  --success: #247b63;
  --warning: #9a5b00;
  --danger: #b4232d;
  --error: #b4232d;
  --focus: #a9472f;
  --ink: #15120e;
  --on-accent: #fffaf0;
  --topbar-bg: rgba(244, 241, 234, 0.94);
  --overlay: rgba(30, 24, 17, 0.42);
  --soft-panel: rgba(60, 43, 23, 0.05);
  --cover-shelf: #e8decf;
  --shadow: rgba(52, 40, 24, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  transform: translateY(-180%);
  padding: 10px 14px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

main:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

button,
input,
textarea {
  font: inherit;
}

input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--field) inset;
  transition: background-color 9999s ease-in-out 0s;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px clamp(16px, 4vw, 44px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: var(--ink);
}

.search-wrap {
  position: relative;
}

.search-wrap input {
  width: 100%;
  height: 48px;
  padding: 0 46px 0 16px;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear {
  position: absolute;
  top: 8px;
  right: 6px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
}

.search-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 20;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 40px var(--shadow);
}

.search-suggestions {
  display: grid;
}

.search-suggestions button,
.search-clear-recents,
.search-panel-state {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-suggestions button {
  display: grid;
  gap: 3px;
}

.search-suggestions button.active,
.search-suggestions button:hover,
.search-clear-recents:hover {
  background: var(--accent-soft);
}

.search-suggestions small,
.search-panel-state {
  color: var(--muted);
}

mark {
  border-radius: 3px;
  padding: 0 2px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.search-loading {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.search-loading span {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.search-pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  color: var(--muted);
}

.search-pagination span {
  min-width: 110px;
  text-align: center;
}

.search-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.nav-actions .auth-button {
  max-width: min(190px, 32vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-wrap {
  position: relative;
  display: inline-flex;
}

.user-menu-wrap .auth-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  max-width: min(230px, 38vw);
  padding: 0 10px;
}

.account-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  background-position: center;
  background-size: cover;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

.account-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-caret {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  width: min(240px, 78vw);
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}

.user-menu button {
  min-height: 38px;
  border: 0;
  border-radius: 4px;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.user-menu button:hover,
.user-menu button:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.user-menu button[data-user-menu-signout] {
  color: var(--danger);
}

#signOutButton {
  display: none !important;
}

#notificationButton {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--panel);
  border-radius: 999px;
  padding: 0 4px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .68rem;
  font-weight: 900;
  line-height: 1;
}

.icon-button,
.close-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.nav-link-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
}

.nav-link-button:hover,
.icon-button:hover,
.auth-button:hover {
  border-color: var(--accent-line);
  color: var(--accent-strong);
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 44px) 56px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  justify-content: center;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 44px) 34px;
  color: var(--muted);
  font-size: 0.88rem;
}

.site-footer a {
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent-strong);
}

.spotlight {
  display: grid;
  grid-template-columns: minmax(220px, 34%) minmax(0, 1fr);
  min-height: 380px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(110deg, var(--spotlight-wash), transparent 48%),
    linear-gradient(140deg, var(--spotlight-start), var(--spotlight-end) 70%);
}

.spotlight-art {
  position: relative;
  display: grid;
  min-height: 320px;
  place-items: center;
  background:
    radial-gradient(circle at 30% 30%, var(--spotlight-art-wash), transparent 24%),
    linear-gradient(135deg, var(--spotlight-art-start), var(--spotlight-art-end));
}

.real-cover-art {
  background:
    radial-gradient(circle at 54% 28%, var(--accent-soft), transparent 28%),
    linear-gradient(135deg, var(--panel-2), var(--surface));
}

.spotlight-cover {
  position: relative;
  display: block;
  width: min(210px, 58%);
  aspect-ratio: 0.68;
  overflow: hidden;
  border-radius: 7px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 26px 52px var(--shadow);
}

.spotlight-cover .cover-title-text {
  font-size: clamp(1.5rem, 4vw, 2.6rem);
}

.book-stack {
  position: absolute;
  inset: 36px 32px;
}

.cover {
  position: absolute;
  display: block;
  width: min(190px, 48vw);
  aspect-ratio: 0.68;
  border-radius: 5px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.45);
  transform-origin: bottom center;
}

.cover-one {
  left: 20%;
  top: 8%;
  z-index: 3;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 12%, transparent 12%),
    linear-gradient(145deg, #f5c542, #b74f3f 56%, #18232d);
}

.cover-two {
  left: 38%;
  top: 16%;
  z-index: 2;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 12%, transparent 12%),
    linear-gradient(145deg, #60d2a4, #2e6f8f 58%, #14191f);
  transform: rotate(8deg);
}

.cover-three {
  left: 4%;
  top: 22%;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 12%, transparent 12%),
    linear-gradient(145deg, #d6dde5, #7f5aa8 58%, #191a21);
  transform: rotate(-10deg);
}

.spotlight-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(26px, 6vw, 72px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2.3rem, 7vw, 5.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.spotlight-meta,
.book-author,
.book-tags,
.chapter-meta,
.comment-meta {
  color: var(--muted);
}

.rating-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 24px 0;
}

.rating-score {
  color: var(--accent);
  font-size: 2rem;
  font-weight: 900;
}

.rating-stars {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 900;
}

.rating-summary {
  margin: 0;
  color: var(--accent-strong);
  font-weight: 900;
}

.spotlight-actions,
.chapter-actions,
.comment-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.auth-button,
.text-button,
.segmented button,
.genre-list button,
.comment-form button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}

.primary-button {
  padding: 0 18px;
  border-color: transparent;
  background: var(--accent);
  color: var(--ink);
  font-weight: 800;
}

.secondary-button,
.auth-button,
.text-button,
.comment-form button {
  padding: 0 16px;
  background: var(--panel-2);
}

.auth-button.signed-in {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.hidden {
  display: none !important;
}

.global-status {
  position: sticky;
  top: 71px;
  z-index: 9;
  margin: 0;
  padding: 10px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
}

.global-status.error {
  background: color-mix(in srgb, var(--danger) 20%, var(--panel));
  color: var(--text);
}

.global-status.success {
  background: color-mix(in srgb, var(--success) 20%, var(--panel));
}

.state-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--muted);
}

.state-card strong {
  color: var(--text);
}

.state-card.error {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
}

.state-card.success {
  border-color: color-mix(in srgb, var(--success) 55%, var(--line));
}

.loading-block {
  display: grid;
  gap: 10px;
}

.loading-line {
  min-height: 18px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface), var(--panel-2), var(--surface));
  background-size: 220% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
}

.loading-line.short {
  width: 48%;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.content-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  margin-top: 24px;
}

.home-sections {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.home-section {
  display: grid;
  gap: 14px;
}

.home-section-heading {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
}

.home-section-heading h2,
.home-state h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.home-section-heading p:not(.eyebrow),
.home-state p {
  max-width: 760px;
  margin: 6px 0 0;
  color: var(--muted);
}

.home-shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.home-book-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.home-cover-button {
  display: grid;
  width: 70px;
  height: 106px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--cover-shelf);
}

.home-book-cover {
  position: relative;
  display: block;
  width: 58px;
  aspect-ratio: 0.68;
  overflow: hidden;
  border-radius: 4px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 10px 18px var(--shadow);
}

.home-book-cover .cover-genre,
.home-book-cover .cover-title-text,
.home-book-cover .cover-author-text {
  display: none;
}

.home-book-copy h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.home-state {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.home-state.error {
  border-color: rgba(220, 38, 38, 0.5);
}

.profile-section,
.author-section,
.route-section {
  margin-top: 24px;
}

.route-page {
  display: grid;
  gap: 16px;
}

.route-hero {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.route-cover {
  position: relative;
  display: block;
  width: 100%;
  max-width: 180px;
  aspect-ratio: 0.68;
  overflow: hidden;
  border-radius: 6px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 18px 36px var(--shadow);
}

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

.reading-status-control {
  display: inline-grid;
  gap: 4px;
  min-width: 160px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.reading-status-control select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
}

.route-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.route-panel h3 {
  margin-top: 0;
}

.legal-page {
  gap: 16px;
}

.legal-intro {
  max-width: 860px;
  color: var(--muted);
}

.legal-review-note {
  margin-top: 16px;
}

.legal-section-list article {
  display: grid;
  gap: 8px;
}

.legal-section-list p + p {
  margin-top: 2px;
}

.route-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-list li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.diagnostics-list {
  display: grid;
  gap: 10px;
}

.diagnostics-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.diagnostics-card strong {
  font-size: 0.95rem;
}

.diagnostics-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.diagnostics-card code {
  max-width: 100%;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.book-page {
  gap: 18px;
}

.book-page-hero {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: clamp(18px, 4vw, 36px);
  align-items: start;
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, var(--accent-soft), transparent 42%),
    var(--panel);
}

.book-page-cover-wrap {
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface);
}

.book-page-cover {
  position: relative;
  display: block;
  width: min(220px, 100%);
  aspect-ratio: 0.68;
  overflow: hidden;
  border-radius: 7px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 24px 48px var(--shadow);
}

.book-page-cover .cover-title-text {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
}

.book-page-copy {
  min-width: 0;
}

.book-subtitle {
  max-width: 820px;
  margin: 8px 0 0;
  color: var(--accent-strong);
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  font-weight: 800;
}

.book-description {
  max-width: 920px;
  color: var(--muted);
  line-height: 1.6;
}

.book-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.book-stat-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.book-stat-grid strong {
  display: block;
  color: var(--accent);
  font-size: 1.45rem;
  line-height: 1;
}

.book-stat-grid span {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.metadata-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.metadata-list div {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.metadata-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.metadata-list dt {
  color: var(--muted);
  font-weight: 800;
}

.metadata-list dd {
  margin: 0;
  color: var(--text);
}

.rating-distribution {
  display: grid;
  gap: 8px;
}

.rating-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.rating-row > span {
  color: var(--text);
  font-weight: 900;
}

.rating-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface);
}

.rating-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.panel-heading {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-heading h3 {
  margin: 0 0 4px;
}

.spoiler-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 800;
}

.spoiler-toggle input {
  accent-color: var(--accent);
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-shell {
  display: grid;
  gap: 14px;
}

.review-tools,
.review-form-footer,
.review-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.review-tools label,
.review-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.review-tools select,
.review-form input,
.review-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--input);
  color: var(--text);
  font: inherit;
}

.review-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.review-form textarea {
  min-height: 130px;
  resize: vertical;
}

.review-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.review-card-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.review-card-head > div:first-child {
  display: grid;
  gap: 3px;
}

.review-meta-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.review-body {
  margin-top: 10px;
}

.review-card p,
.review-body p {
  margin: 8px 0 0;
  color: var(--muted);
}

.review-card.spoiler-hidden {
  border-style: dashed;
}

.empty-state.compact {
  padding: 18px;
}

.mini-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.mini-book-card {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mini-cover-button {
  display: grid;
  width: 60px;
  height: 90px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--panel-2);
}

.mini-book-cover {
  position: relative;
  display: block;
  width: 52px;
  aspect-ratio: 0.68;
  overflow: hidden;
  border-radius: 4px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 10px 18px var(--shadow);
}

.mini-book-cover .cover-genre,
.mini-book-cover .cover-title-text,
.mini-book-cover .cover-author-text {
  display: none;
}

.mini-book-card h4 {
  margin: 0 0 4px;
}

.author-hero {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, var(--accent-soft), transparent 44%),
    var(--panel);
}

.author-avatar {
  position: relative;
  display: grid;
  width: 84px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 2.4rem;
  font-weight: 900;
}

.author-avatar.has-image {
  background-position: center;
  background-size: cover;
  color: transparent;
}

.author-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.author-actions {
  margin-top: 12px;
}

.author-copy {
  min-width: 0;
}

.author-copy h3 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 5vw, 3.4rem);
}

.author-copy p {
  max-width: 820px;
  color: var(--muted);
}

.author-website {
  color: var(--accent);
  font-weight: 800;
}

.author-summary {
  margin-bottom: 16px;
}

.author-books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.author-book-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.author-book-cover {
  width: 62px;
}

.author-book-card h4 {
  margin: 0;
}

.library-panel {
  margin-bottom: 16px;
}

.library-list-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.library-form,
.library-inline-form,
.library-note-form {
  display: grid;
  gap: 12px;
}

.library-form {
  max-width: 720px;
}

.library-inline-form {
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  align-items: end;
  margin: 12px 0;
}

.library-note-form {
  grid-column: 1 / -1;
  grid-template-columns: minmax(160px, 1fr) auto;
  align-items: center;
  width: 100%;
}

.library-form label,
.library-inline-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.library-form input,
.library-form textarea,
.library-inline-form input,
.library-inline-form select,
.library-note-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input);
  color: var(--text);
}

.library-form textarea {
  min-height: 88px;
  resize: vertical;
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: none;
  gap: 10px;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.library-custom-lists {
  display: grid;
  gap: 16px;
}

.library-book-card .activity-actions {
  flex-wrap: wrap;
}

.social-profile-list {
  display: grid;
  gap: 10px;
}

.social-profile-chip {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.social-profile-chip span,
.social-profile-chip small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.social-profile-chip small {
  grid-column: 2;
  color: var(--muted);
}

.social-avatar {
  grid-row: 1 / span 2;
  display: grid;
  width: 38px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--accent);
  font-weight: 900;
}

.social-avatar.has-image {
  background-position: center;
  background-size: cover;
  color: transparent;
}

.activity-preferences {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.notification-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.notification-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.notification-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.notification-card.unread {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.notification-title {
  margin: 0 0 4px;
  font-weight: 900;
}

.notification-copy {
  min-width: 0;
}

.notification-preferences {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.admin-dashboard .profile-summary {
  margin-top: 16px;
}

.admin-filterbar {
  display: grid;
  grid-template-columns: 180px minmax(180px, 1fr) minmax(220px, 1.3fr);
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.admin-note {
  margin-bottom: 12px;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-card.compact {
  grid-template-columns: 1fr;
}

.admin-card h4 {
  margin: 0 0 4px;
  text-transform: capitalize;
}

.admin-card p {
  margin: 6px 0 0;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 280px;
}

.admin-actions .secondary-button {
  min-height: 34px;
  padding-inline: 10px;
}

.secondary-button.danger {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  color: var(--danger);
}

.author-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 800;
}

.author-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.author-link.inline {
  min-height: auto;
  color: var(--accent-strong);
}

.profile-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.profile-hero {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.profile-avatar {
  width: 112px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 2.4rem;
  font-weight: 800;
  background-size: cover;
  background-position: center;
}

.profile-avatar.has-image {
  color: transparent;
}

.profile-hero-copy h1,
.profile-hero-copy h2 {
  margin: 0 0 6px;
}

.profile-hero-copy p {
  margin: 0 0 10px;
}

.profile-stat,
.profile-panel,
.activity-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.profile-stat {
  padding: 16px;
}

.profile-stat strong {
  display: block;
  color: var(--accent);
  font-size: 1.8rem;
  line-height: 1;
}

.profile-stat span,
.activity-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  gap: 16px;
}

.profile-panel {
  padding: 16px;
}

.profile-settings-form textarea {
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--field);
  color: var(--text);
}

.profile-export {
  margin-top: 16px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--panel-2);
  color: var(--text);
}

.profile-panel h3 {
  margin: 0 0 12px;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 12px;
  content-visibility: auto;
  contain-intrinsic-size: 120px 420px;
}

.activity-cover {
  position: relative;
  display: block;
  width: 46px;
  aspect-ratio: 0.68;
  overflow: hidden;
  border-radius: 4px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 10px 18px var(--shadow);
}

.activity-cover .cover-genre,
.activity-cover .cover-title-text,
.activity-cover .cover-author-text {
  display: none;
}

.activity-copy {
  min-width: 0;
}

.activity-card h4 {
  margin: 0;
  font-size: 1rem;
}

.activity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filters {
  align-self: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.filter-drawer-heading {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.filters h2 {
  margin: 20px 0 10px;
  font-size: 0.95rem;
}

.filters h2:first-child {
  margin-top: 0;
}

.filter-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.filter-field select,
.filter-field input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--field);
  color: var(--text);
}

.filter-field select:focus,
.filter-field input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented,
.genre-list {
  display: grid;
  gap: 8px;
}

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

.segmented button,
.genre-list button {
  padding: 0 10px;
  background: var(--surface);
}

.segmented button.active,
.genre-list button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.range-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

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

.active-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.active-filter-chips p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.active-filter-chips button {
  min-height: 32px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.filter-clear-button {
  width: 100%;
}

.section-heading {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
}

.catalog-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.filter-toggle,
.filter-drawer-heading {
  display: none;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.7rem);
}

.section-heading p:last-child {
  color: var(--muted);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.book-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  content-visibility: auto;
  contain-intrinsic-size: 360px 320px;
}

.cover-button {
  width: 100%;
  height: 230px;
  border: 0;
  background: var(--cover-shelf);
}

.book-cover {
  position: relative;
  display: block;
  width: 112px;
  height: 170px;
  margin: 30px auto;
  overflow: hidden;
  border-radius: 5px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 18px 36px var(--shadow);
}

.designed-cover {
  isolation: isolate;
}

.designed-cover::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 76% 18%, rgba(255, 255, 255, 0.28), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 42%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.28) 0 14%, transparent 14%);
  content: "";
}

.cover-spine {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: 14%;
  background: rgba(0, 0, 0, 0.26);
}

.cover-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.cover-failed {
  display: grid;
  place-items: end center;
  padding: 10px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.26) 0 13%, transparent 13%),
    linear-gradient(145deg, var(--accent-soft), var(--panel-2));
}

.cover-failed::after {
  position: relative;
  z-index: 2;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  content: "Cover unavailable";
}

.cover-genre,
.cover-title-text,
.cover-author-text {
  position: relative;
  z-index: 1;
  display: block;
  margin-left: 18%;
  margin-right: 9%;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.42);
}

.cover-genre {
  margin-top: 14%;
  font-size: 0.44rem;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.cover-title-text {
  margin-top: 24%;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.02;
}

.cover-author-text {
  position: absolute;
  right: 0;
  bottom: 8%;
  left: 0;
  font-size: 0.48rem;
  font-weight: 800;
  line-height: 1.12;
}

.has-cover-image .cover-spine,
.has-cover-image .cover-genre,
.has-cover-image .cover-title-text,
.has-cover-image .cover-author-text {
  display: none;
}

.book-card-body {
  padding: 14px;
}

.card-title-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.card-title-row h3 {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.25;
}

.score-pill {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 900;
}

.book-author,
.book-tags {
  margin: 8px 0;
  font-size: 0.92rem;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag-chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.detail-tags {
  margin: 14px 0 4px;
}

.text-button {
  width: 100%;
  margin-top: 8px;
}

.read-toggle {
  width: 100%;
  margin-top: 8px;
}

.read-toggle.is-read {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.book-dialog {
  width: min(1120px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.book-dialog::backdrop {
  background: var(--overlay);
}

.auth-dialog {
  width: min(420px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.auth-dialog::backdrop {
  background: var(--overlay);
}

.rating-dialog {
  width: min(430px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 80px var(--shadow);
}

.rating-dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(3px);
}

.rating-shell {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 28px;
}

.rating-shell h2 {
  margin: -8px 36px 0 0;
  font-size: 1.45rem;
}

.rating-help {
  margin: -8px 0 0;
  color: var(--muted);
}

.rating-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.rating-field input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--field);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  outline: none;
}

.rating-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.rating-range-field input {
  padding: 0;
  accent-color: var(--accent);
}

.rating-stepper,
.rating-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rating-stepper .secondary-button {
  flex: 1 1 120px;
}

.rating-presets button {
  min-width: 42px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 900;
}

.rating-presets button:hover,
.rating-presets button:focus,
.rating-presets button.active {
  border-color: var(--accent);
  outline: 0;
  color: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.rating-preview {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.rating-preview span:first-child {
  color: var(--accent);
  font-size: 3rem;
  font-weight: 900;
}

.rating-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
}

.auth-shell {
  position: relative;
  padding: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 36px 0 18px;
}

.auth-tabs button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.auth-tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form.hidden {
  display: none;
}

.auth-form h2 {
  margin: 0 0 4px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.auth-form input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--field);
  color: var(--text);
}

.auth-form .auth-checkbox {
  grid-template-columns: 18px 1fr;
  align-items: start;
  color: var(--text);
}

.auth-form .auth-checkbox input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.auth-inline-link {
  width: fit-content;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
}

.auth-message.error {
  color: var(--danger);
}

.auth-message.success {
  color: var(--accent-2);
}

.dialog-shell {
  position: relative;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  font-size: 1.5rem;
}

.book-detail {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 24px;
  padding: 28px;
}

.detail-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 0.68;
  overflow: hidden;
  border-radius: 6px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.42);
}

.detail-cover .cover-genre {
  font-size: 0.72rem;
}

.detail-cover .cover-title-text {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.detail-cover .cover-author-text {
  font-size: 0.82rem;
}

.detail-title {
  margin: 0 52px 8px 0;
  font-size: clamp(1.8rem, 5vw, 3.4rem);
}

.chapter-list {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.chapter {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chapter-bg);
}

.chapter-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.chapter-summary h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.chapter-score {
  display: grid;
  min-width: 64px;
  height: 44px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
}

.discussion {
  display: none;
  padding: 0 14px 14px;
}

.chapter.open .discussion {
  display: block;
}

.detail-poster {
  align-self: start;
}

.detail-poster-meta {
  margin-top: 14px;
}

.rating-line.compact {
  gap: 8px;
  margin: 0 0 12px;
}

.rating-line.compact .rating-score {
  font-size: 1.1rem;
}

.chapter-board {
  margin-top: 24px;
}

.chapter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 700;
}

.chapter-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.chapter-grid-head {
  display: grid;
  grid-template-columns: 44px 92px minmax(0, 1fr);
  gap: 10px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.chapter {
  border: 0;
  background: transparent;
}

.chapter-summary {
  display: grid;
  width: 100%;
  grid-template-columns: 44px 92px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.chapter-index {
  display: grid;
  place-items: center;
  min-height: 54px;
  color: var(--muted);
  font-weight: 900;
}

.chapter-score {
  width: 92px;
  min-width: 0;
  height: 54px;
  font-size: 1.55rem;
  letter-spacing: 0;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.chapter-copy {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 54px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.chapter-copy h3 {
  margin: 0 0 2px;
  font-size: 0.98rem;
}

.chapter.open .chapter-copy,
.chapter-summary:hover .chapter-copy {
  border-color: var(--accent-line);
  background: var(--panel-2);
}

.chapter.open .chapter-score {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
}

.chapter .discussion {
  margin: 8px 0 4px 146px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft-panel);
}

.rating-awesome {
  background: #047a36;
  color: #f3f4f6;
}

.rating-great {
  background: #22c55e;
  color: #09210f;
}

.rating-good {
  background: #facc15;
  color: #251a00;
}

.rating-regular {
  background: #f59e0b;
  color: #251300;
}

.rating-bad {
  background: #ef4444;
  color: #fff5f5;
}

.rating-garbage {
  background: #991b1b;
  color: #fff1f2;
}

.chapter-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.chapter-dialog::backdrop {
  background: var(--overlay);
}

.chapter-tile-grid {
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 16px 22px;
  margin-top: 18px;
}

.chapter-tile-row {
  display: grid;
  grid-template-columns: 34px minmax(94px, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.chapter-tile-row .chapter-index {
  min-height: 72px;
  place-items: center;
  color: var(--muted);
}

.chapter-tile {
  display: grid;
  width: 100%;
  min-height: 72px;
  place-items: center;
  align-content: center;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.chapter-tile:hover {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
}

.chapter-score-number {
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
}

.chapter-tile-name {
  max-width: 100%;
  margin-top: 4px;
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-detail {
  padding: 28px;
}

.chapter-detail-head {
  display: grid;
  grid-template-columns: 46px 120px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-right: 34px;
}

.chapter-detail-head .chapter-tile {
  min-height: 82px;
}

.chapter-index.large {
  min-height: 82px;
  font-size: 1rem;
}

.chapter-detail h2 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.chapter-comments {
  margin-top: 18px;
}

.chapter-comments h3 {
  margin: 0 0 10px;
}

.chapter-discussion-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-panel);
}

.chapter-discussion-summary {
  min-width: 0;
}

.chapter-discussion-summary strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

.chapter-discussion-summary p {
  margin: 0;
}

.chapter-discussion-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
}

.chapter-discussion-toolbar label,
.comment-sort-control {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.chapter-discussion-toolbar select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--field);
  color: var(--text);
}

.chapter-discussion-toolbar .spoiler-toggle {
  min-height: 34px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: .88rem;
}

.compact-control {
  min-height: 34px;
  padding-inline: 12px;
}

.comments {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

.comment {
  padding: 12px 14px;
  border-left: 3px solid var(--accent-2);
  border-radius: 0 8px 8px 0;
  background: var(--panel-2);
}

.comment.reply {
  margin-left: 0;
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--panel-2) 88%, var(--surface));
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.comment-head strong {
  font-size: .95rem;
  line-height: 1.2;
}

.comment-head .tag-chip {
  min-height: 20px;
  padding-inline: 7px;
  font-size: .72rem;
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-top: 10px;
}

.comment-action {
  display: inline-flex;
  width: auto;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 800;
}

.comment-action:hover,
.comment-action:focus-visible {
  background: var(--surface);
  color: var(--text);
}

.comment-action-primary {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.comment-action-primary:hover,
.comment-action-primary:focus-visible {
  background: var(--accent);
  color: var(--on-accent);
}

.comment-action.danger {
  color: var(--danger);
}

.comment-action-menu {
  position: relative;
}

.comment-action-menu summary {
  display: inline-flex;
  min-height: 28px;
  cursor: pointer;
  align-items: center;
  border-radius: 6px;
  padding: 0 8px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 800;
  list-style: none;
}

.comment-action-menu summary::-webkit-details-marker {
  display: none;
}

.comment-action-menu summary:hover,
.comment-action-menu summary:focus-visible {
  background: var(--surface);
  color: var(--text);
}

.comment-action-menu-content {
  position: absolute;
  z-index: 5;
  right: 0;
  top: calc(100% + 4px);
  display: grid;
  min-width: 132px;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 30px var(--shadow);
}

.comment-action-menu-content .comment-action {
  justify-content: flex-start;
}

.comment-replies {
  display: grid;
  gap: 10px;
  margin-left: 18px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.comment p {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
}

.comment-form.compact {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.comment-form.compact textarea {
  min-height: 64px;
}

.comment-form.compact button {
  min-height: 34px;
  padding-inline: 12px;
}

.moderation-honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.comment-form textarea {
  flex: 1 1 260px;
  min-height: 42px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--field);
  color: var(--text);
}

.login-required {
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--soft-panel);
}

.guideline-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.guideline-list article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft-panel);
}

.guideline-list h3 {
  margin: 0 0 6px;
}

.guideline-list p {
  margin: 0;
  color: var(--muted);
}

.login-required button {
  margin-left: 8px;
}

.empty-state {
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .search-wrap {
    grid-column: 1 / -1;
    order: 3;
  }

  .nav-actions {
    flex-wrap: wrap;
    justify-content: end;
  }

  .spotlight,
  .content-grid,
  .book-detail,
  .book-page-hero,
  .book-detail-grid,
  .route-hero,
  .profile-layout,
  .profile-summary,
  .author-hero {
    grid-template-columns: 1fr;
  }

  .spotlight-art {
    min-height: 260px;
  }

  .home-section-heading {
    align-items: start;
    flex-direction: column;
  }

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

  .library-inline-form,
  .library-list-header,
  .notification-heading,
  .admin-filterbar,
  .admin-card {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .admin-actions {
    justify-content: flex-start;
    max-width: none;
  }

  .panel-heading,
  .review-card div {
    align-items: start;
    flex-direction: column;
  }

  .chapter-discussion-toolbar {
    grid-template-columns: 1fr;
  }

  .chapter-discussion-controls {
    justify-content: flex-start;
  }

  .filter-toggle {
    display: inline-flex;
  }

  .filter-drawer-heading {
    display: flex;
  }

  body.filters-open {
    overflow: hidden;
  }

  body.filters-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, 0.58);
  }

  .filters {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(360px, calc(100vw - 28px));
    max-width: 100%;
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 0 8px 8px 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 22px 0 60px var(--shadow);
  }

  .filters.open {
    transform: translateX(0);
  }
}

@media (max-width: 560px) {
  main {
    padding-inline: 12px;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 10px 12px;
  }

  .brand span:last-child {
    display: none;
  }

  .nav-actions {
    gap: 6px;
    justify-content: flex-end;
  }

  .icon-button,
  .close-button {
    width: 40px;
    height: 40px;
  }

  .nav-link-button,
  .auth-button {
    min-height: 40px;
    padding-inline: 10px;
  }

  .nav-actions .auth-button {
    max-width: min(150px, 42vw);
  }

  .user-menu-wrap .auth-button {
    max-width: 48px;
    padding-inline: 8px;
  }

  .account-name,
  .account-caret {
    display: none;
  }

  .user-menu {
    right: 0;
    width: min(230px, calc(100vw - 24px));
  }

  .section-heading,
  .catalog-heading-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .catalog-heading-actions {
    width: 100%;
  }

  .filter-toggle {
    width: 100%;
    justify-content: center;
  }

  .spotlight-copy,
  .book-detail {
    padding: 18px;
  }

  .book-page-cover-wrap {
    padding: 12px;
  }

  .book-stat-grid,
  .metadata-list div,
  .rating-row,
  .mini-book-grid,
  .library-note-form,
  .notification-card,
  .admin-filterbar,
  .admin-card {
    grid-template-columns: 1fr;
  }

  .rating-row {
    gap: 4px;
  }

  .spotlight-cover {
    width: min(170px, 56%);
  }

  .home-shelf-grid,
  .home-book-card {
    grid-template-columns: 1fr;
  }

  .home-book-card {
    align-items: start;
  }

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

  .book-card,
  .profile-panel,
  .route-panel {
    min-width: 0;
  }

  .profile-hero,
  .author-hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .profile-avatar,
  .author-avatar {
    width: min(112px, 32vw);
  }

  .book-dialog,
  .auth-dialog,
  .rating-dialog,
  .chapter-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .rating-shell,
  .auth-shell {
    padding: 20px;
  }

  .rating-actions,
  .spotlight-actions,
  .route-actions,
  .activity-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .rating-actions button,
  .spotlight-actions button,
  .route-actions button,
  .activity-actions button {
    width: 100%;
  }

  .chapter-summary {
    grid-template-columns: 38px 78px minmax(0, 1fr);
  }

  .chapter-grid-head {
    grid-template-columns: 38px 78px minmax(0, 1fr);
  }

  .chapter-score {
    width: 78px;
    font-size: 1.25rem;
  }

  .chapter .discussion {
    margin-left: 0;
  }

  .chapter-tile-grid {
    grid-template-columns: 1fr;
  }

  .chapter-detail-head {
    grid-template-columns: 38px 92px minmax(0, 1fr);
    margin-right: 28px;
  }

  .chapter-detail {
    padding: 20px;
  }

  .chapter-discussion-toolbar {
    padding: 12px;
  }

  .chapter-discussion-controls {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .chapter-discussion-toolbar select,
  .chapter-discussion-toolbar .spoiler-toggle,
  .compact-control {
    width: 100%;
  }

  .comment {
    padding: 11px 12px;
  }

  .comment-actions {
    gap: 2px;
  }

  .comment-action,
  .comment-action-menu summary {
    min-height: 32px;
    padding-inline: 8px;
  }

  .comment-replies {
    margin-left: 8px;
    padding-left: 10px;
  }

  .comment-action-menu-content {
    right: auto;
    left: 0;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .book-dialog,
  .auth-dialog,
  .rating-dialog,
  .chapter-dialog {
    max-height: calc(100dvh - 12px);
  }

  .dialog-shell,
  .chapter-detail,
  .auth-shell,
  .rating-shell {
    max-height: calc(100dvh - 14px);
    overflow-y: auto;
  }
}
