:root {
  --bg: #fbfaf7;
  --ink: #20232a;
  --muted: #6c717b;
  --line: rgba(24, 30, 38, 0.12);
  --teal: #058c8c;
  --teal-dark: #04716f;
  --gold: #d89100;
  --red: #df1f2d;
  --green: #2f8b41;
  --blue: #206acb;
  --surface: #ffffff;
  --soft: #f1eee8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { background: #ebe6dc; }
body { margin: 0; min-height: 100dvh; background: #ebe6dc; color: var(--ink); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 24px calc(92px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 0 60px rgba(38, 30, 18, 0.14);
}
.topbar, .brand, .streak, .jars, .section-title, .goal-row, .tabbar { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: 16px; }
.brand { flex: 1; min-width: 0; gap: 10px; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; object-fit: cover; }
.kicker { margin: 0 0 2px; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.11em; font-weight: 800; }
h1 { margin: 0; font-size: 1.9rem; line-height: 0.94; letter-spacing: -0.05em; white-space: nowrap; }
.streak { flex-direction: column; justify-content: center; min-width: 76px; min-height: 48px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); }
.streak span { color: var(--red); font-size: 1.6rem; font-weight: 900; line-height: 1; }
.streak small { color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
.hero { text-align: center; padding: 16px 0 12px; }
.hero p { margin: 0 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; }
.hero strong { display: block; font-size: clamp(3.45rem, 15vw, 4.6rem); line-height: 0.95; letter-spacing: -0.06em; }
.jars { gap: 12px; margin-bottom: 12px; }
.jar-card { flex: 1; min-width: 0; display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.jar-card img { width: 58px; height: 58px; object-fit: cover; border-radius: 16px; }
.jar-card span { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.jar-card strong { display: block; font-size: 1.35rem; line-height: 1; letter-spacing: -0.04em; }
.jar-card-spend strong { color: var(--teal-dark); }
.jar-card-save strong { color: var(--gold); }
.panel { margin-top: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); }
.section-title { justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-title span, .quick-add h2, .history h2, .settings h2 { margin: 0; color: var(--teal-dark); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 900; }
.text-button { border: 0; background: transparent; color: var(--teal-dark); font-weight: 800; cursor: pointer; }
.goal-row { gap: 16px; }
.goal-art { width: 76px; height: 76px; border-radius: 999px; object-fit: cover; border: 4px solid rgba(5, 140, 140, 0.15); }
.goal-copy { flex: 1; min-width: 0; }
.goal-copy h2 { margin: 0 0 4px; font-size: 1.2rem; }
.goal-copy p { margin: 0 0 8px; color: var(--muted); font-size: 1.1rem; font-weight: 800; }
.goal-copy p strong { color: var(--teal-dark); font-size: 1.28rem; }
.goal-copy small { display: block; margin-top: 8px; color: var(--teal-dark); font-weight: 800; }
.meter { height: 14px; overflow: hidden; border-radius: 999px; background: #e8e2d8; }
.meter span { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #10a9a4); transition: width 220ms ease; }
.quick-add form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend, label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 900; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border: 1px solid var(--line); border-radius: 18px; background: var(--soft); }
.segmented button { min-height: 44px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); font-weight: 900; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--teal); color: white; box-shadow: 0 8px 18px rgba(5, 140, 140, 0.22); }
.segmented [data-dir="out"][aria-pressed="true"] { background: var(--red); box-shadow: 0 8px 18px rgba(223, 31, 45, 0.18); }
.two-tone [data-jar="save"][aria-pressed="true"] { background: var(--gold); box-shadow: 0 8px 18px rgba(216, 145, 0, 0.18); }
.amount-label, .note-label { display: block; }
.amount-label input, .note-label input { width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: 16px; padding: 0 16px; background: #fff; color: var(--ink); font-size: 1.1rem; outline: none; }
.amount-label input:focus, .note-label input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(5, 140, 140, 0.12); }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; align-self: end; }
.chips button { min-height: 52px; border: 0; border-radius: 16px; background: #f0f3f1; color: var(--teal-dark); font-weight: 900; cursor: pointer; }
.note-label, .primary, output { grid-column: 1 / -1; }
.primary, .danger { min-height: 52px; border: 0; border-radius: 18px; color: white; font-weight: 950; text-transform: uppercase; letter-spacing: 0.03em; cursor: pointer; }
.primary { background: var(--teal); }
.danger { width: 100%; margin-top: 10px; background: var(--red); }
output { min-height: 1.2em; color: var(--red); font-size: 0.9rem; font-weight: 800; }
.history ol { list-style: none; padding: 0; margin: 0; }
.entry { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry strong { font-size: 1rem; }
.entry small { color: var(--muted); }
.entry .amount { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 1.2rem; font-weight: 950; }
.entry .in { color: var(--green); }
.entry .out { color: var(--red); }
.settings p { color: var(--muted); line-height: 1.4; }
[data-panel] { display: none; }
[data-view="home"] [data-panel~="home"], [data-view="goal"] [data-panel~="goal"], [data-view="history"] [data-panel~="history"], [data-view="settings"] [data-panel~="settings"] { display: block; }
[data-view="goal"] .goal-panel, [data-view="history"] .history { margin-top: 18px; }
.tabbar { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 10; transform: translateX(-50%); width: min(390px, calc(100% - 28px)); justify-content: space-around; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 26px; background: rgba(255, 255, 255, 0.92); box-shadow: 0 18px 48px rgba(38, 30, 18, 0.18); backdrop-filter: blur(18px); }
.tabbar button { flex: 1; min-height: 48px; border: 0; border-radius: 18px; background: transparent; color: var(--muted); font-weight: 900; cursor: pointer; }
.tabbar button[aria-current="page"] { background: rgba(5, 140, 140, 0.12); color: var(--teal-dark); }
@media (min-width: 820px) {
  .app { max-width: 920px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; padding-inline: 40px; }
  .topbar, .hero, .jars, .goal-panel, .tabbar { grid-column: 1 / -1; }
  .quick-add, .history, .settings { align-self: start; }
  .hero strong { font-size: 6.2rem; }
  .jars { max-width: 660px; justify-self: center; width: 100%; }
}

