:root,
[data-theme="dark"] {
  --bg: #14110e;
  --bg-2: #1b1713;
  --surface: #221d18;
  --surface-strong: #2a241e;
  --paper: #1a1612;
  --ink: #f4ece3;
  --ink-soft: #d7cbbd;
  --muted: #b3a394;
  --line: #3d342b;
  --glass-border: #3d342b;
  --glass-shine: transparent;
  --accent: #e06a3a;
  --accent-2: #e8b84a;
  --accent-3: #e08a3a;
  --accent-dark: #f4ece3;
  --gold: #e8b84a;
  --green: #3d9a6a;
  --amber: #d4922a;
  --red: #d4544a;
  --crimson: #d4544a;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  --glow-teal: rgba(224, 106, 58, 0.18);
  --glow-gold: rgba(232, 184, 74, 0.16);
  --glow-rose: rgba(212, 84, 74, 0.12);
  --header-bg: #1b1713;
  --chip-bg: #2a241e;
  --bar-track: #3d342b;
  --scrollbar: #6b5c4d;
  --focus: rgba(224, 106, 58, 0.35);
}

[data-theme="light"] {
  --bg: #f3eee6;
  --bg-2: #ebe4d8;
  --surface: #fffaf3;
  --surface-strong: #fffdf8;
  --paper: #fffdf8;
  --ink: #1a1612;
  --ink-soft: #3d342b;
  --muted: #6b5c4d;
  --line: #ddd2c3;
  --glass-border: #ddd2c3;
  --glass-shine: transparent;
  --accent: #c24e28;
  --accent-2: #a67c1a;
  --accent-3: #c24e28;
  --accent-dark: #1a1612;
  --gold: #a67c1a;
  --green: #1f7a4d;
  --amber: #a67c1a;
  --red: #b42318;
  --crimson: #b42318;
  --shadow: 0 8px 20px rgba(26, 22, 18, 0.08);
  --glow-teal: rgba(194, 78, 40, 0.12);
  --glow-gold: rgba(166, 124, 26, 0.12);
  --glow-rose: rgba(180, 35, 24, 0.08);
  --header-bg: #fffaf3;
  --chip-bg: #f3eee6;
  --bar-track: #ddd2c3;
  --scrollbar: #b3a394;
  --focus: rgba(194, 78, 40, 0.28);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  background:
    radial-gradient(circle at 12% 0%, var(--glow-gold), transparent 28rem),
    radial-gradient(circle at 88% 100%, var(--glow-teal), transparent 26rem),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

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

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

.site-header,
.app-shell {
  position: relative;
  z-index: 1;
}

.panel,
.glass-card,
.lookup-panel,
.col,
.num-card,
.summary-card,
.site-header {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--header-bg);
}

.brand {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand span { color: var(--gold); }

.nav-toggle {
  display: none;
  min-width: 44px;
  min-height: 44px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.site-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--chip-bg);
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--gold);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.theme-toggle:hover,
.theme-toggle:focus-visible,
.nav-toggle:focus-visible,
.site-nav a:focus-visible,
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.theme-toggle .icon-sun,
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-hero,
.intro {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.page-hero h1,
.intro h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

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

.lede, .subtitle, .hint,
.page-hero p:not(.eyebrow) {
  display: block;
  max-width: 42rem;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.hint { margin-top: 8px; }

.btn-primary,
button[type="submit"],
.btn-cosmic,
.btn-gold-solid {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  color: #fffaf3;
  background: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

button[type="submit"]:hover,
.btn-primary:hover,
.btn-cosmic:hover,
.btn-gold-solid:hover {
  filter: brightness(1.08);
}

input, select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-size: 1rem;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--muted);
}

.error {
  margin: 8px 0 0;
  color: var(--red);
  font-size: 0.95rem;
  font-weight: 700;
}

.weight-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.weight-strip span {
  display: flex;
  flex-direction: column;
  min-width: 88px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
}

.weight-strip strong {
  color: var(--accent);
  font-size: 1.15rem;
  font-family: Fraunces, Georgia, serif;
}

.category-chip {
  min-width: 92px;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cat-most { --bar-color: var(--green); color: #fff; background: var(--green); }
.cat-compatible { --bar-color: #2f7a58; color: #fff; background: #2f7a58; }
.cat-neutral { --bar-color: var(--gold); color: #1a1612; background: var(--gold); }
.cat-caution { --bar-color: var(--amber); color: #1a1612; background: var(--amber); }
.cat-avoid { --bar-color: var(--red); color: #fff; background: var(--red); }

.bar, .bucket-bar {
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--bar-track);
}

.bar span {
  display: block;
  height: 100%;
  width: var(--value);
  border-radius: inherit;
  background: var(--bar-color, var(--accent));
}

.num, .number-seal, .lr-num {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
}

.num {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.95rem;
}

.number-seal {
  width: 44px;
  height: 44px;
  border: 1px solid var(--gold);
  background: var(--chip-bg);
  color: var(--gold);
  font-size: 1.2rem;
}

.number-badge {
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
}

.number-badge:not(:empty) { display: inline-flex; }
.number-badge.tier-best { color: var(--green); background: rgba(61, 154, 106, 0.18); }
.number-badge.tier-caution { color: var(--amber); background: rgba(212, 146, 42, 0.18); }
.number-badge.tier-avoid { color: var(--red); background: rgba(212, 84, 74, 0.18); }

.gender-icon {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 800;
}

.gender-icon.gender-male { color: #3b6ea5; background: rgba(59, 110, 165, 0.16); }
.gender-icon.gender-female { color: #c1447e; background: rgba(193, 68, 126, 0.16); }

@media (max-width: 840px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .site-header.is-open .site-nav { display: flex; }
  .site-nav a { min-height: 44px; }
}

@media (min-width: 841px) {
  .site-header { padding: 8px 20px; }
  .app-shell { width: min(1180px, calc(100% - 40px)); padding-top: 20px; }
}
