:root {
  --bg: #f5f6f3;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #66736d;
  --line: #dfe5e1;
  --teal: #147565;
  --teal-dark: #0c4d43;
  --amber: #b7791f;
  --blue: #1e4e8c;
  --red: #9f3434;
  --shadow: 0 16px 45px rgba(23, 33, 29, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 18px;
  background: #17211d;
  color: #ffffff;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--teal);
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.source-card small {
  margin: 0;
  color: #b8c6c0;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: transparent;
  color: #d8e3de;
  text-align: left;
  cursor: pointer;
}

.nav button:hover,
.nav button.active {
  background: #22342e;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.28);
}

.side-link,
.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  border-radius: var(--radius);
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
}

.side-link {
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.source-card {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.source-card span {
  color: #b8c6c0;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.source-link {
  margin-top: 6px;
  background: var(--teal);
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 246, 243, 0.92);
  backdrop-filter: blur(10px);
}

.icon-button {
  display: none;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.search-wrap input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: #e3f1ec;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.content {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

.hero,
.panel,
.chapter-card,
.call-card,
.category-card,
.quick-card,
.summary-item,
.result {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  padding: 28px;
}

.hero.compact {
  padding: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.05;
}

h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.hero p {
  max-width: 920px;
  margin: 12px 0 0;
  color: #31413b;
  font-size: 18px;
}

.section {
  margin-top: 24px;
}

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

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.stats-grid,
.quick-grid,
.split-grid,
.category-grid,
.highlight-grid {
  display: grid;
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 22px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #f8faf8;
}

.stat strong {
  display: block;
  color: var(--teal-dark);
  font-size: 26px;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.summary-item {
  padding: 14px 16px;
  color: #31413b;
}

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

.panel {
  padding: 20px;
}

.clean-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding-left: 20px;
  color: #31413b;
}

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

.quick-card {
  display: grid;
  gap: 6px;
  min-height: 110px;
  padding: 18px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.quick-card span {
  color: var(--muted);
}

.chapter-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.chapter-list {
  position: sticky;
  top: 92px;
  align-self: start;
  display: grid;
  gap: 7px;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

.chapter-list button {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.chapter-list button.active {
  border-color: var(--teal);
  background: #e3f1ec;
}

.chapter-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.chapter-card {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.chapter-head,
.call-head {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.field-block {
  display: grid;
  gap: 6px;
}

.field-block > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-block p {
  margin: 0;
  color: #31413b;
}

.chip-row,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf1ee;
  color: #31413b;
  font-size: 12px;
  font-weight: 800;
}

.chip.teal {
  background: #e3f1ec;
  color: var(--teal-dark);
}

.chip.amber {
  background: #fff4d7;
  color: #7a4d0b;
}

.fit-badge,
.call-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.fit-badge.high {
  background: #dff2e7;
  color: #17653d;
}

.fit-badge.medium {
  background: #fff4d7;
  color: #7a4d0b;
}

.fit-badge.low {
  background: #edf1ee;
  color: #45534d;
}

.fit-badge.none {
  background: #f9e2e2;
  color: var(--red);
}

.call-number {
  background: var(--teal);
  color: #ffffff;
}

.mini-call-grid,
.call-grid,
.search-results {
  display: grid;
  gap: 12px;
}

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

.mini-call,
.result {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #f8faf8;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.mini-call strong {
  color: var(--teal-dark);
}

.mini-call span,
.result span {
  color: var(--muted);
}

.chapter-calls {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.chapter-calls summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
  list-style: none;
}

.chapter-calls summary::-webkit-details-marker {
  display: none;
}

.chapter-calls summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  background: #e3f1ec;
  color: var(--teal-dark);
  font-size: 20px;
  line-height: 1;
}

.chapter-calls[open] summary::before {
  content: "-";
}

.chapter-calls summary span {
  flex: 1;
}

.chapter-calls summary strong {
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf1ee;
  color: #31413b;
  font-size: 12px;
}

.chapter-call-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.chapter-call-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #f8faf8;
}

.chapter-call-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.chapter-call-item h4,
.chapter-call-item p {
  margin: 0;
}

.chapter-call-item h4 {
  font-size: 17px;
  line-height: 1.3;
}

.chapter-call-item p {
  color: #31413b;
}

.text-button {
  justify-self: start;
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  background: #e3f1ec;
  color: var(--teal-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.filter-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

select {
  min-width: 220px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
  text-transform: none;
}

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

.call-card {
  display: grid;
  gap: 13px;
  padding: 18px;
  scroll-margin-top: 84px;
}

.call-card h3 {
  font-size: 18px;
}

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

.category-card {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.category-card p {
  margin: 0;
  color: #31413b;
}

.category-card .small,
.path {
  color: var(--muted);
  font-size: 13px;
}

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

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.path {
  overflow-wrap: anywhere;
  font-family: Consolas, "Liberation Mono", monospace;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: 300px;
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .icon-button {
    display: inline-flex;
  }

  .chapter-layout,
  .stats-grid,
  .split-grid,
  .quick-grid,
  .mini-call-grid,
  .call-grid,
  .category-grid,
  .highlight-grid {
    grid-template-columns: 1fr;
  }

  .chapter-list {
    position: static;
    max-height: none;
  }
}

@media (max-width: 560px) {
  .content,
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .progress-pill {
    display: none;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .hero,
  .chapter-card,
  .panel {
    padding: 18px;
  }
}
