/* ===== VANA theme — change these to re-colour the whole app ===== */
:root {
  --brand: #2e7d4f;
  --brand-dark: #1f5a34;
  --brand-soft: #e4f1e0;
  --brand-tint: #f4f8f1;
  --accent: #c9a24a;

  --bg: var(--brand-tint);
  --card: #ffffff;
  --text: #1c2a21;
  --muted: #66756b;
  --line: #e2e8df;
  --danger: #c0392b;
  --high: #c0392b;  --high-bg: #fbe9e7;
  --med: #b7791f;   --med-bg: #fdf3e1;
  --low: #4a6fa5;   --low-bg: #e8eef8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(20,60,30,.06);
  color-scheme: light;
}
:root[data-theme="purple"] {
  --brand: #6a3d96; --brand-dark: #4a2370; --brand-soft: #eee4f7; --brand-tint: #f8f4fc;
  --text: #241c2a; --muted: #6f6578; --line: #e7e0ee;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-light]) {
    --bg: #121814; --card: #1b231e; --text: #e8efe9; --muted: #9aa89f; --line: #2a352e;
    --brand-soft: #22392a; --high-bg: #3a2220; --med-bg: #3a2f1c; --low-bg: #1f2a3a;
    color-scheme: dark;
  }
  :root[data-theme="purple"]:not([data-light]) { --bg: #16121a; --card: #201a26; --brand-soft: #33244a; --line: #2f2638; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.splash { min-height: 100dvh; display: grid; place-items: center; }
.splash img { width: 96px; border-radius: 22px; opacity: .9; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card img { width: 112px; height: 112px; border-radius: 26px; box-shadow: var(--shadow); }
.login-card h1 { font-family: "Iowan Old Style", "Palatino", Georgia, serif; font-weight: 500;
  letter-spacing: .3em; margin: 18px 0 2px; color: var(--brand-dark); font-size: 32px; padding-left: .3em; }
.login-card img.logo-full { width: 260px; height: auto; border-radius: 0; box-shadow: none; }
body.on-login { background: #f9f1da; }
@media (prefers-color-scheme: dark) { body.on-login .login-card img.logo-full { border-radius: 20px; } }
.brand img { border: 1px solid var(--line); }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; }
.login-card form { display: grid; gap: 10px; }
.err { color: var(--danger); min-height: 1.4em; margin: 6px 0 0; font-size: 14px; }

/* ---------- Layout ---------- */
.shell { max-width: 760px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; position: sticky; top: 0;
  background: var(--bg); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand b { font-family: "Iowan Old Style", "Palatino", Georgia, serif; font-weight: 500; letter-spacing: .25em;
  color: var(--brand-dark); font-size: 20px; }
.hello { color: var(--muted); font-size: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff;
  font-weight: 600; font-size: 14px; border: 0; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

.tabs { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs button.on { background: var(--brand); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }

.group { margin-top: 18px; }
.group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 4px 8px; font-weight: 600; }
.group h3.overdue { color: var(--danger); }
.list { display: grid; gap: 8px; }

.card { display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
  border-left: 4px solid var(--who, var(--brand)); }
.card.selected { outline: 2px solid var(--brand); }
.card.done .card-title { text-decoration: line-through; color: var(--muted); }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 600; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 6px; font-size: 13px; color: var(--muted); }
.when.late { color: var(--danger); font-weight: 600; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.pri-High { color: var(--high); background: var(--high-bg); }
.pri-Medium { color: var(--med); background: var(--med-bg); }
.pri-Low { color: var(--low); background: var(--low-bg); }
.st-Open { color: var(--muted); background: var(--line); }
.st-InProgress { color: var(--brand-dark); background: var(--brand-soft); }
.st-Done { color: #fff; background: var(--brand); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty img { width: 64px; opacity: .5; border-radius: 16px; }

.fab { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 32px;
  line-height: 1; box-shadow: 0 6px 20px rgba(0,0,0,.22); z-index: 10; }

/* ---------- Inputs & buttons ---------- */
.input, select.input, textarea.input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); outline: none; font-size: 16px; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { min-height: 80px; resize: vertical; }
.btn { border: 1px solid var(--line); background: var(--card); padding: 11px 16px; border-radius: 12px; font-weight: 600; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; }
.icon-btn { border: 0; background: none; font-size: 22px; padding: 6px; color: var(--muted); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-weight: 600; font-size: 14px; }
.seg input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.seg input:disabled + span { opacity: .5; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.toggle input { width: 22px; height: 22px; accent-color: var(--brand); }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* ---------- Sheet: bottom sheet on phone, side panel on laptop ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(10,20,14,.35); display: flex; align-items: flex-end; }
.panel { background: var(--bg); width: 100%; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.18);
  animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-head h2 { flex: 1; margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.rows { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row > span:first-child { color: var(--muted); font-size: 14px; }
.row select { border: 0; background: none; font-weight: 600; text-align: right; padding: 0; }
.notes { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.actions .btn { flex: 1; }
.private-badge { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--line); border-radius: 999px; padding: 3px 8px; }

.comments h4 { margin: 4px 0 10px; font-size: 15px; }
.comment { display: flex; gap: 10px; margin-bottom: 12px; }
.comment .bubble { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 8px 12px; }
.comment .bubble b { font-size: 13px; }
.comment .bubble small { color: var(--muted); font-size: 12px; margin-left: 6px; }
.comment .bubble p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .x { border: 0; background: none; color: var(--muted); font-size: 16px; align-self: flex-start; }
.add-comment { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding-top: 6px; }
.add-comment .input { flex: 1; }

.menu { position: absolute; right: 16px; top: 58px; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); min-width: 230px; overflow: hidden; z-index: 30; }
.menu button { display: block; width: 100%; text-align: left; padding: 12px 16px; border: 0; background: none; border-top: 1px solid var(--line); }
.menu button:first-child { border-top: 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom));
  background: #1d2420; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 40; max-width: 90vw; font-size: 14px; text-align: center; }

/* ---------- Laptop / iPad landscape ---------- */
@media (min-width: 960px) {
  .shell { max-width: 820px; padding: 0 32px 60px; }
  body.panel-open .shell { margin: 0 460px 0 auto; max-width: none; padding-left: max(32px, calc((100vw - 460px - 820px) / 2)); }
  .sheet { background: transparent; inset: 0 0 0 auto; width: 460px; align-items: stretch; }
  .panel { max-height: none; height: 100dvh; border-radius: 0; border-left: 1px solid var(--line);
    box-shadow: -8px 0 30px rgba(0,0,0,.06); padding: 20px 24px 28px; animation: none; }
  .grab { display: none; }
  .fab { right: 40px; bottom: 32px; }
  body.panel-open .fab { right: 500px; }
}

/* ---------- Logo button + left drawer ---------- */
button.brand { border: 0; background: none; padding: 4px 8px 4px 2px; margin-left: -2px; text-align: left; border-radius: 12px; color: inherit; }
button.brand:hover { background: var(--brand-soft); }
.burger { font-size: 20px; color: var(--muted); width: 18px; text-align: center; }
.drawer { position: fixed; inset: 0; z-index: 35; background: rgba(10,20,14,0); transition: background .2s; }
.drawer.open { background: rgba(10,20,14,.35); }
.drawer-panel { position: absolute; top: 0; bottom: 0; left: 0; width: min(290px, 82vw); background: var(--bg);
  padding: calc(18px + env(safe-area-inset-top)) 14px 24px calc(14px + env(safe-area-inset-left));
  box-shadow: 8px 0 30px rgba(0,0,0,.18); transform: translateX(-100%); transition: transform .22s ease-out; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 0 6px 18px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.drawer-head img { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); }
.drawer-head b { font-family: "Iowan Old Style", "Palatino", Georgia, serif; font-weight: 500; letter-spacing: .25em; color: var(--brand-dark); font-size: 20px; }
.drawer-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 13px 12px;
  border-radius: 12px; font-size: 17px; font-weight: 600; text-align: left; color: var(--text); }
.drawer-item span { font-size: 20px; }
.drawer-item em { margin-left: auto; font-style: normal; font-size: 13px; color: var(--muted); }
.drawer-item.on { background: var(--brand-soft); color: var(--brand-dark); }
.drawer-item:hover:not(.on) { background: var(--card); }

/* ---------- Events ---------- */
.event-card { align-items: center; }
.datebox { flex: none; width: 48px; text-align: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); padding: 6px 0; line-height: 1.1; }
.datebox small { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.datebox b { font-size: 20px; }
.faces { display: inline-flex; flex-direction: row-reverse; }
.faces .avatar { margin-left: -6px; border: 2px solid var(--card); box-sizing: content-box; }
.maplink { color: var(--brand); font-weight: 600; text-decoration: none; text-align: right; overflow-wrap: anywhere; }
.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.who-pick input { position: absolute; opacity: 0; pointer-events: none; }
.who-pick span { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-weight: 600; font-size: 15px; }
.who-pick input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.who-pick input:focus-visible + span { outline: 2px solid var(--brand); }
.panel > .hint { margin: 0 0 12px; }
.meta.votes { margin-top: 6px; gap: 6px; }
.vote { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.v-going { background: var(--brand-soft); color: var(--brand-dark); }
.v-maybe { background: var(--med-bg); color: var(--med); }
.v-no { background: var(--high-bg); color: var(--high); }
.v-ask { background: #fff4d6; color: #8a6200; }
.votelist .who { display: inline-flex; align-items: center; gap: 8px; color: var(--text) !important; font-weight: 600; }
.votelist b { font-size: 14px; }
.votelist b.v-none { color: var(--muted); background: none; }
.votelist b.v-going, .votelist b.v-maybe, .votelist b.v-no { background: none; }
#voteSeg span { font-size: 13px; }

/* ---------- Recurring ---------- */
.rep { font-size: 12px; font-weight: 700; color: #6a3d96; background: #efe6f8; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
@media (prefers-color-scheme: dark) { :root:not([data-light]) .rep { background: #33244a; color: #d6bfee; } }
.repbox { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.repbox.on { border-color: var(--brand); }
.tgl { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; position: relative; }
.sw-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw { position: relative; flex: none; width: 51px; height: 31px; border-radius: 999px; background: #d5dbd6; transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: left .2s; }
.sw-input:checked + .sw { background: var(--brand); }
.sw-input:checked + .sw::after { left: 22px; }
.sw-input:focus-visible + .sw { outline: 2px solid var(--brand); outline-offset: 2px; }
#repOpts { border-top: 1px solid var(--line); margin: 12px -14px 0; padding: 12px 14px 0; }
#repOpts .field { margin: 12px 0 0; }
#freqSeg span { font-size: 13px; }
.days { display: flex; gap: 4px; }
.days label { flex: 1; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span { display: block; text-align: center; padding: 8px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-weight: 600; font-size: 12px; }
.days input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
#endDate { margin-top: 8px; }
.preview { background: #f3eefa; border-radius: 10px; padding: 8px 12px; font-size: 14px; color: #4a2370; margin: 12px 0 2px; }
@media (prefers-color-scheme: dark) { :root:not([data-light]) .preview { background: #2a2036; color: #e3d2f5; } }
.rep-hint { margin: -6px 0 12px; }
.hist-title { margin: 4px 0 8px; font-size: 15px; }
.hist .row { font-size: 14px; }
.hist .ok { color: var(--brand); }
.hist .miss { color: var(--danger); }
