:root {
  --bg-1: #f2ecdf;
  --bg-2: #e7ddcd;
  --ink: #2a251f;
  --muted: #6f6558;
  --accent: #9a6d3a;
  --accent-soft: #b88954;
  --card: rgba(255, 250, 241, 0.78);
  --line: rgba(108, 81, 49, 0.2);
  --shadow: 0 16px 44px rgba(87, 63, 35, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(184, 137, 84, 0.18) 0%, rgba(184, 137, 84, 0) 42%),
    radial-gradient(circle at 84% 100%, rgba(154, 109, 58, 0.14) 0%, rgba(154, 109, 58, 0) 46%),
    linear-gradient(155deg, var(--bg-1), var(--bg-2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(164, 126, 84, 0.06) 0,
    rgba(164, 126, 84, 0.06) 1px,
    transparent 1px,
    transparent 78px
  );
}

.app-shell {
  width: min(980px, 92vw);
  margin: 34px auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
}

.hero-card,
.results-panel {
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(5px);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 28px;
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: #9a6d3a;
  font-weight: 700;
}

h1 {
  margin: 12px 0;
  font-family: "Comic Neue", sans-serif;
  font-size: clamp(1.2rem, 2vw, 2rem);
  line-height: 1.08;
}

.subtext {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.recommend-form {
  display: grid;
  gap: 10px;
}

.recommend-form label {
  font-size: 0.88rem;
  color: var(--muted);
}

.input-row {
  display: flex;
  gap: 10px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.filter-field label {
  font-size: 0.82rem;
  color: var(--muted);
}

.input-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 1rem;
  padding: 0.78rem 0.9rem;
  font-family: inherit;
  background: rgba(255, 253, 247, 0.8);
  color: var(--ink);
}

.filter-field input {
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.93rem;
  padding: 0.62rem 0.75rem;
  font-family: inherit;
  background: rgba(255, 253, 247, 0.8);
  color: var(--ink);
}

.filter-field select {
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.93rem;
  padding: 0.62rem 0.75rem;
  font-family: inherit;
  background: rgba(255, 253, 247, 0.8);
  color: var(--ink);
}

.filter-field input::placeholder {
  color: #9a8b78;
}

.input-row input::placeholder {
  color: #9a8b78;
}

.input-row button {
  border: 0;
  border-radius: 12px;
  padding: 0.78rem 1rem;
  font-family: inherit;
  font-weight: 700;
  color: #fffaf1;
  background: linear-gradient(145deg, #b48753, #8f6434);
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.input-row button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.status {
  min-height: 1.25rem;
  margin-top: 12px;
  color: var(--muted);
}

.score-meter-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}

.score-meter {
  position: relative;
  display: flex;
  gap: 3px;
  padding: 3px;
  background: #f3f4f6;
  border-radius: 6px;
  cursor: default;
}

/* Tooltip */
.score-tooltip {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  
  background: #111827;
  color: white;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  
  transition: opacity 0.2s ease;
}

/* Arrow */
.score-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  
  border-width: 5px;
  border-style: solid;
  border-color: #111827 transparent transparent transparent;
}

/* Show on hover */
.score-meter:hover .score-tooltip {
  opacity: 1;
}

.score-segment {
  display: block;
  width: 30px;
  height: 10px;
  border-radius: 3px;
  background: #e5e7eb;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
}

.score-segment.filled.score-bright-green {
  background: #22c55e;
}

.score-segment.filled.score-pastel-green {
  background: #86efac;
}

.score-segment.filled.score-yellow {
  background: #facc15;
}

.score-segment.filled.score-orange {
  background: #fb923c;
}

.score-segment.filled.score-red {
  background: #ef4444;
}

.score-star {
  font-size: 18px;
  line-height: 1;
  color: #f5b301;
}

.results-panel {
  padding: 20px;
}

.results-header {
  margin-bottom: 8px;
}

.results-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.matched-title {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.active-filters {
  margin: 6px 0 0;
  color: #7b5a34;
  font-size: 0.84rem;
  font-weight: 500;
}

.title-corrections {
  margin-top: 8px;
}

.correction-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.correction-item {
  border: 1px solid rgba(154, 109, 58, 0.28);
  background: rgba(154, 109, 58, 0.1);
  color: #6a4825;
  border-radius: 10px;
  padding: 6px 9px;
  font-size: 0.82rem;
}

.results-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.9), rgba(247, 238, 225, 0.9));
  animation: rise 260ms ease both;
}

.result-title {
  margin: 0;
  font-weight: 700;
}

.result-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(154, 109, 58, 0.14);
  color: #7e552a;
  font-weight: 700;
}

.result-description {
  margin: 10px 0 0;
  color: #3f3529;
  font-size: 0.9rem;
  line-height: 1.45;
}

.result-actions {
  margin-top: 10px;
}

.optout-btn {
  border: 1px solid rgba(143, 100, 52, 0.35);
  border-radius: 10px;
  background: rgba(255, 249, 239, 0.9);
  color: #7e552a;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.optout-btn:hover {
  transform: translateY(-1px);
  background: rgba(246, 231, 206, 0.95);
}

.book-facts {
  margin-top: 10px;
  display: grid;
  gap: 5px;
  font-size: 0.86rem;
  color: #4b3f30;
}

.book-facts p {
  margin: 0;
}

.compare-grid {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: #4b3f30;
}

.compare-grid p {
  margin: 0;
}

.flag {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 7px;
  letter-spacing: 0.04em;
}

.flag.yes {
  background: rgba(87, 141, 112, 0.2);
  color: #245e3f;
}

.flag.no {
  background: rgba(187, 122, 56, 0.2);
  color: #8e4f17;
}

.reasoning {
  margin-top: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.reasoning summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.86rem;
}

.reasoning p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.score-factors {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
}

@media (max-width: 520px) {
  .score-factors {
    grid-template-columns: 1fr;
  }
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

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

  .input-row {
    flex-direction: column;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }
}
