:root {
  --bg: #17131a;
  --surface: #221c26;
  --surface-2: #2c2531;
  --border: #3a3140;
  --text: #f1eaf2;
  --muted: #a99bad;
  --accent: #e0679a;
  --accent-ink: #1a0f15;
  --accent-soft: rgba(224, 103, 154, 0.16);
  --no: #c96a6a;
  --no-soft: rgba(201, 106, 106, 0.18);
  --willing: #b9aebf;
  --want: #5fbfa6;
  --want-soft: rgba(95, 191, 166, 0.16);
  --really: #e0679a;
  --warn: #f2a65a;
  --warn-soft: rgba(242, 166, 90, 0.14);
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf6f8;
    --surface: #ffffff;
    --surface-2: #f3ecf1;
    --border: #e3d6df;
    --text: #2a1f29;
    --muted: #7a6a78;
    --accent: #c2477c;
    --accent-ink: #ffffff;
    --accent-soft: rgba(194, 71, 124, 0.1);
    --no: #b04a4a;
    --no-soft: rgba(176, 74, 74, 0.1);
    --willing: #6f6475;
    --want: #2f8f78;
    --want-soft: rgba(47, 143, 120, 0.1);
    --really: #c2477c;
    --warn: #b9661a;
    --warn-soft: rgba(185, 102, 26, 0.1);
    --shadow: 0 6px 24px rgba(60, 20, 50, 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.8em; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }

.app { max-width: 720px; margin: 0 auto; padding: 0 16px 140px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 10px;
}
.brand { white-space: nowrap; font-weight: 700; letter-spacing: 0.02em; display: flex; align-items: center; gap: 8px; }
.brand .dots { display: inline-flex; }
.brand .dots i { width: 14px; height: 14px; border-radius: 50%; display: block; }
.brand .dots i:first-child { background: var(--accent); }
.brand .dots i:last-child { background: var(--warn); opacity: 0.85; margin-left: -6px; }
.nav { display: flex; gap: 2px; justify-content: flex-end; }
.nav a, .nav button {
  background: none; border: 0; padding: 6px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-size: 0.9rem;
}
.nav a.on { background: var(--surface-2); color: var(--text); }
.nav a:hover, .nav button:hover { color: var(--text); }

/* ---------- generic ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 12px 0;
}
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface-2);
  padding: 10px 16px; border-radius: 999px; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: none; }
.btn.danger { color: var(--no); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.banner {
  border-radius: var(--radius); padding: 12px 14px; margin: 12px 0;
  background: var(--accent-soft); border: 1px solid transparent;
}
.banner.warn { background: var(--warn-soft); }
.error { color: var(--no); min-height: 1.5em; }
label.field { display: block; margin: 10px 0; }
label.field span { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg);
}
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- login ---------- */
.login { max-width: 360px; margin: 12vh auto 0; }
.login .btn { width: 100%; margin-top: 8px; }

/* ---------- disclosure ---------- */
.disclosure h2 { margin-top: 1.2em; }
.disclosure ul { padding-left: 1.2em; margin: 0 0 0.8em; }
.disclosure li { margin: 0.35em 0; }
.disclosure .see { border-left: 3px solid var(--accent); padding-left: 12px; }
.disclosure .nosee { border-left: 3px solid var(--want); padding-left: 12px; }
.disclosure .infer { border-left: 3px solid var(--warn); padding-left: 12px; }
.ack-bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 16px; border-top: 1px solid var(--border); }
.ack-bar label { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.ack-bar input { margin-top: 4px; width: 18px; height: 18px; flex: none; }

/* ---------- legend ---------- */
.legend { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 0.9rem; align-items: start; margin-bottom: 10px; }
.legend .pill { justify-self: start; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.pill.no { background: var(--no-soft); color: var(--no); }
.pill.willing { background: var(--surface-2); color: var(--willing); }
.pill.want { background: var(--want-soft); color: var(--want); }
.pill.really { background: var(--accent-soft); color: var(--really); }
.pill.na { background: var(--surface-2); color: var(--muted); }

/* ---------- categories ---------- */
.chips {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  scrollbar-width: thin;
}
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; font-size: 0.85rem; white-space: nowrap;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .count { opacity: 0.65; margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip.done:not(.on) { border-color: var(--want); }

/* ---------- items ---------- */
.item { padding: 14px 16px; }
.item-text { font-weight: 600; margin-bottom: 2px; }
.item-note { font-size: 0.85rem; color: var(--warn); margin-bottom: 6px; }
.item-by { font-size: 0.8rem; color: var(--muted); }
.role { margin-top: 10px; }
.role + .role { padding-top: 10px; border-top: 1px dashed var(--border); }
.role-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lvl {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px;
  padding: 9px 4px; cursor: pointer; font-size: 0.85rem; font-weight: 600; min-height: 42px;
}
.lvl[aria-pressed=true].no { background: var(--no); border-color: var(--no); color: #fff; }
.lvl[aria-pressed=true].willing { background: var(--willing); border-color: var(--willing); color: var(--bg); }
.lvl[aria-pressed=true].want { background: var(--want); border-color: var(--want); color: #fff; }
.lvl[aria-pressed=true].really { background: var(--really); border-color: var(--really); color: #fff; }
.extras { display: flex; gap: 14px; align-items: center; margin-top: 8px; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; }
.extras label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.extras input { width: 16px; height: 16px; }
.na-btn { background: none; border: 1px solid transparent; border-radius: 999px; padding: 2px 10px; cursor: pointer; color: var(--muted); }
.na-btn[aria-pressed=true] { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.stop-hint {
  margin-top: 8px; font-size: 0.85rem; padding: 8px 10px; border-radius: 8px;
  background: var(--warn-soft); color: var(--warn);
}

.pager { display: flex; justify-content: space-between; gap: 8px; margin: 16px 0; }

/* ---------- custom add ---------- */
.add-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 480px) { .add-form .two { grid-template-columns: 1fr; } }

/* ---------- bottom bar ---------- */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bottom-inner { max-width: 720px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.progress { flex: 1; min-width: 0; }
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.2s; }

/* ---------- results ---------- */
.res-section h2 { display: flex; align-items: baseline; gap: 8px; margin-top: 1.4em; }
.res-section h2 .n { color: var(--muted); font-weight: 400; font-size: 0.95rem; }
.res-cat { margin: 14px 0 4px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.res {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; margin: 6px 0; display: flex; gap: 10px; align-items: flex-start;
}
.res .t { flex: 1; min-width: 0; }
.res .dir { font-size: 0.85rem; color: var(--muted); }
.res.really { border-color: var(--really); background: var(--accent-soft); }
.res.stop { border-color: var(--warn); background: var(--warn-soft); }
.res .who { font-size: 0.85rem; color: var(--warn); font-weight: 600; }
.tag { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.new { color: var(--want); background: var(--want-soft); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  max-width: min(480px, calc(100vw - 32px)); padding: 20px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog ul { padding-left: 1.2em; }
