:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1d2733;
    --muted: #6b7785;
    --border: #e1e6eb;
    --primary: #1f6feb;
    --primary-dark: #1858c0;
    --primary-soft: #e6effd;
    --yes: #1a9b5b;
    --yes-soft: #dcf3e6;
    --if: #c98a00;
    --if-soft: #fdf1d3;
    --no: #9aa5b1;
    --no-soft: #f1f3f5;
    --danger: #d23b3b;
    --best: #fff8d6;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 .25rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 24px; padding-bottom: 48px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 15px; }
.topnav { display: flex; gap: 1.25rem; align-items: center; }
.topnav form { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 400px; margin: 40px auto; }
.card.empty { text-align: center; padding: 40px; }
.table-card { padding: 0; overflow-x: auto; }

.stack > * + * { margin-top: 14px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .muted { margin: 0; }
.actions { display: flex; gap: 8px; }
.actions form { margin: 0; }
.description { background: var(--surface); border-left: 3px solid var(--primary); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; }

.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; align-items: start; }
.two-col > .card { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.form-grid > .card { margin-bottom: 0; }
.form-actions { grid-column: 1 / -1; }
@media (max-width: 800px) {
    .two-col, .form-grid { grid-template-columns: 1fr; }
}

label { display: block; font-weight: 600; font-size: .9rem; }
label.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], textarea, select {
    display: block; width: 100%; margin-top: 4px; padding: 9px 11px;
    border: 1px solid var(--border); border-radius: 8px; font: inherit; color: inherit; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input:disabled, textarea:disabled { background: var(--no-soft); }
.name-field { max-width: 360px; }

.btn {
    display: inline-flex; align-items: center; gap: .4rem; padding: 8px 14px;
    border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fdecec; }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn-large { padding: 12px 22px; font-size: 1rem; }
button.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--danger); }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.center { text-align: center; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--yes-soft); color: #11613a; }
.alert-error { background: #fdecec; color: #8e1f1f; }
.alert-final { background: var(--primary-soft); color: #123d80; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.badge-open { background: var(--yes-soft); color: var(--yes); }
.badge-muted { background: var(--no-soft); color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }

/* Calendar */
.calendar { max-width: 380px; user-select: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 700; }
.cal-nav { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.cal-nav:hover { background: var(--bg); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal-day { aspect-ratio: 1; border: 1px solid transparent; border-radius: 8px; background: var(--bg); font: inherit; cursor: pointer; }
.cal-day:hover { border-color: var(--primary); }
.cal-day.weekend { color: var(--muted); }
.cal-day.today { border-color: var(--primary); font-weight: 700; }
.cal-day.selected { background: var(--primary); color: #fff; font-weight: 700; }
.cal-day.past { opacity: .4; }
.cal-day:disabled { cursor: default; border-color: transparent; }
.selected-head { display: flex; justify-content: space-between; align-items: center; }
.chips { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: #123d80; border-radius: 999px; padding: 3px 4px 3px 10px; font-size: .85rem; }
.chip button { border: 0; background: none; cursor: pointer; font-size: 1rem; line-height: 1; color: inherit; padding: 0 4px; }

/* Results matrix */
.matrix-wrap { overflow-x: auto; }
.matrix { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.matrix th, .matrix td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--border); }
.matrix .name-col { text-align: left; white-space: nowrap; padding-right: 16px; position: sticky; left: 0; background: var(--surface); font-weight: 600; min-width: 140px; }
.matrix thead th { min-width: 64px; vertical-align: bottom; }
.matrix thead th span { display: block; line-height: 1.2; }
.d-month { font-size: .7rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.d-day { font-size: 1.3rem; font-weight: 700; }
.d-week { font-size: .75rem; color: var(--muted); font-weight: 400; }
.matrix .best { background: var(--best); }
.matrix th.final { box-shadow: inset 0 3px 0 var(--primary); }
.matrix tr.me .name-col::after { content: " (you)"; color: var(--muted); font-weight: 400; }
.matrix tr.me td, .matrix tr.me th { background: var(--primary-soft); }
.cell { font-weight: 700; }
.cell.yes { background: var(--yes-soft); color: var(--yes); }
.cell.if-needed { background: var(--if-soft); color: var(--if); }
.cell.no { color: var(--no); }
.cell.pending { color: var(--no); }
.cell.inline { display: inline-block; min-width: 30px; padding: 0 6px; border-radius: 4px; text-align: center; margin-left: 10px; }
.matrix tfoot td, .matrix tfoot th { border-bottom: 0; font-weight: 700; }
.t-yes { color: var(--yes); }
.t-if { color: var(--if); font-size: .85rem; margin-left: 2px; }
.comment-dot { cursor: help; font-size: .8rem; }
.legend { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.best-swatch { display: inline-block; width: 16px; height: 16px; background: var(--best); border: 1px solid #ecdc8c; border-radius: 4px; margin-left: 10px; vertical-align: middle; }

/* Participants */
.participants { list-style: none; margin: 0; padding: 0; }
.participants li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.participants li:first-child { padding-top: 0; }
.p-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.push-right { margin: 0 0 0 auto; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { margin: 0; font-size: .85rem; color: var(--muted); }

/* Respond page */
.quick-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.date-options { list-style: none; margin: 0; padding: 0; }
.date-options li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.date-options li.final { background: var(--primary-soft); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.date-label { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.cal-icon { display: inline-flex; flex-direction: column; align-items: center; width: 48px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.cal-icon .d-month { display: block; width: 100%; text-align: center; background: var(--primary); color: #fff; font-size: .65rem; padding: 1px 0; }
.cal-icon .d-day { font-size: 1.2rem; line-height: 1.6; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg { position: relative; font-weight: 600; font-size: .88rem; cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--border); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 9px 14px; color: var(--muted); background: #fff; transition: background .12s, color .12s; }
.seg:hover span { background: var(--bg); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
.seg-yes input:checked + span { background: var(--yes); color: #fff; }
.seg-if input:checked + span { background: var(--if); color: #fff; }
.seg-no input:checked + span { background: #5f6b78; color: #fff; }
.seg input:disabled + span { cursor: not-allowed; }
@media (max-width: 640px) {
    .segmented { width: 100%; }
    .seg { flex: 1; }
    .seg span { text-align: center; padding: 9px 6px; }
}

/* Share link */
.share-card { border-color: #bcd3f7; background: linear-gradient(0deg, var(--surface), var(--primary-soft)); }
.share-card .copy-row input { color: var(--text); font-size: .95rem; }
.personal-link { padding: 16px 20px; }
.personal-link .not-you { margin: 8px 0 0; }
details summary { cursor: pointer; margin-bottom: 6px; }

.known-people { padding: 16px 20px; border-color: #bcd3f7; background: var(--primary-soft); }
.known-people p { margin: 0; }
.name-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
