@font-face { font-family: Inter; src: url("../fonts/Inter-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url("../fonts/Inter-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Inter; src: url("../fonts/Inter-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Noto Serif"; src: url("../fonts/NotoSerif-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Serif"; src: url("../fonts/NotoSerif-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f6f3ee;
  --bg-2: #efeae3;
  --paper: #fbf8f3;
  --ink: #24312e;
  --muted: #4f5854;
  --line: #e4ddd4;
  --brand: #2f4f52;
  --brand-2: #243f42;
  --mint: #e4eeed;
  --income: #2a6550;
  --income-soft: #e6f0ea;
  --expense: #8c4a40;
  --expense-soft: #f6e8e3;
  --alert: #8e2f2a;
  --amber: #8a6232;
  --amber-soft: #f6efe4;
  --shadow: none;
  --radius: 18px;
  --serif: "Noto Serif", Georgia, serif;
  --sans: Inter, "Segoe UI", sans-serif;
  --nav: 76px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #1e2321;
  --bg-2: #262c29;
  --paper: #2a312e;
  --ink: #f4f1eb;
  --muted: #c8c2b8;
  --line: #3a423e;
  --brand: #c9d8d6;
  --brand-2: #e4eeed;
  --mint: #243433;
  --income: #a9cdb8;
  --income-soft: #24362e;
  --expense: #e7b5a8;
  --expense-soft: #3a2c28;
  --alert: #f0a8a2;
  --amber: #e2c49a;
  --amber-soft: #3a3226;
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  min-height: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.press { transition: transform .16s ease, background .16s ease; }
.press:active { transform: scale(.98); }

.boot, .auth-bg {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px 48px;
  background: var(--bg);
}
.auth-card, .boot-card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 22px 24px;
  animation: rise .45s cubic-bezier(.16,.84,.32,1);
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--brand); color: #f6f3ee;
  font-family: var(--serif); font-size: 22px;
}
html[data-theme="dark"] .mark { color: #1a2426; }
.brand h1, .panel h2, .top h1 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.brand p, .lede { color: var(--muted); margin: 4px 0 0; }
.field { display: grid; gap: 6px; margin-top: 12px; }
.field span, .kicker { font-size: 13px; color: var(--muted); }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 48px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--paper); padding: 10px 12px;
}
input[type="checkbox"], input[type="radio"], input[type="range"], input[type="file"] {
  width: auto; min-height: 0; padding: 0;
}
textarea { min-height: 80px; resize: vertical; }
.row-2 { display: grid; gap: 10px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.help, .error { font-size: 13px; color: var(--muted); }
.error { color: var(--alert); }
.warn-box {
  margin-top: 14px; padding: 12px 14px; border-radius: 16px;
  background: var(--amber-soft); color: var(--ink); font-size: 14px;
}
.btn {
  border: 0; border-radius: 999px; min-height: 48px; padding: 0 16px;
  background: var(--paper); border: 1px solid var(--line);
}
.btn.primary { background: #2f4f52; color: #f6f3ee; border-color: transparent; }
html[data-theme="dark"] .btn.primary { background: #c9d8d6; color: #1a2426; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--expense-soft); color: var(--expense); border-color: transparent; }
.btn.block { width: 100%; margin-top: 14px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.users { display: flex; gap: 8px; overflow: auto; padding-bottom: 4px; margin: 8px 0; }
.users button { border-radius: 999px; border: 1px solid var(--line); background: var(--paper); padding: 8px 12px; white-space: nowrap; }

.shell { min-height: 100dvh; }
.rail { display: none; }
.main { min-height: 100dvh; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 20px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.top h1 { font-size: 28px; }
.icon-btn, .tabbar a, .rail a {
  display: grid; place-items: center; gap: 4px;
  text-decoration: none; color: var(--muted); background: transparent; border: 0;
}
.icon-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line); }
.icon-btn svg, .tabbar svg, .rail svg, .item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.view { padding: 8px 22px calc(var(--nav) + 96px); display: grid; gap: 28px; }
.view.enter { animation: rise .42s cubic-bezier(.16,.84,.32,1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: transparent; font-size: 22px; color: var(--muted); }
.month-nav span { font-size: 15px; }
.balance { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 22px 22px; }
.hero-num { font-family: var(--serif); font-size: clamp(40px, 12vw, 56px); line-height: 1.05; margin: 8px 0 22px; letter-spacing: -0.03em; }
.balance-month { display: grid; gap: 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.month-num { font-family: var(--serif); font-size: 28px; margin: 4px 0 0; }
.pair { display: flex; gap: 18px; font-size: 14px; }
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px;
}
.panel h2 { font-size: 18px; font-weight: 600; }
.more-links { display: grid; }
.more-links a { padding: 16px 2px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.alert-line { margin: 0; color: var(--alert); font-size: 14px; }
.alert-line a { color: var(--alert); }
.panel header, .split { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.muted { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 16px; padding: 10px; }
.stat b { display: block; font-family: var(--serif); font-size: 18px; margin-top: 4px; }
.in { color: var(--income); }
.out { color: var(--expense); }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 20px; fill: var(--muted); font-family: var(--sans); }
.bar.in { fill: var(--income); }
.bar.out { fill: var(--expense); }
.chart-col { transform-box: fill-box; transform-origin: center bottom; animation: risebar .7s cubic-bezier(.2,.8,.2,1) both; }
.chart-projected { opacity: .45; }
@keyframes risebar { from { transform: scaleY(.08); opacity: 0; } }
.chart.line .area { fill: color-mix(in srgb, var(--brand) 25%, transparent); }
.chart.line .stroke { fill: none; stroke: var(--brand); stroke-width: 3; }
.chart.line circle { fill: var(--brand); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 99px; display: inline-block; margin-right: 6px; }
.donut { width: 132px; height: 132px; }
.donut-hole { fill: var(--paper); }
.item > strong { white-space: nowrap; }
.cat-row, .item, .menu-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  width: 100%; text-align: left; background: transparent; border: 0; padding: 8px 0;
}
.menu-row { padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.dot { width: 12px; height: 12px; border-radius: 99px; }
.track { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--brand); border-radius: inherit; transform-origin: left; animation: grow .7s both; }
.track.over i { background: var(--alert); }
@keyframes grow { from { transform: scaleX(.05); } }
.empty { padding: 8px 0 4px; }
.empty h3 { margin: 0 0 4px; font-size: 18px; }
.thumb, .shot {
  width: 54px; height: 70px; border-radius: 12px; object-fit: cover; background: var(--bg); border: 0; padding: 0;
}
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 12px; background: var(--bg); color: var(--muted); margin: 2px 4px 2px 0; }
.badge.warn { background: var(--amber-soft); color: var(--ink); }
.badge.ok { background: var(--mint); color: var(--brand-2); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border-radius: 999px; border: 1px solid var(--line); background: var(--paper); padding: 8px 12px; white-space: nowrap; }
.chip.on { background: var(--mint); border-color: transparent; color: var(--brand-2); }
.drop {
  border: 1px dashed var(--line);
  border-radius: 18px; padding: 28px 18px; text-align: center; background: var(--paper);
}
.drop.over { transform: scale(1.01); background: var(--mint); }
.manage {
  display: grid; grid-template-columns: 28px 1fr; gap: 10px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.stack { display: grid; gap: 8px; margin-top: 8px; }
.bulk {
  position: sticky; bottom: calc(var(--nav) + 8px); z-index: 4;
  display: flex; gap: 8px; flex-wrap: wrap; padding: 10px; border-radius: 18px;
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border-top: 1px solid var(--line);
}
.tabbar a { font-size: 11px; }
.tabbar a.on, .rail a.on { color: var(--brand); }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav) + 16px + env(safe-area-inset-bottom));
  z-index: 7; width: 58px; height: 58px; border-radius: 20px; border: 0;
  background: #2f4f52; color: #f6f3ee; font-size: 32px;
}
html[data-theme="dark"] .fab { background: #c9d8d6; color: #1a2426; }
.fab.open { transform: rotate(45deg); }
.fab-menu {
  position: fixed; right: 18px; bottom: calc(var(--nav) + 84px + env(safe-area-inset-bottom));
  z-index: 7; display: grid; gap: 8px; width: min(240px, calc(100% - 36px));
  animation: rise .28s cubic-bezier(.16,.84,.32,1);
}
.fab-menu button { justify-content: flex-start; display: flex; gap: 8px; align-items: center; background: var(--paper); }
.scrim { position: fixed; inset: 0; background: rgba(18, 24, 22, .28); z-index: 6; }
.sheet, .viewer, .story, .tour {
  position: fixed; z-index: 8; left: 0; right: 0; bottom: 0;
  background: var(--paper); border-radius: 28px 28px 0 0; padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow); animation: sheet .35s cubic-bezier(.16,.84,.32,1);
  max-height: min(92dvh, 820px); overflow: auto;
}
@keyframes sheet { from { transform: translateY(24px); opacity: .6; } }
.viewer-back, .story-back, .tour-back {
  position: fixed; inset: 0; z-index: 8;
  background: rgba(18, 22, 20, .55);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } }
.viewer, .story { top: 4dvh; bottom: 4dvh; left: 12px; right: 12px; border-radius: 28px; display: flex; flex-direction: column; padding: 12px; }
.stage { flex: 1; min-height: 220px; background: #161c19; border-radius: 20px; overflow: hidden; touch-action: none; display: grid; place-items: center; position: relative; }
.stage img { max-width: 100%; max-height: 100%; transform-origin: center; }
.zoombar { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.zoombar button { width: 42px; height: 42px; border-radius: 14px; border: 0; background: rgba(255,255,255,.9); color: #16332c; }
.meta { padding: 12px 6px 4px; display: grid; gap: 8px; }
.meta b { font-family: var(--serif); font-size: 28px; }
.story { background: transparent; box-shadow: none; padding: 0; }
.story-top { position: absolute; left: 16px; right: 16px; top: 12px; z-index: 2; display: grid; gap: 8px; }
.segs { display: flex; gap: 4px; }
.segs i { display: block; height: 3px; border-radius: 99px; background: rgba(255,255,255,.85); transform-origin: left; transform: scaleX(0); }
.segs i.on { transform: scaleX(1); transition: transform .4s linear; }
.story-track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: 28px; }
.story-track::-webkit-scrollbar { display: none; }
.story-card {
  min-width: 100%; scroll-snap-align: center; padding: 72px 28px 32px;
  background: #2f4f52;
  color: #f6f3ee; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px;
}
.story-card h2 { font-family: var(--serif); font-size: 34px; margin: 0; }
.story-card .big { font-family: var(--serif); font-size: 42px; }
.tour { top: auto; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav) + 24px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 999px; z-index: 9;
  animation: rise .3s ease;
}
.year-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.year-table th, .year-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.year-table th:first-child, .year-table td:first-child { text-align: left; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.progress-note { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-note i { display: block; height: 100%; width: 40%; background: var(--brand); animation: load 1s ease infinite; }
@keyframes load { 50% { margin-left: 60%; } }

@media (min-width: 980px) {
  .rail {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; inset: 0 auto 0 0; width: 232px; padding: 22px 14px;
    background: var(--paper); border-right: 1px solid var(--line);
  }
  .rail a { grid-template-columns: 24px 1fr; justify-content: start; padding: 10px 12px; border-radius: 12px; font-size: 15px; }
  .rail a.on { background: var(--mint); }
  .main { margin-left: 232px; }
  .tabbar { display: none; }
  .view { padding-bottom: 40px; }
  .fab { bottom: 24px; }
  .dash { display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px; }
  .dash .span { grid-column: 1 / -1; }
  .viewer { left: 50%; right: auto; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(920px, calc(100% - 48px)); height: min(640px, calc(100% - 48px)); display: grid; grid-template-columns: 1.15fr .85fr; padding: 12px; }
  .story { left: 50%; right: auto; width: min(420px, calc(100% - 48px)); transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
