/* 家計ひとめ：通帳とレシートをイメージ。緑青の帯に大きな数字、記録は罫線の帳簿 */
:root {
  --bg: #eef2f1; --card: #ffffff; --ink: #1d2b29; --sub: #566865; --line: #d6dfdd;
  --teal: #2f6f68; --teal-soft: #dcebe8; --warn: #b5523b; --track: #e3eae8;
  --hero: #2f6f68; --hero-ink: #ffffff; --hero-sub: #cfe5e1; --gold: #f2c46b;
  --rule: #dfe7e5;
  --c0: #2f6f68; --c1: #5b77a6; --c2: #c07a46; --c3: #7f6aa6; --c4: #7c8a87;
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --num: "SF Mono", "Menlo", "Consolas", "Roboto Mono", ui-monospace, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111917; --card: #1a2422; --ink: #e4ecea; --sub: #9fb0ac; --line: #2b3835;
    --teal: #6fb8ad; --teal-soft: #22403b; --warn: #f09a82; --track: #26332f;
    --hero: #1f4a45; --hero-ink: #f2f8f6; --hero-sub: #b6d4cf; --gold: #f2c46b; --rule: #24302d;
    --c0: #6fb8ad; --c1: #8ea6d4; --c2: #e0a073; --c3: #b3a1d8; --c4: #a3b0ad; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.6; font-feature-settings: "palt"; }
.shell { max-width: 560px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 12px; }
.brand { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: .04em; }
.brand svg { width: 20px; height: 20px; fill: var(--teal); }
.month { display: flex; align-items: center; gap: 2px; }
.month h1 { margin: 0; font-size: 16px; font-weight: 700; min-width: 7.5em; text-align: center; font-variant-numeric: tabular-nums; }
.month button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; font-size: 24px; cursor: pointer; color: var(--sub); }
.month button:hover { background: var(--teal-soft); }

