/* 家計簿 — 白基調・若竹の緑1色。主役は大きな数字（design-taste §2） */

:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1c1a16;
  --muted: #6e695f;
  --line: #e5e1d7;
  --track: #ece8de;
  --accent: #4a9a2a;
  --accent-ink: #ffffff;
  --accent-soft: #eaf3e2;
  --over: #8a8478;      /* 枠をこえた分。赤にしない */
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 6px 20px rgba(40, 30, 10, .04);
  --mincho: 'Shippori Mincho B1', 'Yu Mincho', 'Hiragino Mincho ProN', serif;
  --gothic: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
  --r: .55em;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --card: #1d1c19;
    --ink: #eeeae1;
    --muted: #a19b8f;
    --line: #2f2d28;
    --track: #2b2924;
    --accent: #7cc152;
    --accent-ink: #10140c;
    --accent-soft: #223019;
    --over: #8f897d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--gothic);
  font-weight: 500;
  line-height: 1.6;
  padding-bottom: calc(136px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 16px 24px; }
.view { display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }
#view-home { max-width: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.eyebrow { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.h2 { font-family: var(--mincho); font-weight: 800; font-size: 24px; margin: 0; }
.num-xl, .num-xxl { font-family: var(--mincho); font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1; }
.num-xl { font-size: 44px; }
.num-xxl { font-size: 64px; }
.yen { font-family: var(--mincho); font-weight: 700; font-size: 18px; margin-left: 4px; }

/* ------------------------------------------------------------ ホーム */
.home-grid { display: grid; gap: 14px; grid-template-columns: 1fr; max-width: 640px; margin: 0 auto; width: 100%; }
@media (min-width: 960px) {
  .home-grid { grid-template-columns: 1fr 1fr; max-width: none; align-items: start; }
}

.goal-title { font-family: var(--mincho); font-weight: 800; font-size: 24px; line-height: 1.35; margin: 6px 0 14px; }
.goal-amount { margin: 0 0 14px; }
.goal-pace { margin: 10px 0 0; font-size: 14px; }
.goal-notes { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted); }
.goal-notes li + li { margin-top: 2px; }
.goal-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

