/* 家計簿: 家計簿ノートの見た目（採用した案）。白い罫線ノート・鉛筆の黒・赤鉛筆で締める集計 */
@font-face { font-family: 'UD Num'; src: url(fonts/udnum-700.woff2) format('woff2'); font-weight: 700; font-display: swap; unicode-range: U+25, U+2B-3A, U+3F, U+A5, U+2014, U+2212; }

:root {
  color-scheme: light;
  /* 紙は白、罫はごく淡い灰緑、印刷の枠は濃い灰緑 */
  --bg: #ffffff; --surface: #ffffff; --sunk: #f1f5f2;
  --ink: #1d2320; --ink2: #424b46; --mute: #5c6761; --line: #d3dfd7; --line2: #a9bbb0; --frame: #3d4a43;
  --red: #c4262e; --red-soft: #f6d9da;
  --accent: #1d2320; --accent-ink: #ffffff; --focus: #1d2320;
  --ok: #22704a; --prov: #8a5a00; --wait: #5c6761; --check: #c4262e; --move: #424b46; --in: #22704a;
  --lit: #fffae0; --lit-strong: #f0cc3c; --warn-bg: #fff8e1; --err-bg: #fdeced; --info-bg: #eef3f0;
  --toast: #1d2320; --toast-ink: #ffffff; --toast-act: #ff9e98;
  --num: 'UD Num', 'BIZ UDPGothic', ui-sans-serif, system-ui, sans-serif;
  --sans: 'BIZ UDPGothic', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic UI', 'Meiryo', system-ui, sans-serif;
  --r: 2px; --r-s: 2px;
  --nav-h: 64px; --top-h: 48px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151917; --surface: #151917; --sunk: #1d2320;
    --ink: #e4eae6; --ink2: #bac5bf; --mute: #94a19a; --line: #2a332e; --line2: #45534b; --frame: #7d8c84;
    --red: #ff8077; --red-soft: #3a2220;
    --accent: #e4eae6; --accent-ink: #151917; --focus: #e4eae6;
    --ok: #66c28f; --prov: #e5bf5a; --wait: #94a19a; --check: #ff8077; --move: #bac5bf; --in: #66c28f;
    --lit: #232118; --lit-strong: #a8892c; --warn-bg: #2a2617; --err-bg: #2e1c1b; --info-bg: #1d2320;
    --toast: #e4eae6; --toast-ink: #151917; --toast-act: #b3121c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151917; --surface: #151917; --sunk: #1d2320;
  --ink: #e4eae6; --ink2: #bac5bf; --mute: #94a19a; --line: #2a332e; --line2: #45534b; --frame: #7d8c84;
  --red: #ff8077; --red-soft: #3a2220;
  --accent: #e4eae6; --accent-ink: #151917; --focus: #e4eae6;
  --ok: #66c28f; --prov: #e5bf5a; --wait: #94a19a; --check: #ff8077; --move: #bac5bf; --in: #66c28f;
  --lit: #232118; --lit-strong: #a8892c; --warn-bg: #2a2617; --err-bg: #2e1c1b; --info-bg: #1d2320;
  --toast: #e4eae6; --toast-ink: #151917; --toast-act: #b3121c;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line2) var(--bg); caret-color: var(--ink); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain; }
::selection { background: var(--lit-strong); color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
h2, h3 { text-wrap: balance; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* 上の帯（ノートの表題欄）と下のタブ（見出しのインデックス） */
#top { position: sticky; top: 0; z-index: 5; height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 16px; display: flex; align-items: center; gap: 12px; background: var(--bg); border-bottom: 1px solid var(--frame); }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: .12em; }
#sync { flex: 1; text-align: right; font-size: 12px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sync[data-state="err"] { color: var(--check); }
#main { padding: 12px 12px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; outline: none; }
#nav { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--frame); }
#nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--mute); text-decoration: none; -webkit-user-select: none; user-select: none; border-left: 1px solid var(--line); }
#nav a:first-child { border-left: 0; }
#nav a[aria-current="page"] { color: var(--ink); font-weight: 700; background: var(--sunk); box-shadow: inset 0 2px 0 var(--ink); }
#nav a[aria-current="page"] .ic { stroke-width: 2.1; }
#nav a.cam { color: var(--accent-ink); }
#nav a.cam .ic { width: 50px; height: 50px; padding: 13px; margin-top: -16px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--frame); }
#nav a.cam span { margin-top: 2px; color: var(--ink2); }
#nav a.cam[aria-current="page"] span { color: var(--ink); }

/* 表示板 → ノートの集計欄（枠で囲み、締めの数字に赤の二重線） */
.board { background: var(--surface); color: var(--ink); border: 1px solid var(--frame); border-radius: 0; padding: 0 0 14px; }
.b-lbl { font-size: 12px; color: var(--mute); letter-spacing: .08em; }
.board .b-lbl { padding: 7px 14px 6px; background: var(--sunk); border-bottom: 1px solid var(--line2); color: var(--ink2); font-size: 12.5px; font-weight: 700; letter-spacing: .14em; }
.b-big { width: fit-content; max-width: calc(100% - 28px); margin: 12px 14px 0; padding-bottom: 3px; font: 700 clamp(40px, 12vw, 54px)/1.05 var(--num); color: var(--ink); letter-spacing: .01em; border-bottom: 4px double var(--red); }
.board[data-over="1"] .b-big { color: var(--red); }
.board[data-over="1"] .b-lbl { color: var(--red); }
.b-sub { display: flex; flex-wrap: wrap; gap: 0; margin: 12px 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--ink2); }
.b-sub span { font-family: var(--num), var(--sans); font-weight: 400; padding: 6px 12px 6px 10px; border-left: 1px solid var(--line); }
.b-sub span:first-child { border-left: 0; padding-left: 0; }
.b-btn { margin: 12px 14px 0; min-height: 44px; padding: 0 18px; border-radius: var(--r); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: 700 15px var(--sans); cursor: pointer; }
.b-link { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 3px; cursor: pointer; font-size: 12.5px; }
.b-bar { position: relative; height: 8px; margin: 14px 14px 0; border: 1px solid var(--line2); background: var(--surface); }
.b-bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink2); transition: width .6s var(--ease); }
.b-bar b { position: absolute; top: -5px; width: 2px; height: 16px; margin-left: -1px; background: var(--red); }

