:root {
  --bg: #eef2f3;
  --panel: #f7f8f5;
  --panel-strong: #ffffff;
  --ink: #1d2428;
  --muted: #687076;
  --line: #d4dbdc;
  --accent: #1d6f68;
  --accent-strong: #154f4a;
  --accent-soft: #d9eeea;
  --note: #fff3c4;
  --example: #eef5ff;
  --rule: #edf8f4;
  --mark: #ffe08a;
  --shadow: 0 14px 36px rgba(29, 36, 40, 0.1);
  font-family:
    "Inter", "SF Pro Text", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(29, 111, 104, 0.08), transparent 30%),
    linear-gradient(0deg, rgba(58, 90, 104, 0.07), transparent 45%),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: rgba(247, 248, 245, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand img {
  width: 74px;
  aspect-ratio: 0.72;
  object-fit: cover;
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(29, 36, 40, 0.16);
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.1rem;
  line-height: 1.3;
}

.search-box {
  display: grid;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  outline: none;
}

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

.section-nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.nav-button:hover {
  background: rgba(29, 111, 104, 0.08);
}

.nav-button.active {
  border-color: rgba(29, 111, 104, 0.28);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.nav-title {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.nav-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.reader {
  min-width: 0;
  padding: 26px clamp(18px, 4vw, 54px) 60px;
}

.reader-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  max-width: 980px;
  margin: 0 auto 18px;
}

.reader-header h2 {
  max-width: 760px;
  font-size: clamp(1.45rem, 2.3vw, 2.4rem);
  line-height: 1.16;
}

.header-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.zoom-controls {
  display: grid;
  grid-template-columns: 34px minmax(54px, auto) 34px 54px;
  align-items: center;
  gap: 6px;
}

.zoom-button,
.zoom-reset,
.text-toggle {
  min-height: 34px;
  border: 1px solid rgba(29, 111, 104, 0.36);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 900;
}

.zoom-button {
  width: 34px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.zoom-reset,
.text-toggle {
  padding: 7px 12px;
}

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

.zoom-value {
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}

.zoom-button:hover:not(:disabled),
.zoom-reset:hover,
.text-toggle:hover,
.text-toggle.active {
  background: var(--accent);
  color: #ffffff;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.child-tabs {
  display: flex;
  max-width: 980px;
  margin: 0 auto 18px;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.child-tab {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.83rem;
  font-weight: 800;
}

.child-tab:hover {
  border-color: rgba(29, 111, 104, 0.5);
  color: var(--accent-strong);
}

.content {
  display: grid;
  max-width: 980px;
  margin: 0 auto;
  gap: 16px;
  --page-zoom: 1;
}

.page-sheet {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.page-sheet header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.page-viewport {
  overflow-x: auto;
  background: #ffffff;
}

.original-page {
  display: block;
  width: calc(100% * var(--page-zoom));
  max-width: none;
  height: auto;
  margin: 0 auto;
  background: #ffffff;
}

.simple-text {
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.simple-text summary {
  padding: 12px 16px;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 900;
}

.simple-text div {
  padding: 0 16px 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.75;
}

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

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .section-nav {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .reader-header {
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .zoom-controls {
    grid-template-columns: 34px minmax(54px, auto) 34px 54px;
  }

  .stats {
    justify-content: flex-start;
  }

}
