:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1c1b18;
  --muted: #6a675f;
  --line: #dedbd2;
  --accent: #0f6e5c;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --yes: #1d7a4a;
  --yes-soft: #d9f0e2;
  --maybe: #946200;
  --maybe-soft: #fbedc9;
  --no: #b03a2e;
  --no-soft: #f8dcd8;
  --none: #a9a59b;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 5%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1e1d1a;
    --surface-2: #2a2925;
    --text: #f1efe9;
    --muted: #a6a297;
    --line: #36342f;
    --accent: #3fbf9f;
    --accent-ink: #0b1f1a;
    --accent-soft: #1b3a32;
    --yes: #5fd08f;
    --yes-soft: #193a28;
    --maybe: #f0bf4c;
    --maybe-soft: #3b3017;
    --no: #f07f72;
    --no-soft: #43201c;
    --none: #6c6960;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px 120px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 8px 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 4px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
.eyebrow { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.card.soft { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 0.925rem; margin: 0 0 4px; }

/* Buttons and inputs */
button, .btn {
  font: inherit; font-weight: 600;
  min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 0 8px; }
.btn-danger { color: var(--no); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 140px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=tel], input[type=date], input[type=time], textarea {
  font: inherit; width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
}
textarea { min-height: 80px; resize: vertical; }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 4px 0 0; }
.error { color: var(--no); font-weight: 600; margin: 8px 0 0; }

/* Segmented control (3 states and toggles) */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { min-height: 44px; padding: 0 6px; font-weight: 600; border-radius: 10px; }
.seg button[aria-pressed=true].v-yes { background: var(--yes-soft); border-color: var(--yes); color: var(--yes); }
.seg button[aria-pressed=true].v-maybe { background: var(--maybe-soft); border-color: var(--maybe); color: var(--maybe); }
.seg button[aria-pressed=true].v-no { background: var(--no-soft); border-color: var(--no); color: var(--no); }
.seg button[aria-pressed=true].v-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Who are you */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.people button { justify-content: flex-start; text-align: left; min-height: 56px; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: inline-grid; place-items: center; font-size: 0.85rem; font-weight: 700;
  background: var(--surface-2); color: var(--text);
}
.people .done { margin-left: auto; color: var(--yes); font-weight: 800; }

/* Identity bar + tabs */
.who-bar { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.who-bar strong { flex: 1; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin: 12px 0; }
.tabs button { border: 0; background: transparent; min-height: 44px; }
.tabs button[aria-selected=true] { background: var(--surface); box-shadow: var(--shadow); }

/* Day cards */
.day { padding: 14px 16px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.day-date { font-weight: 700; font-size: 1.05rem; }
.badge { font-size: 0.78rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.busy { background: var(--no-soft); color: var(--no); }
.badge.free { background: var(--yes-soft); color: var(--yes); }
.day.is-final { border-color: var(--accent); border-width: 2px; }

/* Sticky save bar */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bar-inner { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.bar-inner .progress { flex: 1; font-size: 0.9rem; color: var(--muted); }
.bar-inner button { flex: none; min-width: 140px; }

/* Results */
.rank { display: flex; align-items: center; gap: 12px; }
.rank-pos { flex: none; width: 28px; font-weight: 800; color: var(--muted); }
.rank-main { flex: 1; min-width: 0; }
.meter { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: 6px 0; }
.meter i { display: block; }
.meter .m-yes { background: var(--yes); }
.meter .m-maybe { background: var(--maybe); }
.counts { display: flex; gap: 12px; font-size: 0.85rem; color: var(--muted); }
.counts b.c-yes { color: var(--yes); } .counts b.c-maybe { color: var(--maybe); } .counts b.c-no { color: var(--no); }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; font-weight: 700; border: 2px solid transparent; }
.dot.v-yes { background: var(--yes-soft); color: var(--yes); border-color: var(--yes); }
.dot.v-maybe { background: var(--maybe-soft); color: var(--maybe); border-color: var(--maybe); }
.dot.v-no { background: var(--no-soft); color: var(--no); border-color: var(--no); }
.dot.v-none { background: transparent; color: var(--none); border: 2px dashed var(--none); }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.names { font-size: 0.9rem; margin: 6px 0 0; }

.grid-wrap { display: none; overflow-x: auto; }
@media (min-width: 768px) {
  main { max-width: 760px; }
  .grid-wrap { display: block; }
}
table.grid { border-collapse: collapse; font-size: 0.875rem; width: 100%; }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.grid th:first-child, table.grid td:first-child { text-align: left; }
.sym-yes { color: var(--yes); font-weight: 800; } .sym-maybe { color: var(--maybe); font-weight: 800; }
.sym-no { color: var(--no); font-weight: 800; } .sym-none { color: var(--none); }

/* Final banner */
.final { background: var(--accent); color: var(--accent-ink); border: 0; }
.final .eyebrow, .final .muted { color: inherit; opacity: 0.85; }
.final .btn { background: var(--surface); color: var(--text); border-color: transparent; }
.final h2 { font-size: 1.35rem; margin: 2px 0 12px; }

/* Bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 40%); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 18px; } }

/* Create: month picker */
.steps { display: flex; gap: 6px; margin: 4px 0 12px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps span.on { background: var(--accent); }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head button { min-width: 48px; padding: 0; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cal .dow { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 4px 0; }
.cal button { min-height: 44px; padding: 0; border-radius: 10px; font-weight: 600; }
.cal button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cal button.today { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 0.85rem; padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--text); }
.person-row { display: flex; gap: 8px; margin-bottom: 8px; }
.person-row input:first-child { flex: 1.2; }
.person-row input:nth-child(2) { flex: 1; }
.person-row button { flex: none; min-width: 48px; padding: 0; }
.share-link { word-break: break-all; font-family: ui-monospace, monospace; font-size: 0.85rem; background: var(--surface-2); padding: 10px; border-radius: 10px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; z-index: 30; font-weight: 600; }
