:root {
  --bg: #fbf6f1;
  --surface: #ffffff;
  --surface-2: #f4ede6;
  --ink: #2a2330;
  --ink-2: #6f6575;
  --line: #e8dfd6;
  --accent: #7a5af5;
  --accent-ink: #ffffff;
  --girl: #e0628f;
  --girl-soft: #fde8ef;
  --boy: #3f86d6;
  --boy-soft: #e3effc;
  --yes: #22a873;
  --no: #e2546a;
  --maybe: #e9a23b;
  --shadow: 0 10px 30px rgba(60, 35, 50, 0.12), 0 2px 6px rgba(60, 35, 50, 0.06);
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1820;
    --surface: #28232d;
    --surface-2: #322c38;
    --ink: #f3eef5;
    --ink-2: #b2a8b8;
    --line: #3d3644;
    --accent: #9c84ff;
    --girl: #f080a8;
    --girl-soft: #45283a;
    --boy: #6aa6ec;
    --boy-soft: #223650;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin: 1.1rem 0 0.4rem; }

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 6px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.icon-btn {
  border: 0; background: transparent; padding: 8px; border-radius: 12px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); }

main { flex: 1; min-height: 0; overflow-y: auto; }
.view { max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; }
#view-swipe { display: flex; flex-direction: column; height: 100%; max-width: 460px; padding-bottom: 8px; }

.tabbar {
  display: flex;
  justify-content: center;
  gap: 4px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
}
.tabbar button {
  position: relative;
  flex: 1;
  max-width: 160px;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  border-radius: 12px;
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 600;
}
.tabbar button.active { color: var(--accent); }
.badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 8px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--no);
  color: #fff;
  font-size: 0.7rem;
  line-height: 18px;
}

/* ---------- Controls ---------- */
.seg {
  display: flex;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 10px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.seg.small button { padding: 5px 10px; font-size: 0.82rem; }
.seg.big button { padding: 12px 10px; font-size: 1rem; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); border-color: var(--accent); }
.btn.danger { color: var(--no); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px; font-size: 0.85rem; }

input:not([type="checkbox"]), select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row input { flex: 1 1 180px; }
.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.field em { font-style: normal; font-weight: 400; color: var(--ink-2); }
.check { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 0.95rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.sub { color: var(--ink-2); margin: 4px 0 0; }
.small { font-size: 0.82rem; }
.center { text-align: center; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--line);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.count { color: var(--ink-2); font-weight: 500; }

/* ---------- Swipe ---------- */
.progress { display: flex; align-items: center; gap: 10px; margin: 12px 2px 0; font-size: 0.8rem; color: var(--ink-2); }
.bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.3s; }

.deck { position: relative; flex: 1; min-height: 300px; margin: 14px 0 6px; }
.card {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 20px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.25s ease;
  will-change: transform;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 45%;
  background: linear-gradient(to bottom, var(--tint), transparent);
  pointer-events: none;
}
.card.girl { --tint: var(--girl-soft); --sex: var(--girl); }
.card.boy { --tint: var(--boy-soft); --sex: var(--boy); }
.card.top { z-index: 2; cursor: grab; }
.card.top.dragging { cursor: grabbing; transition: none; }
.card.next { z-index: 1; transform: scale(0.94) translateY(14px); opacity: 0.7; }
.card.leaving { z-index: 3; pointer-events: none; }
.card.enter { animation: rise 0.22s ease-out; }
@keyframes rise { from { transform: scale(0.94) translateY(14px); } }

.card > * { position: relative; }
.card-badge {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--sex);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
}
.card-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 3.4rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.card-name.m { font-size: 2.8rem; }
.card-name.l { font-size: 2.2rem; }
.card-full { font-family: var(--serif); font-size: 1.15rem; color: var(--ink-2); margin-top: 8px; }
.card-meta { margin-top: 14px; font-size: 0.9rem; color: var(--ink-2); }
.card-note {
  position: absolute;
  bottom: 18px;
  left: 20px;
  right: 20px;
  font-size: 0.78rem;
  color: var(--ink-2);
}
.stamp {
  position: absolute;
  top: 56px;
  padding: 4px 14px;
  border: 4px solid currentColor;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
}
.stamp-yes { left: 22px; color: var(--yes); transform: rotate(-14deg); }
.stamp-no { right: 22px; color: var(--no); transform: rotate(14deg); }
.stamp-maybe { left: 50%; top: auto; bottom: 48px; color: var(--maybe); transform: translateX(-50%); }

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: 28px;
}
.empty h2 { font-family: var(--serif); font-size: 1.6rem; }

