/* Calm, monochrome look: large numbers, soft cards, two muted accents (needed / optional). */
:root {
  --bg: #f8f9fb;
  --card: #ffffff;
  --card-line: #e9edef;
  --text: #1b1e22;
  --text-2: #5f686f;
  --hint: #8b939b;
  --line: #edf0f1;
  --soft: #f0f2f4;
  --primary: #202329;
  --primary-text: #ffffff;
  --need: #75a993;
  --want: #e8a775;
  --need-text: #4f8a71;
  --want-text: #c47c43;
  --need-soft: #e8f2ed;
  --want-soft: #fbefe4;
  --danger: #d0574f;
  --shadow: 0 1px 2px rgb(24 32 51 / .04), 0 8px 24px rgb(24 32 51 / .05);
  --radius: 24px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1b1d20;
  --card: #25282c;
  --card-line: #2f3338;
  --text: #f4f5f6;
  --text-2: #b4bac0;
  --hint: #858d95;
  --line: #30353a;
  --soft: #2c3035;
  --primary: #f4f5f6;
  --primary-text: #1b1d20;
  --need: #96c8b2;
  --want: #efb783;
  --need-text: #96c8b2;
  --want-text: #efb783;
  --need-soft: #25352f;
  --want-soft: #3a2f25;
  --danger: #ef7d74;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 520px; margin: 0 auto; padding: 18px 20px calc(32px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select { font: inherit; color: var(--text); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; }
.eyebrow { font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--hint); }
.backlink { display: inline-flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 15px; }
.backlink b { font-size: 22px; font-weight: 400; line-height: 1; color: var(--text); }
h1 { font-size: 27px; line-height: 1.15; margin: 22px 0 0; letter-spacing: -0.02em; font-weight: 750; }
.sub { color: var(--hint); font-size: 14.5px; margin-top: 6px; }

.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; gap: 2px; flex-shrink: 0; }
.seg button { min-width: 38px; padding: 6px 10px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--hint); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; padding: 10px; }

/* ---------- hero ---------- */
.hero { margin: 28px 0 22px; }
.hero .cap { color: var(--hint); font-size: 15px; }
.hero .big { font-size: 52px; font-weight: 800; letter-spacing: -0.045em; line-height: 1.02; margin-top: 8px; }
.hero .alt { color: var(--hint); font-size: 14.5px; margin-top: 8px; }

