:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #68707d;
  --line: #dde3e7;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --brand: #2f6f73;
  --accent: #a8653d;
  --soft: #edf3f1;
  --shadow: 0 18px 50px rgba(33, 39, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.primary,
.secondary {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 700;
}

.primary {
  background: var(--brand);
  color: white;
}

.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
}

.reader-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5vw;
  border-bottom: 1px solid rgba(32, 36, 42, 0.08);
  background: rgba(251, 250, 246, 0.86);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand span {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
}

.topbar nav {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-weight: 700;
}

.hero {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 4vw;
  align-items: center;
  padding: 42px 5vw 72px;
}

.hero-copy p,
.section-head p,
.admin-header p,
.form-head p,
.chapter-list p {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(42px, 6vw, 86px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.hero-visual {
  min-height: 520px;
  display: grid;
  place-items: center;
  position: relative;
}

.book-stack {
  width: min(62vw, 360px);
  height: min(78vw, 470px);
  border-radius: 8px 20px 20px 8px;
  box-shadow: var(--shadow);
  position: absolute;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16), transparent 18%),
    linear-gradient(135deg, #315d62, #9a6d51);
}

.book-stack::after {
  content: "";
  position: absolute;
  inset: 34px 28px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
}

.book-stack.one {
  transform: rotate(-8deg) translate(-30px, 8px);
}

.book-stack.two {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.15), transparent 18%),
    linear-gradient(135deg, #733f56, #d19b58);
  transform: rotate(4deg) translate(45px, -10px) scale(0.86);
}

.book-stack.three {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.15), transparent 18%),
    linear-gradient(135deg, #314d7d, #7f8057);
  transform: rotate(12deg) translate(5px, 55px) scale(0.72);
}

.library-band,
.reader-panel {
  padding: 64px 5vw;
}

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

.section-head h2,
.chapter-list h2,
.admin-header h1,
.form-head h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0;
}

.search-box {
  width: min(100%, 360px);
}

.search-box span,
label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 12px 13px;
  outline: 0;
}

textarea {
  resize: vertical;
  line-height: 1.7;
}

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

.book-card {
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  grid-template-columns: 120px 1fr;
  overflow: hidden;
}

.cover {
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 28%),
    var(--cover);
  background-size: cover;
  background-position: center;
  color: white;
}

.cover span {
  font-size: 12px;
  opacity: 0.82;
}

.cover strong {
  font-size: 24px;
  line-height: 1.15;
}

.book-card-body {
  padding: 20px;
  display: grid;
  gap: 12px;
}

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

.book-card-body h3 {
  margin: 0;
  font-size: 22px;
}

.book-card-body em {
  color: #4b535c;
  font-style: normal;
  line-height: 1.65;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-row span,
.status {
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.book-card button {
  align-self: end;
  background: var(--ink);
  color: white;
}

.reader-panel {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.chapter-list,
.reading-surface,
.book-form,
.book-table-panel,
.ops-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.chapter-list {
  position: sticky;
  top: 96px;
  padding: 22px;
}

#chapterList {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

#chapterList button {
  justify-content: flex-start;
  background: #f5f7f6;
  color: var(--ink);
}

#chapterList button.active {
  background: var(--brand);
  color: white;
}

.reading-surface {
  min-height: 70vh;
  padding: clamp(28px, 5vw, 72px);
}

.reading-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 24px;
}

.reading-toolbar button {
  background: #f3f5f4;
}

.reading-surface h2 {
  font-size: 40px;
  margin: 10px 0 24px;
  letter-spacing: 0;
}

.chapter-content {
  max-width: 820px;
  line-height: 2.05;
  color: #2c3035;
}

.chapter-content p {
  margin: 0 0 1.2em;
}

.night {
  --paper: #171b1e;
  --panel: #20262b;
  --ink: #eef1ee;
  --muted: #a9b0b6;
  --line: #343c43;
  --soft: #253331;
}

.night .reading-surface,
.night .chapter-list,
.night .book-card,
.night input,
.night textarea,
.night select {
  background: #20262b;
}

.night .chapter-content,
.night .book-card-body em {
  color: #d9dedb;
}

.admin-body {
  background: #f4f6f5;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.admin-sidebar {
  background: #1f282b;
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-sidebar .brand {
  margin-bottom: 24px;
}

.admin-sidebar button {
  justify-content: flex-start;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
}

.admin-sidebar button.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.admin-main {
  padding: 28px;
}

.admin-header,
.form-head,
.form-actions,
.book-row,
.row-actions {
  display: flex;
  align-items: center;
}

.admin-header,
.form-head {
  justify-content: space-between;
  gap: 16px;
}

.ops-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.ops-metrics div {
  padding: 18px;
}

.ops-metrics span {
  color: var(--muted);
  font-weight: 700;
}

.ops-metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(480px, 1.15fr);
  gap: 18px;
  align-items: start;
}

.book-form,
.book-table-panel {
  padding: 20px;
}

.book-form {
  display: grid;
  gap: 16px;
}

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

.upload-drop {
  border: 1px dashed #9fb4b2;
  border-radius: 8px;
  background: #f1f6f5;
  padding: 18px;
  cursor: pointer;
}

.upload-drop input {
  display: none;
}

.cover-preview {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfb;
}

.cover-preview[hidden] {
  display: none;
}

.cover-preview img {
  width: 88px;
  height: 116px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--soft);
}

.form-actions {
  gap: 12px;
}

#saveNotice {
  color: var(--brand);
  font-weight: 800;
}

.compact {
  align-items: center;
  margin-bottom: 14px;
}

.compact h2 {
  font-size: 24px;
}

.book-table {
  display: grid;
  gap: 10px;
}

.book-row {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  gap: 14px;
  background: #fbfcfb;
}

.mini-cover {
  width: 48px;
  height: 62px;
  flex: 0 0 auto;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--cover);
  color: white;
  font-weight: 900;
}

.book-row h3,
.book-row p {
  margin: 0;
}

.book-row p {
  margin-top: 5px;
  color: var(--muted);
}

.book-row > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.status.draft {
  color: #946319;
  background: #fff2d4;
}

.status.archived {
  color: #69717a;
  background: #edf0f2;
}

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

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: white;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  background: white;
}

@media (max-width: 980px) {
  .hero,
  .reader-panel,
  .admin-shell,
  .admin-workspace {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
  }

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

  .chapter-list {
    position: static;
  }
}

@media (max-width: 680px) {
  .topbar,
  .section-head,
  .admin-header,
  .form-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero {
    min-height: auto;
    padding-top: 36px;
  }

  .hero-visual {
    min-height: 360px;
  }

  .book-card,
  .field-grid,
  .ops-metrics {
    grid-template-columns: 1fr;
  }

  .cover {
    min-height: 190px;
  }

  .admin-main,
  .library-band,
  .reader-panel {
    padding: 28px 18px;
  }

  .book-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}
