:root {
  /* Layout: app shell. Rail nav at >=960px; sticky header + bottom tab bar on phones. Content is a feed of cards, one column on phones, two on desktop. */
  --bg: #F2F5F3;
  --surface: #FFFFFF;
  --surface-2: #F5F7F6;
  --surface-3: #E9EEEB;
  --paper: #FCFDFB;
  --ink: #17201C;
  --ink-2: #4A5651;
  --muted: #65706B;
  --line: #E2E8E5;
  --line-strong: #C9D2CD;
  --accent: #0C7F57;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1F2E9;
  --accent-track: #D3ECDF;
  --in: #2563D9;
  --out: #D2363D;
  --warn: #E39B0B;
  --warn-ink: #9A5E00;
  --crit: #D03B3B;
  --scrim: rgba(12, 18, 15, .42);
  --toast-bg: #17201C;
  --toast-fg: #F2F5F3;
  --toast-act: #8FE3BD;
  --shadow: 0 1px 2px rgba(23, 32, 28, .04), 0 6px 20px rgba(23, 32, 28, .05);
  --shadow-lg: 0 18px 50px rgba(23, 32, 28, .18);
  --radius: 20px;
  --font-ui: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-display: "Do Hyeon", "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: "IBM Plex Mono", "IBM Plex Sans KR", ui-monospace, Consolas, monospace;
}