/* お知らせ（罫の行に書いた注意書き） */
.notes { display: grid; gap: 0; margin-top: 10px; }
.note { display: grid; grid-template-columns: 20px 1fr; gap: 6px; align-items: start; min-height: 44px; text-align: left; padding: 10px 8px 9px 2px; background: none; border: 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; color: var(--ink2); cursor: pointer; }
.note::before { content: ''; width: 8px; height: 8px; margin: 6px 6px 0; border-radius: 50%; background: var(--frame); }
.note[data-k="balance"]::before, .note[data-k="noReceipt"]::before { background: var(--check); }
.note:hover { color: var(--ink); background: var(--sunk); }

/* 日ごとの行（ノートの1行。左に日付の欄、右に金額の欄の縦罫） */
.days { display: grid; gap: 18px; margin-top: 18px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 700; color: var(--ink); padding: 0 8px 4px; letter-spacing: .04em; }
.day-h span:last-child { font: 700 13px var(--num), var(--sans); color: var(--red); }
/* 表の頭（時刻｜摘要｜金額・状態）。列は .row と同じ幅 */
.cols { display: grid; grid-template-columns: 42px minmax(0, 1fr) 94px; gap: 8px; padding: 0 8px 4px; margin-bottom: -10px; font-size: 12px; color: var(--mute); letter-spacing: .08em; border-bottom: 1px solid var(--frame); }
.cols span:last-child { text-align: right; }
.day-h span.day-n { color: var(--mute); font-weight: 400; }
.rows { background: var(--surface); border-top: 1px solid var(--frame); border-bottom: 1px solid var(--line2); border-radius: 0; overflow: hidden; }
.row { width: 100%; display: grid; grid-template-columns: 42px 24px minmax(0, 1fr) 94px; gap: 8px; align-items: center; padding: 8px 8px; min-height: 56px; border: 0; border-top: 1px solid var(--line); text-align: left; cursor: pointer; transition: background-color .2s;
  background: linear-gradient(var(--line2), var(--line2)) 54px 0 / 1px 100% no-repeat, linear-gradient(var(--line), var(--line)) right 106px top 0 / 1px 100% no-repeat; background-color: transparent; }
