/* DishDibs styles: warm, simple, phone-first */
:root {
  --bg: #fbf6ee;
  --card: #ffffff;
  --ink: #2a211b;
  --muted: #7a6c60;
  --line: #eadfd0;
  --brand: #a8324a;        /* cranberry */
  --brand-dark: #87263a;
  --brand-soft: #f8e6ea;
  --green: #3f7a52;
  --green-soft: #e3f1e6;
  --gold: #c98a1c;
  --gold-soft: #fcf0d6;
  --red: #b3261e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .06);
  --font: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font);
  background-image: radial-gradient(circle at 10% -10%, #f6e3cf 0, transparent 40%), radial-gradient(circle at 110% 10%, #f3dbe0 0, transparent 35%);
  background-attachment: fixed;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 5vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; margin: 0 auto; padding: 14px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--brand); text-decoration: none; font-family: var(--display); font-size: 1.35rem; font-weight: 600; }
.brand b { font-weight: 700; color: var(--ink); }
.brand-mark { width: 28px; height: 28px; }
.topbar-link { font-weight: 700; text-decoration: none; font-size: .95rem; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 10px 16px 40px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin: 0 0 16px;
}
@media (max-width: 520px) { .card { padding: 18px 16px; } }

.hero { text-align: center; padding: 18px 8px 22px; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 34em; margin: 0 auto; }

/* ---------- forms ---------- */
.field { margin: 0 0 16px; position: relative; }
.field > label, .label { display: block; font-weight: 700; font-size: .92rem; margin: 0 0 6px; }
.opt { font-weight: 400; color: var(--muted); font-size: .85em; }
.hint { color: var(--muted); font-size: .88rem; margin: 4px 0 8px; }
.hint.warn { color: #8a5a00; background: var(--gold-soft); padding: 6px 10px; border-radius: 10px; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fffdf9;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; min-height: 46px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input.readonly { background: #f5efe6; color: var(--muted); }
input[type=checkbox] { width: auto; min-height: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; gap: 0; } }
.form-error { background: #fdecea; color: var(--red); border-radius: 10px; padding: 10px 12px; font-weight: 600; margin: 0 0 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 11px 18px; min-height: 44px; transition: background .15s, transform .05s;
}
.btn:hover { background: #fbf5ec; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--red); border-color: #f0c9c5; }
.btn.small { padding: 7px 13px; min-height: 36px; font-size: .9rem; }
.btn.big { width: 100%; padding: 15px; font-size: 1.08rem; }
.link-btn { background: none; border: 0; padding: 4px 6px; font: inherit; font-weight: 700; font-size: .9rem; color: var(--brand); cursor: pointer; }
.link-btn.danger { color: var(--muted); }
.icon-btn { background: none; border: 0; font-size: 1.6rem; line-height: 1; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: #f5efe6; }
.icon-btn-space { width: 40px; flex: none; }
.chip-btn { font: inherit; font-size: .85rem; font-weight: 700; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; margin: 2px; cursor: pointer; }

/* ---------- create page ---------- */
.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-opt { font-size: 1.5rem; width: 46px; height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; }
.emoji-opt.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand-soft); }
.needed-rows { display: grid; gap: 8px; margin-bottom: 8px; }
.needed-row { display: grid; grid-template-columns: 1fr 130px 40px; gap: 8px; align-items: center; }
@media (max-width: 520px) { .needed-row { grid-template-columns: 1fr 118px 36px; gap: 6px; } }

.autocomplete { position: relative; }
.ac-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px;
  list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.ac-list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: .95rem; }
.ac-list li:hover, .ac-list li[aria-selected=true] { background: var(--brand-soft); }

