:root { -webkit-text-size-adjust: 100%; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; } } /* iPhone: follows the Larger Text setting */
:root, [data-theme="day"] {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1f2a33; --muted: #58626b; --line: #e6e1d8;
  --safe: #1f6b4e; --safe-soft: #e3f3ec; --tight: #8a5a12; --tight-soft: #fbf0dc; --over: #a8362f; --over-soft: #f9e3e1;
  --bill: #2f5e91; --bill-soft: #e4edf7; --save: #5f43a8; --save-soft: #eee8fa; --pay: #1f6b4e; /* every text colour ≥ 4.5:1 contrast (measured) */
  --shadow: 0 1px 2px rgba(31,42,51,.06), 0 4px 14px rgba(31,42,51,.06);
}
[data-theme="night"] {
  --bg: #0f1a24; --card: #172532; --ink: #e8eef2; --muted: #93a3b1; --line: #253645;
  --safe: #5cc79d; --safe-soft: #173a30; --tight: #e7b35a; --tight-soft: #3a2f17; --over: #ef7d74; --over-soft: #3d1f1d;
  --bill: #7fb0e6; --bill-soft: #1b3047; --save: #b39cf0; --save-soft: #2a2347; --pay: #5cc79d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 1rem/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px 24px; }
h1 { font-size: 1.25rem; margin: 4px 0 2px; font-weight: 650; }
h2 { font-size: 0.9375rem; margin: 22px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 6px 0; }
.sub { color: var(--muted); font-size: 0.875rem; }
.card { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); margin: 10px 0; }
.hero { text-align: center; padding: 22px 16px; }
.hero .label { color: var(--muted); font-size: 0.875rem; }
.hero .big { font-size: 2.875rem; font-weight: 700; letter-spacing: -.02em; margin: 4px 0; }
.hero.safe { background: var(--safe-soft); } .hero.safe .big { color: var(--safe); }
.hero.tight { background: var(--tight-soft); } .hero.tight .big { color: var(--tight); }
.hero.over { background: var(--over-soft); } .hero.over .big { color: var(--over); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .left { min-width: 0; flex: 1; } .row .name { font-weight: 600; } .row .meta { color: var(--muted); font-size: 0.8125rem; }
.amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.pill { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 99px; background: var(--bill-soft); color: var(--bill); font-weight: 600; }
.pill.pay { background: var(--safe-soft); color: var(--pay); } .pill.save { background: var(--save-soft); color: var(--save); }
.pill.late { background: var(--over-soft); color: var(--over); } .pill.done { background: var(--line); color: var(--muted); }
button, .btn { font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--ink); color: var(--bg); font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.soft { background: var(--bill-soft); color: var(--bill); }
button.small { padding: 7px 12px; font-size: 0.875rem; border-radius: 10px; }
button.link { background: none; color: var(--bill); padding: 4px 0; font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.full { width: 100%; }
label { display: block; font-size: 0.875rem; color: var(--muted); margin: 12px 0 4px; }
input, select { font: inherit; width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--bill); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.next { display: flex; align-items: center; gap: 12px; }
.next .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--safe); flex: none; }
.banner { background: var(--tight-soft); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 0.875rem; margin: 8px 0; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--save); border-radius: 99px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 2px; background: var(--card); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs button { flex: 1; max-width: 112px; background: none; color: var(--muted); padding: 8px 4px; font-size: 0.75rem; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button .ic { font-size: 1.1875rem; line-height: 1; }
.tabs button.on { color: var(--ink); background: var(--bg); }
.sheet { position: fixed; inset: 0; background: rgba(15,26,36,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
[hidden] { display: none !important; } /* hidden always wins, even over .row */
.sheet[hidden] { display: none; }
.sheet .panel { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 4px 0; }
.cal .day { background: var(--card); border-radius: 10px; min-height: 58px; padding: 4px; font-size: 0.75rem; box-shadow: var(--shadow); min-width: 0; overflow: hidden; cursor: pointer; }
.cal .day.out { opacity: .35; } .cal .day.today { outline: 2px solid var(--ink); }
.cal .day .n { font-weight: 700; } .cal .day .m { display: block; font-size: 0.6875rem; font-weight: 600; border-radius: 6px; padding: 1px 3px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m.b { background: var(--bill-soft); color: var(--bill); } .m.p { background: var(--safe-soft); color: var(--pay); } .m.s { color: var(--muted); }
.steps { display: flex; gap: 6px; margin: 4px 0 12px; } .steps i { flex: 1; height: 4px; border-radius: 99px; background: var(--line); } .steps i.on { background: var(--ink); }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 0.875rem; z-index: 20; }
.muted { color: var(--muted); } .center { text-align: center; } .right { text-align: right; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; font-size: 0.875rem; }
.how .row { padding: 7px 0; font-size: 0.875rem; }
@media (max-width: 380px) { .cal { gap: 2px; } .cal .day { padding: 3px 2px; min-height: 50px; } .cal .day .m { font-size: 0.625rem; padding: 1px 2px; } .hero .big { font-size: 2.5rem; } }
@media (min-width: 700px) { .hero .big { font-size: 3.5rem; } }
