:root {
  --bg: #f6f3fa; --surface: #ffffff; --ink: #1d1530; --muted: #6a6280; --line: #e4ddef;
  --brand: #5b2a86; --brand-ink: #ffffff; --soft: #efe7f8; --good: #1c7c54; --warn: #8a5a00; --warn-bg: #fff4d6; --bad: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14101d; --surface: #1f1a2c; --ink: #f2eefa; --muted: #a79fbd; --line: #352d49;
    --brand: #b78be0; --brand-ink: #1a1026; --soft: #2b2340; --good: #6fd3a5; --warn: #ffd47a; --warn-bg: #3a2f12; --bad: #ff8a80;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
h2 small { font-size: 13px; font-weight: 500; color: var(--muted); }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 6px; }
a { color: var(--brand); }
code { background: var(--soft); padding: 1px 5px; border-radius: 6px; font-size: 13px; }
em { font-style: normal; font-weight: 400; color: var(--muted); }

.page { max-width: 1040px; margin: 0 auto; padding: 14px 16px calc(48px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.top { display: flex; align-items: center; gap: 12px; min-height: 44px; padding-top: env(safe-area-inset-top); }
.top h1 { flex: 1; min-width: 0; }
.top nav { display: flex; gap: 14px; align-items: center; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { text-decoration: none; font-weight: 600; white-space: nowrap; padding: 10px 4px; }
.save-state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.hello { font-size: 1.15rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 14px; }
.error { color: var(--bad); font-size: 14px; }
.warn-box { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.install { font-size: 14px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 16px; padding: 22px; color: var(--muted); }

.stack { display: grid; gap: 14px; align-content: start; min-width: 0; }
.narrow { max-width: 640px; width: 100%; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.panel.ai { border-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; }

label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; min-width: 0; }
input, textarea, select {
  font: inherit; font-size: 16px; font-weight: 400; color: var(--ink); width: 100%; min-width: 0;
  padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg);
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--brand); padding: 0; }
input[type=color] { width: 46px; height: 46px; padding: 3px; border-radius: 12px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.big { min-height: 54px; font-size: 1.1rem; border-radius: 16px; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.linkish { background: none; border: 0; padding: 10px 4px; font: inherit; font-size: 14px; color: var(--brand); cursor: pointer; text-decoration: underline; }
.danger { color: var(--bad); }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.tabs a { padding: 12px 10px; font-size: 15px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 12px; padding: 4px; }
.seg button { min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface); box-shadow: 0 1px 4px rgb(0 0 0 / .15); }
.swatches { display: flex; flex-wrap: wrap; gap: 14px; }
.swatch { justify-items: center; font-weight: 500; font-size: 13px; }
.check { display: flex; align-items: center; gap: 12px; font-weight: 500; font-size: 15px; min-height: 44px; cursor: pointer; }
.check span { display: grid; min-width: 0; }
.check small, .rows small { color: var(--muted); font-size: 13px; font-weight: 400; overflow-wrap: anywhere; }

.rows { list-style: none; margin: 0; padding: 0; display: grid; }
.rows > li { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.rows > li:first-child { border-top: 0; }
.rows.compact > li { padding: 4px 0; }
.rows.pick { max-height: 300px; overflow-y: auto; }
.rows li.done { opacity: .6; }
.grow { flex: 1; min-width: 0; display: grid; }
.guest-row { display: block !important; }
.row-main { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 4px 0; font: inherit; color: inherit; text-align: left; cursor: pointer; min-height: 44px; }
.row-detail { display: grid; gap: 10px; padding: 10px 0 6px; font-size: 15px; }
.row-detail p small { display: block; }
.pill { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.pill.going { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.pill.declined { color: var(--muted); }

.tally { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tally div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; text-align: center; display: grid; }
.tally strong { font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tally span { font-size: 13px; color: var(--muted); }

.event-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.event-list a { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 18px; text-decoration: none; color: var(--c3); background: linear-gradient(150deg, var(--c1), var(--c2)); min-height: 96px; }
.event-list img, .thumb { width: 60px; height: 75px; border-radius: 10px; object-fit: cover; flex: none; display: grid; place-items: center; font-size: 28px; background: rgb(255 255 255 / .15); }
.event-info { display: grid; gap: 2px; min-width: 0; font-size: 14px; }
.event-info strong { font-size: 1.1rem; overflow-wrap: anywhere; }

.split { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.preview { display: grid; gap: 8px; align-content: start; }
.preview-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.preview iframe { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.cover-thumb { width: 140px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 12px; }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr) 380px; }
  .preview { position: sticky; top: 60px; }
}

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #24124d, #6a2c91); }
.login-card { width: min(100%, 380px); background: var(--surface); border-radius: 24px; padding: 28px 24px; display: grid; gap: 10px; text-align: center; box-shadow: 0 20px 60px rgb(0 0 0 / .35); }
.login-card form { display: grid; gap: 14px; text-align: left; margin-top: 10px; }
.logo { font-size: 3rem; line-height: 1; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; max-width: 92vw; padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 15px; box-shadow: 0 10px 30px rgb(0 0 0 / .3); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.warn { background: var(--warn-bg); color: var(--warn); }

@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } }
