:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #171717;
  --muted: #62666d;
  --line: #dfe3e8;
  --accent: #111111;
  --accent-soft: #eceff3;
  --danger: #9f1d1d;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.search-panel,
.stats,
.results-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.search-panel {
  display: grid;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.25rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.search-form input,
.assistant-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
}

.search-form input:focus,
.assistant-form input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.search-form button,
.assistant-form button {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 0 22px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.search-form button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.search-form .secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.assistant-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.status {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.suggestions-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.suggestions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.stats,
.results-section {
  margin-top: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.8rem;
}

.stats-lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.stats-lists ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stats-lists li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

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

.count-pill {
  min-width: 36px;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--accent-soft);
  text-align: center;
  font-weight: 700;
}

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

.results.empty {
  display: block;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.book-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.book-card h3 {
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.book-meta {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 7px 10px;
  margin: 0;
  font-size: 0.94rem;
}

.book-meta dt {
  color: var(--muted);
}

.book-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1080px);
    padding-top: 16px;
  }

  .search-panel,
  .stats,
  .results-section {
    padding: 18px;
  }

  .search-form,
  .assistant-form,
  .stats-grid,
  .stats-lists {
    grid-template-columns: 1fr;
  }

  .search-form button {
    width: 100%;
  }
}