.row:first-child { border-top: 0; }
.row:hover { background-color: var(--sunk); }
.row.lit { background-color: var(--lit); animation: lit 1.6s var(--ease) 1; }
@keyframes lit { from { background-color: color-mix(in oklab, var(--lit-strong) 40%, var(--lit)); } }
.r-time { font: 700 13px var(--num), var(--sans); color: var(--ink2); }
.wb { --c: #888; width: 24px; height: 24px; border-radius: 3px; background: var(--c); color: #fff; font: 700 13px/24px var(--sans); text-align: center; flex: none; }
.r-main { min-width: 0; display: grid; }
.r-store { font-size: 15px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sub { font-size: 12px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-amt { display: grid; justify-items: end; min-width: 0; }
.r-yen { font: 700 16px var(--num), var(--sans); white-space: nowrap; }
.r-amt[data-type="transfer"] .r-yen { color: var(--move); font-weight: 400; }
.r-amt[data-type="income"] .r-yen { color: var(--in); }
.r-st { font-size: 12px; letter-spacing: .02em; white-space: nowrap; }
.row[data-st="ok"] .r-st { color: var(--ok); }
.row[data-st="prov"] .r-st { color: var(--prov); font-weight: 700; }
.row[data-st="wait"] .r-st { color: var(--wait); }
.row[data-st="wait"] .r-yen { color: var(--mute); font-weight: 400; }
.row[data-st="check"] .r-st, .row[data-st="diff"] .r-st { color: var(--check); font-weight: 700; }
.row[data-st="move"] .r-st, .row[data-st="in"] .r-st { color: var(--mute); }

.empty { text-align: center; color: var(--mute); padding: 40px 12px; display: grid; gap: 8px; justify-items: center; }
.more-link { text-align: center; margin-top: 18px; }

/* ボタン・入力（角はほぼ直角、1px の線） */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line2); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 14px; white-space: nowrap; transition: background-color .15s, border-color .15s; }
.btn:hover { border-color: var(--ink2); background: var(--sunk); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 13px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: var(--ink2); border-color: var(--ink2); }
.btn.danger { color: var(--check); border-color: color-mix(in oklab, var(--check) 50%, transparent); }
.btn.big { width: 100%; min-height: 52px; font-size: 16px; margin-top: 14px; }
label.btn input[type=file] { display: none; }
.icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: var(--r); background: none; color: var(--ink2); cursor: pointer; }
.icon:hover { background: var(--sunk); color: var(--ink); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btns.end { justify-content: flex-end; margin-top: 18px; }
/* 確定・保存は、長いレシートでも面の下に見え続ける */
.sheet-b > .edit > .btns.end { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); margin: 18px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--frame); }
/* 入力欄は下線だけ（ノートの記入欄） */
input[type=text], input[type=search], input[type=date], input[type=time], input[type=number], select, textarea { width: 100%; min-height: 44px; padding: 8px 8px; border: 0; border-bottom: 1px solid var(--line2); border-radius: 0; background: transparent; font-size: 16px; }
input:focus, select:focus, textarea:focus { border-bottom-color: var(--ink); background: var(--sunk); }
input::placeholder, textarea::placeholder { color: var(--mute); }
.f { display: grid; gap: 4px; margin-top: 12px; }
.f-l { font-size: 12px; color: var(--ink2); letter-spacing: .06em; }
.f-h { font-size: 12px; color: var(--mute); line-height: 1.55; }
.f-h.prov { color: var(--prov); margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line2); border-radius: var(--r); overflow: hidden; margin-top: 4px; }
.seg button { min-height: 44px; border: 0; border-left: 1px solid var(--line2); background: var(--surface); cursor: pointer; font-size: 14px; }
.seg button:first-child { border-left: 0; }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* 下から出る面（ノートの別紙） */
dialog.sheet { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 92dvh; padding: 0; border: 0; border-top: 1px solid var(--frame); border-radius: 0; background: var(--surface); color: var(--ink); display: flex; flex-direction: column; }
dialog.sheet[open] { animation: up .32s var(--ease); }
@keyframes up { from { transform: translateY(24px); opacity: .4; } }
dialog.sheet::backdrop { background: rgb(15 22 18 / .45); }
.sheet-h { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 6px 16px; border-bottom: 1px solid var(--frame); }
.sheet-h h2 { font-size: 16px; letter-spacing: .04em; }
.sheet-b { overflow: auto; padding: 4px 16px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.ask { margin: 12px 0 4px; line-height: 1.7; }
img.full { width: 100%; height: auto; display: block; margin-top: 8px; border: 1px solid var(--line); }

/* 取引の確認 */
.imgs { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scroll-snap-type: x mandatory; }
.thumb { flex: none; width: 96px; height: 128px; padding: 0; border: 1px solid var(--line2); border-radius: 0; background: var(--sunk); overflow: hidden; cursor: zoom-in; scroll-snap-align: start; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.warn { margin-top: 10px; padding: 10px 12px; border-radius: 0; background: var(--warn-bg); border: 1px solid color-mix(in oklab, var(--prov) 40%, transparent); font-size: 13.5px; line-height: 1.6; }
.warn[data-level="err"] { background: var(--err-bg); border-color: color-mix(in oklab, var(--check) 40%, transparent); }
.warn[data-level="info"] { background: var(--info-bg); border-color: var(--line2); }
.items { margin: 16px 0 0; padding: 0; border: 0; }
.items legend { font-size: 12px; color: var(--ink2); letter-spacing: .06em; padding: 0; margin-bottom: 4px; }
.it-list { display: grid; gap: 0; border-top: 1px solid var(--frame); }
.it { display: grid; grid-template-columns: minmax(0, 1fr) 84px 62px 44px; grid-template-areas: "n p r x" "c c c c"; gap: 4px 6px; padding: 8px 0; background: none; border-bottom: 1px solid var(--line); border-radius: 0; }
.it input, .it select { background: transparent; }
.it-name { grid-area: n; } .it-price { grid-area: p; text-align: right; font-family: var(--num), var(--sans); } .it-rate { grid-area: r; padding: 8px 4px; } .it-cat { grid-area: c; min-height: 44px; font-size: 14px; } .it .icon { grid-area: x; }
.it[data-disc="1"] .it-price { color: var(--check); }
.it-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 0; padding: 8px 0; border-bottom: 4px double var(--red); font-size: 13px; color: var(--ink2); font-family: var(--sans); }
.lend { margin-top: 14px; border: 1px solid var(--line2); border-radius: 0; padding: 0 12px 12px; }
.lend summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-size: 14px; }
.split { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; flex-wrap: wrap; }
.split input { width: 64px; }

