:root {
  color-scheme: light;
  --page: #f7f5ef;
  --surface: #ffffff;
  --ink: #1e2421;
  --muted: #58625d;
  --rule: #dce1dd;
  --accent: #1d5746;
  --accent-soft: #e4eee9;
  --gold: #9c6500;
  --focus: #0067c5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 1rem; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: .14em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.site-header, .layout, footer { width: min(1120px, calc(100% - 2rem)); margin-inline: auto; }
.site-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 390px); gap: 3rem; align-items: end; padding: 1.75rem 0 1.35rem; border-bottom: 1px solid var(--rule); }
.eyebrow { margin: 0 0 .4rem; color: var(--accent); font-size: .78rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
h1 { max-width: 720px; margin: 0; font-size: clamp(2.2rem, 4vw, 3.45rem); line-height: 1.02; letter-spacing: -.045em; font-weight: 620; }
.intro { max-width: 650px; margin: .65rem 0 0; color: var(--muted); font-size: 1rem; }

.site-tools { display: grid; gap: 1rem; }
.search-area { position: relative; }
.search-area > label { display: block; margin-bottom: .4rem; color: var(--muted); font-size: .88rem; font-weight: 650; }
.search-box { position: relative; }
.search-box > svg { position: absolute; z-index: 1; top: .85rem; left: .85rem; width: 1.25rem; color: var(--muted); }
.search-box input { width: 100%; min-height: 3rem; padding: .7rem .9rem .7rem 2.8rem; border: 1px solid var(--rule); border-radius: .55rem; background: var(--surface); color: var(--ink); font-size: 1rem; }
.suggestions { position: absolute; z-index: 10; top: calc(100% + .4rem); left: 0; right: 0; overflow: hidden; border: 1px solid var(--rule); border-radius: .55rem; background: var(--surface); box-shadow: 0 .7rem 2rem rgba(24, 40, 33, .14); }
.suggestion { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: .7rem; align-items: center; width: 100%; min-height: 3.4rem; padding: .5rem .7rem; border: 0; border-bottom: 1px solid var(--rule); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover, .suggestion.active { background: var(--accent-soft); }
.suggestion-photo { width: 2.5rem; height: 2.5rem; border-radius: .55rem; background: #dce3df; object-fit: cover; object-position: var(--photo-position, 50% 35%); opacity: 0; transition: opacity 140ms ease; }
.suggestion-photo.is-loaded { opacity: 1; }
.suggestion-copy { min-width: 0; }
.suggestion-name { display: block; font-weight: 700; }
.suggestion-name mark { padding: 0; background: transparent; color: var(--accent); font-weight: 800; }
.suggestion-group { display: block; color: var(--muted); font-size: .82rem; }
.deck-action { display: flex; align-items: center; }
#anki-download { display: inline-flex; align-items: center; gap: .7rem; min-height: 3rem; padding: .55rem .75rem; border: 1px solid var(--rule); border-radius: .6rem; background: rgba(255, 255, 255, .55); color: var(--ink); text-decoration: none; transition: border-color 140ms ease, background-color 140ms ease; }
#anki-download:hover { border-color: #aebbb4; background: var(--surface); }
#anki-download > svg { flex: none; width: 1.2rem; height: 1.2rem; color: var(--accent); }
#anki-download > span { display: grid; }
#anki-download strong { color: var(--accent); font-size: .9rem; font-weight: 680; line-height: 1.3; }
#anki-download small { color: var(--muted); font-size: .78rem; line-height: 1.3; }

.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 3.5rem; align-items: start; padding: 1.65rem 0 4rem; }
.group-panel { position: sticky; top: 1rem; }
.group-panel h2 { margin: 0 0 .6rem; color: var(--muted); font-size: .9rem; }
#group-nav { display: grid; gap: .3rem; }
.group-button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .7rem; width: 100%; min-height: 3rem; padding: .72rem .8rem; border: 0; border-left: 2px solid transparent; border-radius: .2rem .5rem .5rem .2rem; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.group-button:hover { background: rgba(29, 87, 70, .045); }
.group-button[aria-current="page"] { border-left-color: var(--accent); background: rgba(29, 87, 70, .06); color: #123f32; }
.group-name { font-weight: 650; line-height: 1.3; }
.group-total { color: var(--muted); font-size: .74rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.group-hint { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; line-height: 1.3; }

.section-heading { display: flex; justify-content: space-between; gap: 2rem; align-items: end; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.15rem); font-weight: 620; line-height: 1.15; }
.section-heading p { margin: .4rem 0 0; color: var(--muted); }
.section-actions { display: grid; justify-items: end; gap: .45rem; flex: none; }
#group-count { color: var(--muted); font-size: .9rem; }
.person { border-top: 1px solid var(--rule); }
.person:last-child { border-bottom: 1px solid var(--rule); }
.person summary { display: grid; grid-template-columns: 4.15rem minmax(0, 1fr) 1.5rem; gap: 1rem; align-items: center; margin-inline: -.55rem; padding: .9rem .55rem; border-left: 2px solid transparent; border-radius: .15rem .5rem .5rem .15rem; list-style: none; cursor: pointer; transition: background-color 140ms ease, border-color 140ms ease; }
.person summary::-webkit-details-marker { display: none; }
.person summary:hover { background: rgba(29, 87, 70, .055); }
.person[open] summary { border-left-color: var(--accent); background: rgba(29, 87, 70, .055); }
.person-photo-wrap { position: relative; width: 4.15rem; height: 4.8rem; border: 1px solid rgba(29, 42, 36, .08); border-radius: .55rem; overflow: hidden; background: #dce3df; }
.person-photo { width: 100%; height: 100%; object-fit: cover; object-position: var(--photo-position, 50% 35%); display: block; opacity: 0; filter: saturate(.92) contrast(.98); transition: opacity 170ms ease; }
.person-photo.is-loaded { opacity: 1; }
.photo-loading { position: absolute; inset: 0; background: linear-gradient(145deg, #dce3df, #edf1ee); transition: opacity 170ms ease, visibility 170ms ease; }
.person-photo.is-loaded + .photo-loading { opacity: 0; visibility: hidden; }
.person-name { display: block; margin-bottom: .15rem; font-size: 1.22rem; font-weight: 680; }
.one-line { display: block; max-width: 650px; color: var(--muted); }
.disclosure-icon { width: 1.1rem; height: 1.1rem; color: var(--accent); transition: transform 160ms ease; }
.person[open] .disclosure-icon { transform: rotate(180deg); }

.deeper-section { margin-top: 1rem; border: 1px solid var(--rule); border-radius: .65rem; background: rgba(255, 255, 255, .45); }
.deeper-section > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; padding: .8rem 1rem; list-style: none; cursor: pointer; }
.deeper-section > summary::-webkit-details-marker { display: none; }
.deeper-section > summary:hover { background: rgba(29, 87, 70, .055); }
.deeper-section > summary strong, .deeper-section > summary small { display: block; }
.deeper-section > summary strong { color: var(--accent); font-size: 1rem; }
.deeper-section > summary small { margin-top: .08rem; color: var(--muted); font-size: .82rem; }
.deeper-section > summary svg { width: 1.1rem; color: var(--accent); transition: transform 160ms ease; }
.deeper-section[open] > summary svg { transform: rotate(180deg); }
.deeper-list { padding: 0 1rem 1rem; }
.deeper-list .person:first-child { border-top: 1px solid var(--rule); }

.profile { margin: 0; padding: .35rem .75rem 1.3rem 5.75rem; }
.fact { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: 1rem; padding: .6rem 0; }
.fact + .fact { border-top: 0; }
.fact h3 { margin: 0; color: var(--muted); font-size: .86rem; font-weight: 650; }
.fact p, .fact ul { margin: 0; }
.fact ul { padding-left: 1.15rem; }
.links { display: flex; flex-wrap: wrap; gap: .55rem 1.2rem; }
.links a { font-weight: 700; }
.no-wiki { color: var(--muted); }
.resources { display: grid; gap: .55rem; margin-top: .8rem; }
.resource-card { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr) 1rem; gap: .75rem; align-items: center; max-width: 36rem; padding: .5rem 0; border: 0; border-top: 1px solid var(--rule); border-radius: 0; color: var(--ink); text-decoration: none; transition: color 140ms ease; }
.resource-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.resource-thumb { width: 3.25rem; height: 3.25rem; border-radius: .45rem; background: #fff; object-fit: contain; object-position: center; }
.resource-card img.resource-thumb { padding: .28rem; }
.resource-card.resource-book { grid-template-columns: 2.7rem minmax(0, 1fr) 1rem; }
.resource-card.resource-book img.resource-thumb { width: 2.7rem; height: 3.8rem; padding: 0; border-radius: .25rem; object-fit: cover; }
.resource-thumb-text { display: grid; place-items: center; color: var(--accent); font-size: 1.35rem; font-weight: 800; }
.resource-copy { min-width: 0; }
.resource-label { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; }
.resource-title { display: -webkit-box; overflow: hidden; font-size: .92rem; font-weight: 700; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.resource-arrow { width: 1rem; color: var(--accent); }

footer { padding: 1.35rem 0 2.5rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: .84rem; }
footer p { max-width: 800px; margin: 0 0 .55rem; }
footer strong { color: var(--ink); }
.footer-main { display: flex; justify-content: space-between; gap: 2rem; align-items: start; }
.feedback-open, .feedback-send { min-height: 2.75rem; border: 1px solid var(--accent); border-radius: .55rem; font-weight: 700; cursor: pointer; transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease; }
.feedback-open { display: inline-flex; flex: none; gap: .45rem; align-items: center; min-height: 2.4rem; padding: .35rem .2rem; border-color: transparent; background: transparent; color: var(--accent); }
.feedback-open svg { width: 1.15rem; height: 1.15rem; }
.feedback-open:hover { background: var(--accent-soft); }
.feedback-open:active, .feedback-send:active { transform: translateY(1px); }
.feedback-send { padding: .58rem 1rem; background: var(--accent); color: #fff; }
.feedback-send:hover { background: #123f32; border-color: #123f32; }
.creator { margin-top: 1rem; color: var(--ink); }
.creator a { font-weight: 650; }

.feedback-dialog { width: min(31rem, calc(100% - 1.5rem)); padding: 0; border: 1px solid rgba(29, 87, 70, .12); border-radius: 1rem; background: var(--surface); color: var(--ink); box-shadow: 0 1.5rem 4.5rem rgba(19, 36, 29, .3); }
.feedback-dialog::backdrop { background: rgba(15, 27, 23, .56); backdrop-filter: blur(2px); }
.feedback-dialog form { display: grid; gap: .5rem; padding: 1.5rem; }
.dialog-heading { display: flex; justify-content: space-between; gap: 1.25rem; align-items: center; margin-bottom: .7rem; }
.dialog-heading h2 { margin: 0; font-size: 1.55rem; line-height: 1.2; letter-spacing: -.02em; }
.dialog-close { display: grid; place-items: center; flex: none; width: 2.35rem; height: 2.35rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.dialog-close svg { width: 1.25rem; height: 1.25rem; }
.dialog-close:hover { background: var(--accent-soft); color: var(--accent); }
.feedback-dialog label { margin-top: .55rem; font-size: .92rem; font-weight: 750; }
.feedback-dialog label span, .form-note { color: var(--muted); font-weight: 400; }
.select-wrap { position: relative; }
.select-wrap > svg { position: absolute; top: 50%; right: .9rem; width: 1.15rem; height: 1.15rem; color: var(--accent); pointer-events: none; transform: translateY(-50%); }
.feedback-dialog input, .feedback-dialog select, .feedback-dialog textarea { width: 100%; min-height: 3.1rem; padding: .72rem .8rem; border: 1px solid #b9c3bd; border-radius: .6rem; background: #fff; color: var(--ink); transition: border-color 140ms ease, box-shadow 140ms ease; }
.feedback-dialog select { appearance: none; padding-right: 2.8rem; cursor: pointer; }
.feedback-dialog select:invalid { color: #6c7771; }
.feedback-dialog select option { color: var(--ink); }
.feedback-dialog textarea { min-height: 8.5rem; resize: vertical; }
.feedback-dialog textarea::placeholder { color: #758079; opacity: 1; }
.feedback-dialog select:focus-visible, .feedback-dialog textarea:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 87, 70, .16); }
.form-actions { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-top: .9rem; }
.feedback-send:disabled { opacity: .65; cursor: wait; }
.form-note { margin: 0; font-size: .82rem; }
.feedback-status { min-height: 0; margin: 0; color: var(--accent); font-weight: 700; }
.feedback-status:not(:empty) { min-height: 1.35rem; margin-top: .15rem; }
.feedback-success { display: grid; justify-items: center; padding: 2.5rem 1.5rem 1.6rem; text-align: center; }
.feedback-success[hidden] { display: none; }
.success-icon { display: grid; place-items: center; width: 3.4rem; height: 3.4rem; margin-bottom: 1rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.success-icon svg { width: 1.8rem; height: 1.8rem; }
.feedback-success h2 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.feedback-success p { margin: .45rem 0 1.5rem; color: var(--muted); }
.feedback-done { min-width: 7rem; min-height: 2.75rem; padding: .58rem 1rem; border: 1px solid var(--accent); border-radius: .55rem; background: var(--accent); color: #fff; font-weight: 750; cursor: pointer; }
.feedback-done:hover { background: #123f32; border-color: #123f32; }

@media (max-width: 800px) {
  .site-header { grid-template-columns: 1fr; gap: 1.6rem; padding-top: 2rem; }
  .layout { grid-template-columns: 1fr; gap: 2rem; }
  .group-panel { position: sticky; z-index: 5; top: 0; padding: .55rem 0 .35rem; border-bottom: 1px solid var(--rule); background: var(--page); }
  #group-nav { display: flex; gap: .45rem; overflow-x: auto; padding: .15rem .15rem .55rem; margin-inline: -.15rem; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .group-button { display: flex; align-items: center; gap: .55rem; min-width: max-content; min-height: 2.7rem; padding: .6rem .78rem; border: 1px solid var(--rule); scroll-snap-align: start; }
  .group-hint { display: none; }
  .group-panel h2 { font-size: 1rem; }
}

@media (max-width: 560px) {
  .site-header, .layout, footer { width: min(100% - 1.25rem, 1120px); }
  .section-heading { align-items: start; flex-direction: column; gap: 1rem; }
  .section-actions { width: 100%; justify-items: start; }
  .deck-action { align-items: flex-start; }
  #anki-download { width: 100%; }
  .person summary { grid-template-columns: 3.6rem minmax(0, 1fr) 1.2rem; gap: .8rem; }
  .person-photo-wrap { width: 3.6rem; height: 4.15rem; }
  .profile { margin-left: 0; padding: .4rem .75rem 1rem; }
  .fact { grid-template-columns: 1fr; gap: .25rem; }
  .footer-main { display: grid; }
  .feedback-open { width: 100%; }
  .feedback-dialog form { padding: 1.25rem; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .feedback-send { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .person summary, .disclosure-icon, .person-photo, .photo-loading, .suggestion-photo, .feedback-open, .feedback-send, .feedback-done { transition: none; }
  .deeper-section > summary svg { transition: none; }
}
