:root {
  color-scheme: light;
  --ink: #102238;
  --muted: #5f6f81;
  --paper: #f5f7fb;
  --surface: #ffffff;
  --line: rgba(16, 34, 56, 0.13);
  --shadow: 0 18px 50px rgba(16, 34, 56, 0.10);
  --radius: 22px;
  --accent: #0a7a70;
  --accent-strong: #07564f;
  --accent-soft: #d7f4ed;
  --accent-ink: #062d2a;
  --secondary: #f0aa36;
  --display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="girls"] {
  --ink: #2b1433;
  --muted: #765f7b;
  --paper: #fcf6fb;
  --line: rgba(63, 25, 70, 0.14);
  --shadow: 0 18px 50px rgba(72, 26, 80, 0.11);
  --accent: #9e285d;
  --accent-strong: #6d1743;
  --accent-soft: #f8dce9;
  --accent-ink: #4a1231;
  --secondary: #e59322;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 7% 6%, color-mix(in srgb, var(--accent-soft) 65%, transparent) 0, transparent 28rem),
    var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--accent-strong); }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: .75rem 1rem;
  border-radius: .75rem;
  background: var(--ink);
  color: white;
}
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: .75rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -.02em;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: var(--surface);
  font-size: 1.35rem;
}

.companion-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .62rem .85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 650;
}
.companion-link::after { content: "↗"; color: var(--accent); }

main { overflow: hidden; }

.search-stage {
  position: relative;
  padding: clamp(2.6rem, 7vw, 6rem) clamp(1rem, 4vw, 4rem) clamp(2rem, 5vw, 4rem);
  border-bottom: 1px solid var(--line);
}

.search-stage::after {
  content: "ⵣ";
  position: absolute;
  right: clamp(-1rem, 2vw, 3rem);
  top: -5rem;
  z-index: -1;
  color: color-mix(in srgb, var(--accent) 10%, transparent);
  font: 32rem/1 var(--display);
  transform: rotate(8deg);
}

.stage-inner { max-width: 1050px; margin: 0 auto; }
.eyebrow {
  margin: 0 0 .6rem;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  margin-bottom: .8rem;
  font: clamp(3rem, 8vw, 6.8rem)/.94 var(--display);
  letter-spacing: -.06em;
}

h1 em { color: var(--accent); font-weight: 500; }

.intro {
  max-width: 760px;
  margin-bottom: 1.7rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .75rem;
  max-width: 900px;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 64px;
  padding: 0 .65rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-box svg { width: 22px; fill: none; stroke: var(--accent); stroke-width: 2; }
.search-box input {
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0 .8rem;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}
.search-box input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  font-size: 1.35rem;
}
.icon-button:hover { background: var(--accent-soft); }

.primary-button, .secondary-button, .text-button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 760;
}
.primary-button {
  min-height: 64px;
  padding: .8rem 1.25rem;
  background: var(--ink);
  color: white;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--ink) 18%, transparent);
}
.primary-button:hover { background: var(--accent-strong); }
.secondary-button { padding: .78rem 1rem; border: 1px solid var(--line); background: var(--surface); }
.text-button { padding: .4rem; background: transparent; color: var(--accent-strong); }

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: .9rem;
}
.metrics strong { color: var(--ink); }

.section-shell {
  width: min(1320px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.section-heading h2 { margin-bottom: .2rem; font: clamp(2rem, 4vw, 3.6rem)/1 var(--display); letter-spacing: -.045em; }
.section-heading p { margin-bottom: 0; color: var(--muted); }

.featured-strip {
  display: grid;
  grid-auto-columns: minmax(245px, 1fr);
  grid-auto-flow: column;
  gap: .9rem;
  overflow-x: auto;
  padding: .2rem .1rem 1.15rem;
  scroll-snap-type: x mandatory;
}
.featured-strip .name-card { scroll-snap-align: start; }

.catalogue-section {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 40%, transparent);
}

.catalogue-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: clamp(1.2rem, 3vw, 3rem);
  align-items: start;
}

.filter-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(16, 34, 56, .06);
}

.filter-panel h3 { margin: 0; font-size: 1rem; }
.filter-panel label { display: grid; gap: .35rem; color: var(--muted); font-size: .84rem; font-weight: 700; }
.filter-panel select {
  width: 100%;
  min-height: 44px;
  padding: 0 .7rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  color: var(--ink);
}

.toggle-line { grid-template-columns: 1fr auto !important; align-items: center; }
.toggle-line input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.favorites-meta { padding-top: .75rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.results-head h2 { margin: 0; font: clamp(1.9rem, 3vw, 2.8rem)/1 var(--display); letter-spacing: -.04em; }
.results-count { margin: 0; color: var(--muted); }

.alphabet {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: 1.25rem;
}
.letter-button {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: .84rem;
  font-weight: 740;
}
.letter-button:hover, .letter-button.is-active { border-color: var(--accent); background: var(--accent); color: white; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
}

.name-card {
  position: relative;
  min-height: 205px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(16, 34, 56, .05);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.name-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow); }