.created { text-align: center; }
.created-emoji, .big-emoji { font-size: 3.2rem; line-height: 1; margin-bottom: 8px; }
.link-box { text-align: left; background: #fffaf3; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 14px 0; }
.link-box.secret { background: var(--gold-soft); border-color: #f0dcae; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: .92rem; }
.my-events h2 { font-size: 1.1rem; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: 0; }
.plain-list a { font-weight: 700; text-decoration: none; }
.empty { text-align: center; padding: 40px 22px; }

/* ---------- event page ---------- */
.loading { text-align: center; color: var(--muted); }
.spinner { width: 34px; height: 34px; margin: 10px auto; border: 4px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ev-head { text-align: center; background: linear-gradient(180deg, #fff 0, #fffaf4 100%); }
.ev-emoji { font-size: 3rem; line-height: 1; margin-bottom: 6px; }
.ev-meta { display: inline-grid; gap: 4px; text-align: left; margin: 4px 0 10px; }
.meta-row { display: flex; gap: 8px; align-items: baseline; }
.meta-ico { width: 1.4em; text-align: center; flex: none; }
.ev-note { white-space: pre-wrap; text-align: left; background: #fffaf3; border-left: 4px solid var(--gold); border-radius: 8px; padding: 10px 14px; margin: 6px 0 14px; }
.ev-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; z-index: 10; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 210px; display: grid; }
.menu-pop a { padding: 10px 12px; border-radius: 8px; text-decoration: none; font-weight: 600; color: var(--ink); }
.menu-pop a:hover { background: var(--brand-soft); }

.host-panel { border: 2px dashed #e6c3ca; background: #fffafb; }
.host-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.host-head .hint { margin: 0; }
.host-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.banner { background: var(--gold-soft); border: 1px solid #f0dcae; border-radius: 12px; padding: 10px 14px; margin: 0 0 16px; font-weight: 600; }

.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sec-head h2 { margin: 0; }
.count { font-family: var(--font); font-weight: 600; font-size: .85rem; color: var(--muted); }
.muted { color: var(--muted); }

.pill { display: inline-block; font-family: var(--font); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; background: #f1ebe2; color: var(--muted); border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }
.pill.host { background: var(--brand); color: #fff; margin-left: 0; }
.pill.need { background: var(--gold-soft); color: #8a5a00; }

/* guests */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 6px 0 14px; }
.stat { text-align: center; background: #fffaf3; border-radius: 12px; padding: 8px 4px; }
.stat b { display: block; font-family: var(--display); font-size: 1.4rem; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.households { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.household { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.household.mine { border-color: #e6c3ca; background: #fffafb; }
.hh-top { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.hh-top .link-btn { margin-left: auto; }
.hh-note { margin: 6px 0 0; color: var(--muted); font-size: .9rem; white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #f6f1ea; border-radius: 999px; padding: 4px 10px; font-size: .9rem; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.st-yes .dot { background: var(--green); }
.chip.st-maybe .dot { background: var(--gold); }
.chip.st-no { color: var(--muted); text-decoration: line-through; }
.chip.st-no .dot { background: #c9bdb0; }
.chip .kid { font-size: .68rem; font-weight: 800; text-transform: uppercase; background: #fff; border-radius: 999px; padding: 0 6px; color: var(--muted); }

/* items */
.avoid { margin: 0 0 12px; font-size: .92rem; }
.avoid summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.avoid .tags { margin-top: 8px; }
.cat-head { margin: 18px 0 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.item.needed { border-style: dashed; border-color: #e7cf9d; background: #fffcf4; }
.item.mine { border-color: #e6c3ca; background: #fffafb; }
.item.flagged { box-shadow: inset 4px 0 0 var(--red); }
.item-main { min-width: 0; }
.item-name { font-weight: 700; }
.item-by { color: var(--green); font-weight: 600; font-size: .92rem; }
.item-by::before { content: "🙋 "; }
.item-tags { font-size: .82rem; color: var(--muted); }
.item-tags .flag { color: var(--red); font-weight: 700; }
.item-flag { font-size: .82rem; color: var(--red); font-weight: 700; }
.item-note { font-size: .9rem; color: var(--muted); font-style: italic; white-space: pre-wrap; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 2px; flex: none; }

/* toggles */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #f3ece2; border-radius: 999px; padding: 3px; }
.seg.disabled { opacity: .6; pointer-events: none; }
.seg-opt { font: inherit; font-weight: 700; font-size: .9rem; border: 0; background: transparent; border-radius: 999px; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg-opt[aria-checked=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg-opt.yes[aria-checked=true] { background: var(--green); color: #fff; }
.seg-opt.maybe[aria-checked=true] { background: var(--gold); color: #fff; }
.seg-opt.no[aria-checked=true] { background: #8d8076; color: #fff; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-opt { font: inherit; font-size: .88rem; font-weight: 700; border: 1.5px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.tag-opt[aria-pressed=true] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }

/* RSVP people */
.people { display: grid; gap: 10px; margin: 8px 0 10px; }
.person { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fffdf9; }
.person-top { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.person-bottom { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.kid-toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .9rem; cursor: pointer; }
.kid-toggle input { width: 20px; height: 20px; accent-color: var(--brand); }
.people-summary { font-weight: 700; color: var(--green); margin: 0; }

/* dialogs */
.dlg { border: 0; padding: 0; border-radius: 20px; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgba(40, 20, 10, .3); color: var(--ink); }
.dlg::backdrop { background: rgba(42, 33, 27, .45); }
.dlg-inner { padding: 18px 20px 20px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dlg-head h2 { margin: 0; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@media (max-width: 520px) {
  .dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
  .dlg-inner { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .dlg-actions .btn { flex: 1; }
}

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-weight: 700; box-shadow: var(--shadow); transition: all .25s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.sec-head .btn { white-space: nowrap; flex: none; }