/* colour themes (light) — picked in 설정; dark versions follow the dark blocks */
:root[data-pal="ocean"] { --accent: #0B6E8A; --bg: #F0F5F7; --surface-2: #F3F7F9; --surface-3: #E5EDF1; --line: #DCE6EB; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: color-mix(in srgb, #0B6E8A 35%, #fff); }
:root[data-pal="sunset"] { --accent: #B9461A; --bg: #F7F3F0; --surface-2: #FAF6F3; --surface-3: #EFE7E1; --line: #E9E0D9; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: color-mix(in srgb, #B9461A 35%, #fff); }
:root[data-pal="lavender"] { --accent: #6544C4; --bg: #F4F3F9; --surface-2: #F7F6FB; --surface-3: #EAE7F4; --line: #E2DFEF; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: color-mix(in srgb, #6544C4 35%, #fff); }
:root[data-pal="blossom"] { --accent: #B4245F; --bg: #F9F2F5; --surface-2: #FBF6F8; --surface-3: #F1E5EA; --line: #ECDDE3; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: color-mix(in srgb, #B4245F 35%, #fff); }
:root[data-pal="graphite"] { --accent: #374151; --bg: #F3F4F5; --surface-2: #F6F7F8; --surface-3: #E8EAED; --line: #E1E4E8; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: color-mix(in srgb, #374151 35%, #fff); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1311; --surface: #161C19; --surface-2: #1C2420; --surface-3: #252E2A; --paper: #1B221F;
    --ink: #ECF1EE; --ink-2: #B3BEB9; --muted: #8E9993; --line: #27312D; --line-strong: #3A4641;
    --accent: #34B382; --accent-ink: #05140D; --accent-soft: #143528; --accent-track: #1E4434;
    --in: #6AA3FF; --out: #FF6E73; --warn: #F0A92A; --warn-ink: #F3B54A; --crit: #FF6B6B;
    --scrim: rgba(0, 0, 0, .6); --toast-bg: #ECF1EE; --toast-fg: #0E1311; --toast-act: #0C7F57;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .03); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1311; --surface: #161C19; --surface-2: #1C2420; --surface-3: #252E2A; --paper: #1B221F;
  --ink: #ECF1EE; --ink-2: #B3BEB9; --muted: #8E9993; --line: #27312D; --line-strong: #3A4641;
  --accent: #34B382; --accent-ink: #05140D; --accent-soft: #143528; --accent-track: #1E4434;
  --in: #6AA3FF; --out: #FF6E73; --warn: #F0A92A; --warn-ink: #F3B54A; --crit: #FF6B6B;
  --scrim: rgba(0, 0, 0, .6); --toast-bg: #ECF1EE; --toast-fg: #0E1311; --toast-act: #0C7F57;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .03); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-pal="ocean"]:not([data-theme="light"]) { --accent: #3CB4D3; --accent-ink: #04161C; --bg: #0C1316; --surface: #141C20; --surface-2: #1A2328; --surface-3: #232D33; --line: #26323A; --paper: #1A2328; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #0B6E8A; }
  :root[data-pal="sunset"]:not([data-theme="light"]) { --accent: #F58A55; --accent-ink: #1E0C04; --bg: #15110F; --surface: #1D1815; --surface-2: #241E1A; --surface-3: #2E2621; --line: #322A24; --paper: #241E1A; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #B9461A; }
  :root[data-pal="lavender"]:not([data-theme="light"]) { --accent: #A68CF6; --accent-ink: #120A26; --bg: #111018; --surface: #18171F; --surface-2: #1F1D28; --surface-3: #282634; --line: #2C2A38; --paper: #1F1D28; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #6544C4; }
  :root[data-pal="blossom"]:not([data-theme="light"]) { --accent: #F17AAE; --accent-ink: #24060F; --bg: #161013; --surface: #1E171A; --surface-2: #251D21; --surface-3: #2F252A; --line: #33282E; --paper: #251D21; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #B4245F; }
  :root[data-pal="graphite"]:not([data-theme="light"]) { --accent: #B8C2CF; --accent-ink: #0F1216; --bg: #0F1113; --surface: #17191C; --surface-2: #1D2024; --surface-3: #26292E; --line: #2B2F34; --paper: #1D2024; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #374151; }
}
:root[data-pal="ocean"][data-theme="dark"] { --accent: #3CB4D3; --accent-ink: #04161C; --bg: #0C1316; --surface: #141C20; --surface-2: #1A2328; --surface-3: #232D33; --line: #26323A; --paper: #1A2328; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #0B6E8A; }
:root[data-pal="sunset"][data-theme="dark"] { --accent: #F58A55; --accent-ink: #1E0C04; --bg: #15110F; --surface: #1D1815; --surface-2: #241E1A; --surface-3: #2E2621; --line: #322A24; --paper: #241E1A; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #B9461A; }
:root[data-pal="lavender"][data-theme="dark"] { --accent: #A68CF6; --accent-ink: #120A26; --bg: #111018; --surface: #18171F; --surface-2: #1F1D28; --surface-3: #282634; --line: #2C2A38; --paper: #1F1D28; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #6544C4; }
:root[data-pal="blossom"][data-theme="dark"] { --accent: #F17AAE; --accent-ink: #24060F; --bg: #161013; --surface: #1E171A; --surface-2: #251D21; --surface-3: #2F252A; --line: #33282E; --paper: #251D21; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #B4245F; }
:root[data-pal="graphite"][data-theme="dark"] { --accent: #B8C2CF; --accent-ink: #0F1216; --bg: #0F1113; --surface: #17191C; --surface-2: #1D2024; --surface-3: #26292E; --line: #2B2F34; --paper: #1D2024; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface)); --toast-act: #374151; }

/* 항상 같은 색 테마 — 기기의 밝게·어둡게 설정과 상관없이 늘 이 색을 써요. html:root로 위의 어두운 화면 규칙보다 앞서요. */
html:root[data-pal="hanji"] {
  --bg: #F1ECE2; --surface: #FBF8F2; --surface-2: #F5F0E6; --surface-3: #E8E1D3; --paper: #FFFDF8;
  --ink: #29241D; --ink-2: #574E43; --muted: #6F6355; --line: #E2D9C9; --line-strong: #CBBFAA;
  --accent: #2E4A7D; --accent-ink: #FFFFFF; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface));
  --in: #1F6F68; --out: #B2392E; --warn: #C98A12; --warn-ink: #865700; --crit: #B2392E;
  --scrim: rgba(41,36,29, .42); --toast-bg: #29241D; --toast-fg: #F1ECE2; --toast-act: #A9BDE3;
  --shadow: 0 1px 2px rgba(41,36,29, .05), 0 6px 20px rgba(41,36,29, .06); --shadow-lg: 0 18px 50px rgba(41,36,29, .2);
  color-scheme: light;
}
html:root[data-pal="citrus"] {
  --bg: #FFF4E6; --surface: #FFFFFF; --surface-2: #FFF8EF; --surface-3: #FBE9D4; --paper: #FFFCF7;
  --ink: #2A1C10; --ink-2: #5B4433; --muted: #78604E; --line: #F3E1CC; --line-strong: #E3C7A8;
  --accent: #B0500E; --accent-ink: #FFFFFF; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface));
  --in: #2459C9; --out: #C42B3A; --warn: #D99500; --warn-ink: #8A5700; --crit: #C42B3A;
  --scrim: rgba(42,28,16, .42); --toast-bg: #2A1C10; --toast-fg: #FFF4E6; --toast-act: #FFB98A;
  --shadow: 0 1px 2px rgba(42,28,16, .05), 0 6px 20px rgba(42,28,16, .06); --shadow-lg: 0 18px 50px rgba(42,28,16, .2);
  color-scheme: light;
}
html:root[data-pal="sky"] {
  --bg: #EBF1FB; --surface: #FFFFFF; --surface-2: #F3F6FC; --surface-3: #DFE7F6; --paper: #FAFCFF;
  --ink: #131A2C; --ink-2: #444E66; --muted: #626C86; --line: #DCE3F1; --line-strong: #BFCAE0;
  --accent: #2B4FCF; --accent-ink: #FFFFFF; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface));
  --in: #0F7F6C; --out: #CF3440; --warn: #D99500; --warn-ink: #8A5700; --crit: #CF3440;
  --scrim: rgba(19,26,44, .42); --toast-bg: #131A2C; --toast-fg: #EBF1FB; --toast-act: #A9BCFF;
  --shadow: 0 1px 2px rgba(19,26,44, .05), 0 6px 20px rgba(19,26,44, .06); --shadow-lg: 0 18px 50px rgba(19,26,44, .2);
  color-scheme: light;
}
html:root[data-pal="mintchoco"] {
  --bg: #E1F3EE; --surface: #FBFEFD; --surface-2: #EDF8F4; --surface-3: #D2ECE5; --paper: #FFFFFF;
  --ink: #2B1D17; --ink-2: #57463E; --muted: #6A5B53; --line: #D0E9E2; --line-strong: #AED5CA;
  --accent: #6A3E2A; --accent-ink: #FFFFFF; --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 22%, var(--surface));
  --in: #1E62C9; --out: #C8323C; --warn: #D99500; --warn-ink: #835300; --crit: #C8323C;
  --scrim: rgba(43,29,23, .42); --toast-bg: #2B1D17; --toast-fg: #E1F3EE; --toast-act: #8FE3CB;
  --shadow: 0 1px 2px rgba(43,29,23, .05), 0 6px 20px rgba(43,29,23, .06); --shadow-lg: 0 18px 50px rgba(43,29,23, .2);
  color-scheme: light;
}
html:root[data-pal="night"] {
  --bg: #0A0F1F; --surface: #121A2E; --surface-2: #18213A; --surface-3: #212B47; --paper: #161F36;
  --ink: #E9EDF8; --ink-2: #B0B9D1; --muted: #8892AF; --line: #222C47; --line-strong: #34405F;
  --accent: #F2C35A; --accent-ink: #1C1503; --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 28%, var(--surface));
  --in: #7DA9FF; --out: #FF7E8A; --warn: #F0A92A; --warn-ink: #F5BC52; --crit: #FF7070;
  --scrim: rgba(0, 0, 0, .62); --toast-bg: #E9EDF8; --toast-fg: #0A0F1F; --toast-act: #8A6510;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
html:root[data-pal="cocoa"] {
  --bg: #15100D; --surface: #1F1814; --surface-2: #271F1A; --surface-3: #312721; --paper: #231B16;
  --ink: #F4EBE3; --ink-2: #CBBAAB; --muted: #A08E7F; --line: #33281F; --line-strong: #4A3C31;
  --accent: #E7A867; --accent-ink: #1F1206; --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 28%, var(--surface));
  --in: #86B5FF; --out: #FF8679; --warn: #F0A92A; --warn-ink: #F5BC52; --crit: #FF7A6E;
  --scrim: rgba(0, 0, 0, .62); --toast-bg: #F4EBE3; --toast-fg: #15100D; --toast-act: #8C531B;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
html:root[data-pal="wine"] {
  --bg: #170B12; --surface: #22111B; --surface-2: #2A1622; --surface-3: #351D2B; --paper: #261420;
  --ink: #F7E8EF; --ink-2: #D2B2C1; --muted: #AD8A9B; --line: #3A2130; --line-strong: #553044;
  --accent: #FF8DB3; --accent-ink: #2A0716; --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 28%, var(--surface));
  --in: #8DB6FF; --out: #FF9A6B; --warn: #F0A92A; --warn-ink: #F5BC52; --crit: #FF8A6B;
  --scrim: rgba(0, 0, 0, .62); --toast-bg: #F7E8EF; --toast-fg: #170B12; --toast-act: #A3335B;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
html:root[data-pal="neon"] {
  --bg: #0C0A18; --surface: #151226; --surface-2: #1C1832; --surface-3: #252041; --paper: #19152D;
  --ink: #EEEAFF; --ink-2: #B8B0DA; --muted: #9088B6; --line: #262043; --line-strong: #3A3264;
  --accent: #34E0F0; --accent-ink: #021A1E; --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface)); --accent-track: color-mix(in srgb, var(--accent) 28%, var(--surface));
  --in: #B48CFF; --out: #FF5FA2; --warn: #FFC23D; --warn-ink: #FFD36B; --crit: #FF5F7E;
  --scrim: rgba(0, 0, 0, .62); --toast-bg: #EEEAFF; --toast-fg: #0C0A18; --toast-act: #0A7D88;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 50; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.sm { width: 16px; height: 16px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.in-c { color: var(--in); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.app {
  display: grid; grid-template-columns: minmax(0, 1fr);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.main { min-width: 0; width: 100%; max-width: 1080px; padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
.rail { display: none; }
.brand { font-family: var(--font-display); font-size: 24px; line-height: 1; color: var(--ink); display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.brand b { font-weight: 400; }
.brand b::after { content: "."; color: var(--accent); }
.brand small { font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }

.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 8px; min-height: 60px;
  background: var(--bg); box-shadow: 0 0 0 100vmax var(--bg); clip-path: inset(0 -100vmax);
}
.top .brand { font-size: 21px; }
.month { display: flex; align-items: center; gap: 2px; margin-inline: auto; }
.month-label { font-size: 17px; font-weight: 700; padding: 6px 8px; border-radius: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.month-label:hover { background: var(--surface-3); }
.top-end { display: flex; align-items: center; gap: 4px; flex: none; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; padding: 0 4px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.sync[data-s="busy"]::before { background: var(--warn); }
.sync[data-s="error"]::before, .sync[data-s="local"]::before { background: var(--crit); }
.sync[data-s="loading"]::before { background: var(--line-strong); }
.sync .t { display: none; }
.top-end { margin-left: auto; }
#notice:not(:empty) { margin-bottom: 16px; }
[data-o="1"] { order: 1; } [data-o="2"] { order: 2; } [data-o="3"] { order: 3; } [data-o="4"] { order: 4; }
[data-o="5"] { order: 5; } [data-o="6"] { order: 6; } [data-o="7"] { order: 7; } [data-o="8"] { order: 8; } [data-o="9"] { order: 9; } [data-o="10"] { order: 10; } [data-o="11"] { order: 11; }
@media (max-width: 420px) { .month-label .y.cur { display: none; } .top .brand small { display: none; } }

@media (min-width: 960px) {
  .app { grid-template-columns: 208px minmax(0, 1fr); column-gap: 32px; }
  .rail {
    display: flex; flex-direction: column; gap: 22px;
    position: sticky; top: env(safe-area-inset-top, 0px); align-self: start;
    height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding-block: 26px 20px;
  }
  .main { padding-bottom: 56px; }
  .top { clip-path: inset(0 -100vmax 0 -32px); }
  .top .brand, .only-phone { display: none !important; }
  .month { margin-inline: 0 auto; }
  .sync .t { display: inline; }
}
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 500; color: var(--ink-2); }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.nav-item[aria-current="page"] .i { color: var(--accent); }
.rail-foot { margin-top: auto; font-size: 12px; color: var(--muted); line-height: 1.6; }

.tabbar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 10px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tab[aria-current="page"] .i { color: var(--accent); }
.tab-add {
  justify-self: center; width: 52px; height: 52px; margin: -16px 0 9px; border-radius: 18px;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 32%, transparent);
}
.tab-add:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.tab-add .i { width: 26px; height: 26px; stroke-width: 2.2; }
@media (min-width: 960px) { .tabbar { display: none; } }

/* ---------- common ---------- */
.view { display: grid; gap: 16px; padding-top: 4px; }
.view-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 40px; }
.view-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; text-wrap: balance; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-t { font-size: 15px; font-weight: 600; }
.card-link { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 500; color: var(--muted); padding: 4px 2px 4px 6px; border-radius: 8px; }
.card-link:hover { color: var(--ink); }
.card-link .i { width: 15px; height: 15px; }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.cols > .col { display: contents; }
@media (min-width: 760px) {
  .cols { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; }
  .cols > .col { display: grid; gap: 16px; min-width: 0; }
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.btn .i { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn-soft { background: var(--surface-3); color: var(--ink); }
.btn-soft:hover { background: var(--line); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--crit); }
.btn-danger:hover { background: var(--surface-3); }
.btn-sm { padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; padding: 14px 16px; font-size: 16px; border-radius: 14px; }
.rail .btn-block { padding: 12px 16px; font-size: 15px; }

.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-3); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 14px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap; text-align: center; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 13px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

.input { width: 100%; min-width: 0; padding: 10px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 16px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; background: var(--surface); }
select.input { padding-right: 32px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }

.emo { width: 38px; height: 38px; border-radius: 13px; background: var(--surface-2); display: grid; place-items: center; font-size: 19px; line-height: 1; flex: none; color: var(--ink-2); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; line-height: 1.5; padding: 0 6px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); vertical-align: 1px; margin-left: 4px; white-space: nowrap; }
.tag.sub { background: var(--accent-soft); color: var(--accent); }

.notice { display: flex; gap: 10px 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--accent-soft); border-radius: 16px; padding: 12px 14px 12px 16px; font-size: 14px; }
.notice.warn { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--warn); }
.notice p { flex: 1 1 260px; }
.notice .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.notice .btn-sm.btn-soft { background: var(--surface); }

.empty { display: grid; justify-items: center; gap: 6px; padding: 26px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.empty b { color: var(--ink); font-size: 15.5px; font-weight: 600; }
.empty .btn { margin-top: 8px; }

/* ---------- home ---------- */
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hero-label { font-size: 14.5px; font-weight: 500; color: var(--ink-2); }
.hero-num { font-size: clamp(36px, 9vw, 48px); font-weight: 700; letter-spacing: -.035em; line-height: 1.15; margin-top: 6px; overflow-wrap: anywhere; }
.hero-num .u { font-size: .46em; font-weight: 600; letter-spacing: 0; margin-left: 3px; color: var(--ink-2); }
.delta { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; font-size: 13px; font-weight: 500; padding: 4px 10px 4px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.delta .i { width: 15px; height: 15px; stroke-width: 2.2; }
.delta.good { background: var(--accent-soft); color: var(--accent); }
.delta.bad { background: var(--surface-2); color: var(--warn-ink); box-shadow: inset 0 0 0 1px var(--warn); }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.stat-l { display: block; font-size: 12.5px; color: var(--muted); }
.stat-v { display: block; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.meter { height: 10px; border-radius: 999px; background: var(--accent-track); overflow: hidden; }
.meter > span { display: block; height: 100%; min-width: 0; border-radius: 999px; background: var(--accent); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.meter.warn { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); }
.meter.warn > span { background: var(--warn); }
.meter.over { background: color-mix(in srgb, var(--crit) 20%, var(--surface)); }
.meter.over > span { background: var(--crit); }
.meter.thin { height: 6px; }
.state { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 1px 8px 1px 6px; border-radius: 999px; white-space: nowrap; }
.state .i { width: 14px; height: 14px; stroke-width: 2.2; }
.state.warn { color: var(--warn-ink); background: color-mix(in srgb, var(--warn) 15%, var(--surface)); }
.state.over { color: var(--crit); background: color-mix(in srgb, var(--crit) 11%, var(--surface)); }
.bud-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.bud-pct { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.bud-pct small { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 4px; letter-spacing: 0; }
.bud-of { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bud-foot { margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.bud-foot b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.rank { display: grid; gap: 2px; }
.rank-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 40px; align-items: center; gap: 12px; padding: 8px; margin-inline: -8px; border-radius: 14px; width: calc(100% + 16px); text-align: left; }
button.rank-row:hover { background: var(--surface-2); }
.rank-main { display: grid; gap: 6px; min-width: 0; }
.rank-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.rank-name { font-weight: 500; overflow-wrap: anywhere; }
.rank-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.rank-pct { font-size: 12.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 14px; height: 0; border-top: 2.5px solid var(--accent); border-radius: 2px; }
.key.prev { border-top-color: var(--line-strong); }
.key.bud { border-top: 1.5px dashed var(--ink-2); }
.chart { position: relative; margin-top: 4px; touch-action: pan-y; border-radius: 8px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--line-strong); stroke-width: 1; }
.chart .tl { fill: var(--muted); font-size: 11px; font-family: var(--font-ui); }
.chart .lab { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: var(--font-ui); }
.chart .budl { stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 4 4; }
.chart .budt { fill: var(--ink-2); font-size: 11px; font-weight: 500; font-family: var(--font-ui); }
.chart .l-this { stroke: var(--accent); stroke-width: 2.5; fill: none; }
.chart .a-this { fill: var(--accent); opacity: .1; }
.chart .l-prev { stroke: var(--line-strong); stroke-width: 2; fill: none; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .xh { stroke: var(--ink-2); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; top: 4px; z-index: 3; pointer-events: none; min-width: 150px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 12px; padding: 8px 11px; font-size: 12.5px; }
.tip-d { font-weight: 600; margin-bottom: 4px; }
.tip-r { display: flex; align-items: center; gap: 8px; }
.tip-r .k { width: 12px; height: 0; border-top: 2.5px solid var(--accent); border-radius: 2px; }
.tip-r .k.prev { border-top-color: var(--line-strong); }
.tip-r .v { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 10px; }
.tip-r .n { color: var(--muted); }
.chart-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.tbl-wrap { max-height: 260px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--ink-2); }

.chart .dot-this { fill: var(--accent); }
.chart .dot-prev { fill: var(--line-strong); }
.welcome { display: grid; gap: 12px; padding: 28px 24px; max-width: 640px; }
.welcome-p { color: var(--ink-2); line-height: 1.7; max-width: 52ch; }
.welcome-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.welcome-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.welcome-list .i { color: var(--accent); margin-top: 1px; }
.welcome-list b { color: var(--ink); font-weight: 600; margin-right: 6px; }
.welcome-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- transactions ---------- */
.tx { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 8px; margin-inline: -8px; border-radius: 14px; width: calc(100% + 16px); text-align: left; }
.tx:hover { background: var(--surface-2); }
.tx .emo { width: 40px; height: 40px; font-size: 20px; border-radius: 14px; }
.tx-main { min-width: 0; display: grid; }
.tx-title { font-weight: 500; overflow-wrap: anywhere; }
.tx-sub { font-size: 12.5px; color: var(--muted); }
.tx-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.tx-amt.in { color: var(--in); }
.day + .day { margin-top: 6px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 0 6px; margin-bottom: 2px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.day-h b { color: var(--ink); font-weight: 600; font-size: 14px; }
.day-h .s { font-variant-numeric: tabular-nums; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.sumbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 14px 16px; }
.sumbar > div { min-width: 0; }
.sumbar > div + div { border-left: 1px solid var(--line); padding-left: 10px; }
.sumbar .stat-v { font-size: clamp(13.5px, 3.6vw, 16px); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select.input { width: auto; flex: 0 1 auto; padding-block: 8px; font-size: 14px; }
.search { position: relative; flex: 1 1 200px; min-width: 0; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; pointer-events: none; }
.search .input { padding: 8px 12px 8px 34px; font-size: 14px; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 500; color: var(--muted); padding-bottom: 2px; }
.cal-dow.sun { color: var(--out); }
.cal-dow.sat { color: var(--in); }
.cal-cell { min-height: 78px; min-width: 0; border-radius: 12px; padding: 5px 5px 6px; display: flex; flex-direction: column; align-items: stretch; gap: 0; background: var(--surface-2); font-size: 11px; line-height: 1.3; text-align: right; overflow: hidden; }
.cal-cell .d { font-size: 12.5px; font-weight: 600; color: var(--ink-2); text-align: left; margin-bottom: auto; }
.cal-cell .ce { font-size: 13px; line-height: 1.35; text-align: left; white-space: nowrap; letter-spacing: -1px; margin-bottom: 1px; }
.cal-cell .ci, .cal-cell .co { white-space: nowrap; }
@media (max-width: 380px) { .cal-cell .ci, .cal-cell .co { font-size: 9.5px; letter-spacing: -.4px; } }
.cal-cell .a-short { display: none; }
.cal.compact .cal-cell .a-full { display: none; }
.cal.compact .cal-cell .a-short { display: inline; }
@media (max-width: 560px) { .cal-cell .a-full { display: none; } .cal-cell .a-short { display: inline; } }
.cal.compact { gap: 3px; }
.cal.compact .cal-cell { min-height: 62px; padding: 4px 4px 5px; border-radius: 10px; }
.cal.compact .cal-cell .ce { font-size: 11.5px; }
.cal-hint { margin-left: 2px; }
.day-sheet { display: grid; gap: 16px; }
.day-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.day-sum .stat-v { font-size: 15.5px; }
.cal-cell .ci { color: var(--in); font-variant-numeric: tabular-nums; font-weight: 500; }
.cal-cell .co { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }
.cal-cell.h1 { background: color-mix(in srgb, var(--out) 6%, var(--surface-2)); }
.cal-cell.h2 { background: color-mix(in srgb, var(--out) 11%, var(--surface-2)); }
.cal-cell.h3 { background: color-mix(in srgb, var(--out) 17%, var(--surface-2)); }
.cal-cell.today .d { color: var(--accent); }
.cal-cell.today .d::after { content: "오늘"; font-size: 10px; margin-left: 3px; font-weight: 600; }
.cal-cell[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-cell.blank { background: transparent; pointer-events: none; }
.cal-day { margin-top: 16px; }
.cal-none { padding: 12px 0 4px; font-size: 14px; }
.cal-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.cal-legend i { width: 16px; height: 10px; border-radius: 3px; background: var(--surface-2); display: inline-block; }
.cal-legend i.h1 { background: color-mix(in srgb, var(--out) 6%, var(--surface-2)); }
.cal-legend i.h2 { background: color-mix(in srgb, var(--out) 11%, var(--surface-2)); }
.cal-legend i.h3 { background: color-mix(in srgb, var(--out) 17%, var(--surface-2)); }
@media (max-width: 420px) {
  .cal { gap: 3px; }
  .cal-cell { min-height: 66px; padding: 4px 3px 5px; font-size: 10px; border-radius: 10px; }
  .cal-cell .ce, .cal.compact .cal-cell .ce { font-size: 10px; letter-spacing: -1.5px; }
  .cal-hint { display: none; }
  .cal-cell.today .d::after { content: none; }
}

/* ---------- subscriptions ---------- */
.subs-hero { display: grid; gap: 2px; margin-bottom: 14px; }
.subs-hero .hero-num { font-size: clamp(30px, 7vw, 38px); margin-top: 2px; }
.sub-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 8px; margin-inline: -8px; width: calc(100% + 16px); border-radius: 14px; text-align: left; }
.sub-row:hover { background: var(--surface-2); }
.sub-row.paused { opacity: .55; }
.sub-row .emo { width: 40px; height: 40px; font-size: 20px; border-radius: 14px; }
.sub-name { font-weight: 500; overflow-wrap: anywhere; }
.sub-meta { font-size: 12.5px; color: var(--muted); }
.sub-end { display: grid; justify-items: end; gap: 3px; }
.sub-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dday { font-size: 11.5px; font-weight: 600; padding: 0 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; line-height: 1.7; }
.dday.soon { background: var(--accent-soft); color: var(--accent); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; border-radius: 999px; background: var(--line-strong); transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.receipt-wrap { filter: drop-shadow(0 6px 16px rgba(23, 32, 28, .1)); }
.receipt {
  background: var(--paper); color: var(--ink); font-family: var(--font-mono); font-size: 13px; line-height: 1.55;
  padding: 26px 22px 30px;
  -webkit-mask: radial-gradient(circle 5px at 50% 0, transparent 97%, #000) top / 14px 51% repeat-x, radial-gradient(circle 5px at 50% 100%, transparent 97%, #000) bottom / 14px 51% repeat-x;
  mask: radial-gradient(circle 5px at 50% 0, transparent 97%, #000) top / 14px 51% repeat-x, radial-gradient(circle 5px at 50% 100%, transparent 97%, #000) bottom / 14px 51% repeat-x;
}
.rc-title { text-align: center; font-family: var(--font-display); font-size: 21px; letter-spacing: .04em; }
.rc-sub { text-align: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.rc-rule { border: 0; border-top: 1.5px dashed var(--line-strong); margin: 14px 0; }
.rc-line { display: flex; align-items: baseline; gap: 6px; }
.rc-line .n { overflow-wrap: anywhere; min-width: 0; }
.rc-line .dots { flex: 1; min-width: 12px; border-bottom: 1.5px dotted var(--line-strong); transform: translateY(-4px); }
.rc-line .v { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rc-note { font-size: 11.5px; color: var(--muted); margin: 0 0 8px 0; }
.rc-total { font-weight: 600; font-size: 14.5px; }
.rc-bar { height: 38px; margin: 18px auto 6px; width: 78%; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px, var(--ink) 8px 11px, transparent 11px 12px, var(--ink) 12px 13px, transparent 13px 16px); opacity: .85; }
.rc-foot { text-align: center; font-size: 11px; color: var(--muted); letter-spacing: .08em; }

/* ---------- budget ---------- */
.bud-row { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 0; }
.bud-row + .bud-row { border-top: 1px solid var(--line); }
.bud-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bud-name { font-weight: 500; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bud-nums { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bud-nums b { color: var(--ink); font-weight: 600; }
.bud-row .meter { margin-top: 7px; }
.bud-left { font-size: 12.5px; color: var(--muted); margin-top: 5px; font-variant-numeric: tabular-nums; }

/* ---------- settings ---------- */
.set-list { display: grid; gap: 8px; }
.set-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 38px; gap: 8px; align-items: center; }
.set-row.m { grid-template-columns: minmax(0, 1fr) 38px; }
.set-row .emoji { text-align: center; padding-inline: 4px; font-size: 19px; }
.set-add { margin-top: 12px; }
.set-note { font-size: 13.5px; color: var(--ink-2); line-height: 1.65; }
.set-note + .set-note { margin-top: 8px; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: grid; align-items: end; justify-items: center; }
.scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade .2s ease; }
.sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg);
  padding: 18px max(20px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  animation: rise .26s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 640px) {
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; padding: 22px 24px 24px; max-height: calc(100vh - 48px); }
}
@keyframes rise { from { transform: translateY(28px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-h h2 { font-size: 18px; font-weight: 700; }
.field { display: grid; gap: 8px; min-width: 0; }
.lab { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.amt { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--line); padding: 2px 2px 8px; }
.amt:focus-within { border-bottom-color: var(--accent); }
.amt input { flex: 1; width: 100%; min-width: 0; border: 0; background: transparent; outline: none; font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; padding: 0; }
.amt input::placeholder { color: var(--line-strong); }
.amt span { font-size: 20px; font-weight: 600; color: var(--ink-2); }
.amt-hint { font-size: 12.5px; color: var(--muted); min-height: 1.2em; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick .chip { padding: 5px 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.quick .chip-x { display: inline-grid; place-items: center; padding: 5px 9px; color: var(--muted); }
.chip-x .i { width: 14px; height: 14px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.cat-opt { display: grid; justify-items: center; gap: 4px; padding: 10px 2px 8px; border-radius: 14px; background: var(--surface-2); border: 1.5px solid transparent; font-size: 12px; color: var(--ink-2); text-align: center; line-height: 1.25; overflow-wrap: anywhere; }
.cat-opt .e { font-size: 22px; line-height: 1; }
.cat-opt:hover { border-color: var(--line-strong); }
.cat-opt[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.learn { font-size: 12.5px; color: var(--accent); min-height: 0; }
.sheet-actions { display: flex; gap: 8px; align-items: center; }
.sheet-actions .btn-block { flex: 1; }
.sheet-note { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.b-grid { display: grid; gap: 8px; }
.b-item { display: grid; grid-template-columns: 34px minmax(0, 1fr) 132px; gap: 10px; align-items: center; }
.b-item .emo { width: 34px; height: 34px; font-size: 17px; border-radius: 11px; }
.b-item .input { text-align: right; font-variant-numeric: tabular-nums; padding-block: 8px; }

/* ---------- AI assistant ---------- */
.rail .ai-open { margin-top: -12px; padding: 11px 16px; font-size: 14.5px; }
.rail .ai-open .i, .ai-chip .i { color: var(--accent); }
.ai-log { display: grid; gap: 10px; align-content: start; min-height: 120px; max-height: min(50vh, 460px); overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.6; min-width: 0; }
.ai-t { white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.me { justify-self: end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.ai-msg.bot { justify-self: start; background: var(--surface-2); color: var(--ink); border-bottom-left-radius: 6px; }
.ai-msg.err { box-shadow: inset 0 0 0 1.5px var(--warn); }
.ai-msg.thinking { color: var(--muted); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.ai-changes { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ai-changes li::before { content: "✓"; color: var(--accent); font-weight: 700; margin-right: 6px; }
.ai-changes li.bad::before { content: "!"; color: var(--warn-ink); }
.ai-foot { display: flex; gap: 8px; margin-top: 8px; }
.ai-foot .btn-soft { background: var(--surface); }
.ai-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.ai-intro { display: grid; gap: 12px; font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.ai-ex { white-space: normal; text-align: left; }
.ai-note { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- habits, report, setup, sms, credit ---------- */
.habit-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.habit-row .sub { display: block; font-size: 12.5px; margin-top: 2px; }
.habit-num { display: block; font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.habit-num small { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 3px; letter-spacing: 0; }
.habit-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.report-num { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 8px; }
.report-num .muted { font-size: 14px; font-weight: 500; letter-spacing: 0; }
.report-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.report-list b { color: var(--ink); }
.cal-cell .cn { font-size: 10px; font-weight: 700; color: var(--accent); text-align: left; letter-spacing: -.3px; }
.setup-plan { display: grid; gap: 12px; }
.setup-cats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); }
.setup-cats b { color: var(--ink); font-weight: 600; }
.sms-open { justify-self: start; color: var(--accent); }
.sms-box textarea { font-size: 14px; resize: vertical; min-height: 88px; }
.credit-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
@media (max-width: 560px) { .credit-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .credit-form .btn { grid-column: 1 / -1; } }
.policy-card { display: grid; gap: 10px; justify-items: start; }

/* ---------- savings goals ---------- */
.view-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.goal-card { display: grid; gap: 14px; }
.goal-meter { position: relative; }
.goal-meter .plan-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--ink); }
.state.good { color: var(--accent); background: var(--accent-soft); }
.dep-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto 38px; gap: 10px; align-items: center; padding: 6px 0; }
.dep-row .emo { font-size: 16px; font-weight: 700; }

/* ---------- loans ---------- */
.loan-sum .stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (min-width: 760px) { .loan-sum .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.loan-card { display: grid; gap: 14px; }
.loan-top { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.loan-top .emo { width: 40px; height: 40px; border-radius: 14px; }
.loan-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.loan-meta { font-size: 12.5px; color: var(--muted); }
.loan-prog { display: grid; gap: 7px; }
.loan-prog .row { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.loan-prog .row b { color: var(--ink); font-weight: 600; }
.loan-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.loan-facts .stat-v { font-size: 15.5px; }
.loan-facts .sub { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.loan-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.tbl tr.paid td { color: var(--muted); }
.tbl tr.now td { background: var(--accent-soft); font-weight: 600; }
.tbl-wrap.tall { max-height: min(60vh, 520px); }

/* ---------- theme picker / backup ---------- */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.theme-opt { display: grid; gap: 8px; justify-items: stretch; text-align: left; padding: 8px 8px 10px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.theme-opt[aria-checked="true"] { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.theme-sw { display: flex; gap: 4px; }
.theme-sw i { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.backup-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.account { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.account img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.account b { display: block; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  background: var(--toast-bg); color: var(--toast-fg); border-radius: 14px; padding: 10px 12px 10px 16px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); animation: rise .2s ease;
}
.toast button { color: var(--toast-act); font-weight: 700; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
@media (min-width: 960px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 약관 링크 · 회원 탈퇴 (웹) */
.legal-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 13px; }
.legal-row a, .leave-link { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.legal-row a:hover, .leave-link:hover { color: var(--ink); }
.leave-link { margin-left: auto; }
.btn-leave { background: var(--crit); color: #fff; }
.btn-leave:hover:not(:disabled) { filter: brightness(.94); }
.leave-err { color: var(--crit); font-size: 13px; margin-top: 6px; }

/* 테마 미리보기 */
.theme-gt { font-size: 13px; font-weight: 600; color: var(--ink); margin: 4px 0 8px; }
.theme-gt span { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.themes + .theme-gt { margin-top: 16px; }
.theme-prev { display: block; height: 46px; border-radius: 9px; padding: 7px; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .28); }
.theme-prev i { display: flex; flex-direction: column; justify-content: center; gap: 5px; height: 100%; border-radius: 6px; padding: 0 8px; }
.theme-prev b { display: block; width: 56%; height: 6px; border-radius: 3px; }
.theme-prev s { display: block; width: 82%; height: 4px; border-radius: 2px; opacity: .5; }
.theme-prev { position: relative; overflow: hidden; }
.theme-dk { position: absolute; inset: 0 0 0 50%; padding: 7px 7px 7px 0; }
.theme-dk i { border-radius: 0 6px 6px 0; padding-left: 0; }
.theme-dk b { width: 40%; } .theme-dk s { width: 70%; }
.theme-n { padding-left: 2px; }

/* 통계 */
.view-switch { display: flex; }
.st-hero .hero-num { margin-top: 2px; }
.st-sum { list-style: none; margin: 14px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); display: grid; gap: 7px; }
.st-sum li { position: relative; padding-left: 16px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.st-sum li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.st-sum b { color: var(--ink); }
.kpi { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
@media (min-width: 720px) { .kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi > div { min-width: 0; }
.kpi-v { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; margin-top: 2px; overflow-wrap: anywhere; }
.kpi-v small { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.kpi-s { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.cc { position: relative; margin-top: 4px; }
.cc-plot { position: relative; display: flex; align-items: stretch; height: 168px; padding-top: 22px; border-bottom: 1px solid var(--line-strong); }
.cc-col { flex: 1 1 0; display: flex; align-items: flex-end; justify-content: center; min-width: 0; padding: 0 2px; border-radius: 8px 8px 0 0; cursor: default; }
.cc-col:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-col.hov { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.cc-bar { position: relative; display: block; width: min(24px, 70%); border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--ink) 20%, var(--surface)); transition: height .3s ease; }
.cc-col.on .cc-bar { background: var(--accent); }
.cc-col.hov:not(.on) .cc-bar { background: color-mix(in srgb, var(--ink) 30%, var(--surface)); }
.cc-bar em { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; font-style: normal; font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.cc-ref { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--ink-2); pointer-events: none; z-index: 1; }
.cc-ref em { position: absolute; right: 0; bottom: 2px; font-style: normal; font-size: 11px; font-weight: 500; color: var(--ink-2); background: var(--surface); padding: 0 0 0 4px; }
.cc-x { display: flex; margin-top: 6px; }
.cc-x span { flex: 1 1 0; text-align: center; font-size: 12px; color: var(--muted); }
.cc-x span.on { color: var(--ink); font-weight: 600; }
.cc .tip { top: -6px; }
.tip-r .v { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.dlt.up { color: var(--out); }
.dlt.down { color: var(--accent); }
.rank-row.freq .rank-pct .i { width: 16px; height: 16px; color: var(--muted); }
.emo.num { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.split { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface); }
.split .s-fix { background: var(--accent); }
.split .s-var { background: color-mix(in srgb, var(--ink) 20%, var(--surface)); }
.split-leg { display: grid; gap: 8px; margin-top: 14px; }
.split-leg > div { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 44px; align-items: center; gap: 10px; font-size: 14px; }
.split-leg .k { width: 12px; height: 12px; border-radius: 3px; }
.split-leg .k.fix { background: var(--accent); }
.split-leg .k.var { background: color-mix(in srgb, var(--ink) 20%, var(--surface)); }
.split-leg small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.split-leg b { font-weight: 600; font-variant-numeric: tabular-nums; }
.split-leg .muted { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- web version: page base + sign-in screen ---------- */
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.auth { min-height: 100vh; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 24px; padding: 30px 26px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.auth-card .brand { font-size: 26px; margin-bottom: 6px; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.auth-sub { color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.auth-form { display: grid; gap: 12px; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-msg { font-size: 13.5px; color: var(--crit); min-height: 1.3em; line-height: 1.5; }
.auth-msg.ok { color: var(--accent); }
.auth-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.auth-links button { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }

/* 약관 동의 · 약관 링크 */
.auth-agree { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); padding: 12px; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.auth-agree input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.auth-agree a, .auth-legal a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.auth-legal { display: flex; justify-content: center; gap: 16px; margin-top: 18px; font-size: 12.5px; color: var(--muted); }
