:root {
  color-scheme: light;
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --reader-bg: #fafbfc;
  --line: #d8e0e6;
  --text: #1f2933;
  --muted: #6b7785;
  --faint: #94a2af;
  --teal: #1d8d88;
  --teal-dark: #126d69;
  --blue: #2e6db6;
  --blue-dark: #22558f;
  --rose: #c94876;
  --amber: #ad6b19;
  --green-soft: #e7f6ef;
  --blue-soft: #e8f1fb;
  --rose-soft: #fce8f0;
  --amber-soft: #f8eedf;
  --shadow: 0 14px 34px rgba(31, 41, 51, .09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  max-width: 100%;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

button.ghost {
  background: #fff;
  color: var(--teal-dark);
  border-color: var(--line);
}

button.ghost:hover {
  background: var(--green-soft);
  border-color: #9fcfca;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

input,
select {
  width: 100%;
  max-width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(29, 141, 136, .14);
}

.login-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 22px;
  background: #fff;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(360px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 46px rgba(31, 41, 51, .10);
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card button {
  width: 100%;
}

body[data-auth="authenticated"] .login-view,
body[data-auth="checking"] .app-shell,
body[data-auth="anonymous"] .app-shell {
  display: none;
}

body[data-auth="authenticated"] .app-shell {
  display: block;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 62px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 22px rgba(31, 41, 51, .06);
}

.site-header > *,
.search-board > *,
.search-tools,
.user-menu {
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 18px;
  font-weight: 800;
}

.brand:hover {
  background: transparent;
  color: var(--teal-dark);
}

.top-nav {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.nav-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
}

.nav-link:hover,
.nav-link.active {
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.user-menu {
  position: relative;
  justify-self: end;
}

.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.user-menu-button:hover,
.user-menu:hover .user-menu-button {
  background: var(--blue-soft);
  border-color: #bfd7f2;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 13px;
}

.user-arrow {
  color: var(--faint);
  font-size: 12px;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 80;
  width: 236px;
  padding: 6px;
  border: 1px solid #dfe4f2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(31, 41, 51, .14);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity .15s ease, transform .15s ease;
  visibility: hidden;
}

.user-menu:hover .user-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.menu-item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.menu-item strong {
  font-size: 14px;
  line-height: 1.25;
}

.menu-item span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-soft);
}

.logout-item strong {
  color: #d82932;
}

.status {
  position: fixed;
  top: 74px;
  right: 22px;
  z-index: 95;
  max-width: min(420px, calc(100vw - 44px));
  padding: 9px 12px;
  border: 1px solid #dfe4f2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(31, 41, 51, .14);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}

.status.ok {
  color: var(--teal-dark);
}

.status.error {
  border-color: #f0c8c3;
  background: #fff8f7;
  color: #ad342b;
}

main {
  min-height: calc(100vh - 62px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page {
  width: min(1500px, calc(100% - 44px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 700;
}

.search-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: 0 18px 40px rgba(31, 41, 51, .18);
}

.search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.search-head h2 {
  margin: 0;
  color: #32465a;
  font-size: 18px;
  line-height: 1.3;
}

.advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.advanced-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.advanced-toggle i {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #e7ebf1;
}

.advanced-toggle i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(31, 41, 51, .28);
  transition: transform .15s ease;
}

.advanced-toggle input:checked + i {
  background: var(--blue);
}

.advanced-toggle input:checked + i::after {
  transform: translateX(16px);
}

.search-copy h1,
.section-head h2,
.action-panel h2,
.detail-main h1,
.reader-header h1 {
  margin: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.search-copy h1 {
  font-size: 30px;
}

.search-copy p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.search-tools {
  display: grid;
  gap: 14px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.search-form input {
  min-height: 64px;
  border: 0;
  border-left: 4px solid #36b6bb;
  background: #fff;
  box-shadow: 0 5px 22px rgba(64, 159, 161, .14) inset, 0 1px 0 rgba(255, 255, 255, .8);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  padding-inline: 18px;
}

.search-form input::placeholder {
  color: #bac6d1;
  font-style: italic;
}

.search-form button[type="submit"] {
  min-height: 48px;
  padding-inline: 18px;
  border-color: #b9e3e5;
  background: #fff;
  color: #159aa0;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(31, 41, 51, .08);
}

.search-form button[type="submit"]:hover {
  border-color: #36b6bb;
  background: #eefafb;
}

.search-tab-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #e3e8ee;
}

.search-tabs {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
}

.search-tabs button {
  min-height: 38px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #516173;
  font-weight: 800;
  padding: 8px 14px 10px;
}

.search-tabs button:hover,
.search-tabs button.active {
  background: transparent;
  color: #2867e8;
  border-bottom-color: #3b82f6;
}

.search-icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #637083;
  padding: 0;
  font-size: 16px;
  font-weight: 800;
}

.icon-button:hover {
  background: #edf3f8;
  color: var(--blue-dark);
}

.icon-button.success {
  color: #2ca76f;
}

.icon-button.danger-icon {
  color: #ef5b2a;
}

.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
}

.filter-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #435469;
  font-weight: 800;
  white-space: nowrap;
}

.filter-field span {
  font-size: 14px;
}

.filter-field select {
  width: auto;
  min-width: 128px;
  min-height: 38px;
  padding-block: 7px;
  color: #435469;
}

.sort-direction-field {
  gap: 10px;
}

.sort-direction {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border-color: #2f6df1;
  background: #2f6df1;
  color: #fff;
  font-weight: 800;
}

.sort-direction:hover {
  border-color: #2056c6;
  background: #2056c6;
}

.sort-direction b {
  font-size: 20px;
  line-height: 1;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 28px;
}

.stats-strip div {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stats-strip span {
  display: block;
  font-size: 24px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.stats-strip b {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.library-section,
.chapter-section,
.action-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.section-head,
.action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head {
  margin-bottom: 18px;
}

.library-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.library-meta span,
.library-meta {
  white-space: nowrap;
}

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}

.book-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  padding: 0;
  text-align: left;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(31, 41, 51, .07);
}

.book-card:hover,
.book-card.active {
  background: #fff;
  border-color: #98c9c4;
  box-shadow: 0 12px 26px rgba(31, 41, 51, .12);
}

.cover-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--surface-soft);
  overflow: hidden;
}

.cover-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--faint);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.book-badges {
  position: absolute;
  inset: 8px 8px auto 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.card-corner-label {
  position: absolute;
  right: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  border-radius: 7px;
  background: rgba(31, 41, 51, .82);
  color: #fff;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  max-width: 100%;
  border-radius: 7px;
  padding: 3px 8px;
  color: #fff;
  background: var(--teal);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge.blue {
  background: var(--blue);
}

.badge.rose {
  background: var(--rose);
}

.book-body {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.book-title {
  min-height: 40px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.book-author,
.book-meta,
.reader-meta,
.chapter-meta,
.detail-meta,
.intro-box {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  max-width: 100%;
  border-radius: 6px;
  padding: 3px 6px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--faint);
  font-size: 12px;
}

.load-more {
  display: block;
  width: min(260px, 100%);
  margin: 22px auto 0;
}

.empty-state {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.detail-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.detail-hero {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-hero > .empty-state {
  grid-column: 1 / -1;
}

.detail-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-main {
  min-width: 0;
}

.detail-main h1 {
  font-size: 30px;
  overflow-wrap: anywhere;
}

.detail-author {
  margin: 8px 0 12px;
  color: var(--blue-dark);
  font-weight: 700;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.stat-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-pill strong {
  color: var(--text);
}

.intro-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.action-panel {
  margin: 16px 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr));
  gap: 10px;
  width: min(680px, 100%);
}

.shelf-section {
  min-height: calc(100vh - 150px);
}

.blank-page {
  min-height: calc(100vh - 62px);
}

.admin-page {
  display: none;
}

.admin-page.active {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-nav {
  position: sticky;
  top: 80px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-tab {
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 800;
}

.admin-tab:hover,
.admin-tab.active {
  border-color: #bfd7f2;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.admin-workspace,
.admin-pane {
  min-width: 0;
}

.admin-pane {
  display: none;
}

.admin-pane.active {
  display: block;
}

.admin-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-form,
.admin-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.admin-search {
  grid-template-columns: minmax(240px, 1fr) auto;
  width: min(560px, 100%);
}

.channel-form {
  grid-template-columns: minmax(0, .8fr) minmax(160px, .35fr) minmax(0, 1fr) auto;
  margin-top: 14px;
}

.channel-quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.quick-channel {
  display: grid;
  gap: 2px;
  min-width: 118px;
  min-height: 52px;
  text-align: left;
}

.quick-channel strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
}

.quick-channel span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.inline-check input {
  width: 16px;
  min-height: 16px;
}

.admin-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-row.active {
  border-color: #98c9c4;
  background: var(--green-soft);
}

.admin-row-main {
  min-width: 0;
}

.admin-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
}

.channel-row.active .channel-badge {
  background: #cdebe4;
  color: var(--teal-dark);
}

.channel-db-path {
  margin-top: 7px;
  padding: 7px 9px;
  border: 1px solid #dfe7ed;
  border-radius: 7px;
  background: #fff;
  color: #516173;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.channel-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.channel-stats span {
  border-radius: 999px;
  background: #eef3f7;
  color: #516173;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.admin-row-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.admin-actions button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.danger {
  border-color: #d82932;
  background: #d82932;
}

.danger:hover {
  border-color: #ad1e26;
  background: #ad1e26;
}

.admin-library {
  display: grid;
  gap: 18px;
}

.admin-novel-grid {
  margin-top: 6px;
}

.admin-detail-hero {
  margin-top: 0;
}

.detail-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.admin-chapters {
  min-width: 0;
  margin-top: 8px;
}

.admin-metric-grid,
.settings-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.settings-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-settings {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-metric,
.setting-row {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-metric span,
.setting-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-metric strong,
.setting-row strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 14px;
}

.volume-title {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 8px 0;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}

.chapter-button {
  display: grid;
  gap: 4px;
  min-height: 68px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 10px;
  text-align: left;
}

.chapter-button:hover,
.chapter-button.active {
  background: var(--blue-soft);
  border-color: #bfd7f2;
}

.chapter-title {
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.reader-view {
  min-height: calc(100vh - 62px);
  background: var(--reader-bg);
}

.reader-shell {
  min-height: calc(100vh - 62px);
}

.reader-header {
  position: sticky;
  top: 62px;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px max(22px, calc((100% - 1160px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 8px 22px rgba(31, 41, 51, .06);
}

.reader-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.reader-heading > div {
  min-width: 0;
}

.reader-header h1 {
  font-size: 22px;
  overflow-wrap: anywhere;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.reader-content {
  width: min(900px, calc(100% - 44px));
  margin: 0 auto;
  padding: 36px 0 78px;
  font-size: 19px;
  line-height: 2;
  outline: none;
}

.reader-content p {
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}

.reader-content img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  margin: 16px auto;
}

body.reader-full {
  overflow-x: hidden;
  background: var(--reader-bg);
}

body.reader-full .site-header {
  display: none;
}

body.reader-full .reader-view {
  min-height: 100vh;
}

body.reader-full .reader-shell {
  min-height: 100vh;
}

body.reader-full .reader-header {
  top: 0;
}

body.reader-full .reader-content {
  width: min(920px, calc(100% - 48px));
  font-size: 20px;
}

@media (max-width: 1120px) {
  .site-header {
    grid-template-columns: 1fr;
  }

  .admin-page.active {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    position: static;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  }

  .admin-tab {
    text-align: center;
    padding-inline: 8px;
  }

  .top-nav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .user-menu {
    justify-self: stretch;
    width: 100%;
  }

  .user-menu-button {
    width: 100%;
    justify-content: center;
  }

  .user-dropdown {
    left: 0;
    right: auto;
    width: min(100%, 360px);
  }

  .search-board,
  .detail-hero,
  .admin-library {
    grid-template-columns: 1fr;
  }

  .detail-cover {
    width: min(220px, 100%);
  }

  .reader-header {
    top: 0;
  }
}

@media (max-width: 760px) {
  .site-header {
    padding: 10px 14px;
  }

  .user-dropdown {
    width: calc(100vw - 28px);
  }

  .page {
    width: calc(100vw - 24px);
    max-width: 1500px;
    padding-top: 16px;
  }

  .search-board,
  .library-section,
  .detail-hero,
  .chapter-section,
  .action-panel {
    padding: 14px;
  }

  .search-form,
  .admin-form,
  .admin-search,
  .stats-strip,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .search-head,
  .search-tab-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search-icons {
    justify-content: flex-end;
  }

  .filter-field,
  .filter-field select,
  .sort-direction {
    width: 100%;
  }

  .filter-field {
    align-items: stretch;
    flex-direction: column;
    white-space: normal;
  }

  .admin-row {
    grid-template-columns: 1fr;
  }

  .admin-nav,
  .admin-metric-grid,
  .settings-list {
    grid-template-columns: 1fr;
  }

  .admin-actions {
    justify-content: stretch;
  }

  .admin-actions button {
    flex: 1 1 calc(50% - 8px);
  }

  .search-tabs button {
    flex: 1 1 calc(50% - 8px);
    padding-inline: 8px;
  }

  .novel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .book-title {
    min-height: 0;
  }

  .section-head,
  .action-panel,
  .reader-header,
  .reader-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .reader-header {
    padding: 12px;
  }

  .reader-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .reader-actions button {
    min-width: 0;
    padding-inline: 8px;
  }

  #toggleReader {
    grid-column: 1 / -1;
  }

  .reader-content {
    width: min(calc(100% - 28px), 680px);
    padding: 24px 0 58px;
    font-size: 18px;
    line-height: 1.95;
  }
}

@media (max-width: 460px) {
  .novel-grid {
    grid-template-columns: 1fr;
  }

  .reader-content {
    width: min(calc(100% - 28px), 360px);
  }
}