/* 一覧 */
.list-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.list-h h2 { letter-spacing: .06em; }
.month { display: flex; align-items: center; gap: 2px; }
.month h2 { font-size: 18px; min-width: 7.5em; text-align: center; }
.list-sum { display: flex; gap: 12px; font: 13px var(--num), var(--sans); color: var(--ink2); }
.filters { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px; margin-top: 10px; align-items: center; }
.filters .more-f, .filters > .btn { grid-column: 1 / -1; }
.more-f summary { font-size: 13px; color: var(--ink2); min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.chip-check { min-height: 44px; padding: 0 12px; border-radius: var(--r); border: 1px solid color-mix(in oklab, var(--check) 50%, transparent); background: var(--surface); color: var(--check); font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip-check[aria-pressed="true"] { background: var(--check); color: var(--surface); border-color: var(--check); }
select.chip { min-height: 44px; font-size: 13px; padding: 4px 8px; }
.page-h { font-size: 20px; margin: 4px 4px 12px; letter-spacing: .06em; }

/* 撮る */
.cam-actions { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--frame); border-radius: 0; }
.shoot { width: 96px; height: 96px; border-radius: 50%; border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: 700 17px var(--sans); letter-spacing: .1em; cursor: pointer; box-shadow: inset 0 0 0 4px var(--surface); }
.shoot:active { transform: scale(.97); }
.cam-side { display: grid; gap: 8px; }
.cam .switch { margin-top: 8px; }
.strip { display: grid; gap: 12px; margin-top: 12px; }
.group { background: var(--surface); border: 1px solid var(--line2); border-radius: 0; padding: 10px; }
.g-n { font-size: 12.5px; color: var(--ink2); }
.g-imgs { display: flex; gap: 8px; overflow-x: auto; margin-top: 6px; }
figure.thumb { margin: 0; position: relative; cursor: default; height: 150px; }
figure.thumb figcaption { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; background: color-mix(in oklab, var(--surface) 90%, transparent); border-top: 1px solid var(--line); }
figure.thumb .icon { width: 44px; height: 44px; }
.thumb.busy { display: grid; place-items: center; font-size: 12px; color: var(--mute); width: 96px; height: 128px; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .5; } }

