:root {
  --paper: #f6f3ec; --card: #fffdf8; --ink: #1c2420; --ink-2: #4b5650; --ink-3: #7d8781; --line: #e4ded1;
  --brand: #2f5d4e; --brand-ink: #ffffff; --brand-soft: #e3ece7; --warm: #b8592f; --warm-soft: #f6e6dc;
  --gold: #a87a1c; --gold-soft: #f4ead2; --blue: #2e5d8a; --blue-soft: #e2ebf4; --plum: #7a4a78; --plum-soft: #efe4ee;
  --danger: #a23b2e; --ok: #2f7a4f; --shadow: 0 1px 2px rgba(28,36,32,.06), 0 4px 16px rgba(28,36,32,.05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141816; --card: #1c211f; --ink: #ece8df; --ink-2: #bdc2bc; --ink-3: #8c948e; --line: #2c3330;
    --brand: #7fb69f; --brand-ink: #0f1513; --brand-soft: #23332c; --warm: #e39570; --warm-soft: #3a2a21;
    --gold: #d9b45e; --gold-soft: #352e1d; --blue: #8db6de; --blue-soft: #1e2a36; --plum: #c99bc6; --plum-soft: #2f2430;
    --danger: #e27b6d; --ok: #7cc79a; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-text-size-adjust: 100%; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.hidden { display: none !important; }

#app { max-width: 600px; margin: 0 auto; min-height: 100vh; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 6px; }
.wordmark { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; color: var(--ink); text-decoration: none; display: flex; gap: 8px; align-items: center; }
.wordmark .dot { width: 22px; height: 22px; border-radius: 7px; background: var(--brand); color: var(--brand-ink); display: inline-grid; place-items: center; font-size: .8rem; }
.banner { background: var(--gold-soft); color: var(--ink); border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin: 8px 0; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.banner.demo { background: var(--blue-soft); }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
nav.tabs .inner { display: flex; width: 100%; max-width: 600px; }
nav.tabs a { flex: 1; text-align: center; padding: 10px 0 9px; color: var(--ink-3); text-decoration: none; font-size: .75rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav.tabs a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav.tabs a.on { color: var(--brand); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); margin: 12px 0; }
.card.flat { box-shadow: none; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 4px; }
.section-title h2 { font-size: 1.1rem; }

.btn { appearance: none; border: 1px solid transparent; background: var(--brand); color: var(--brand-ink); border-radius: 12px; padding: 11px 16px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--brand); padding: 8px 10px; min-height: 36px; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.send-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.send-row .btn { padding: 11px 6px; font-size: .95rem; }
.send-row.four { grid-template-columns: repeat(2, 1fr); }

label { display: block; font-size: .875rem; font-weight: 600; color: var(--ink-2); margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 11px 12px; min-height: 44px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
textarea.message { font-size: 1rem; min-height: 150px; background: var(--paper); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--ink); }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--brand); }
.hint { font-size: .8rem; color: var(--ink-3); margin-top: 4px; }
.err { color: var(--danger); font-size: .9rem; margin-top: 8px; }

.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--brand-soft); color: var(--brand); }
.chip.anniversary { background: var(--brand-soft); color: var(--brand); }
.chip.birthday, .chip.wedding { background: var(--warm-soft); color: var(--warm); }
.chip.life { background: var(--plum-soft); color: var(--plum); }
.chip.equity { background: var(--gold-soft); color: var(--gold); }
.chip.review { background: var(--blue-soft); color: var(--blue); }
.chip.quiet, .chip.market_update { background: var(--line); color: var(--ink-2); }
.chip.pending { background: var(--gold-soft); color: var(--gold); }
.chip.demo { background: var(--blue-soft); color: var(--blue); }

.hello { margin: 10px 0 2px; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.streak { font-weight: 600; color: var(--warm); }

.item { padding: 14px 16px; }
.item .head { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.num { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--paper); border: 1px solid var(--line); display: grid; place-items: center; font-size: .85rem; font-weight: 700; color: var(--ink-2); }
.item.top .num { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.item.done { opacity: .62; }
.item.done .num { background: var(--ok); color: #fff; border-color: var(--ok); }
.item .name { font-weight: 700; font-size: 1.05rem; }
.item .why { color: var(--ink-2); font-size: .92rem; margin-top: 2px; }
.composer { margin-top: 12px; }
.composer .tools { display: flex; justify-content: space-between; margin: 6px 0 10px; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list a.li, .list .li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); }
.list .li:first-child { border-top: 0; }
.li .title { font-weight: 600; }
.li .sub { font-size: .82rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { flex: 0 0 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: var(--brand-soft); color: var(--brand); }

.filters { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
.filters button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: .85rem; white-space: nowrap; cursor: pointer; }
.filters button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fact { background: var(--paper); border-radius: 12px; padding: 10px 12px; }
.fact .k { font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.fact .v { font-weight: 700; font-family: var(--serif); font-size: 1.1rem; }
.fact .s { font-size: .78rem; color: var(--ink-3); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.tile .big { font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.tile .k { font-size: .8rem; color: var(--ink-3); }
.bars { display: flex; gap: 4px; align-items: flex-end; height: 34px; margin-top: 8px; }
.bars i { flex: 1; background: var(--brand-soft); border-radius: 3px; min-height: 3px; }
.bars i.on { background: var(--brand); }
.hbar { display: grid; grid-template-columns: 130px 1fr 52px; gap: 10px; align-items: center; padding: 6px 0; font-size: .9rem; }
.hbar .track { height: 10px; background: var(--paper); border-radius: 99px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 99px; }
.risk { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; width: 64px; flex: 0 0 64px; }
.risk i { display: block; height: 100%; background: var(--warm); }

.prev-row { border-top: 1px solid var(--line); padding: 10px 0; font-size: .9rem; }
.prev-row:first-child { border-top: 0; }
.status { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 6px; padding: 2px 6px; }
.status.new { background: var(--brand-soft); color: var(--brand); }
.status.dup { background: var(--line); color: var(--ink-2); }
.status.upd { background: var(--gold-soft); color: var(--gold); }
.status.bad { background: var(--warm-soft); color: var(--danger); }
.counts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.counts div { background: var(--paper); border-radius: 12px; padding: 10px; }
.counts b { font-family: var(--serif); font-size: 1.4rem; display: block; }
.mapgrid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 6px 10px; align-items: center; font-size: .9rem; }
.mapgrid select { min-height: 38px; padding: 6px 8px; }
.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 26px 16px; text-align: center; cursor: pointer; background: var(--card); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }

.plans { display: grid; gap: 10px; }
.plan { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--card); }
.plan .price { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; }

.auth { max-width: 420px; margin: 0 auto; padding-top: 6vh; }
.auth .hero { font-family: var(--serif); font-size: 2.1rem; line-height: 1.15; margin: 18px 0 6px; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; z-index: 50; display: flex; gap: 14px; align-items: center; font-size: .92rem; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast button { background: none; border: 0; color: var(--gold-soft); font-weight: 700; cursor: pointer; padding: 0; }
.modal-bg { position: fixed; inset: 0; background: rgba(20,24,22,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-width: 600px; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }
.empty { text-align: center; padding: 28px 12px; }
.empty .art { font-size: 2.4rem; }
pre.note { white-space: pre-wrap; font: inherit; margin: 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.kv:first-child { border-top: 0; }
