:root {
  --ink: #1b2430;
  --muted: #5d6877;
  --line: #cbd5df;
  --soft: #eef3f7;
  --paper: #fbfbf9;
  --gold: #b78a32;
  --book: #8a6f18;
  --book-dark: #282313;
  --book-ink: #5b4810;
  --book-line: #d9c987;
  --book-soft: #f4efd8;
  --white: #ffffff;
  --shadow: 0 12px 24px rgba(27, 36, 48, .08);
  --radius: 7px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f7f8f8 0, #eef2f5 420px, #fbfbf8 100%);
}

.wrap {
  width: min(1140px, calc(100% - 36px));
  margin: 0 auto;
}

.topbar {
  background: linear-gradient(115deg, var(--book-dark), var(--book));
  color: var(--white);
}

.topbar-inner {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 0 25px;
}

.panel-title {
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .08em;
  font-size: 11px;
}

h1 {
  margin: 0 0 12px;
  max-width: 960px;
  font-size: 44px;
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar p {
  margin: 0;
  max-width: 860px;
  line-height: 1.42;
}

.topbar .tagline {
  font-size: 14px;
  font-weight: 800;
  color: var(--white);
}

.about-button {
  align-self: flex-start;
  margin-top: 7px;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 2px;
  color: var(--white);
  background: rgba(255,255,255,.08);
  padding: 9px 13px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.about-button:hover {
  background: rgba(255,255,255,.16);
}

.status-line {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.72);
}

.feature-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 14px;
}

.feature-card {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.84);
  padding: 16px 14px 18px;
  min-height: 148px;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.feature-card h2 {
  margin: 0 0 12px;
  color: var(--book-dark);
  font-size: 22px;
  line-height: 1.08;
  letter-spacing: 0;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 42px;
  min-width: 0;
}

.search-panel,
.results-panel {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  min-width: 0;
}

.search-panel {
  padding: 18px;
  position: sticky;
  top: 12px;
}

.results-panel {
  padding: 18px;
}

label {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  height: 38px;
  margin-top: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 0 11px;
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(183, 138, 50, .32);
  border-color: var(--gold);
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions,
.results-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions {
  margin-top: 16px;
}

button {
  min-height: 38px;
  border: 1px solid var(--book);
  background: var(--book);
  color: var(--white);
  font-weight: 800;
  padding: 0 14px;
  border-radius: 4px;
  cursor: pointer;
}

button:hover { filter: brightness(1.06); }

button.ghost {
  background: var(--white);
  color: var(--book-ink);
}

.actions button {
  flex: 1;
}

.results-head {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.results-head p {
  margin: 7px 0 0;
  color: var(--muted);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.chip {
  border: 1px solid var(--book-line);
  color: var(--book-ink);
  background: var(--book-soft);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.results {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.record {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.record,
.record * {
  overflow-wrap: anywhere;
}

.record-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge {
  color: var(--book-ink);
  background: var(--book-soft);
  border: 1px solid var(--book-line);
  border-radius: 999px;
  padding: 3px 7px;
}

.record h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.subtitle {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.authors {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}

.download-fulltext {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--book-line);
  background: var(--paper);
  color: var(--book-ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.download-fulltext:hover {
  filter: brightness(1.06);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
}

.meta div {
  min-width: 120px;
}

.snippet {
  margin: 0;
  color: #273545;
  line-height: 1.48;
}

.snippet-list {
  margin: 0;
  padding-left: 22px;
  color: #273545;
}

.snippet-list li {
  margin: 0 0 8px;
  line-height: 1.48;
}

.text-hit {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.text-hit h3 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--book);
}

.reading-summary {
  margin-top: 14px;
  padding-top: 0;
  min-width: 0;
}

.reading-summary h3 {
  margin: 12px 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--book);
}

.reading-summary h3.section-divider {
  margin-top: 14px;
  padding-top: 0;
}

.reading-summary p {
  margin: 0;
  line-height: 1.48;
}

.audit-note {
  color: #7b2834;
  background: #fff5f6;
  border: 1px solid #e1c2c9;
  padding: 9px;
  font-weight: 700;
}

.toc-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 30px;
  margin: 0;
  padding-left: 20px;
}

.toc-list li {
  margin: 0 0 6px;
  line-height: 1.35;
  min-width: 0;
}

.toc-title {
  color: var(--book-ink);
  font-weight: 800;
}

.toc-list span {
  color: var(--muted);
  font-size: 12px;
}

.toc-empty {
  color: var(--muted);
  background: var(--paper);
  border: 1px dashed var(--line);
  padding: 10px;
  font-weight: 700;
}

mark {
  background: #f5dda4;
  padding: 0 2px;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.links a {
  border: 1px solid var(--line);
  color: var(--book-ink);
  background: var(--soft);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.pagination button {
  min-width: 38px;
  padding: 0 10px;
}

.pagination button.active {
  background: var(--book-dark);
  border-color: var(--book-dark);
}

.empty {
  border: 1px dashed var(--line);
  padding: 26px;
  color: var(--muted);
  text-align: center;
  background: var(--paper);
}

@media (max-width: 850px) {
  .results-head {
    display: block;
  }

  .feature-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .search-panel {
    position: static;
  }

  .toc-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .wrap {
    width: min(100% - 22px, 1140px);
  }

  .feature-cards,
  .grid-two {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 34px;
  }

  .topbar-inner {
    min-height: 150px;
  }

  .topbar .tagline {
    font-size: 13px;
  }
}
