/* 色の役割: 地(紙) / 線・文字(ink) / もらった(teal) / つかった(pink)。この4つだけ。 */
:root {
  --bg: #f1eee3;
  --paper: #fffdf6;
  --ink: #3b3b4f;
  --ink2: #67677a;
  --line: #d9d4c3;
  --teal: #0f8178;
  --onteal: #ffffff;
  --tealtext: #0c6f67;
  --pink: #ff6b8b;
  --onpink: #3b3b4f;
  --pinktext: #b3304f;
  --tealtint: #d9efe9;
  --pinktint: #ffe3e9;
  --font: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Noto Sans JP", "Noto Sans CJK JP", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151a;
    --paper: #1f2026;
    --ink: #ece9df;
    --ink2: #aaa8a0;
    --line: #3a3b44;
    --teal: #3fc0b3;
    --onteal: #10201e;
    --tealtext: #5fd3c7;
    --pink: #ff8aa5;
    --onpink: #2a1a20;
    --pinktext: #ff9fb6;
    --tealtint: #1d3532;
    --pinktint: #3a2229;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 18px; line-height: 1.6;
}
#app {
  max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  background: var(--paper);
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom));
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.35; }
h2 { font-size: 20px; margin: 26px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--ink); }
h3 { font-size: 18px; margin: 18px 0 6px; }
p { margin: 6px 0; }
.small { font-size: 15px; color: var(--ink2); }
.warn { color: var(--pinktext); font-weight: 700; }
svg.ic { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ヘッダー */
.top { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.kidchip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 4px 14px;
  background: none; border: 2px solid var(--ink); border-radius: 12px; font-weight: 700; font-size: 20px;
}
.kidchip svg.ic { width: 20px; height: 20px; }

/* おさいふ */
.purse { margin: 14px 0 6px; padding: 14px 16px 12px; border: 2px solid var(--ink); border-radius: 14px; transform: rotate(-0.5deg); }
.purse .lab { font-size: 16px; color: var(--ink2); }
.purse .num { font-size: 56px; font-weight: 800; line-height: 1.15; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; word-break: break-all; }
.purse .num small { font-size: 22px; font-weight: 700; margin-left: 4px; }
.purse .neg { color: var(--pinktext); }

.bigbtns { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 12px; margin: 14px 0; }
.big {
  min-height: 84px; border: 2px solid var(--ink); border-radius: 14px; font-size: 24px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.big svg.ic { width: 32px; height: 32px; }
.big.in { background: var(--teal); color: var(--onteal); }
.big.out { background: var(--pink); color: var(--onpink); }

/* ボタン */
.btn {
  min-height: 48px; padding: 8px 18px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper);
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.main { background: var(--teal); color: var(--onteal); }
.btn.pink { background: var(--pink); color: var(--onpink); }
.btn.sub { border-color: var(--line); font-weight: 600; }
.btn.danger { border-color: var(--pinktext); color: var(--pinktext); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.block { width: 100%; }
.btn.slim { min-height: 44px; padding: 4px 14px; font-size: 16px; }
.linkbtn { background: none; border: none; padding: 10px 0; min-height: 48px; text-decoration: underline; text-underline-offset: 3px; color: var(--ink); font-size: 16px; text-align: left; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }

/* きろく(一覧) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 2px;
  background: none; border: none; text-align: left;
}
.item .d { width: 48px; font-size: 15px; color: var(--ink2); flex: none; font-variant-numeric: tabular-nums; }
.item .w { flex: 1; min-width: 0; }
.item .w b { display: block; font-weight: 700; }
.item .w span { display: block; font-size: 15px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.p { color: var(--tealtext); }
.amt.m { color: var(--pinktext); }
.empty { padding: 18px 2px; color: var(--ink2); }

/* もくひょう */
.goal { padding: 14px 0 16px; border-bottom: 1px solid var(--line); }
.goal .nm { font-size: 20px; font-weight: 800; }
.bar { height: 22px; border: 2px solid var(--ink); border-radius: 8px; background: var(--paper); overflow: hidden; margin: 8px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--teal); }
.bar.pk > i { background: var(--pink); }
.goal .rest { font-size: 19px; font-weight: 700; }
.goal.done .nm { color: var(--ink2); }

/* まとめ */
.monthnav { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.iconbtn { width: 48px; height: 48px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); display: inline-flex; align-items: center; justify-content: center; }
.iconbtn:disabled { opacity: 0.35; }
.monthnav b { font-size: 22px; }
.sum3 { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; }
.sum3 > div { padding: 8px 6px; text-align: center; border-right: 1px solid var(--line); }
.sum3 > div:last-child { border-right: none; }
.sum3 .l { font-size: 14px; color: var(--ink2); display: block; }
.sum3 .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; word-break: break-all; line-height: 1.3; display: block; }
.cbar { margin: 8px 0; }
.cbar .t { display: flex; justify-content: space-between; font-weight: 700; }
.cbar .t span:last-child { font-variant-numeric: tabular-nums; }
.cbar .tr { height: 16px; background: var(--tealtint); border-radius: 6px; overflow: hidden; margin-top: 2px; }
.cbar.out .tr { background: var(--pinktint); }
.cbar .tr i { display: block; height: 100%; background: var(--teal); border-radius: 6px; }
.cbar.out .tr i { background: var(--pink); }

/* タブ */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  max-width: 560px; margin: 0 auto; background: var(--paper); border-top: 2px solid var(--ink);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { background: none; border: none; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: 14px; font-weight: 700; color: var(--ink2); position: relative; }
.tabs button[aria-current="page"] { color: var(--ink); }
.tabs button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 4px; background: var(--teal); border-radius: 0 0 4px 4px; }

