:root {
  --bg: #efe5d0;
  --bg-deep: #d8c4a0;
  --panel: rgba(255, 249, 239, 0.88);
  --panel-solid: #fffaf1;
  --panel-strong: #f7eddc;
  --border: #d8c0a0;
  --border-strong: #c7a578;
  --text: #2f2417;
  --muted: #746554;
  --accent: #8a5424;
  --accent-strong: #5b7d70;
  --shadow: rgba(77, 52, 24, 0.12);
  --shadow-strong: rgba(66, 42, 17, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "STZhongsong", "Noto Serif SC", "Songti SC", serif;
  background:
    radial-gradient(circle at top left, rgba(91, 125, 112, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(173, 122, 61, 0.18), transparent 32%),
    linear-gradient(180deg, #f5ead7 0%, var(--bg) 48%, #e8dbc2 100%);
}

a,
button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1500px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 22px 0 30px;
}

.hero,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 18px 44px var(--shadow);
  backdrop-filter: blur(12px);
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 22px;
  padding: 28px 28px 24px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -140px -140px auto;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 125, 112, 0.22) 0%, rgba(91, 125, 112, 0) 70%);
  pointer-events: none;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero h1,
.panel h2 {
  margin: 0;
  line-height: 1.15;
}

.hero h1 {
  font-size: clamp(34px, 4vw, 56px);
  max-width: none;
}

.hero-lead {
  margin: 14px 0 0;
  max-width: 44rem;
  line-height: 1.8;
  font-size: 17px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-link,
.mini-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fdf3e1;
  color: var(--accent);
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.action-link:hover,
.mini-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(112, 72, 29, 0.12);
}

.action-link.secondary,
.mini-action.secondary {
  background: #f1f4ef;
  color: var(--accent-strong);
  border-color: rgba(91, 125, 112, 0.34);
}

.action-link[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 251, 245, 0.76);
  border: 1px solid rgba(216, 192, 160, 0.86);
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin: 8px 0 0;
  font-size: 28px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 370px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.sidebar,
.reader-column {
  min-width: 0;
}

.reader-column {
  display: grid;
  gap: 18px;
}

.sidebar-panel,
.control-panel,
.reader-panel {
  padding: 22px;
}

.panel-head,
.reader-toolbar {
  display: flex;
  gap: 14px;
  align-items: start;
  justify-content: space-between;
}

.panel-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.search-box {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.search-box span {
  font-size: 14px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fffdf9;
  color: var(--text);
}

.search-box input:focus {
  outline: 2px solid rgba(91, 125, 112, 0.18);
  border-color: var(--accent-strong);
}

.book-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.book-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fcf7ee;
  color: var(--text);
}

.book-tab.is-active {
  background: #f7e6c8;
  border-color: var(--border-strong);
  color: var(--accent);
}

.chapter-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  max-height: calc(100vh - 300px);
  overflow: auto;
  padding-right: 4px;
}

.chapter-item {
  width: 100%;
  padding: 14px 14px 15px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.9);
  color: inherit;
  text-align: left;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.chapter-item:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.chapter-item.is-active {
  background: linear-gradient(135deg, #f9ebcf 0%, #f5f0e6 100%);
  border-color: var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(138, 84, 36, 0.08);
}

.chapter-id {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.chapter-name {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.chapter-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  padding: 18px 16px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.76);
  color: var(--muted);
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.entity-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(164px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.entity-filter {
  display: grid;
  gap: 6px;
  align-content: start;
  width: 100%;
  padding: 14px 14px 13px;
  border-radius: 20px;
  border: 1px solid var(--entity-border, var(--border));
  background: var(--entity-bg, var(--panel-solid));
  color: var(--entity-fg, var(--text));
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.entity-filter.is-disabled {
  background: rgba(245, 239, 230, 0.56);
  border-color: rgba(116, 101, 84, 0.24);
  color: rgba(47, 36, 23, 0.54);
}

.entity-filter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 16px;
}

.entity-symbol {
  font-weight: 700;
}

.entity-count {
  margin: 0;
  font-size: 12px;
  color: inherit;
  opacity: 0.85;
}

.reader-status {
  min-height: 24px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.reader-status.is-error {
  color: #9d174d;
}

.reader-status.is-success {
  color: #3f6c5f;
}

.chapter-frame {
  width: 100%;
  min-height: 72vh;
  margin-top: 8px;
  border: 1px solid rgba(199, 165, 120, 0.5);
  border-radius: 22px;
  background: #fffaf1;
}

.noscript-banner {
  width: min(680px, calc(100vw - 24px));
  margin: 16px auto 32px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid #c96b6b;
  background: #fff1f1;
  color: #7f1d1d;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .chapter-list {
    max-height: 420px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw, calc(100vw - 12px));
    padding-top: 12px;
  }

  .hero,
  .sidebar-panel,
  .control-panel,
  .reader-panel {
    padding: 18px;
    border-radius: 24px;
  }

  .panel-head,
  .reader-toolbar {
    display: block;
  }

  .panel-note {
    text-align: left;
  }

  .hero h1 {
    max-width: none;
  }

  .entity-filters {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .chapter-frame {
    min-height: 66vh;
  }
}
