:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #60646c;
  --line: #d9d5cc;
  --accent: #0f6b57;
  --accent-2: #8d3f2b;
  --mark: #ffe29a;
  --shadow: 0 10px 28px rgba(35, 31, 25, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button,
input,
select {
  font: inherit;
}

.topbar {
  align-items: end;
  background: #fffaf0;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 104px;
  padding: 22px 28px;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1;
  margin-bottom: 0;
}

h2 {
  font-size: 0.92rem;
  line-height: 1.2;
  margin-bottom: 0;
}

.stats {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.88rem;
  gap: 8px;
  justify-content: flex-end;
  max-width: 720px;
}

.stat {
  background: rgba(15, 107, 87, 0.08);
  border: 1px solid rgba(15, 107, 87, 0.16);
  border-radius: 999px;
  color: #22443d;
  padding: 5px 10px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(360px, 0.95fr) minmax(360px, 1.05fr);
  height: calc(100vh - 104px);
  min-height: 640px;
}

.filters,
.results-pane,
.reader-pane {
  min-height: 0;
}

.filters {
  background: #fbfaf7;
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 18px;
}

.search-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.search-input,
.facet-select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  width: 100%;
}

.search-input {
  font-size: 1rem;
  min-height: 44px;
  padding: 10px 12px;
}

.facet-select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 52%,
    calc(100% - 12px) 52%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  cursor: pointer;
  margin-top: 10px;
  min-height: 40px;
  padding: 8px 34px 8px 10px;
}

.search-input:focus,
.facet-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 87, 0.14);
}

.filter-section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

.section-head,
.results-toolbar,
.reader-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.plain-button {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 4px 0;
}

.secondary-button,
.show-more {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.86rem;
  font-weight: 700;
  min-height: 36px;
  padding: 8px 12px;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-button:hover,
.show-more:hover {
  border-color: var(--accent);
}

.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.results-pane {
  background: #fdfcf8;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.results-toolbar {
  border-bottom: 1px solid var(--line);
  min-height: 72px;
  padding: 14px 18px;
}

.result-count {
  font-size: 1rem;
  font-weight: 800;
}

.active-filters {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.8rem;
  gap: 6px;
  margin-top: 6px;
}

.filter-pill {
  background: rgba(141, 63, 43, 0.09);
  border: 1px solid rgba(141, 63, 43, 0.18);
  border-radius: 999px;
  color: #603123;
  padding: 3px 8px;
}

.results {
  overflow: auto;
  padding: 12px;
}

.result {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 10px;
  padding: 12px;
}

.result:hover,
.result.active {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.result-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.78rem;
  gap: 8px;
  margin-bottom: 7px;
}

.result-title {
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 8px;
}

.snippet {
  color: #33363b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0 0 10px;
  white-space: pre-wrap;
}

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

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

.tag {
  background: #f1f0ea;
  border-radius: 999px;
  color: #50545b;
  font-size: 0.72rem;
  padding: 3px 7px;
}

.show-more {
  align-self: center;
  margin: 0 0 14px;
}

.hidden {
  display: none;
}

.reader-pane {
  background: #ece8df;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.reader-head {
  background: #fbfaf7;
  border-bottom: 1px solid var(--line);
  min-height: 72px;
  padding: 14px 18px;
}

.reader-head h2 {
  font-size: 1rem;
}

.reader-content {
  background: #d8d2c7;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  width: 100%;
}

.reader-image {
  background: #ffffff;
  box-shadow: var(--shadow);
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: 100%;
}

.reader-image.hidden {
  display: none;
}

.empty {
  color: var(--muted);
  padding: 20px;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: minmax(240px, 300px) 1fr;
    height: auto;
    min-height: 0;
  }

  .reader-pane {
    grid-column: 1 / -1;
    min-height: 620px;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    min-height: auto;
    padding: 18px;
  }

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

  .app-shell {
    display: block;
  }

  .filters,
  .results-pane,
  .reader-pane {
    border-right: 0;
    min-height: auto;
  }

  .results-pane {
    border-top: 1px solid var(--line);
  }

  .reader-pane {
    border-top: 1px solid var(--line);
    height: 75vh;
  }
}
