:root {
  --bg: #faf7f5;
  --surface: #ffffff;
  --text: #1f1a1c;
  --muted: #6d6468;
  --line: #ece4e6;
  --brand: #e8475f;
  --brand-ink: #ffffff;
  --brand-soft: #fde8eb;
  --yes: #1f8a5b;
  --yes-soft: #e1f4ea;
  --maybe: #b7791f;
  --maybe-soft: #fbf0dc;
  --no: #8a8186;
  --no-soft: #f0ecee;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 6px 20px rgb(0 0 0 / .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141113; --surface: #1e1a1c; --text: #f3eef0; --muted: #a59ca0; --line: #332c2f;
    --brand: #ff6b7f; --brand-ink: #1a0b0e; --brand-soft: #3a1d23;
    --yes: #4fc58c; --yes-soft: #17352a; --maybe: #e6b04f; --maybe-soft: #3a2f17; --no: #a59ca0; --no-soft: #2b2528;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
  }
}
:root[data-theme="dark"] {
  --bg: #141113; --surface: #1e1a1c; --text: #f3eef0; --muted: #a59ca0; --line: #332c2f;
  --brand: #ff6b7f; --brand-ink: #1a0b0e; --brand-soft: #3a1d23;
  --yes: #4fc58c; --yes-soft: #17352a; --maybe: #e6b04f; --maybe-soft: #3a2f17; --no: #a59ca0; --no-soft: #2b2528;
  --shadow: 0 1px 2px rgb(0 0 0 / .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "Rubik", "Assistant", Arial, sans-serif;
}
main { max-width: 560px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.6rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.25rem; margin: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- Login ---------- */
.login { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.logo { width: 64px; height: 64px; margin: 0 auto; }
.login form { display: grid; gap: 12px; }
.field { width: 100%; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 1.05rem; }
.field:focus { border-color: var(--brand); outline: none; }
.code { letter-spacing: .5em; text-align: center; font-size: 1.5rem; direction: ltr; }
.ltr { direction: ltr; text-align: right; }
.btn { border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 600; font-size: 1.05rem; background: var(--brand); color: var(--brand-ink); min-height: 48px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; color: var(--brand); padding: 8px; font-weight: 600; }
.link:disabled { color: var(--muted); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Header + filters ---------- */
.top { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 14px; gap: 8px; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; margin: 0 -16px; padding-inline: 16px; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: .9rem; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.progress > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .3s; }

/* ---------- Cards ---------- */
.list { display: grid; gap: 16px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line); }
.card[data-state="no"] { opacity: .7; }
.card[data-state="pri"] { border-color: var(--yes); }
.body { padding: 16px; display: grid; gap: 12px; }
.meta { color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--brand-soft); color: var(--text); border-radius: 999px; padding: 3px 11px; font-size: .85rem; }
.desc { margin: 0; white-space: pre-line; }
.desc.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.more { justify-self: start; padding: 0; }

.extra { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.extra label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.extra select, .extra textarea { border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); padding: 10px 12px; color: var(--text); }
.extra select { max-width: 9rem; }
.extra textarea { min-height: 72px; resize: vertical; }
.saved { font-size: .8rem; color: var(--yes); min-height: 1.2em; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

#toast { position: fixed; inset-inline: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; text-align: center; box-shadow: var(--shadow); }

/* ---------- login labels ---------- */
.lbl { font-size: .9rem; color: var(--muted); margin-bottom: -6px; }

/* ---------- client cards (v2) ---------- */
.howto { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto p { margin: 8px 0 0; }
.head { display: flex; align-items: center; gap: 12px; }
.who { flex: 1; min-width: 0; }
.avatar-sm { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 1.2rem; flex: none; }
.badge { flex: none; border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 600; }
.badge.pri { background: var(--yes-soft); color: var(--yes); }
.badge.no { background: var(--no-soft); color: var(--no); }
.profile { justify-self: start; color: var(--brand); font-weight: 600; text-decoration: none; }
.profile:hover { text-decoration: underline; }
.ranking { display: grid; gap: 8px; }
.ranking .lbl { margin: 0; }
.nums { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wide { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rk { border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; min-height: 44px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rk.num[aria-pressed="true"] { background: var(--yes); border-color: var(--yes); color: var(--surface); }
.rk.def[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.rk.no[aria-pressed="true"] { background: var(--no-soft); border-color: var(--no); color: var(--text); }
.notes { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }

/* ---------- admin ---------- */
body.admin main { max-width: 1100px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; margin-bottom: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.grid4 label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.grid4 .field { padding: 10px 12px; font-size: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.sm { border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 10px; font-size: .85rem; font-weight: 600; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; min-height: 36px; cursor: pointer; }
.sm.danger { border-color: var(--brand); color: var(--brand); }
.pill { border-radius: 999px; padding: 1px 8px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.pill.on { background: var(--yes-soft); color: var(--yes); }
.pill.off { background: var(--no-soft); color: var(--no); }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; }
tr.inactive td { opacity: .6; }
tr.inactive td:last-child { opacity: 1; }
.answers-table tr.touched td { background: var(--yes-soft); }
.note-cell { white-space: pre-line; min-width: 12rem; }
@media (max-width: 760px) {
  table.clients thead { display: none; }
  table.clients, table.clients tbody, table.clients tr, table.clients td { display: block; width: 100%; }
  table.clients tr { border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px; margin-bottom: 12px; }
  table.clients td { border: 0; padding: 6px 0; display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 8px; }
  table.clients td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; }
  table.clients tr.editing td { display: block; }
}

/* ---------- admin answers: sorting + emails ---------- */
.answers-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
.sort-select { padding: 6px 10px; font-size: .9rem; border-radius: 10px; width: auto; }
button.sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; white-space: nowrap; }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--text); }
.arrow { color: var(--muted); }
.email-cell { white-space: nowrap; }
.copy-one { margin-inline-start: 8px; }
.copy-one { border: 1px solid var(--line); background: var(--surface); color: var(--brand); border-radius: 8px; padding: 2px 8px; font-size: .8rem; font-weight: 600; cursor: pointer; }
.copy-one.ok, .sm.ok { color: var(--yes); border-color: var(--yes); }
.rk-pill { border-radius: 999px; padding: 2px 9px; font-size: .82rem; white-space: nowrap; }
.rk-pill.rpri { background: var(--yes-soft); color: var(--yes); font-weight: 600; }
.rk-pill.rno { background: var(--no-soft); color: var(--no); }
.rk-pill.rdef { color: var(--muted); }
.offscreen { position: fixed; top: -1000px; opacity: 0; }

/* ---------- contacted ---------- */
.contacted-note { background: var(--brand-soft); color: var(--text); border-radius: 10px; padding: 6px 10px; font-size: .9rem; justify-self: start; }
.contact-cell { white-space: nowrap; }
.contact-toggle { border: 1.5px dashed var(--line); background: var(--surface); color: var(--muted); border-radius: 10px; padding: 4px 10px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.contact-toggle.on { border-style: solid; border-color: var(--brand); background: var(--brand-soft); color: var(--text); }

/* ---------- selection + bulk copy ---------- */
.selbar { display: grid; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.selbar .actions { align-items: center; }
.small-btn { min-height: 36px; padding: 6px 14px; font-size: .9rem; }
.btn.ok { background: var(--yes); }
th.check, td.check { width: 2rem; text-align: center; }
td.check input, th.check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); }
.answers-table tr.selected td { background: var(--brand-soft); }

/* ---------- magic links ---------- */
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-align: center; margin: 0; }
.notice.warn { border-color: var(--maybe); background: var(--maybe-soft); }
.link-panel { border-color: var(--brand); }
.linkbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.linkbox code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .85rem; }
.sm.wa { border-color: #25d366; color: #128c4a; }

/* ---------- all links + extra columns ---------- */
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-link { border: 1.5px solid var(--brand); color: var(--brand); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .9rem; text-decoration: none; }
.profile-link:hover { background: var(--brand-soft); }
.extras { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: .92rem; }
.extras dt { color: var(--muted); }
.extras dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
