:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --soft: #f6f7fb;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e8eaf1;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --ok: #059669;
  --ok-soft: #e7f8f1;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 17px; letter-spacing: -0.01em; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(255,255,255,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -0.02em; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand i { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, #6366f1, #a78bfa); display: inline-block; }
.wrap { max-width: 960px; margin: 0 auto; padding: 20px 16px 80px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.head .sub { color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* controls */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 12px; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--soft); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn.primary:hover { background: #1e293b; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.accent:hover { background: #4338ca; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; min-height: 44px;
  font-size: 16px; /* stops iOS zoom on focus */
}
textarea { resize: vertical; min-height: 110px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #334155; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.event-card { display: block; color: inherit; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.event-card:hover { transform: translateY(-2px); }
.event-card h2 { margin-bottom: 4px; }
.event-card .meta { color: var(--muted); font-size: 14px; }
.mini-stats { display: flex; gap: 18px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mini-stats b { display: block; font-size: 20px; letter-spacing: -0.02em; }
.mini-stats span { font-size: 12px; color: var(--muted); }

.stats { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin-bottom: 20px; }
.stats .stat:last-child { grid-column: 1 / -1; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(5, 1fr); } .stats .stat:last-child { grid-column: auto; } }
.stat { background: var(--soft); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; letter-spacing: -0.02em; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 500; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin: 6px 0 20px; }
.bar > div { height: 100%; background: linear-gradient(90deg, #6366f1, #a78bfa); border-radius: 99px; transition: width .3s; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.yes { background: var(--ok-soft); color: var(--ok); }
.pill.no { background: var(--bad-soft); color: var(--bad); }
.pill.sent { background: var(--accent-soft); color: var(--accent); }
.note { margin-top: 6px; font-size: 14px; color: #334155; font-style: italic; }
.pill.arrived { background: var(--accent-soft); color: var(--accent); }

/* guest list: rows on desktop, stacked cards on phones */
.tools { display: flex; gap: 8px; margin: 22px 0 12px; flex-wrap: wrap; }
.tools input { flex: 1 1 200px; }
.tools select { flex: 0 1 150px; }
.guest { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); align-items: center; }
.guest:first-child { border-top: 0; }
.guest .name { font-weight: 600; }
.guest .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.guest .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) {
  .guest { grid-template-columns: 1fr; }
  .guest .acts { justify-content: flex-start; }
  .guest .acts .btn { flex: 1 1 auto; }
  h1 { font-size: 22px; }
}

/* modal / bottom sheet */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.sheet { background: #fff; border-radius: 20px; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; padding: 22px; box-shadow: var(--shadow); }
@media (max-width: 560px) { .modal { align-items: flex-end; padding: 0; } .sheet { border-radius: 20px 20px 0 0; padding-bottom: 32px; } }
.sheet h2 { margin-bottom: 4px; }
.sheet .row.end { justify-content: flex-end; margin-top: 20px; }
.qr-box { width: 220px; margin: 12px auto 0; }
.qr-box svg { width: 100%; height: auto; display: block; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 600; z-index: 99; font-size: 14px; max-width: calc(100vw - 32px); }
.error { color: var(--bad); font-size: 14px; margin-top: 10px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* login */
.login { max-width: 380px; margin: 14vh auto 0; padding: 0 16px; text-align: center; }
.login .card { box-shadow: var(--shadow); text-align: left; margin-top: 24px; }

/* scanner */
.scan { max-width: 520px; margin: 0 auto; }
.viewfinder { position: relative; border-radius: 20px; overflow: hidden; background: #0f172a; aspect-ratio: 1 / 1; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 22px; box-shadow: 0 0 0 999px rgba(15,23,42,.35); }
.verdict { margin-top: 14px; padding: 16px 18px; border-radius: var(--radius); font-weight: 600; }
.verdict small { display: block; font-weight: 500; opacity: .85; margin-top: 2px; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.already { background: var(--warn-soft); color: var(--warn); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict.idle { background: var(--soft); color: var(--muted); }
.scan-count { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 6px; }
.scan-count b { font-size: 28px; letter-spacing: -0.02em; }
.recent { margin-top: 18px; }
.recent div { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }

/* public invite */
.invite { max-width: 520px; margin: 0 auto; padding: 24px 16px 64px; }
.sheet-msg { text-align: center; margin-top: 24vh; }
.card-invite { border: 1px solid var(--line); border-radius: 24px; padding: 40px 26px 32px; text-align: center; box-shadow: var(--shadow); }
.eyebrow { text-transform: uppercase; letter-spacing: .28em; font-size: 11px; font-weight: 600; color: var(--accent); }
.to { margin-top: 14px; color: var(--muted); }
.card-invite h1 { font-size: 34px; line-height: 1.15; margin: 10px 0 6px; letter-spacing: -0.025em; }
.host { color: var(--muted); }
.rule { height: 1px; background: var(--line); width: 56px; margin: 28px auto; }
.bigdate { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.bigdate span { text-transform: uppercase; letter-spacing: .2em; font-size: 12px; font-weight: 600; color: var(--muted); }
.bigdate b { font-size: 64px; letter-spacing: -0.04em; margin: 4px 0; }
.when p { margin-top: 10px; font-weight: 600; }
.where { margin-top: 14px; color: #334155; }
.links { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 16px; border-radius: 99px; border: 1px solid var(--line); color: var(--text); font-weight: 600; font-size: 14px; }
.chip:hover { background: var(--soft); }
.desc { color: #334155; white-space: pre-wrap; margin-top: 26px; }
.block { margin-top: 26px; }
.block h2, .rsvp-box h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); margin-bottom: 8px; }
.rsvp-box h2 { font-size: 20px; text-transform: none; letter-spacing: -0.01em; color: var(--text); margin-bottom: 4px; }
.timeline { display: inline-grid; gap: 8px; text-align: left; }
.timeline div { display: grid; grid-template-columns: 70px 1fr; gap: 12px; }
.timeline b { color: var(--accent); }
.small { font-size: 13px; }
.rsvp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.rsvp .btn { min-height: 52px; font-size: 15px; }
.rsvp .btn.on { background: var(--text); color: #fff; border-color: var(--text); }
.party { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.party button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 22px; cursor: pointer; }
.lbl { text-align: left; margin-top: 18px; }
.send { width: 100%; margin-top: 12px; min-height: 52px; background: var(--accent); border-color: var(--accent); color: #fff; }
.send:hover { background: #4338ca; }
.answer { margin: 16px 0; padding: 16px; border-radius: 16px; background: var(--ok-soft); color: var(--ok); }
.answer.no { background: var(--soft); color: #334155; }
.answer p { margin-top: 8px; font-style: italic; }
.pass { margin-top: 18px; border: 1px solid var(--line); border-radius: 24px; padding: 24px; text-align: center; box-shadow: var(--shadow); }
.checked { margin-top: 18px; padding: 14px; border-radius: 14px; background: var(--ok-soft); color: var(--ok); font-weight: 600; text-align: center; }
@media (max-width: 400px) { .card-invite { padding: 32px 18px 26px; } .card-invite h1 { font-size: 28px; } .bigdate b { font-size: 54px; } }

/* inline add-guest row */
.addrow { display: flex; gap: 8px; margin-top: 10px; flex-wrap: nowrap; }
.addrow input { flex: 1 1 auto; min-width: 0; }
.addrow .btn { flex: 0 0 auto; white-space: nowrap; }
.linkbtn { appearance: none; border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; padding: 8px 0 0; cursor: pointer; }

/* admin pictures */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.thumb { position: relative; border-radius: 12px; overflow: hidden; background: var(--soft); aspect-ratio: 1 / 1; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-tag { position: absolute; top: 6px; left: 6px; background: rgba(15,23,42,.8); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.tacts { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 4px; padding: 6px; background: linear-gradient(transparent, rgba(15,23,42,.65)); }
.tacts button { flex: 1; appearance: none; border: 0; border-radius: 8px; background: rgba(255,255,255,.92); font: inherit; font-size: 12px; font-weight: 600; padding: 7px 4px; min-height: 32px; cursor: pointer; }

/* event card cover */
.event-card .cover { margin: -18px -18px 14px; height: 130px; background: var(--soft) center / cover no-repeat; border-radius: var(--radius) var(--radius) 0 0; }

/* invitation pictures */
.hero { margin: -40px -26px 28px; aspect-ratio: 4 / 3; background: var(--soft) center / cover no-repeat; border-radius: 24px 24px 0 0; }
.gallery { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); margin-top: 26px; }
.gallery img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 14px; display: block; cursor: zoom-in; }
.gallery img:first-child:nth-last-child(odd) { grid-column: 1 / -1; aspect-ratio: 16 / 10; }
.lightbox { position: fixed; inset: 0; background: rgba(15,23,42,.92); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }
@media (max-width: 400px) { .hero { margin: -32px -18px 24px; } }

/* live connection indicator */
.livedot { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; flex: 0 0 auto; transition: background .3s; }
.livedot.on { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
#account { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
