:root {
  --bg: #f7f3ec;
  --surface: #fffdf9;
  --ink: #1f2a24;
  --muted: #5d6a62;
  --line: #e4ddd0;
  --accent: #1f6f4f;
  --accent-ink: #ffffff;
  --need: #1f6f4f;
  --want: #b0412e;
  --nice: #a26a12;
  --error: #a3322a;
  --shadow: 0 1px 2px rgba(31, 42, 36, 0.06), 0 8px 24px rgba(31, 42, 36, 0.06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a17;
    --surface: #1c2420;
    --ink: #ecefe9;
    --muted: #a2b0a7;
    --line: #2e3a34;
    --accent: #5cc595;
    --accent-ink: #0f1a14;
    --need: #5cc595;
    --want: #f08b74;
    --nice: #e6b25a;
    --error: #f08b74;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  flex: 1;
}

.brand { margin-bottom: 8vh; }
.logo {
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}

h1, h2, h3 { font-family: Fraunces, Georgia, serif; line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); font-weight: 700; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.05rem; margin-top: 24px; }

.lede { color: var(--muted); font-size: 1.08rem; margin: 0 0 28px; }

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

button, input { font: inherit; color: inherit; }

.search {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 10px 14px;
  outline: none;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform 0.1s ease, opacity 0.15s ease;
}
button:hover { opacity: 0.92; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, input:focus-visible, .option:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.error { color: var(--error); margin: 14px 4px 0; }
.fine { color: var(--muted); font-size: 0.85rem; margin-top: 16px; }

.manual {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.manual p { margin: 0 0 12px; }
.manual-form { display: grid; gap: 12px; }
.manual-form label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.manual-form input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--ink);
}
.manual-form button { justify-self: start; }

.product {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.product.no-image { grid-template-columns: 1fr; }
.product img {
  width: 88px; height: 88px; object-fit: contain;
  border-radius: 10px; background: #fff;
}
.product .title { font-weight: 600; margin: 0 0 2px; overflow-wrap: anywhere; }
.product .meta { color: var(--muted); font-size: 0.9rem; margin: 0; overflow-wrap: anywhere; }
.product .warn { color: var(--nice); font-size: 0.85rem; margin: 6px 0 0; }
.product.mini { grid-template-columns: 56px 1fr; }
.product.mini.no-image { grid-template-columns: 1fr; }
.product.mini img { width: 56px; height: 56px; }

.saved {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.saved p { margin: 0 0 12px; }

.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease; }
.step { color: var(--muted); font-size: 0.85rem; margin: 14px 0 4px; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 14px;
  padding: 0;
}
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.option:hover { border-color: var(--accent); }
.option input { accent-color: var(--accent); margin: 0; }
.option.selected { border-color: var(--accent); }

.center { text-align: center; padding-top: 10vh; color: var(--muted); }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 16px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.verdict {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--tone, var(--accent));
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.verdict[data-verdict="need"] { --tone: var(--need); }
.verdict[data-verdict="want"] { --tone: var(--want); }
.verdict[data-verdict="nice_to_have"] { --tone: var(--nice); }
.badge {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tone);
  border: 1.5px solid var(--tone);
}
.verdict ul { margin: 0; padding-left: 20px; }
.verdict li { margin-bottom: 6px; }
.questions-list li::marker { content: "? "; color: var(--tone); font-weight: 700; }
.tip {
  margin: 20px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg);
}

.meter { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; font-size: 0.8rem; color: var(--muted); }
.track {
  position: relative; flex: 1; height: 8px; border-radius: 8px;
  background: linear-gradient(90deg, var(--want), var(--nice), var(--need));
  opacity: 0.85;
}
.track span {
  position: absolute; top: 50%; left: 50%;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--ink);
  transform: translate(-50%, -50%);
  transition: left 0.6s ease;
}

.explainer {
  margin-top: 24px;
  padding: 4px 4px 0;
}
.explainer p { color: var(--muted); }

.foot { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 16px; }

@media (max-width: 480px) {
  .brand { margin-bottom: 5vh; }
  .search { flex-direction: column; border-radius: var(--radius); }
  .search button { width: 100%; }
  .product { grid-template-columns: 64px 1fr; }
  .product img { width: 64px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