/* シート(下から出る入力画面) */
.back { position: fixed; inset: 0; background: rgba(20, 20, 30, 0.45); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 94dvh; max-height: 94vh; overflow-y: auto; background: var(--paper);
  border: 2px solid var(--ink); border-bottom: none; border-radius: 18px 18px 0 0;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
}
@supports (height: 1dvh) { .sheet { max-height: 94dvh; } }
.sheet .head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.sheet .head h2 { margin: 0; border: none; padding: 0; font-size: 22px; }
.cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0; }
.cat { min-height: 48px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); font-weight: 700; padding: 4px 8px; }
.cat[aria-pressed="true"] { border-color: var(--ink); background: var(--tealtint); }
.sheet.out .cat[aria-pressed="true"] { background: var(--pinktint); }
.amtbox { margin: 8px 0; padding: 6px 12px; border-bottom: 3px solid var(--ink); text-align: right; font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; min-height: 64px; }
.amtbox small { font-size: 20px; margin-left: 4px; }
.amtbox.zero { color: var(--ink2); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad button { min-height: 54px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 24px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.pad button:active { background: var(--tealtint); }
.field { display: block; margin: 12px 0 0; font-weight: 700; font-size: 16px; }
.field input, .field select, .txt {
  display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 6px 12px; font: inherit; font-size: 18px; font-weight: 500;
  color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 12px;
}
.sheet .okrow { position: sticky; bottom: 0; background: var(--paper); padding-top: 10px; }
.dots { display: flex; gap: 14px; justify-content: center; margin: 14px 0; }
.dots i { width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 50%; }
.dots i.on { background: var(--ink); }
.pinwrap { max-width: 320px; margin: 0 auto; }

.note { border: 2px dashed var(--line); border-radius: 12px; padding: 8px 12px; margin: 10px 0; font-size: 16px; }
.hello { padding-top: 24px; }
.hello h1 { font-size: 30px; }
.steps { margin: 6px 0 6px 0; padding-left: 24px; }
.steps li { margin: 4px 0; }
.kidrow { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.kidrow .nm { flex: 1; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 12px; border: 2px solid var(--line); border-radius: 10px; min-height: 44px; }
.chip button { background: none; border: none; min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.chip button svg.ic { width: 20px; height: 20px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.seg button { min-height: 48px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); font-weight: 700; }
.seg button[aria-pressed="true"] { border-color: var(--ink); background: var(--tealtint); }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 12px; font-weight: 700; max-width: 90vw; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
@media (min-width: 768px) {
  body { font-size: 20px; }
  .purse .num { font-size: 68px; }
}
@media (prefers-reduced-motion: no-preference) {
  .big:active, .btn:active { transform: translateY(1px); }
}

.budget { margin: 6px 0 2px; padding: 0 2px; }
.budget .t { display: flex; justify-content: space-between; font-weight: 700; }
