:root {
  --bg: #14181f;
  --panel: #1c222b;
  --panel-2: #232a35;
  --line: #2c3440;
  --text: #e8eaed;
  --muted: #8e97a3;
  --accent: #f4a261;
  --accent-ink: #1b1208;
  --ok: #5cc98a;
  --warn: #f0b040;
  --bad: #f2867f;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 max(12px, env(safe-area-inset-right)) calc(76px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 2px 8px; font-weight: 600; }
.card h3 { margin-top: 0; }
.muted { color: var(--muted); }
.small, small { font-size: 13px; }
.err { color: var(--bad); }
.warn { color: var(--warn); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; }
.grow { flex: 1; min-width: 0; }
main { max-width: 720px; margin: 0 auto; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 10; background: var(--bg); max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 0 10px;
}
.bar h1 { font-size: 20px; margin: 0; flex: 1; }
.offline { font-size: 12px; color: var(--warn); border: 1px solid var(--warn); border-radius: 10px; padding: 1px 8px; }
.icon-btn, .add-btn {
  min-width: 42px; height: 42px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-size: 20px; text-decoration: none; color: var(--text);
}
.add-btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-size: 24px; font-weight: 700; }

/* bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--panel);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
  color: var(--muted); text-decoration: none; font-size: 12px;
}
.tabs a .ti { font-size: 20px; line-height: 1.1; }
.tabs a.on { color: var(--accent); }

/* buttons & inputs */
button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; }
button.ghost, .ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.small, .small.ghost { padding: 6px 12px; font-size: 14px; }
button.danger, .ghost.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: transparent; }
button:disabled { opacity: .5; }
input, select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; margin: 0; }
textarea { resize: vertical; }
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* cards */
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 0 0 10px; color: var(--text); text-decoration: none; }
button.card { width: 100%; text-align: left; font-weight: 400; }
.card.row { display: flex; align-items: center; gap: 12px; }
.card.row small { display: block; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.card.overdue { border-color: var(--bad); }
.card.due { border-color: var(--warn); }
.when { min-width: 64px; font-weight: 600; font-size: 14px; }
.when small { display: block; color: var(--muted); font-weight: 400; }

/* home */
.weather-mini { display: flex; align-items: center; gap: 14px; }
.wm-now { display: flex; align-items: center; gap: 4px; }
.wm-icon { font-size: 34px; }
.wm-temp { font-size: 30px; font-weight: 600; }
.wm-text { display: flex; flex-direction: column; font-size: 14px; }
.notice.pinned { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }

/* lists */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chip { flex: none; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 20px; padding: 8px 14px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip .count { font-size: 12px; opacity: .75; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 2px; }
.add-item { display: flex; gap: 8px; margin: 0 0 12px; }
.add-item input { flex: 1; }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 6px; }
.item-text { flex: 1; background: none; color: var(--text); text-align: left; padding: 10px 4px; font-weight: 400; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.item-text small { color: var(--muted); }
.item.done .item-text { text-decoration: line-through; color: var(--muted); }
.done-box { margin: 16px 0; }
.done-box summary { color: var(--muted); cursor: pointer; padding: 8px 2px; }

/* bills */
.month-total { padding: 10px 12px; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.totals small { display: block; color: var(--muted); }
.totals b { font-size: 17px; }
.bill { display: flex; align-items: center; gap: 10px; }
.bill-main { flex: 1; min-width: 0; background: none; color: var(--text); text-align: left; padding: 0; font-weight: 400; display: flex; flex-direction: column; }
.bill .amount { white-space: nowrap; }
.pay { padding: 8px 12px; }

/* calendar */
.grid-head, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.grid-head span { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cell { background: var(--panel); color: var(--text); border: 1px solid transparent; border-radius: 10px; padding: 6px 0 2px; min-height: 44px; font-weight: 500; display: flex; flex-direction: column; align-items: center; }
.cell.blank { background: none; }
.cell i { font-style: normal; color: var(--accent); font-size: 12px; line-height: 1; letter-spacing: 1px; }
.cell.today { border-color: var(--accent); }
.cell.sel { background: var(--accent); color: var(--accent-ink); }
.cell.sel i { color: var(--accent-ink); }
.day h3 { margin-top: 16px; }
.event .grow small { display: block; }

/* weather – fixed blocks, nothing expands */
.wx-place { margin: 4px 2px 0; }
.wx-head { padding: 6px 2px 14px; }
.wx-top { display: flex; align-items: center; gap: 12px; }
.big-icon { font-size: 58px; line-height: 1; }
.wx-temp { font-size: 72px; font-weight: 300; line-height: 1; }
.wx-temp sup { font-size: 22px; vertical-align: top; position: relative; top: 8px; }
.wx-hl { font-size: 24px; align-self: flex-end; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.wx-hl i { width: 1px; height: 22px; background: var(--muted); }
.wx-text { font-size: 24px; margin: 8px 0 2px; }
.wx-block h3 { margin: 0 0 10px; color: var(--text); font-size: 14px; }
.wx-hours { display: flex; gap: 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin: 0 -6px; padding: 0 6px; touch-action: pan-x pan-y; }
.wx-hours::-webkit-scrollbar { display: none; }
.wx-hour { flex: none; width: 54px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.wx-hour .hi { font-size: 22px; }
.rain { color: #8fc1ff; font-size: 11px; }
.wx-days { display: flex; flex-direction: column; }
.wx-day { display: grid; grid-template-columns: 1fr 32px 52px 34px 30px; align-items: center; gap: 6px; padding: 4px 0; }
.wx-day .di { font-size: 20px; text-align: center; }
.wx-day b, .wx-day > span:last-child { text-align: right; }
.wx-day.warned .dn { color: var(--warn); }
.wx-air { display: flex; align-items: center; justify-content: space-between; }
.wx-air h3 { margin: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 6px; vertical-align: middle; background: var(--ok); }
.dot.fair { background: var(--warn); }
.dot.poor { background: var(--bad); }
.wx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; }
.wx-cell { display: flex; align-items: center; gap: 10px; }
.wx-cell small { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.ci { width: 38px; height: 38px; border-radius: 10px; background: var(--panel-2); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex: none; }
.sub { text-align: center; color: var(--muted); font-size: 12px; text-transform: uppercase; margin: 22px 0 6px; }
.arc { display: block; width: 70%; max-width: 260px; margin: 0 auto; overflow: visible; }
.arc-track { fill: none; stroke: var(--line); stroke-width: 2; }
.arc-done { fill: none; stroke: #f5c542; stroke-width: 2; }
.sun { fill: #f5c542; }
.sun.down { fill: #fff; }
.sunrow { display: flex; justify-content: space-between; align-items: flex-end; text-align: center; padding: 0 6%; }
.sunrow small { display: block; color: var(--muted); }
.moonbox { text-align: center; }
.moon { width: 72px; height: 72px; display: block; margin: 0 auto 6px; }
.moon-dark { fill: #3a3424; }
.moon-lit { fill: #f5c542; }
.wx-health { display: flex; flex-direction: column; gap: 8px; }
.hrow { display: flex; align-items: center; gap: 12px; }
.results .card { margin-top: 6px; }
.results small { display: block; }

/* dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 14px; }
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; position: sticky; bottom: -16px; background: var(--panel); padding: 8px 0; }
.rem { display: flex; gap: 8px; }
.rem select { flex: 1; }
.rem .minutes { width: 110px; flex: none; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; z-index: 30; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.4); }

/* sign-in */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding-bottom: 0; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.login-card h1 { margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 16px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.login-card button { width: 100%; margin-top: 18px; padding: 12px; }
.login-card .err { color: var(--bad); margin: 10px 0 0; }