.name-card.is-featured { min-height: 230px; background: linear-gradient(145deg, var(--surface), var(--accent-soft)); }
.card-open {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: inherit;
  align-content: start;
  gap: .5rem;
  padding: 1.1rem 3.2rem 1.1rem 1.1rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.card-open strong { font: 1.72rem/1.05 var(--display); letter-spacing: -.035em; }
.card-kicker { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.card-meaning { min-height: 2.8rem; margin: 0; color: var(--ink); font-size: .91rem; line-height: 1.4; }
.card-meaning.is-muted { color: var(--muted); }
.card-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: auto; }
.badge { padding: .25rem .48rem; border-radius: 999px; background: var(--paper); color: var(--muted); font-size: .68rem; font-weight: 700; }
.theme-badge { background: var(--accent-soft); color: var(--accent-ink); text-transform: capitalize; }
.favorite-button {
  position: absolute;
  right: .75rem;
  top: .75rem;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  cursor: pointer;
}
.favorite-button svg { width: 19px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.favorite-button:hover, .favorite-button.is-active { border-color: var(--secondary); background: color-mix(in srgb, var(--secondary) 18%, white); }
.favorite-button.is-active svg { fill: var(--secondary); stroke: var(--secondary); }

.load-more-row { display: flex; justify-content: center; margin-top: 1.4rem; }
.load-more-row .secondary-button { min-width: 190px; }
.empty-state { grid-column: 1 / -1; padding: 4rem 1.2rem; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }
.empty-state > span { display: inline-grid; width: 54px; height: 54px; place-items: center; margin-bottom: .8rem; border-radius: 18px; background: var(--accent-soft); color: var(--accent); font-size: 1.8rem; }
.empty-state h2, .empty-state h3 { margin-bottom: .3rem; font: 1.6rem var(--display); }
.empty-state p { color: var(--muted); }

.methodology-section { border-top: 1px solid var(--line); }
.methodology-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: 2rem; }
.methodology-grid h2 { font: clamp(2rem, 4vw, 3.5rem)/1 var(--display); letter-spacing: -.04em; }
.methodology-grid p { max-width: 760px; color: var(--muted); }
.source-list { display: grid; gap: .65rem; margin: 0; padding: 0; list-style: none; }
.source-list a { display: grid; gap: .18rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-decoration: none; }
.source-list a:hover { border-color: var(--accent); }
.source-list span { color: var(--muted); font-size: .78rem; }
.caution { padding: 1rem 1.1rem; border-left: 4px solid var(--secondary); border-radius: 0 12px 12px 0; background: color-mix(in srgb, var(--secondary) 12%, var(--surface)); color: var(--ink) !important; }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem clamp(1rem, 4vw, 4rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
}

dialog {
  width: min(610px, calc(100% - 1.5rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border: 0;
  border-radius: 24px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 100px rgba(9, 16, 32, .3);
}
dialog::backdrop { background: rgba(10, 15, 30, .58); backdrop-filter: blur(5px); }
.dialog-shell { position: relative; padding: clamp(1.3rem, 4vw, 2.3rem); }
.dialog-close { position: absolute; right: 1rem; top: 1rem; }
.dialog-kicker { margin-bottom: .4rem; color: var(--accent); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.dialog-shell h2 { margin: 0 3rem .65rem 0; font: clamp(2.7rem, 8vw, 4.8rem)/1 var(--display); letter-spacing: -.055em; }
.dialog-meaning { font-size: 1.1rem; }
.dialog-meaning.is-muted { color: var(--muted); }
.detail-list { display: grid; margin: 1.4rem 0; border-top: 1px solid var(--line); }
.detail-list div { display: grid; grid-template-columns: 145px 1fr; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--muted); font-size: .82rem; font-weight: 700; }
.detail-list dd { margin: 0; }
.source-note { color: var(--muted); font-size: .84rem; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.2rem; }
.dialog-actions .primary-button { min-height: 48px; }

.loading-shell { min-height: 55vh; display: grid; place-items: center; padding: 3rem; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--secondary) 85%, white); outline-offset: 3px; }

@media (max-width: 1000px) {
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalogue-layout { grid-template-columns: 1fr; }
  .filter-panel { position: static; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-panel h3, .favorites-meta, .toggle-line, .filter-panel .text-button { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .topbar { min-height: 62px; }
  .brand span:last-child { display: none; }
  .companion-link { padding: .55rem .7rem; font-size: .8rem; }
  .search-stage { padding-top: 2.5rem; }
  .search-stage::after { right: -6rem; top: 2rem; font-size: 19rem; }
  h1 { font-size: clamp(2.9rem, 15vw, 4.6rem); }
  .search-row { grid-template-columns: 1fr; }
  .primary-button { min-height: 54px; }
  .metrics { gap: .5rem 1rem; }
  .section-shell { width: min(100% - 1.2rem, 1320px); }
  .section-heading, .results-head { align-items: start; flex-direction: column; }
  .filter-panel { grid-template-columns: 1fr; }
  .filter-panel h3, .favorites-meta, .toggle-line, .filter-panel .text-button { grid-column: auto; }
  .results-grid { grid-template-columns: 1fr; }
  .name-card { min-height: 180px; }
  .methodology-grid { grid-template-columns: 1fr; }
  .footer { flex-direction: column; }
  .detail-list div { grid-template-columns: 1fr; gap: .18rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