.week-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.month-head { margin-top: 20px; } /* v0.4 今月（月で見る枠）。見た目は3タブで作り直す */
.week-left { margin: 10px 0 4px; }
.week-left.over .num-xxl { color: var(--ink); }
.frames { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.frame-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.frame-name { font-weight: 700; font-size: 15px; }
.frame-left { font-family: var(--mincho); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.frame-left small { font-family: var(--gothic); font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 2px; }
.frame-left.is-over { color: var(--over); }
.frame-bar { height: 4px; border-radius: 99px; background: var(--track); margin-top: 6px; overflow: hidden; }
.frame-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.frame-bar span.is-over { background: var(--over); }
.frame-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.unsorted-note { display: block; margin-top: 16px; font-size: 13px; color: var(--muted); text-decoration: none; border-top: 1px solid var(--line); padding-top: 12px; }
.unsorted-note:hover { color: var(--ink); }
.import-note { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.import-note.is-warn { color: var(--ink); font-weight: 600; }
.import-note.is-warn::before { content: "● "; color: var(--over); }


/* ------------------------------------------------------------ ボタン */
.btn {
  min-height: 42px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--card); color: var(--ink);
  font-weight: 700; font-size: 15px; cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { border-color: var(--accent); filter: brightness(1.05); }
.btn-wide { min-height: 54px; font-size: 16px; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn-icon { min-width: 42px; padding: 0; font-size: 22px; line-height: 1; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; padding-left: 4px; padding-right: 4px; }
.btn-quiet.armed { color: var(--ink); border-color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }

/* ------------------------------------------------------------ 明細 */
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.import-msg { margin: 0; padding: 10px 14px; border-radius: var(--r); background: var(--accent-soft); font-size: 14px; }
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.tx-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tx { display: grid; grid-template-columns: 3.2em minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.tx:first-child { border-top: 0; }
.tx-date { font-size: 13px; color: var(--muted); line-height: 1.3; }
.tx-date b { display: block; font-family: var(--mincho); font-weight: 800; font-size: 17px; color: var(--ink); }
.tx-main { min-width: 0; }
.tx-content { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-inst { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tx-amount { font-family: var(--mincho); font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amount.plus { color: var(--accent); }
.tx.is-excluded .tx-amount, .tx.is-excluded .tx-content { color: var(--muted); }
.pill {
  min-height: 30px; padding: 3px 10px; border-radius: 99px;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.pill:hover { border-color: var(--muted); }
.pill.is-unsorted { border-color: var(--accent); color: var(--accent); }
.pill.is-exclude { color: var(--muted); }
.empty { text-align: center; margin: 24px 0; }

/* ------------------------------------------------------------ ふり返り */
.review-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.review-table td { padding: 8px 0; border-top: 1px solid var(--line); vertical-align: baseline; }
.review-table tr:first-child td { border-top: 0; }
.review-table td:last-child { text-align: right; white-space: nowrap; }
.review-table .amt { font-family: var(--mincho); font-weight: 800; font-size: 17px; }
.review-table .of { color: var(--muted); font-size: 13px; margin-left: 4px; }
.review-table .over { color: var(--over); font-size: 12px; display: block; }

textarea, input[type=text], input[type=date], select {
  width: 100%; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); font-size: 16px;
}
textarea { resize: vertical; margin-top: 8px; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; }
.row-end .btn { flex-shrink: 0; white-space: nowrap; } /* 長い断り文が出ても「保存」を縦に潰さない */

/* ------------------------------------------------------------ 設定 */
.form label { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 10px; }
.form label input, .form label textarea { margin-top: 4px; color: var(--ink); font-weight: 500; }
.form .eyebrow { margin-top: 18px; color: var(--ink); }
.form .eyebrow:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 360px) { .grid2 { grid-template-columns: 1fr; } }
.plain-list { list-style: none; margin: 8px 0 0; padding: 0; }
.plain-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); min-width: 0; }
.plain-list li:first-child { border-top: 0; }
.plain-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-list .cat { font-size: 12px; color: var(--muted); white-space: nowrap; }
.plain-list .btn { min-height: 36px; padding: 4px 10px; font-size: 13px; }
.rule-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; margin-top: 10px; }
@media (max-width: 520px) { .rule-add { grid-template-columns: 1fr 1fr; } .rule-add input { grid-column: 1 / -1; } }

/* ------------------------------------------------------------ タブ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; align-items: center; justify-content: center; min-height: 56px;
  color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px; position: relative;
}
.tabbar a.on { color: var(--ink); }
.tabbar a.on::before { content: ''; position: absolute; top: -1px; left: 30%; right: 30%; height: 2px; background: var(--accent); border-radius: 2px; }

/* ------------------------------------------------------------ ダイアログ */
.dlg {
  border: 1px solid var(--line); border-radius: calc(var(--r) * 1.6);
  background: var(--card); color: var(--ink);
  padding: 0; width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
.dlg::backdrop { background: rgba(20, 18, 14, .4); }
.dlg-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }
.amount-input { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--line); padding-bottom: 4px; }
.amount-input:focus-within { border-color: var(--accent); }
.amount-input input {
  border: 0; background: transparent; padding: 0; min-height: 0; outline: none !important;
  font-family: var(--mincho); font-weight: 800; font-size: 44px; line-height: 1.1; width: 100%; min-width: 0; font-variant-numeric: tabular-nums;
}
.amount-input span { font-family: var(--mincho); font-weight: 700; font-size: 18px; }
.chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.chips-col { grid-template-columns: repeat(2, 1fr); }
.chip {
  min-height: 46px; padding: 8px 10px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-weight: 700; font-size: 14px; cursor: pointer; text-align: left;
}
.chip:hover { border-color: var(--muted); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }
.chip small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.more summary { cursor: pointer; color: var(--muted); font-size: 13px; min-height: 32px; }
.more input { margin-top: 8px; }
.form-error { margin: 0; font-size: 13px; color: var(--ink); background: var(--track); padding: 6px 10px; border-radius: var(--r); }
.cat-tx { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.invite-result { min-height: 96px; }
.invite-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.invite-line:first-child { border-top: 0; }
.invite-line b { font-family: var(--mincho); font-weight: 800; font-size: 26px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rule-q { margin: 0; font-size: 17px; }
.rule-q strong { font-family: var(--mincho); font-weight: 800; }
.rule-q + label input { margin-top: 4px; }

/* ------------------------------------------------------------ 帯・トースト */
.env-banner {
  background: repeating-linear-gradient(-45deg, #f5c400 0 14px, #1c1a16 14px 28px);
  color: #fff; text-align: center; font-size: 12px; font-weight: 700; padding: 4px;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}
.toast {
  position: fixed; left: 50%; bottom: calc(132px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r);
  font-size: 14px; font-weight: 700; z-index: 30; max-width: calc(100vw - 32px);
  animation: toast-in .16s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

/* 判子：積立を記録したとき（design-taste §2「完成の演出は判子で刻む」） */
.stamp {
  position: absolute; right: 18px; top: 18px; width: 72px; height: 72px;
  border: 3px solid var(--accent); border-radius: 50%; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mincho); font-weight: 800; font-size: 15px; line-height: 1.1; text-align: center;
  transform: rotate(-12deg); pointer-events: none;
  animation: stamp .32s cubic-bezier(.2, 1.4, .4, 1) both, stamp-out .5s ease-in 1.6s forwards;
}
@keyframes stamp { from { opacity: 0; transform: rotate(-12deg) scale(1.8); } to { opacity: .9; transform: rotate(-12deg) scale(1); } }
@keyframes stamp-out { to { opacity: 0; } }
.goal { position: relative; }

@media (max-width: 400px) {
  .num-xxl { font-size: 54px; }
  .num-xl { font-size: 38px; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------ v0.1 レビュー後（2026-11-29） */
.goal-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* 目標の帯：押すと詳細が開く */
.goal-band {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 6px 12px;
  width: 100%; min-height: 56px; padding: 12px 16px; text-align: left; cursor: pointer;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.goal-band:hover { border-color: var(--muted); }
.band-label { font-weight: 700; font-size: 14px; white-space: nowrap; }
.band-num { justify-self: end; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.band-num b { font-family: var(--mincho); font-weight: 800; font-size: 17px; }
.band-meter { grid-column: 1 / -1; position: relative; height: 6px; border-radius: 99px; background: var(--track); margin: 4px 7px 2px; }
.band-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 99px; background: var(--accent); transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.band-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--card); border: 3px solid var(--accent); transition: left .35s cubic-bezier(.2, .8, .2, 1); }

/* 目標の詳細 */
.goal-room { margin: -8px 0 12px; color: var(--muted); font-size: 14px; }
.goal-amount { margin: 0 0 16px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 2px; }
.goal-amount .yen { margin-left: 4px; }
.goal-pct { font-family: var(--mincho); font-weight: 700; font-size: 16px; color: var(--muted); margin-left: 2px; }
.gauge { display: flex; align-items: center; gap: 3px; }
.gauge > span { position: relative; overflow: hidden; border-radius: 99px; background: var(--track); min-width: 0; }
.g-main { height: 12px; }
.g-ext { height: 5px; opacity: .9; }
.g-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 99px; transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.g-ext .g-fill { opacity: .55; }
.gauge-legend { position: relative; height: 20px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.gauge-legend span { position: absolute; top: 0; white-space: nowrap; }
.gauge-legend span:first-child { transform: translateX(-100%); font-weight: 700; color: var(--ink); }
.gauge-legend span:last-child { right: 0; }

/* 下のタブの上に常に出す2つのボタン */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: calc(57px + env(safe-area-inset-bottom)); z-index: 11;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.actionbar .btn { min-height: 48px; font-size: 16px; }
@media (min-width: 700px) { .actionbar { padding-left: calc(50% - 320px); padding-right: calc(50% - 320px); } }

/* ふり返りの一番上の1行 */
.review-lead { margin: 0; padding: 14px 16px; border-radius: var(--r); background: var(--accent-soft); font-size: 15px; line-height: 1.7; }
.review-lead b { font-family: var(--mincho); font-weight: 800; font-size: 22px; margin: 0 1px; }
.review-lead.plain { background: transparent; border: 1px solid var(--line); }

/* 誘われた？ */
.invite-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.invite-choice .btn { min-height: 48px; font-size: 14px; }
.invite-skip { margin: 8px 0; font-size: 16px; text-align: center; }
.invite-skip b { font-family: var(--mincho); font-weight: 800; font-size: 40px; color: var(--accent); margin: 0 2px; }
.rule-hits { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.6em; overflow-wrap: anywhere; }

/* 明細は行全体を押せる */
.tx { cursor: pointer; min-height: 56px; }
.tx:hover { background: var(--bg); }
.tx:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pill { pointer-events: none; display: inline-flex; align-items: center; }
.goal-unit { white-space: nowrap; }
@media (max-width: 400px) { .goal-unit { font-size: 16px; } .goal-pct { font-size: 14px; } }

/* 合言葉の層（dialog でなく、画面いっぱいの層。Esc や戻るで消えない） */
.login-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-layer[hidden] { display: none; }
.login-box { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
