:root {
  color-scheme: light;
  --bg: #f6f6f7;
  --surface: #fff;
  --ink: #25262a;
  --muted: #6c6e75;
  --line: #e2e3e6;
  --accent: #383b43;
  --accent-soft: #edeef0;
  --negative: #795552;
  --negative-soft: #f6efed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg); font-size: 16px; }
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.app-shell { max-width: 1200px; min-height: 100vh; margin: auto; padding: 0 clamp(20px, 4vw, 64px) 100px; }
.topbar { min-height: 78px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 650; letter-spacing: -.03em; }
.settings-button { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface); font-size: 14px; }
.settings-button:hover { border-color: var(--accent); }
.view { margin: auto; }
.choose-view { max-width: 620px; padding-top: clamp(30px, 6vh, 64px); }
.context-row { display: flex; justify-content: space-between; gap: 16px; min-height: 22px; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.context-row:has(#progress-label:only-child) { justify-content: flex-end; }
.card-stage { height: clamp(280px, 43vh, 420px); position: relative; }
.name-card, .empty-state { height: 100%; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: 0 18px 50px rgba(30, 30, 35, .06); }
.name-card { display: grid; place-items: center; padding: 30px; touch-action: pan-y; user-select: none; position: relative; overflow: hidden; will-change: transform; }
.card-content { max-width: 100%; text-align: center; }
.card-content h2 { margin: 0; overflow-wrap: anywhere; font: 400 clamp(54px, 8vw, 86px)/1.12 Georgia, "Times New Roman", serif; letter-spacing: -.06em; }
.card-history { margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.swipe-label { position: absolute; top: 17%; padding: 8px 12px; border: 2px solid currentColor; border-radius: 9px; font-size: 17px; font-weight: 650; opacity: 0; pointer-events: none; }
.swipe-no { left: 20px; color: var(--negative); transform: rotate(-8deg); }
.swipe-yes { right: 20px; color: var(--accent); transform: rotate(8deg); }
.empty-state { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 30px; }
.empty-state h2 { margin: 0 0 12px; font-size: 22px; font-weight: 650; }
.empty-state p { margin: 0; color: var(--muted); line-height: 1.5; }
.action-row { display: flex; justify-content: center; gap: 32px; margin: 18px 0 0; }
.vote-button { flex: 0 0 72px; width: 72px; height: 72px; border: 1px solid transparent; border-radius: 50%; font-size: 16px; font-weight: 650; transition: background .15s, transform .15s; }
.vote-button:hover { transform: translateY(-1px); }
.vote-no { color: var(--negative); border-color: #e9dcd9; background: var(--negative-soft); }
.vote-yes { color: #fff; background: var(--accent); }
.undo-button { display: block; min-height: 44px; margin: 9px auto 0; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.undo-button:hover { color: var(--ink); }
.sync-line { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.lists-view { max-width: 760px; padding-top: clamp(32px, 5vh, 56px); }
.list-tabs { display: flex; gap: 32px; border-bottom: 1px solid var(--line); }
.list-tabs button { min-height: 50px; padding: 0 2px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 15px; }
.list-tabs button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.list-tabs span { margin-left: 5px; font-variant-numeric: tabular-nums; }
.list-tools { min-height: 74px; display: flex; align-items: center; justify-content: flex-end; }
.review-button { min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 650; }
.review-button:hover { border-color: var(--accent); }
.name-list { border-top: 1px solid var(--line); }
.name-list:empty { border-top: 0; }
.name-row { min-height: 70px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.name-row-text { flex: 1; font: 400 26px Georgia, "Times New Roman", serif; }
.name-row-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.list-empty { padding: 72px 12px; text-align: center; color: var(--muted); }
.bottom-nav { max-width: 620px; min-height: 62px; display: flex; gap: 4px; position: sticky; z-index: 5; bottom: max(12px, env(safe-area-inset-bottom)); margin: 42px auto 0; padding: 5px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 32px rgba(30, 30, 35, .1); }
.bottom-nav button { flex: 1; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 14px; }
.bottom-nav button.nav-active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
dialog { width: min(440px, calc(100vw - 24px)); max-width: none; padding: 0; border: 0; border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: 0 22px 80px #0003; }
dialog::backdrop { background: rgba(25, 25, 30, .45); }
.settings-sheet { padding: 30px; }
.sheet-head h2 { margin: 0 0 30px; font-size: 24px; font-weight: 650; }
.settings-sheet .field-title { display: block; margin: 24px 0 10px; font-size: 14px; font-weight: 650; }
.segmented { display: flex; padding: 4px; border-radius: 12px; background: var(--bg); }
.segmented button { flex: 1; min-height: 42px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; }
.segmented button.active { background: var(--surface); color: var(--accent); box-shadow: 0 2px 8px #0001; font-weight: 650; }
.category-options { display: flex; flex-wrap: wrap; gap: 8px; }
.category-options button { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 13px; }
.category-options button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.done-button { width: 100%; min-height: 50px; margin-top: 32px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 650; }
@media (max-width: 700px) {
  .app-shell { padding: 0 18px 90px; }
  .topbar { min-height: 68px; }
  .topbar h1 { font-size: 20px; }
  .choose-view { padding-top: 26px; }
  .card-stage { height: clamp(260px, 42vh, 350px); }
  .card-content h2 { font-size: clamp(48px, 12vw, 70px); }
  .lists-view { padding-top: 24px; }
  .list-tools { min-height: 68px; }
  .bottom-nav { margin-top: 30px; }
}
@media (max-width: 390px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .vote-button { font-size: 14px; }
  .name-row-text { font-size: 23px; }
  .name-row-count { font-size: 11px; }
  .list-tabs { gap: 20px; }
  .list-tabs button { font-size: 13px; }
}
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #1b1c20; --surface: #27282d; --ink: #efeff2; --muted: #afb1ba; --line: #41434c; --accent: #e1e2e7; --accent-soft: #36383f; --negative: #e2aaa5; --negative-soft: #392d2b; }
  .name-card, .empty-state { box-shadow: 0 18px 50px #0002; }
  .vote-yes, .done-button { background: #50535f; color: #fff; }
  .segmented button.active { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Reserve the whole feedback area: neither undo nor network status moves navigation. */
.choice-feedback { position: relative; height: 88px; }
.choice-feedback .undo-button { position: absolute; inset: 8px 0 auto; width: 100%; margin: 0; }
.choice-feedback .sync-line { position: absolute; bottom: 0; width: 100%; min-height: 32px; margin: 0; line-height: 16px; }
.list-gender-options { max-width: 380px; margin-bottom: 22px; }
:root[data-gender="male"] { --bg: #f3f7fc; --accent: #235da1; --accent-soft: #e6effb; --line: #dce5f0; }
:root[data-gender="female"] { --bg: #fcf5f8; --accent: #a33667; --accent-soft: #f8e8ef; --line: #eedee5; }
.name-row[data-gender="male"] .name-row-text { color: #235da1; }
.name-row[data-gender="female"] .name-row-text { color: #a33667; }
.reset-link { display: block; min-height: 44px; width: 100%; margin-top: 24px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: #aa3030; font-size: 14px; }
#reset-description { color: var(--muted); line-height: 1.5; }
.reset-actions { display: flex; gap: 12px; margin-top: 24px; }
.reset-actions button { flex: 1; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.reset-actions .danger-button { background: #b23333; color: white; border-color: #b23333; }
@media (prefers-color-scheme: dark) {
 :root[data-gender="male"] { --bg: #17212f; --surface: #222f40; --accent: #99c5ff; --accent-soft: #293f5b; --line: #3a4c65; }
 :root[data-gender="female"] { --bg: #2a1b23; --surface: #382831; --accent: #f4a2c5; --accent-soft: #4c3040; --line: #59414e; }
 :root[data-gender="male"] .vote-yes, :root[data-gender="male"] .done-button { background: #285b9b; }
 :root[data-gender="female"] .vote-yes, :root[data-gender="female"] .done-button { background: #96345f; }
 .name-row[data-gender="male"] .name-row-text { color: #99c5ff; }
 .name-row[data-gender="female"] .name-row-text { color: #f4a2c5; }
 .reset-link { color: #ffaaaa; }
}

/* Initial dialog focus announces its title, without suggesting a selected control. */
#settings-title:focus { outline: none; }
.vote-button { display: flex; align-items: center; justify-content: center; gap: 10px; }
.vote-icon { width: 30px; height: 30px; flex: 0 0 30px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.vote-icon-down { transform: rotate(180deg); }

.settings-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.settings-icon[hidden] { display: none; }
.settings-button.review-exit { padding: 0 16px; }

/* Fixed slots prevent restored filters, counters and empty states moving controls. */
.context-row { height: 22px; line-height: 22px; }
.context-row #progress-label { margin-left: auto; }
.card-history { min-height: 16px; line-height: 16px; }
#card-history[hidden] { display: block !important; visibility: hidden; }
#action-row[hidden] { display: flex !important; visibility: hidden; }
.vote-button:disabled { cursor: default; opacity: .45; }
/* Keep the heading box fixed when the loading text is replaced by a shorter name. */
.card-content { width: 100%; }

.category-options select {width:100%;min-height:48px;border:1px solid var(--line);border-radius:10px;padding:10px 12px;font:inherit;background:var(--surface);color:var(--ink);}
.catalog-settings-links{margin-top:24px;display:flex;flex-direction:column;gap:4px}.catalog-settings-links a{display:flex;align-items:center;min-height:44px;color:var(--ink);text-underline-offset:3px}.data-credit{font-size:12px;line-height:1.5;color:var(--muted)}.data-credit a{color:inherit}
.context-row #filter-summary{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.app-shell > .data-credit {max-width:620px;margin:16px auto 0;text-align:center;}
