:root {                    /* default: Royal — royal blue & gold */
  --bg: #0d1322; --panel: #15203a; --panel2: #1d2b4e; --line: #2b3c66;
  --text: #e9ecf5; --muted: #96a2c4; --accent: #d9b45b;
  --up: #66c98a; --down: #e0716f;
}
html[data-theme="ember"] {
  --bg: #111318; --panel: #191c24; --panel2: #222633; --line: #2a2f3c;
  --text: #eae7e0; --muted: #9298a8; --accent: #e5a558;
  --up: #69c98a; --down: #e0716f;
}
html[data-theme="ice"] {
  --bg: #0d1418; --panel: #141d23; --panel2: #1c2830; --line: #263540;
  --text: #e4ebee; --muted: #8fa3ad; --accent: #56c3dc;
  --up: #69c98a; --down: #e0716f;
}
html[data-theme="nocturne"] {
  --bg: #141020; --panel: #1c1730; --panel2: #262040; --line: #322a52;
  --text: #eae6f2; --muted: #9d94b8; --accent: #a78bda;
  --up: #69c98a; --down: #e0716f;
}
html[data-theme="paper"] { /* light */
  --bg: #f5f2ec; --panel: #fdfbf7; --panel2: #ece6d8; --line: #d8d1c0;
  --text: #29261f; --muted: #7a7468; --accent: #8a6d1d;
  --up: #1a8f4a; --down: #c04543;
}
:root {
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --up-soft: color-mix(in srgb, var(--up) 14%, transparent);
  --down-soft: color-mix(in srgb, var(--down) 14%, transparent);
  --radius: 14px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px)
           calc(env(safe-area-inset-right) + 16px)
           calc(env(safe-area-inset-bottom) + 28px)
           calc(env(safe-area-inset-left) + 16px);
  -webkit-tap-highlight-color: transparent;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.theme-row { margin-top: 26px; display: flex; align-items: center; gap: 12px; justify-content: center; }
.theme-label { color: var(--muted); font-size: 0.75rem; }
.theme-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.theme-dot.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.foot-note { color: var(--muted); font-size: 0.72rem; text-align: center; margin-top: 8px; line-height: 1.5; }

/* ---------- Tally app styles (CSS variables only) ---------- */

input { font: inherit; color: inherit; }

.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.app-name { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; }
.icon-btn { color: var(--muted); padding: 6px; border-radius: 8px; display: flex; align-items: center; }
.icon-btn:active { color: var(--accent); }

.link { color: var(--muted); font-size: 0.85rem; text-decoration: underline; text-underline-offset: 3px; }
.link:active { color: var(--text); }

/* big tap target */
.tapwrap { display: flex; flex-direction: column; align-items: center; gap: 14px; margin: 8px 0 18px; }
.big-tap {
  width: min(68vw, 300px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s ease, border-color 0.08s ease;
}
.big-tap:active { transform: scale(0.97); border-color: var(--accent); background: var(--panel2); }
.big-tap .plus { font-size: 2.8rem; line-height: 1; }
.big-tap .sub { font-size: 0.82rem; color: var(--muted); }

.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: 0.85rem; touch-action: manipulation;
}
.chip.sel { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

.undo-slot { height: 24px; display: flex; justify-content: center; align-items: center; }
.undo-btn { color: var(--accent); font-size: 0.85rem; text-decoration: underline; text-underline-offset: 3px; padding: 2px 10px; }

/* today line */
.today-row { display: flex; align-items: center; gap: 10px; padding: 4px 2px 12px; }
.today-count { font-size: 1.1rem; }
.label { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.dots { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.beer { background: var(--accent); }
.dot.wine { background: var(--muted); }
.dot.spirit { background: transparent; border: 2px solid var(--accent); }
.dot.other { background: transparent; border: 2px solid var(--muted); }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }

/* week block */
.week-line { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.week-count { font-size: 1.2rem; }
.week-sep { color: var(--muted); font-size: 0.85rem; }
.tgt { color: var(--text); font-size: 1rem; text-decoration: underline dotted; text-underline-offset: 3px; padding: 0 2px; }
.tgt-input {
  width: 64px; font-size: 16px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); padding: 3px 8px; text-align: right;
}
.bar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; }
.spend-line { color: var(--muted); font-size: 0.8rem; margin-top: 10px; }

/* trend */
.trend-label { margin-bottom: 8px; }
.trend { display: flex; align-items: flex-end; gap: 12px; height: 80px; }
.tcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.tbar { display: block; width: 16px; border-radius: 4px; background: var(--muted); opacity: 0.55; }
.tbar.cur { background: transparent; border: 2px solid var(--accent); opacity: 1; }
.tval { font-size: 0.75rem; color: var(--muted); }

/* streak */
.streak-line { color: var(--muted); font-size: 0.85rem; padding: 2px 2px 12px; }
.streak-line .mono { color: var(--text); }
.streak-note { color: var(--muted); }

/* history */
.hist-toggle { display: block; margin: 0 auto 12px; }
.hist-panel { padding: 6px 16px; }
.hrow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.hrow:last-child { border-bottom: none; }
.hdate { width: 56px; flex-shrink: 0; color: var(--muted); font-size: 0.82rem; }
.hdate.today { color: var(--accent); }
.hsep { color: var(--muted); }
.hcount { min-width: 16px; text-align: right; }
.htypes { flex: 1; color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step {
  width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font-size: 1.05rem; line-height: 1; flex-shrink: 0; touch-action: manipulation;
}
.step:active { border-color: var(--accent); background: var(--accent-soft); }
.step.off { opacity: 0.35; }

/* empty state */
.empty {
  border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted);
  text-align: center; padding: 22px 16px; font-size: 0.9rem; line-height: 1.5; margin-bottom: 12px;
}

/* settings */
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.panel > :first-child { border-top: none; }
.set-label { font-size: 0.9rem; }
.set-note { color: var(--muted); font-size: 0.75rem; padding: 8px 0 2px; }
.txt-input {
  font-size: 16px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 8px 10px; width: 96px; text-align: right;
}
.switch {
  position: relative; width: 42px; height: 25px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
  border-radius: 50%; background: var(--muted);
  transition: left 0.15s ease, background 0.15s ease;
}
.switch.on { background: var(--accent-soft); border-color: var(--accent); }
.switch.on::after { left: 19px; background: var(--accent); }
.btn-row { display: flex; gap: 10px; padding: 12px 0 4px; border-top: 1px solid var(--line); }
.action-btn {
  flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel2); color: var(--text); font-size: 0.9rem;
}
.action-btn:active { border-color: var(--accent); }
.import-msg { color: var(--muted); font-size: 0.8rem; padding-top: 8px; }
