:root {
  --bg: #101114;
  --panel: #191b20;
  --panel-2: #21242b;
  --text: #f4f2ee;
  --muted: #aaa7a0;
  --line: #353841;
  --accent: #9c1f2e;
  --accent-hover: #b4293a;
  --good: #7bc89c;
  --warn: #e3bd72;
  --danger: #e18484;
  --max-width: 980px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -10%, rgba(156, 31, 46, 0.22), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: inherit; }

.site-header {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.divider { opacity: 0.45; }

.page-shell {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
}

.hero { padding: 56px 0 32px; }

.eyebrow {
  margin: 0 0 8px;
  color: #c98d95;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: clamp(2.45rem, 7vw, 5.3rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.lede {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.search-card,
.plan-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(25, 27, 32, 0.92);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.2);
}

.search-card { padding: 22px; }

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 750;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #121317;
  color: var(--text);
  font: inherit;
  outline: none;
}

textarea {
  min-height: 170px;
  padding: 16px;
  resize: vertical;
}

textarea:focus,
select:focus {
  border-color: #a74d59;
  box-shadow: 0 0 0 3px rgba(156, 31, 46, 0.16);
}

.form-row {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.select-label {
  width: 110px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

select {
  margin-top: 6px;
  padding: 10px 12px;
}

button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
}

#search-button {
  min-width: 150px;
  padding: 12px 18px;
  background: var(--accent);
  color: white;
  font-weight: 850;
}

#search-button:hover:not(:disabled) { background: var(--accent-hover); }
#search-button:disabled { cursor: progress; opacity: 0.72; }

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#search-button.loading .button-label { display: none; }
#search-button.loading .spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.status {
  min-height: 1.3em;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.plan-panel {
  margin-top: 26px;
  padding: 22px;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.section-heading-row h2 { margin-bottom: 0; }

.text-button {
  padding: 4px 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.plan-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.plan-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.plan-item strong {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.results-section { margin-top: 42px; }
.result-summary { color: var(--muted); }
.results-list { margin-top: 18px; display: grid; gap: 16px; }

.result-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.result-topline {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
}

.result-card h3 {
  margin-bottom: 3px;
  font-size: 1.28rem;
}

.result-card h3 a {
  text-decoration: none;
}

.result-card h3 a:hover { text-decoration: underline; }

.byline,
.fandoms,
.summary,
.stats,
.match-notes,
.concerns { color: var(--muted); }

.byline { font-size: 0.9rem; }

.match-score {
  flex: 0 0 auto;
  min-width: 68px;
  padding: 8px 10px;
  border: 1px solid #4a6b57;
  border-radius: 999px;
  color: var(--good);
  text-align: center;
  font-weight: 900;
}

.fandoms { margin: 13px 0 10px; font-size: 0.88rem; }
.summary { margin-bottom: 13px; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0;
}

.tag {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #14161a;
  color: #ccc9c2;
  font-size: 0.78rem;
}

.tag.warning { border-color: #735850; color: #e3b9aa; }
.tag.relationship { border-color: #4e5f77; color: #b9c9e3; }

.stats {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}

.match-notes,
.concerns {
  margin-top: 12px;
  font-size: 0.9rem;
}

.match-notes strong { color: var(--good); }
.concerns strong { color: var(--warn); }

.hidden { display: none !important; }

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

footer {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 70px auto 0;
  padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  color: #777a82;
  font-size: 0.8rem;
}

@media (max-width: 680px) {
  .hero { padding-top: 34px; }
  .form-row { align-items: stretch; flex-direction: column; }
  .select-label { width: 100%; }
  #search-button { width: 100%; }
  .plan-grid { grid-template-columns: 1fr; }
  .result-topline { flex-direction: column; gap: 10px; }
}