/* 集計（月末の締めの欄） */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0; margin-top: 8px; padding: 0; background: var(--surface); border: 1px solid var(--frame); border-radius: 0; }
.hero > div { padding: 12px 14px; min-width: 0; }
.hero > div + div { border-left: 1px solid var(--line2); }
.hero-n { width: fit-content; max-width: 100%; font: 700 30px/1.1 var(--num), var(--sans); margin: 4px 0 6px; padding-bottom: 2px; border-bottom: 4px double var(--red); overflow-wrap: anywhere; }
.hero-n.small { font-size: 22px; border-bottom: 1px solid var(--line2); }
.panel { margin-top: 18px; padding: 10px 0 14px; background: none; border: 0; border-top: 1px solid var(--frame); border-radius: 0; position: relative; }
.panel h3 { font-size: 14px; margin-bottom: 10px; letter-spacing: .06em; }
details.panel summary { cursor: pointer; font-size: 14px; min-height: 44px; display: flex; align-items: center; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.hbars li { display: grid; grid-template-columns: 6.5em minmax(0, 1fr) 10.5em; gap: 8px; align-items: center; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-track { position: relative; height: 10px; background: var(--surface); border: 1px solid var(--line2); border-radius: 0; }
.hb-track i { position: absolute; inset: 0 auto 0 0; background: var(--ink2); border-radius: 0; max-width: 100%; }
.hb-track b { position: absolute; top: -5px; width: 2px; height: 18px; margin-left: -1px; background: var(--red); }
.hb-val { font: 700 13px var(--num), var(--sans); text-align: right; white-space: nowrap; }
.hb-val small { font-weight: 400; color: var(--mute); }
.hb-over { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; color: var(--check); font-size: 12px; }
.hb-over .ic, .ok .ic, .w-obs .ic { width: 16px; height: 16px; vertical-align: -3px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink2); margin-bottom: 4px; }
.lg::before { content: ''; display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--ink); vertical-align: middle; margin-right: 6px; }
.lg.pace::before { border-top: 2px dashed var(--red); }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--frame); stroke-width: 1; }
.chart .tick { fill: var(--mute); font-size: 10px; }
.chart .pace { stroke: var(--red); stroke-width: 1.25; stroke-dasharray: 4 4; }
.chart .cum { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-linejoin: round; }
.chart .cum-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.chart .dlabel { fill: var(--ink2); font-size: 10.5px; }
.chart .dlabel.strong { fill: var(--ink); font-weight: 700; }
.chart .cross { stroke: var(--ink2); stroke-width: 1; }
.chart .bar { fill: var(--ink2); }
.tip { margin-top: 6px; font: 12.5px var(--num), var(--sans); color: var(--ink); background: var(--sunk); border: 1px solid var(--line2); padding: 6px 8px; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 8px; font: 13px var(--num), var(--sans); }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.tbl th { border-bottom-color: var(--frame); font-weight: 700; }
.tbl td + td, .tbl th + th { border-left: 1px solid var(--line); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }

/* 財布（1冊ずつの欄） */
.wallets { display: grid; gap: 12px; margin-top: 12px; }
.wallets + .f-h { margin-top: 10px; }
.wallet { background: var(--surface); border: 1px solid var(--line2); border-top: 1px solid var(--frame); border-radius: 0; padding: 4px 14px 12px; }
.wallet header { display: flex; align-items: center; gap: 10px; min-height: 48px; border-bottom: 1px solid var(--line); }
.wallet h3 { font-size: 16px; }
.wallet header .f-h { flex: 1; }
.w-bal { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 10px; }
.w-n { font: 700 24px var(--num), var(--sans); padding-bottom: 1px; border-bottom: 1px solid var(--line2); }
.w-obs { margin-top: 8px; font-size: 13px; color: var(--ink2); line-height: 1.6; }
.w-obs strong { color: var(--check); }
.w-obs .ok { color: var(--ok); }

/* その他 */
.sec { background: var(--surface); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin-top: 0; }
.sec:first-of-type { border-top: 1px solid var(--frame); }
.sec > summary { min-height: 52px; display: flex; align-items: center; padding: 0 8px; cursor: pointer; font-size: 15px; }
.sec[open] > summary { font-weight: 700; }
.sec-b { padding: 0 8px 16px; }
.sec-b h4 { font-size: 13px; margin: 16px 0 6px; color: var(--ink2); letter-spacing: .04em; }
.cat-list, .recurs, .iou-sum, .ious, .log { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 0; }
.cat-list li { display: grid; grid-template-columns: minmax(0, 1fr) 120px 44px; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); }
.recur { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 0; background: none; border-bottom: 1px solid var(--line); border-radius: 0; }
.recur label:not(.switch) { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.recur input[type=number] { width: 64px; }
.ious li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.log li { font-size: 12px; color: var(--ink2); padding: 4px 0; border-bottom: 1px solid var(--line); }

.toast { position: fixed; z-index: 20; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 480px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-radius: 0; background: var(--toast); color: var(--toast-ink); font-size: 14px; animation: up .3s var(--ease); }
.toast button { background: none; border: 0; color: var(--toast-act); font-weight: 700; cursor: pointer; min-height: 44px; }

/* PC: 左に縦のタブ（ノートの見出しインデックス）、面は中央 */
@media (min-width: 900px) {
  body { padding-left: 96px; }
  #top { padding-left: 24px; }
  #nav { top: 0; right: auto; width: 96px; height: 100dvh; grid-template-columns: 1fr; grid-template-rows: repeat(5, 76px); align-content: start; padding-top: var(--top-h); border-top: 0; border-right: 1px solid var(--frame); }
  #nav a { border-left: 0; border-top: 1px solid var(--line); }
  #nav a:first-child { border-top: 0; }
  #nav a[aria-current="page"] { box-shadow: none; }
  #nav a.cam .ic { margin-top: 0; }
  #main { padding: 20px 24px 40px; }
  .toast { bottom: 24px; }
  dialog.sheet { inset: 0; margin: auto; width: min(560px, 92vw); max-height: 88dvh; border: 1px solid var(--frame); }
  dialog.sheet.wide { width: min(760px, 92vw); }
  .filters { grid-template-columns: auto minmax(0, 1fr) auto; }
  .filters > .btn { grid-column: auto; }
}
/* 広い PC: ホームはノートの見開き（左のページに集計欄とお知らせ、右のページに日ごとの行、真ん中に綴じ目の罫） */
@media (min-width: 1200px) {
  #main:has(> .spread) { max-width: 1240px; }
  .spread { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); align-items: start; }
  .page-l { position: sticky; top: calc(var(--top-h) + 20px); padding-right: 28px; }
  .page-r { min-width: 0; padding-left: 28px; border-left: 1px solid var(--frame); }
  .page-r > .days:first-child { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .wb { border: 1px solid CanvasText; } .b-bar i, .hb-track i { background: Highlight; } }

[hidden] { display: none !important; }