.ratio { display: flex; height: 6px; border-radius: 6px; overflow: hidden; background: var(--soft); margin: 18px 0 0; gap: 3px; }
.ratio i { display: block; height: 100%; border-radius: 6px; }
.ratio .n { background: var(--need); }
.ratio .w { background: var(--want); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.need { background: var(--need); }
.dot.want { background: var(--want); }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gcard { padding: 18px 16px; text-align: left; }
.gcard .dot { width: 12px; height: 12px; }
.gcard .t { color: var(--text-2); font-size: 15px; margin-top: 16px; }
.gcard .amt { font-size: 24px; font-weight: 750; letter-spacing: -0.03em; margin-top: 6px; white-space: nowrap; }
.gcard .alt { color: var(--hint); font-size: 12.5px; margin-top: 4px; }
.gcard .pct { color: var(--hint); font-size: 12.5px; margin-top: 10px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; padding: 14px; border-radius: 18px; font-weight: 650; font-size: 16.5px; }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.secondary { background: var(--card); border: 1px solid var(--card-line); }
.btn.danger { color: var(--danger); background: transparent; }
.btn[disabled] { opacity: .45; }
.btn:active, .row:active, .gcard:active { transform: scale(.985); }
.actions { display: grid; gap: 10px; margin: 16px 0 6px; }

/* ---------- lists ---------- */
h2 { font-size: 21px; font-weight: 750; letter-spacing: -0.015em; margin: 32px 0 6px; display: flex; justify-content: space-between; align-items: baseline; }
h2 a { color: var(--text-2); font-size: 14.5px; font-weight: 500; letter-spacing: 0; }
.list { }
.row { display: flex; align-items: center; gap: 14px; padding: 15px 0; width: 100%; text-align: left; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .mid { flex: 1; min-width: 0; }
.row .name { font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 13px; color: var(--hint); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .tag { font-size: 13px; margin-top: 3px; }
.row .tag.need { color: var(--need-text); }
.row .tag.want { color: var(--want-text); }
.row .right { text-align: right; flex-shrink: 0; }
.row .right .v { font-weight: 700; font-size: 16.5px; }
.row .right .meta { font-size: 12.5px; }
.row .bar { height: 4px; border-radius: 3px; background: var(--soft); margin-top: 9px; overflow: hidden; }
.row .bar i { display: block; height: 100%; border-radius: 3px; }
.thead { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .08em; color: var(--hint); padding: 10px 0; border-bottom: 1px solid var(--line); }
.empty { color: var(--hint); padding: 22px 0; }

.legend-card { padding: 6px 18px; }
.legend-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.legend-row + .legend-row { border-top: 1px solid var(--line); }
.legend-row .l { flex: 1; color: var(--text-2); }
.legend-row .v { font-weight: 700; }
.legend-row .p { color: var(--hint); font-size: 13px; width: 40px; text-align: right; }

.monthnav { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.monthnav button { width: 40px; height: 40px; border-radius: 50%; background: var(--soft); font-size: 18px; color: var(--text); }
.monthnav button[disabled] { opacity: .3; }
.monthnav .m { font-weight: 650; font-size: 16px; }

.people .row .split { font-size: 13px; margin-top: 3px; display: flex; gap: 12px; }
.split .n { color: var(--need-text); } .split .w { color: var(--want-text); }

.banner { border-radius: 18px; padding: 14px 16px; margin-top: 18px; font-size: 14.5px; background: var(--soft); color: var(--text-2); }
.banner.warn { background: var(--want-soft); color: var(--text); }

/* ---------- forms ---------- */
.field { background: var(--card); border: 1px solid var(--card-line); border-radius: 18px; padding: 12px 16px; margin-bottom: 10px; }
.field label { display: block; font-size: 12.5px; color: var(--hint); margin-bottom: 4px; }
.field input { width: 100%; border: 0; outline: 0; background: none; padding: 2px 0; font-size: 17px; }
.amount-input { font-size: 40px !important; font-weight: 800; letter-spacing: -0.04em; }
.conv { color: var(--hint); font-size: 14px; min-height: 19px; margin: 10px 4px 18px; }
.flabel { font-size: 13px; color: var(--hint); margin: 18px 4px 10px; }

.gtoggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gtoggle button { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--card-line); border-radius: 18px; padding: 16px; font-weight: 600; }
.gtoggle button.on.need { border-color: var(--need); background: var(--need-soft); }
.gtoggle button.on.want { border-color: var(--want); background: var(--want-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 1px solid var(--card-line); border-radius: 999px; padding: 9px 14px; font-size: 14.5px; color: var(--text-2); }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

.upload {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  border: 1.5px dashed var(--card-line); border-radius: var(--radius); background: var(--card); padding: 44px 20px; cursor: pointer; margin-top: 18px;
}
.upload .ic { width: 58px; height: 58px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; margin-bottom: 8px; }
.upload .ic svg { width: 26px; height: 26px; }
.upload b { font-size: 18px; }
.upload span { color: var(--hint); font-size: 14px; }
.upload input { display: none; }
.tips { color: var(--hint); font-size: 14px; margin: 18px 0; padding-left: 18px; }
.tips li + li { margin-top: 6px; }

.reading { text-align: center; padding: 70px 20px; }
.reading h3 { margin: 18px 0 8px; font-size: 20px; }

/* ---------- sheet / toast / loading ---------- */
.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(12 14 18 / .45); animation: fade .2s; }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow: auto; max-width: 520px; margin: 0 auto;
  background: var(--bg); border-radius: 28px 28px 0 0; padding: 12px 20px calc(22px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2,.8,.2,1);
}
.sheet-body::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--card-line); margin: 0 auto 16px; }
.sheet h3 { margin: 0 0 4px; font-size: 21px; letter-spacing: -0.01em; }
.sheet .orig { color: var(--hint); font-size: 14px; margin-bottom: 16px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--primary); color: var(--primary-text); padding: 12px 20px; border-radius: 999px; font-size: 15px; max-width: 90vw;
  animation: fade .2s; font-weight: 550;
}
.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--card-line); border-top-color: var(--text); animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--hint); }
.center { text-align: center; }
.mt { margin-top: 18px; }