/* 通帳の帯：下の辺はレシートのギザギザ */
.summary { position: relative; background: var(--hero); color: var(--hero-ink); border-radius: 22px 22px 0 0; padding: 20px 22px 18px; margin-bottom: 12px; }
.summary::after { content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background: linear-gradient(135deg, var(--hero) 50%, transparent 50%) 0 0 / 14px 10px repeat-x, linear-gradient(225deg, var(--hero) 50%, transparent 50%) 0 0 / 14px 10px repeat-x; }
.label { margin: 0; font-size: 13px; color: var(--hero-sub); letter-spacing: .06em; }
.total { margin: 0 0 14px; font-family: var(--num); font-size: 48px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.total #total { display: inline-block; }
.yen { font-size: 26px; color: var(--hero-sub); margin-right: 4px; }
.meter { height: 8px; background: rgba(255,255,255,.18); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 4px; transition: width .5s ease; }
.meter i.over { background: #ff9a80; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.facts p { margin: 0; display: flex; flex-direction: column; min-width: 0; }
.facts span { font-size: 11px; color: var(--hero-sub); }
.facts b { font-family: var(--num); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts b.neg { color: #ffb4a2; }
.ghost { border: 0; background: none; color: var(--hero-ink); padding: 10px 0; min-height: 44px; cursor: pointer; font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--gold); }
.budget-form { border-top: 1px dashed rgba(255,255,255,.3); padding-top: 10px; }
.budget-form label { font-size: 13px; color: var(--hero-sub); }
.inline { display: flex; gap: 8px; margin-top: 4px; align-items: center; }
.inline .pre { font-family: var(--num); font-size: 18px; }
.inline input { flex: 1; min-width: 0; background: var(--card) !important; color: var(--ink); border-color: transparent !important; }
.help { margin: 6px 0 0; font-size: 12px; color: var(--hero-sub); }
.help.err { color: #ffd0c4; font-weight: 700; }
input[type=text], input[type=date] { height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 0 12px; font-size: 16px; }
.solid { border: 0; background: var(--gold); color: #1d2b29; border-radius: 12px; padding: 0 18px; min-height: 46px; font-weight: 700; cursor: pointer; }

h2 { font-size: 13px; font-weight: 700; color: var(--sub); letter-spacing: .12em; margin: 28px 4px 8px; }
.entry { background: var(--card); border-radius: 0 0 20px 20px; padding: 14px 20px 16px; border: 1px solid var(--line); border-top: 0; }
.entry h2 { margin: 6px 0 2px; }
.amount-row { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--teal); }
.yen-big { font-family: var(--num); font-size: 28px; color: var(--sub); }
#amount { flex: 1; min-width: 0; border: 0; background: transparent; height: 62px; font-family: var(--num); font-size: 40px; font-weight: 600; padding: 0; text-align: right; font-variant-numeric: tabular-nums; }
#amount::placeholder { color: var(--line); }
#amount:focus-visible { outline: none; }
.amount-row:focus-within { border-bottom-color: var(--ink); }
.field-err { margin: 6px 0 0; min-height: 0; font-size: 13px; font-weight: 700; color: var(--warn); }
.field-err:empty { display: none; }
.sub-row { display: grid; grid-template-columns: 3em 1fr; gap: 8px 10px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--sub); }
.sub-row input { width: 100%; min-width: 0; color: var(--ink); }
.hint { font-size: 12px; color: var(--sub); margin: 12px 0 8px; }
.cats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 78px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); cursor: pointer; padding: 10px 2px; font-size: 13px; font-weight: 700; transition: transform .1s, border-color .15s; }
.cat svg { width: 28px; height: 28px; }
.c0 svg { color: var(--c0); } .c1 svg { color: var(--c1); } .c2 svg { color: var(--c2); } .c3 svg { color: var(--c3); } .c4 svg { color: var(--c4); }
.cat:hover { border-color: var(--teal); }
.cat:active { transform: scale(.95); }
.toast { min-height: 0; margin: 10px 0 0; font-size: 13px; color: var(--teal); display: flex; flex-wrap: wrap; gap: 0 10px; align-items: center; }
.toast button { border: 0; background: none; color: var(--teal); text-decoration: underline; cursor: pointer; padding: 6px; min-height: 44px; font-weight: 700; }
.toast.err { color: var(--warn); }

/* 使いみち：帳簿の罫線 */
.bars { list-style: none; margin: 0; padding: 0 4px; border-top: 2px solid var(--ink); }
.bars li { display: grid; grid-template-columns: 4.5em 1fr auto; gap: 10px; align-items: center; padding: 9px 0; font-size: 14px; border-bottom: 1px solid var(--rule); }
.bars .track { height: 10px; background: var(--track); border-radius: 5px; overflow: hidden; }
.bars .track i { display: block; height: 100%; border-radius: 5px; transition: width .5s ease; }
.bars .v { font-family: var(--num); font-size: 14px; text-align: right; min-width: 6.5em; font-variant-numeric: tabular-nums; }
.bars .pct { color: var(--sub); font-size: 11px; margin-left: 4px; display: inline-block; min-width: 2.6em; }
.bars li.empty { border-top: 0; display: block; color: var(--sub); font-size: 13px; padding: 14px 0; border-bottom: 0; }

/* 記録：日付で区切った帳簿 */
.day { margin-bottom: 4px; }
.day h3 { margin: 0; padding: 14px 4px 4px; display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--sub); border-bottom: 2px solid var(--ink); }
.day h3 b { font-family: var(--num); color: var(--ink); }
.day ul { list-style: none; margin: 0; padding: 0; }
.day li { display: flex; align-items: center; gap: 10px; padding: 2px 0 2px 4px; border-bottom: 1px solid var(--rule); min-height: 52px; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.day .what { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.day .what small { display: block; color: var(--sub); font-size: 12px; }
.day .amt { font-family: var(--num); font-variant-numeric: tabular-nums; }
.del { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; cursor: pointer; color: var(--sub); font-size: 18px; flex: none; }
.del:hover { background: var(--teal-soft); color: var(--warn); }
.empty { color: var(--sub); padding: 18px 4px; font-size: 14px; margin: 0; border-top: 2px solid var(--ink); }

.foot { margin-top: 40px; text-align: center; font-size: 12px; color: var(--sub); }
.foot p { margin: 2px 0; }
.foot a { color: var(--teal); display: inline-block; padding: 8px; }

@media (max-width: 380px) { .cats { grid-template-columns: repeat(3, 1fr); } .total { font-size: 40px; } }
@media (prefers-reduced-motion: no-preference) {
  .bump { animation: bump .45s ease; }
  .day:first-child li:first-child { animation: slip .35s ease both; }
}
@keyframes bump { 30% { transform: translateY(-4px); color: var(--gold); } }
@keyframes slip { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* 自分で入れた項目 */
.cats .fc { display: contents; }
.fc-chip { position: relative; display: grid; min-width: 0; }
.fc-chip .cat { min-width: 0; }
.cat span { max-width: 100%; overflow-wrap: anywhere; text-align: center; line-height: 1.3; }
.fc-del { position: absolute; top: -6px; right: -6px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--sub); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.fc-del::before { content: ""; position: absolute; inset: -8px; }
.fc-del:hover { color: var(--warn); border-color: var(--warn); }
.fc-open { word-break: keep-all;overflow-wrap:break-word; min-height: 78px; border: 1.5px dashed var(--teal); border-radius: 16px; background: transparent; color: var(--teal); cursor: pointer; font-size: 13px; font-weight: 700; padding: 6px 4px; line-height: 1.35; }
.fc-row { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.fc-in { flex: 1 1 9em; min-width: 0; color: var(--ink); }
.fc-in[aria-invalid=true] { border: 2px solid var(--warn); }
.fc-add, .fc-no, .fc-undo { min-height: 46px; border-radius: 12px; padding: 0 16px; font-weight: 700; cursor: pointer; border: 1px solid var(--teal); background: var(--teal); color: #fff; }
.fc-no, .fc-undo { background: transparent; color: var(--ink); border-color: var(--line); }
@media (prefers-color-scheme: dark) { .fc-add { color: #111917; } }
.fc-err { grid-column: 1 / -1; margin: 0; font-size: 13px; font-weight: 700; color: var(--warn); }
.fc-note { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--sub); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.fc-err:empty, .fc [hidden] { display: none; }
.bars .bn { overflow-wrap: anywhere; line-height: 1.3; }

/* iPhone (WebKit) keeps a fieldset at least as wide as its content; let it shrink so nothing overflows narrow screens */
fieldset{min-width:0;min-inline-size:0}
input,select,textarea{max-width:100%}