.actions { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 8px 0 2px; }
.act {
  border: 0;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.12s;
}
.act:active:not(:disabled) { transform: scale(0.92); }
.act svg { width: 30px; height: 30px; stroke-width: 2.6; }
.act-no { color: var(--no); }
.act-yes { color: var(--yes); }
.act-yes .fill { fill: currentColor; stroke: none; }
.act-maybe { color: var(--maybe); width: 52px; height: 52px; }
.act-undo { color: var(--ink-2); width: 44px; height: 44px; }
.act-undo svg { width: 22px; height: 22px; stroke-width: 2.2; }
.review-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--maybe);
  border-radius: 14px;
  padding: 10px 12px;
}
.review-bar span { display: block; margin: 0; }
.center-row { justify-content: center; }
.review-cta { margin-top: 12px; }
.hint { text-align: center; color: var(--ink-2); font-size: 0.8rem; margin: 6px 0 0; }

/* ---------- List ---------- */
.list-head { display: flex; flex-direction: column; gap: 10px; }
.tabs { display: flex; gap: 6px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0;
  background: none;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--ink-2);
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tabs button b { font-weight: 500; opacity: 0.75; }
.tabs button.active { color: var(--ink); border-color: var(--accent); }
.tabs.dim button { opacity: 0.4; }
#listNote:empty { display: none; }
.name-list { list-style: none; padding: 0; margin: 8px 0; }
.name-list li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.name-list .nm { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.name-list .meta { color: var(--ink-2); font-size: 0.8rem; flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.girl { background: var(--girl); }
.dot.boy { background: var(--boy); }
.mini { display: flex; gap: 4px; }
.mini button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--ink-2);
  padding: 0;
}
.mini svg { width: 16px; height: 16px; stroke-width: 2.6; }
.mini button.on[data-vote="1"] { background: var(--no); border-color: var(--no); color: #fff; }
.mini button.on[data-vote="2"] { background: var(--maybe); border-color: var(--maybe); color: #fff; }
.mini button.on[data-vote="3"] { background: var(--yes); border-color: var(--yes); color: #fff; }
.mini button.on .fill { fill: currentColor; stroke: none; }
.empty-note { text-align: center; color: var(--ink-2); padding: 32px 8px; }

/* ---------- Matches ---------- */
.person { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.person input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.person .who { min-width: 0; }
.person .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .who span { font-size: 0.8rem; color: var(--ink-2); }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 700;
  flex: none;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  background: var(--tint);
  border: 1px solid transparent;
}
.chip.girl { --tint: var(--girl-soft); }
.chip.boy { --tint: var(--boy-soft); }
.chip small { font-family: var(--sans); font-size: 0.7rem; font-weight: 600; color: var(--maybe); margin-left: 4px; }
.match-hero h2 { font-family: var(--serif); font-size: 1.4rem; }
.nudge { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; background: var(--surface-2); }
.nudge p { margin: 0; flex: 1 1 200px; }

/* ---------- Onboarding ---------- */
.onboard {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 24px) 16px 24px;
}
.onboard-card { width: 100%; max-width: 420px; text-align: center; margin: auto 0; }
.onboard-card h1 { font-family: var(--serif); font-size: 2rem; margin-top: 10px; }
.onboard-card .field { text-align: left; }
.onboard-card .btn.wide { margin-top: 20px; padding: 14px; font-size: 1.05rem; }
.onboard-card .partner-note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 14px;
  color: var(--ink);
}
.steps { list-style: none; padding: 0; margin: 18px 0 6px; display: grid; gap: 6px; text-align: left; counter-reset: s; }
.steps li { counter-increment: s; display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); }
.steps li::before {
  content: counter(s);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex: none;
}

/* ---------- Dialog ---------- */
dialog {
  border: 0;
  padding: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 10, 25, 0.45); }
.dialog-body { padding: 18px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.about { margin-top: 18px; }
.who-actions { display: grid; gap: 8px; margin: 16px 0 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  max-width: calc(100vw - 32px);
  width: max-content;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 640px) {
  .card-name { font-size: 2.8rem; }
  .act { width: 56px; height: 56px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .card.enter, .toast, .bar span { transition: none; animation: none; }
}
