:root {
  --orange: #d97706;
  --orange-dark: #a94f08;
  --orange-soft: #fff3df;
  --cream: #fbf8f3;
  --paper: #ffffff;
  --ink: #27221e;
  --muted: #746c64;
  --line: #e9e2d9;
  --green: #087f5b;
  --green-soft: #e6f6ef;
  --red: #c2413b;
  --red-soft: #fff0ee;
  --blue: #2563a6;
  --blue-soft: #edf5ff;
  --shadow: 0 14px 40px rgba(84, 57, 31, .08);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; font-size: 16px; scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 0; min-height: 100vh; background: var(--cream); color: var(--ink); font-family: var(--font); line-height: 1.6; }
button, input, select { font: inherit; }
/*
 * ダブルタップによる拡大を止める。拡大されたまま画面が見切れるのを防ぐのが目的なので、
 * ピンチ操作での拡大は残す（manipulation が無効にするのはダブルタップだけ）。
 * viewport へ user-scalable=no は書かない。拡大したい利用者の手段を奪わないため。
 */
html, body, button, input, select, textarea, label, summary, a { touch-action: manipulation; }
/*
 * iOS Safariの日付・月の入力欄は、既定の外観のままだと中身に合わせて幅が決まり、
 * width:100% を指定しても親からはみ出す。スマホでは外観を外し、普通の入力欄として扱う。
 * PCはカレンダーのアイコンが出る既定の外観のまま残す。
 */
@media (max-width: 759px) {
  input[type="date"], input[type="month"] { -webkit-appearance: none; appearance: none; display: block; max-width: 100%; }
}
button { color: inherit; }
a { color: var(--orange-dark); }
.hidden, [hidden] { display: none !important; }
.money-value { white-space: nowrap; overflow-wrap: normal; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }

.app-shell { min-height: 100vh; }
.sidebar { display: none; }
.main-content { min-width: 0; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.mobile-header { height: 58px; display: flex; align-items: center; padding: 0 18px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
/* デモ表示中の帯。閲覧専用であることと、登録への導線をどの画面でも見せる。 */
.demo-banner { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--orange-soft); border-bottom: 1px solid #f3ddb8; }
.demo-banner-tag { flex: 0 0 auto; padding: 3px 8px; border-radius: 999px; background: var(--orange); color: #fff; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.demo-banner p { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--orange-dark); font-size: 11px; font-weight: 600; line-height: 1.4; }
.demo-banner .button { flex: 0 0 auto; min-height: 34px; padding: 6px 11px; font-size: 12px; text-decoration: none; }
/*
 * デモは閲覧専用。api.php がPOSTを403で拒むため書き換えは起きないが、
 * 押せないボタンを見せる意味がないので、書き込みの入口そのものを出さない。
 * 追加・編集・削除・確定はすべて data-action か固定のidを持つため、ここでまとめて隠せる。
 */
body[data-demo] [data-action^="open-"],
body[data-demo] [data-action^="edit-"],
body[data-demo] [data-action^="archive-"],
body[data-demo] [data-action^="delete-"],
body[data-demo] [data-action="toggle-entry-status"],
body[data-demo] #toggle-month-status,
/* 一括登録は入力しかできない画面なので、閲覧専用のデモでは導線ごと外す。 */
body[data-demo] [data-view="bulk"] { display: none !important; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 750; letter-spacing: -.04em; }
/* アプリ内のロゴはトップへのリンク。見た目は文字のままにする。 */
.app-brand { width: max-content; color: var(--ink); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; box-shadow: 0 5px 14px rgba(217,119,6,.22); }
.brand-logo { width: 32px; height: 32px; display: block; border-radius: 11px; }

/* アイコンは文字色を継承する。サイズは置き場所ごとに指定する。 */
.icon-sprite { display: none; }
.icon { width: 1.5em; height: 1.5em; display: block; flex: 0 0 auto; }
.topbar { height: 58px; display: flex; align-items: center; justify-content: center; gap: 12px; position: sticky; top: 0; z-index: 15; background: rgba(251,248,243,.94); border-bottom: 1px solid rgba(233,226,217,.8); backdrop-filter: blur(12px); }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); font-size: 25px; line-height: 1; cursor: pointer; }
.month-button { position: relative; min-width: 145px; height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); font-weight: 700; cursor: pointer; }
.month-button input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.view { display: none; width: min(100% - 32px, 1040px); margin: 0 auto; padding: 26px 0 8px; }
.view.active { display: block; }
.page-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; margin-bottom: 20px; }
.page-heading h1 { margin: 1px 0 5px; font-size: clamp(25px, 6vw, 35px); line-height: 1.25; letter-spacing: -.045em; }
.page-heading p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; }
.page-heading-action { align-items: center; }
.page-heading-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.eyebrow { margin: 0; color: var(--orange-dark); font-size: 10px; font-weight: 800; letter-spacing: .13em; }

.button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 17px; border: 1px solid transparent; border-radius: 13px; font-weight: 700; cursor: pointer; transition: transform .15s, background .15s, border-color .15s; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button-primary { background: var(--orange); color: #fff; box-shadow: 0 7px 18px rgba(217,119,6,.18); }
.button-primary:hover { background: var(--orange-dark); }
.button-secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.button-danger { background: var(--red-soft); color: var(--red); border-color: #f4cbc7; }
.button-compact { min-height: 40px; width: auto; padding: 7px 13px; font-size: 13px; white-space: nowrap; }

.monthly-notices, .forecast-records-section { margin-bottom: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.monthly-notices-heading, .forecast-records-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.monthly-notices-heading h2, .forecast-records-heading h2 { margin: 0; font-size: 16px; }
.monthly-notices-heading > span { padding: 3px 8px; border-radius: 999px; background: #f8f5f0; color: var(--muted); font-size: 10px; font-weight: 750; }
.monthly-notices-list { display: grid; gap: 8px; }
.monthly-notice { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border-radius: 13px; background: var(--blue-soft); color: var(--blue); }
.monthly-notice.warning { background: var(--orange-soft); color: var(--orange-dark); }
.monthly-notice.danger { background: var(--red-soft); color: var(--red); }
.monthly-notice.ok { background: var(--green-soft); color: var(--green); }
.monthly-notice-mark { flex: 0 0 auto; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.75); font-size: 12px; font-weight: 850; }
.monthly-notice-body { min-width: 0; flex: 1 1 auto; }
.monthly-notice-body strong, .monthly-notice-body small { display: block; }
.monthly-notice-body strong { font-size: 12px; line-height: 1.45; }
.monthly-notice-body small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.monthly-notice-actions { display: flex; flex: 0 0 auto; gap: 6px; }
.notice-action { min-height: 30px; padding: 4px 9px; border: 1px solid currentColor; border-radius: 9px; background: rgba(255,255,255,.72); color: inherit; font-size: 10px; font-weight: 750; cursor: pointer; }
.notice-visibility { color: var(--muted); }
.hidden-notices { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.hidden-notices > summary { display: flex; align-items: center; justify-content: space-between; padding: 5px 2px; color: var(--muted); font-size: 11px; font-weight: 750; cursor: pointer; }
.hidden-notices > summary strong { font-size: 10px; }
.hidden-notices[open] > summary { margin-bottom: 8px; }
.hidden-notices .monthly-notice { background: #f8f5f0; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.forecast-records-heading p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.forecast-records-list { display: grid; gap: 8px; }
.forecast-record-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; align-items: center; gap: 10px; padding: 10px 11px; border-radius: 12px; background: #f8f5f0; }
.forecast-record-date { color: var(--blue); font-size: 11px; font-weight: 800; }
.forecast-record-main { min-width: 0; }
.forecast-record-main strong, .forecast-record-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forecast-record-main strong { font-size: 12px; }
.forecast-record-main small { color: var(--muted); font-size: 10px; }
.forecast-record-amount { font-size: 13px; }
.forecast-record-actions { display: flex; gap: 5px; }
.notice-visibility { margin-left: auto; opacity: .78; }
.hidden-notices { margin-top: 10px; border-top: 1px solid var(--line); }
.hidden-notices > summary { display: flex; align-items: center; justify-content: space-between; padding: 11px 2px 3px; color: var(--muted); font-size: 11px; font-weight: 750; cursor: pointer; }
.hidden-notices > summary strong { font-size: 10px; }
.hidden-notices .monthly-notices-list { margin-top: 8px; }
.hidden-notices .monthly-notice { background: #f4f1ec; color: var(--muted); box-shadow: inset 3px 0 0 #d8d0c6; }

.funds-summary { margin-bottom: 18px; padding: 17px; border: 1px solid #efc181; border-radius: var(--radius); background: linear-gradient(135deg, #fff9ee, #fff); box-shadow: var(--shadow); }
.funds-summary-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.funds-summary-heading div { min-width: 0; }
.funds-summary-heading span { display: block; color: var(--orange-dark); font-size: 9px; font-weight: 850; letter-spacing: .13em; }
.funds-summary-heading strong { display: block; margin-top: 1px; font-size: 13px; }
.funds-summary-heading small { max-width: 360px; color: var(--muted); text-align: right; font-size: 10px; }
.funds-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.funds-summary-grid > div { min-width: 0; padding: 11px 12px; border-radius: 13px; background: rgba(255,255,255,.82); }
.funds-summary-grid span { display: block; color: var(--muted); font-size: 10px; }
.funds-summary-grid strong { display: block; margin-top: 2px; font-size: clamp(15px, 4vw, 21px); line-height: 1.3; }
.funds-summary-grid .total { background: var(--orange); color: #fff; }
.funds-summary-grid .total span { color: rgba(255,255,255,.8); }

.forecast-grid { display: grid; gap: 15px; }
.forecast-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.forecast-card.needs-money { border-color: #efc181; }
.forecast-main { padding: 18px; }
.forecast-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.forecast-title-row h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.forecast-title-row p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.forecast-title-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; }
.need-pill { padding: 4px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 800; white-space: nowrap; }
.needs-money .need-pill { background: var(--orange-soft); color: var(--orange-dark); }
.forecast-balance-button { min-height: 28px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--muted); font-size: 10px; font-weight: 750; white-space: nowrap; cursor: pointer; }
.forecast-balance-button:hover { border-color: #d8cab8; color: var(--orange-dark); }
.forecast-hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; margin: 19px 0 14px; }
.metric { min-width: 0; padding: 13px; border-radius: 14px; background: #f8f5f0; }
.metric.highlight { background: var(--orange-soft); }
.metric.forecast-prediction { background: var(--blue-soft); }
.metric-label { color: var(--muted); font-size: 11px; }
.metric-value { display: block; margin-top: 3px; font-size: clamp(19px, 5vw, 27px); line-height: 1.25; font-weight: 800; letter-spacing: -.035em; white-space: nowrap; }
.metric.highlight .metric-value { color: var(--orange-dark); }
.metric.forecast-prediction .metric-value { color: var(--blue); }
.metric-sub { margin-top: 3px; color: var(--muted); font-size: 10px; }
/* --- 全口座横断の総残高 --- */
.section-title { margin: 26px 0 12px; font-size: 15px; letter-spacing: -.02em; }
.overview-summary { margin-bottom: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.overview-primary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.overview-primary > div { min-width: 0; padding: 13px; border-radius: 14px; background: var(--blue-soft); }
.overview-primary > div:last-child { background: #f8f5f0; }
.overview-primary span { display: block; color: var(--muted); font-size: 11px; }
.overview-primary strong { display: block; margin-top: 3px; font-size: clamp(20px, 5vw, 28px); line-height: 1.25; font-weight: 800; letter-spacing: -.035em; color: var(--blue); }
.overview-primary > div:last-child strong { color: var(--ink); }
.overview-primary small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.overview-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.overview-metrics > div { min-width: 0; padding: 11px 13px; border-radius: 12px; background: #f8f5f0; }
.overview-metrics > div.is-short { background: var(--orange-soft); }
.overview-metrics span { display: block; color: var(--muted); font-size: 11px; }
.overview-metrics strong { display: block; margin-top: 2px; font-size: clamp(15px, 3.9vw, 19px); font-weight: 800; letter-spacing: -.03em; }
.overview-metrics > div.is-short strong { color: var(--orange-dark); }
.overview-metrics small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }

.overview-trend, .overview-timeline { margin-bottom: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.overview-trend-header { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.overview-trend-header .period-tabs { flex: 0 0 auto; }
.overview-trend-header .period-tab { white-space: nowrap; }
.overview-trend-header h2, .overview-timeline-header h2 { margin: 0; font-size: 14px; }
.overview-trend-header p, .overview-timeline-header p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.overview-timeline-header { margin-bottom: 10px; }
.monthly-timeline { margin-top: 0; padding: 0; overflow: hidden; }
.monthly-timeline-details > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; list-style: none; cursor: pointer; }
.monthly-timeline-details > summary::-webkit-details-marker { display: none; }
.monthly-timeline-heading { display: flex; min-width: 0; align-items: center; gap: 10px; }
.monthly-timeline-heading > span:last-child { min-width: 0; }
.monthly-timeline-heading strong, .monthly-timeline-heading small { display: block; }
.monthly-timeline-heading strong { font-size: 14px; }
.monthly-timeline-heading small { margin-top: 1px; color: var(--muted); font-size: 10px; }
.section-icon { width: 30px; height: 30px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 10px; background: var(--blue-soft); color: var(--blue); }
.section-icon .icon { width: 17px; height: 17px; }
.monthly-timeline-chevron { color: var(--muted); font-size: 18px; transition: transform .2s ease; }
.monthly-timeline-details[open] .monthly-timeline-chevron { transform: rotate(180deg); }
.monthly-timeline-content { padding: 0 16px 14px; border-top: 1px solid var(--line); }
.trend-chart svg { display: block; width: 100%; height: auto; }
.trend-zero { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; }
.trend-area { fill: var(--blue-soft); opacity: .7; }
.trend-line { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend-dot { fill: var(--paper); stroke: var(--blue); stroke-width: 2.5; }
.trend-dot.is-short { stroke: var(--orange); fill: var(--orange); }
.trend-value { fill: var(--muted); font-size: 11px; font-weight: 700; }
.trend-month { fill: var(--muted); font-size: 11px; }
.average-summary { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-bottom: 6px; }
.average-summary > div { min-width: 0; padding: 10px 11px; border-radius: 12px; background: #faf7f2; }
.average-summary > div.is-short { background: var(--orange-soft); }
.average-summary span { display: block; color: var(--muted); font-size: 10px; }
.average-summary strong { display: block; margin-top: 2px; font-size: clamp(14px, 3.6vw, 18px); line-height: 1.3; }
.average-summary strong.income { color: var(--green); }
.average-summary small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.average-note { margin: 6px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
/* タブが何を切り替えるのか分かるよう、必ず見出しを添える。 */
.period-field { display: grid; gap: 3px; justify-items: start; }
.period-field-label { color: var(--muted); font-size: 10px; font-weight: 750; }
.period-field .period-tabs { margin-bottom: 0; }

.breakdown-details { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fdfbf8; }
.breakdown-details > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; list-style: none; cursor: pointer; }
.breakdown-details > summary::-webkit-details-marker { display: none; }
.breakdown-heading { display: flex; min-width: 0; align-items: center; gap: 10px; }
.breakdown-heading > span:last-child { min-width: 0; }
.breakdown-heading strong, .breakdown-heading small { display: block; }
.breakdown-heading strong { font-size: 13px; }
.breakdown-heading small { margin-top: 1px; color: var(--muted); font-size: 10px; }
.breakdown-chevron { color: var(--muted); font-size: 18px; transition: transform .2s ease; }
.breakdown-details[open] .breakdown-chevron { transform: rotate(180deg); }
.breakdown-content { display: grid; gap: 9px; padding: 11px 13px 13px; border-top: 1px solid var(--line); }
.breakdown-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 3px 10px; }
.breakdown-name { min-width: 0; }
.breakdown-name strong { display: block; font-size: 13px; letter-spacing: -.02em; }
.breakdown-name small { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; }
.breakdown-amount { font-size: 14px; font-weight: 800; text-align: right; white-space: nowrap; }
.breakdown-amount.is-income { color: var(--green); }
.breakdown-bar { grid-column: 1 / -1; height: 5px; border-radius: 999px; background: #f1ece4; overflow: hidden; }
.breakdown-bar svg { display: block; width: 100%; height: 100%; }
.breakdown-bar-fill { fill: var(--orange); }
.breakdown-bar-fill.is-income { fill: var(--green); }

.money-flow { position: relative; margin-top: 14px; padding: 0 0 2px; }
.money-flow::before { position: absolute; top: 18px; bottom: 20px; left: 7px; width: 2px; background: #cbdced; content: ''; }
.money-flow-dot { position: absolute; z-index: 1; left: 0; top: 4px; width: 16px; height: 16px; border: 4px solid var(--paper); border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px #a8c5e2; }
.money-flow-boundary { position: relative; display: flex; min-height: 48px; align-items: flex-start; padding: 0 0 12px 28px; }
.money-flow-boundary.end { min-height: 40px; padding-top: 12px; padding-bottom: 0; }
.money-flow-boundary.end .money-flow-dot { top: 16px; background: var(--orange); box-shadow: 0 0 0 1px #e9b66d; }
.money-flow-boundary small, .money-flow-balance small { display: block; color: var(--muted); font-size: 9px; font-weight: 600; }
.money-flow-boundary strong { display: block; margin-top: 1px; font-size: 18px; letter-spacing: -.02em; }
.money-flow-day { position: relative; display: grid; grid-template-columns: 126px minmax(0,1fr); padding-bottom: 18px; }
.money-flow-date { position: relative; padding: 3px 12px 0 28px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.money-flow-day-content { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.money-flow-entry, .money-flow-day-total { display: grid; grid-template-columns: minmax(0,1fr) 128px 188px; gap: 12px; min-height: 54px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.money-flow-entry-main { min-width: 0; }
.money-flow-entry-main > strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.money-flow-entry-main > small { display: flex; min-width: 0; align-items: center; gap: 4px; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 9px; white-space: nowrap; }
.money-flow-entry-main .mini-status { flex: 0 0 auto; }
.money-flow-change { text-align: right; font-size: 14px; font-weight: 800; white-space: nowrap; }
.money-flow-change.income { color: var(--green); }
.money-flow-change.outgo { color: var(--red); }
.money-flow-balance { min-width: 0; text-align: right; }
.money-flow-balance strong { display: block; margin-top: 1px; overflow: hidden; color: #534d47; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.money-flow-day-total { border-bottom: 0; background: #f8f5f0; }
.money-flow-day-total > span:first-child { font-size: 11px; font-weight: 800; }
.money-flow-more { border-bottom: 1px solid var(--line); }
.money-flow-more > summary { padding: 8px 12px; color: var(--blue); font-size: 10px; font-weight: 750; cursor: pointer; }
.money-flow-more .money-flow-entry:last-child { border-bottom: 0; }
.money-flow-empty { margin: 0 0 16px 28px; padding: 12px; border-radius: 12px; background: #f8f5f0; color: var(--muted); font-size: 11px; }

.forecast-note { margin: 0 0 10px; padding: 9px 11px; border-radius: 11px; background: #f8f5f0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.forecast-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.forecast-stat { padding: 7px 4px; text-align: center; }
.forecast-stat span { display: block; color: var(--muted); font-size: 10px; }
.forecast-stat strong { display: block; margin-top: 2px; font-size: 12px; }
.forecast-detail-toggle { width: 100%; padding: 11px 18px; border: 0; border-top: 1px solid var(--line); background: #fdfbf8; color: var(--muted); text-align: left; font-size: 12px; font-weight: 700; cursor: pointer; }
.timeline { padding: 0 18px 14px; border-top: 1px solid var(--line); background: #fdfbf8; }
.timeline-header, .timeline-row { display: grid; grid-template-columns: 64px minmax(0,1fr) 72px 120px 130px; gap: 10px; align-items: center; }
.timeline-header { padding: 9px 0 7px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; font-weight: 750; }
.timeline-header span:nth-last-child(-n+2) { text-align: right; }
.timeline-row { min-height: 52px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.timeline-row:last-child { border-bottom: 0; }
.timeline-date { color: var(--muted); }
.timeline-name { min-width: 0; }
.timeline-name-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-status-mobile { display: none; width: fit-content; margin-top: 3px; }
.timeline-amount { text-align: right; font-weight: 750; white-space: nowrap; }
.timeline-amount.income { color: var(--green); }
.timeline-amount.outgoing { color: var(--ink); }
.timeline-balance { text-align: right; font-weight: 800; }

.status-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.status-bar > div { min-width: 0; }
.status-bar #month-status-copy { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.status-badge { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-badge.draft { background: var(--orange-soft); color: var(--orange-dark); }
.status-badge.confirmed { background: var(--green-soft); color: var(--green); }
.entry-groups { display: grid; gap: 15px; }
.entry-group { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.entry-group-title { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; background: #f9f6f1; border-bottom: 1px solid var(--line); }
.entry-group-title h2 { margin: 0; font-size: 14px; }
.entry-group-title strong { font-size: 14px; }
.entry-row { display: grid; grid-template-columns: 45px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.entry-row:last-child { border-bottom: 0; }
.entry-date { color: var(--muted); font-size: 11px; text-align: center; }
.entry-body { min-width: 0; }
.entry-name { display: block; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.entry-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; color: var(--muted); font-size: 10px; }
.entry-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.entry-amount { min-width: 70px; padding: 8px 2px; text-align: right; font-weight: 800; white-space: nowrap; }
.entry-amount.income { color: var(--green); }
.entry-input-button, .entry-status-button { min-height: 34px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 10px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.entry-input-button { color: var(--orange-dark); }
.entry-status-button.draft { border-color: #efc181; background: var(--orange-soft); color: var(--orange-dark); }
.entry-status-button.confirmed { border-color: #b7dfce; background: var(--green-soft); color: var(--green); }
.mini-status { padding: 2px 6px; border-radius: 999px; background: #f1eee9; color: var(--muted); font-size: 9px; font-weight: 750; }
.mini-status.confirmed { background: var(--green-soft); color: var(--green); }
.mini-status.snapshot { background: #eaf2fc; color: var(--blue); }
.mini-status.opening { background: #f0ece5; color: var(--ink); }
.mini-status.planned { background: var(--blue-soft); color: var(--blue); }
.row-menu { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }

.bill-summary { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; margin-bottom: 15px; }
.bill-summary > div { padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.bill-summary span { display: block; color: var(--muted); font-size: 10px; }
.bill-summary strong { display: block; margin-top: 2px; font-size: clamp(16px, 4vw, 22px); }
.bill-summary .primary { border-color: #efc181; background: var(--orange-soft); color: var(--orange-dark); }
.bill-list { display: grid; gap: 13px; }
.bill-group { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.bill-group-summary { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 15px; background: #f9f6f1; cursor: pointer; list-style: none; }
.bill-group-summary::-webkit-details-marker { display: none; }
.bill-group-heading, .bill-group-side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bill-group-heading strong { font-size: 14px; }
.bill-group-heading small { padding: 2px 7px; border-radius: 999px; background: #eee9e2; color: var(--muted); font-size: 9px; white-space: nowrap; }
.bill-group-total { color: var(--orange-dark); font-size: 15px; }
.bill-group-chevron { color: var(--muted); font-size: 17px; line-height: 1; transition: transform .15s; }
.bill-group:not([open]) .bill-group-chevron { transform: rotate(-90deg); }
.bill-group-list { border-top: 1px solid var(--line); }
.bill-row { display: grid; grid-template-columns: 58px minmax(0,1fr) minmax(90px,auto); gap: 12px; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--line); font-size: 12px; }
.bill-row:last-child { border-bottom: 0; }
.bill-main { min-width: 0; }
.bill-name { min-width: 0; font-weight: 750; overflow-wrap: anywhere; }
.bill-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 9px; }
.bill-date { color: var(--muted); }
.bill-amount { text-align: right; font-size: 13px; font-weight: 850; white-space: nowrap; }

.period-tabs { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 12px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); scrollbar-width: none; }
.period-tabs::-webkit-scrollbar { display: none; }
.period-tab { min-height: 36px; flex: 0 0 auto; padding: 6px 13px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.period-tab.active { background: var(--orange-soft); color: var(--orange-dark); }
/* 利用分析の期間指定も、一括登録と同じくスマホでは縦に積む。 */
.custom-period { display: flex; flex-direction: column; align-items: stretch; gap: 9px; margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.custom-period label { min-width: 0; flex: 1; }
.custom-period label span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 750; }
.custom-period input { width: 100%; min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.analytics-range { margin: 0 2px 12px; color: var(--muted); font-size: 11px; }
.analytics-list { display: grid; gap: 14px; }
.analytics-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.analytics-card-header { display: flex; justify-content: space-between; gap: 15px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.analytics-card-header h2 { margin: 0; font-size: 15px; }
.analytics-card-header p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.analytics-metrics { display: flex; gap: 18px; text-align: right; }
.analytics-metrics span { display: block; color: var(--muted); font-size: 9px; }
.analytics-metrics strong { display: block; font-size: 13px; white-space: nowrap; }
.analytics-average-basis { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.analytics-average-help { margin: -4px 2px 12px; color: var(--muted); font-size: 10px; line-height: 1.7; }
.bar-chart-wrap { overflow-x: auto; padding: 16px 14px 12px; scrollbar-width: thin; }
.bar-chart { min-width: 540px; height: 190px; display: flex; align-items: stretch; gap: 7px; border-bottom: 1px solid var(--line); }
.bar-column { min-width: 34px; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; padding: 0; border: 0; background: transparent; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bar-column.is-active .bar-value { color: var(--orange-dark); font-weight: 800; }
.bar-column.is-active .bar-track { background: var(--orange-soft); }
.bar-column.is-active .bar-label { color: var(--orange-dark); font-weight: 800; }
.bar-column.is-active .bar-fill { fill: var(--orange-dark); }
.bar-readout { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0; padding: 11px 16px 14px; border-top: 1px solid var(--line); }
.bar-readout strong { font-size: 12px; }
.bar-readout .money-value { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.bar-readout small { color: var(--muted); font-size: 10px; font-weight: 700; }
.bar-readout small.is-up { color: var(--red); }
.bar-readout small.is-down { color: var(--green); }
.bar-readout-hint { color: var(--muted); font-size: 10px; }
.bar-value { color: var(--muted); font-size: 8px; white-space: nowrap; }
.bar-track { width: min(26px, 72%); height: 135px; border-radius: 7px 7px 0 0; background: #f6f2ec; overflow: hidden; }
.bar-track svg { display: block; width: 100%; height: 100%; }
.bar-fill { fill: var(--orange); }
.bar-column.draft .bar-fill { fill: #f59e0b; opacity: .68; }
.bar-column.future .bar-fill { fill: #94a3b8; opacity: .55; }
.bar-column.negative .bar-value { color: var(--green); }
.analytics-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0 14px; color: var(--muted); font-size: 11px; font-weight: 700; }
.analytics-legend span::before { content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 3px; background: var(--orange); }
.analytics-legend .draft::before { background: #f59e0b; opacity: .68; }
.analytics-legend .future::before { background: #94a3b8; opacity: .55; }
.bar-label { color: var(--muted); font-size: 9px; white-space: nowrap; }

.settings-layout { display: grid; gap: 14px; }
.settings-menu { display: flex; gap: 7px; overflow-x: auto; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); scrollbar-width: none; }
.settings-menu::-webkit-scrollbar { display: none; }
.settings-menu-item { min-height: 42px; flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 8px 11px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); text-align: left; font-size: 12px; font-weight: 750; cursor: pointer; }
.settings-menu-item strong { min-width: 21px; padding: 2px 6px; border-radius: 999px; background: #f5f2ed; color: var(--muted); text-align: center; font-size: 10px; }
.settings-menu-item.active { background: var(--orange-soft); color: var(--orange-dark); }
.settings-menu-item.active strong { background: #fff; color: var(--orange-dark); }
.settings-panel { display: none; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.settings-panel.active { display: block; }
.settings-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.settings-panel-header > div { min-width: 0; flex: 1; }
.settings-panel-header h2 { margin: 0; font-size: 17px; }
.settings-panel-header p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.settings-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.settings-item:last-child { border-bottom: 0; }
.settings-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: var(--orange-soft); color: var(--orange-dark); }
.settings-icon .icon { width: 21px; height: 21px; }
.settings-icon.cash { background: var(--green-soft); color: var(--green); }
.settings-body { min-width: 0; flex: 1; }
.settings-body strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.settings-body span { display: block; color: var(--muted); font-size: 10px; }
.settings-body .money-value { display: inline; }
.settings-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; }
.balance-history { display: flex; flex-wrap: wrap; gap: 4px 9px; margin-top: 7px; padding-top: 6px; border-top: 1px dashed var(--line); }
.balance-history > span { width: 100%; color: var(--muted); font-size: 9px; font-weight: 750; }
.balance-history small { color: var(--muted); font-size: 9px; }
.balance-history small strong { display: inline; margin-left: 2px; color: var(--ink); font-size: 9px; }
.balance-history-editor { padding-top: 12px; border-top: 1px solid var(--line); }
.balance-history-editor h3 { margin: 0 0 8px; font-size: 13px; }
.balance-history-editor-row { display: grid; grid-template-columns: minmax(110px, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12px; }
.balance-history-editor-row small { display: block; color: var(--muted); }
.balance-history-editor-row > span:last-child { display: flex; gap: 4px; }
.text-button { min-height: 36px; padding: 5px 8px; border: 0; background: transparent; color: var(--orange-dark); font-size: 11px; font-weight: 750; cursor: pointer; }
.text-button.danger { color: var(--red); }
.list-empty { padding: 24px 16px; color: var(--muted); text-align: center; font-size: 12px; }

.empty-state { padding: 38px 22px; border: 1px dashed #d8cabc; border-radius: var(--radius); background: rgba(255,255,255,.65); text-align: center; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 13px; border-radius: 17px; background: var(--orange-soft); color: var(--orange-dark); }
.empty-icon .icon { width: 28px; height: 28px; }
.empty-state h2 { margin: 0 0 5px; font-size: 17px; }
.empty-state p { margin: 0 auto 17px; max-width: 460px; color: var(--muted); font-size: 12px; }
.empty-state .button { width: auto; }

.bottom-nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(6,1fr); padding: 5px 4px calc(5px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
.nav-item { border: 0; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; cursor: pointer; }
.bottom-nav .nav-item { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 13px; }
.bottom-nav .nav-icon { width: 26px; height: 26px; }
.bottom-nav .nav-icon .icon { width: 18px; height: 18px; }
.nav-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: #f1eee9; color: var(--muted); transition: background .15s, color .15s; }
.nav-icon .icon { width: 19px; height: 19px; }
.nav-item.active { color: var(--orange-dark); }
.nav-item.active .nav-icon { background: var(--orange); color: #fff; }

.modal-overlay { position: fixed; z-index: 100; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 0; background: rgba(39,34,30,.48); backdrop-filter: blur(4px); }
.modal { width: 100%; max-height: min(91dvh, 780px); overflow-y: auto; overscroll-behavior: contain; background: var(--paper); border-radius: 24px 24px 0 0; box-shadow: 0 -20px 50px rgba(39,34,30,.15); }
.modal-header { position: sticky; z-index: 2; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 18px 14px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 1px 0 0; font-size: 20px; }
.modal-close { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 13px; background: #fff; font-size: 22px; cursor: pointer; }
.modal-form { padding: 18px; }
.field { display: block; min-width: 0; margin-bottom: 15px; }
.field > span { display: block; margin-bottom: 6px; color: #5f574f; font-size: 12px; font-weight: 700; }
/*
 * iOSは16px未満の入力欄へフォーカスすると画面を自動で拡大し、指を離しても拡大したままになる。
 * スマホでは16pxを下回らせず、幅に余裕のあるPCだけ従来の14pxへ戻す。
 */
.field input, .field select { width: 100%; min-height: 46px; padding: 9px 12px; border: 1px solid #d9d0c7; border-radius: 12px; outline: none; background: #fff; color: var(--ink); font-size: 16px; }
.field input:focus, .field select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(217,119,6,.12); }
.field small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.form-hint { margin: -4px 0 14px; color: var(--muted); font-size: 10px; }
.master-change-hint { margin-top: 0; }
.toggle-field { display: flex; align-items: flex-start; gap: 10px; margin: 1px 0 15px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.toggle-field input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--orange); }
.toggle-field span { min-width: 0; }
.toggle-field strong, .toggle-field small { display: block; }
.toggle-field strong { font-size: 13px; }
.toggle-field small, .bonus-month-field small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.bonus-detail-fields { margin: -5px 0 15px; padding: 13px; border-radius: 13px; background: var(--orange-soft); }
.bonus-detail-fields .field { margin-bottom: 12px; }
.bonus-month-field { margin: 0; padding: 0; border: 0; }
.bonus-month-field legend { margin-bottom: 7px; color: #5f574f; font-size: 12px; font-weight: 700; }
.bonus-month-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.bonus-month-grid label { position: relative; cursor: pointer; }
.bonus-month-grid input { position: absolute; opacity: 0; }
.bonus-month-grid span { display: grid; min-height: 34px; place-items: center; border: 1px solid #dfd3c5; border-radius: 9px; background: #fff; color: var(--muted); font-size: 11px; font-weight: 700; }
.bonus-month-grid input:checked + span { border-color: var(--orange); background: var(--orange); color: #fff; }
.balance-account-name { margin: 0 0 15px; padding: 10px 12px; border-radius: 12px; background: var(--orange-soft); color: var(--orange-dark); font-size: 13px; font-weight: 800; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.money-input { position: relative; }
.money-input > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money-input input { padding-left: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.suggestions { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% - 13px); max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.bank-search-field { position: relative; }
.suggestion { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: left; cursor: pointer; }
.suggestion:hover { background: var(--orange-soft); }
.suggestion:last-child { border-bottom: 0; }
.suggestion span { font-size: 13px; font-weight: 700; }
.suggestion small { color: var(--muted); }
.form-error { min-height: 0; margin-bottom: 10px; color: var(--red); font-size: 12px; }
.inline-notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding: 12px; border: 1px solid #efc181; border-radius: 13px; background: var(--orange-soft); }
.inline-notice > div { min-width: 0; }
.inline-notice strong { display: block; color: var(--orange-dark); font-size: 12px; }
.inline-notice span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.inline-notice .button { flex: 0 0 auto; }
.modal-footer { position: sticky; bottom: -18px; display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin: 8px -18px -18px; padding: 13px 18px calc(13px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); }
body.modal-open { overflow: hidden; }

.alert { padding: 11px 13px; border-radius: 12px; font-size: 12px; }
.alert-error { background: var(--red-soft); color: var(--red); border: 1px solid #f0c4c0; }
#global-error { width: min(100% - 32px, 1040px); margin: 16px auto 0; }
.loading { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; background: rgba(251,248,243,.8); color: var(--muted); font-weight: 700; backdrop-filter: blur(3px); }
.toast { position: fixed; z-index: 120; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); transform: translate(-50%, 20px); padding: 10px 16px; border-radius: 12px; background: #2d2925; color: #fff; opacity: 0; pointer-events: none; transition: .2s; font-size: 12px; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 過去データ一括登録。スマホは縦型フォーム、PCは表（760px以上で切り替える）。 */
.settings-link-icon { width: 22px; height: 22px; background: transparent; color: inherit; }
.settings-link-icon .icon { width: 16px; height: 16px; }
/*
 * 月の入力欄は、iOS Safariが内部に広い最小幅を持ち width:100% でも縮まない。
 * 横に並べると機種や文字サイズによっては潰れるため、スマホでは1列ずつ縦に積む。
 * 幅に余裕のあるPCだけ、月2つと「表示」を1行へ戻す。
 */
.bulk-period { display: grid; grid-template-columns: minmax(0,1fr); align-items: end; gap: 10px; margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.bulk-period .field { min-width: 0; margin-bottom: 0; }
.bulk-period .field > span { margin-bottom: 4px; font-size: 10px; color: var(--muted); }
.bulk-period .field input { width: 100%; min-width: 0; min-height: 42px; }
.bulk-period .button { grid-column: 1 / -1; width: 100%; }
.bulk-period .period-tabs { grid-column: 1 / -1; margin-bottom: 0; }
.bulk-period .period-tab { white-space: nowrap; }
.bulk-hint { margin: 0 2px 12px; color: var(--muted); font-size: 11px; line-height: 1.75; }
.bulk-hint strong { color: var(--ink); }
#bulk-error { margin-bottom: 12px; }
.bulk-error-list { margin: 6px 0 0; padding-left: 17px; }
.bulk-error-list li { margin-top: 2px; }

.bulk-table-wrap { display: none; }
.bulk-cards { display: grid; gap: 12px; }
.bulk-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.bulk-card.archived { border-style: dashed; background: rgba(255,255,255,.7); }
.bulk-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.bulk-card-head > div { min-width: 0; }
.bulk-card-head strong { display: block; font-size: 15px; letter-spacing: -.02em; }
.bulk-item-meta { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.bulk-row-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.bulk-tool { min-height: 32px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--muted); font-size: 10px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.bulk-tool:hover { border-color: var(--orange); color: var(--orange-dark); }
.bulk-card-months { display: grid; gap: 8px; padding: 12px 15px 15px; }
.bulk-month-row { display: grid; grid-template-columns: 88px minmax(0,1fr); align-items: center; gap: 10px; }
.bulk-month-label { color: var(--muted); font-size: 12px; font-weight: 750; }
.bulk-input-wrap { position: relative; display: flex; align-items: center; }
.bulk-yen { position: absolute; left: 11px; color: var(--muted); font-size: 12px; pointer-events: none; }
.bulk-input { width: 100%; min-height: 44px; padding: 8px 11px 8px 26px; border: 1px solid #d9d0c7; border-radius: 11px; outline: none; background: #fff; color: var(--ink); text-align: right; font-size: 16px; font-variant-numeric: tabular-nums; }
.bulk-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(217,119,6,.12); }
.bulk-input::placeholder { color: #b9afa4; }
.bulk-input.changed { border-color: var(--orange); background: #fffaf1; }
.bulk-input.invalid { border-color: var(--red); background: var(--red-soft); }
.bulk-input.confirmed { background: var(--green-soft); }
.bulk-input.changed.confirmed { background: #fffaf1; }
.bulk-actions { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 12; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.bulk-actions .button { flex: 0 0 auto; white-space: nowrap; }
.bulk-actions strong { display: block; font-size: 13px; }
.bulk-actions small { display: block; color: var(--muted); font-size: 10px; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 15% 15%, #fff3dc, transparent 35%), var(--cream); }
.auth-card { width: min(100%, 410px); padding: 28px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.auth-card .brand { justify-content: center; margin-bottom: 10px; }
.auth-lead { margin: 0 0 24px; color: var(--muted); text-align: center; font-size: 13px; }
.stack .button { width: 100%; }
.auth-link { margin: 19px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }

.start-card { width: min(100%, 500px); }
.start-card h1 { margin: 20px 0 7px; text-align: center; font-size: clamp(24px, 6vw, 31px); letter-spacing: -.04em; }
.start-card .brand { width: max-content; margin-right: auto; margin-left: auto; color: var(--ink); text-decoration: none; }
.start-actions { display: grid; gap: 10px; }
.start-choice { display: block; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; }
.start-choice:hover { border-color: #d8b27d; transform: translateY(-1px); }
.start-choice.primary { border-color: #efc181; background: var(--orange-soft); }
.start-choice strong, .start-choice span { display: block; }
.start-choice strong { font-size: 15px; }
.start-choice span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.start-note { margin: 18px 0 0; padding: 12px; border-radius: 12px; background: #f8f5f0; color: var(--muted); font-size: 11px; }

.landing-page { overflow-x: hidden; background: #fffdf9; }
.landing-header { width: min(100% - 32px, 1120px); min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 auto; }
.landing-brand { color: var(--ink); text-decoration: none; }
.landing-header nav { display: flex; align-items: center; gap: 14px; }
.landing-login { font-size: 13px; font-weight: 700; text-decoration: none; }
.landing-hero { width: min(100% - 32px, 1120px); display: grid; grid-template-columns: minmax(0,1.08fr) minmax(320px,.92fr); align-items: center; gap: clamp(32px, 7vw, 92px); min-height: 610px; margin: 0 auto; padding: 72px 0 84px; }
.landing-hero-copy h1 { margin: 8px 0 20px; font-size: clamp(38px, 5.4vw, 68px); line-height: 1.16; letter-spacing: -.065em; }
.landing-hero-copy > p:not(.eyebrow):not(.landing-assurance) { max-width: 620px; margin: 0; color: var(--muted); font-size: clamp(15px, 1.7vw, 18px); }
/*
 * 説明文は「。」で切って1行ずつ span へ入れる（class="lines"）。
 * スマホで途中折り返しが起きないよう、各行は短く書く。
 * keep-all は英数字が語の途中で切れるのを防ぐためで、行の長さ自体は文章側で担保する。
 */
.lines span { word-break: keep-all; }
/*
 * 2つのボタンは必ず同じ大きさにする。
 * min-width はラベルが1行に収まる幅で、横に並ばない幅では折り返して縦に積む。
 * どちらの並びでも余りを等分するので、2つの幅は常に揃う。
 */
.landing-actions { display: flex; flex-wrap: wrap; gap: 10px; max-width: 470px; margin-top: 30px; }
.landing-actions .button { flex: 1 1 205px; min-width: 205px; white-space: nowrap; text-decoration: none; }
/* ログイン済みはボタンが1つだけになる。割り付けると不自然に横長になるため content 幅へ戻す。 */
.landing-actions .button:only-child { flex: 0 0 auto; }
.landing-assurance { max-width: 520px; margin: 18px 0 0; padding-left: 22px; position: relative; color: var(--muted); font-size: 11px; }
.landing-assurance::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 900; }
.landing-demo-note { margin-top: 12px; }
.landing-demo-note::before { content: "▸"; color: var(--orange-dark); }
.landing-preview { min-width: 0; padding: 26px; border: 1px solid #efd8b8; border-radius: 28px; background: linear-gradient(145deg, #fff, #fff7e9); box-shadow: 0 28px 80px rgba(120,76,31,.15); transform: rotate(1deg); }
.landing-preview-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.landing-preview-head span { color: var(--ink); font-weight: 800; }
.landing-preview-balance { margin-top: 23px; padding: 20px; border-radius: 18px; background: var(--blue-soft); }
.landing-preview-balance span, .landing-preview-balance small { display: block; color: var(--muted); font-size: 11px; }
.landing-preview-balance strong { display: block; margin: 3px 0; color: var(--blue); font-size: clamp(30px, 5vw, 42px); letter-spacing: -.05em; }
.landing-preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.landing-preview-grid div, .landing-preview-safe { padding: 14px; border-radius: 14px; background: #fff; }
.landing-preview-grid span, .landing-preview-safe span { display: block; color: var(--muted); font-size: 10px; }
.landing-preview-grid strong, .landing-preview-safe strong { display: block; margin-top: 2px; font-size: 17px; }
.landing-preview-safe { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; background: var(--green-soft); color: var(--green); }
.landing-preview-safe strong { font-size: 21px; }
.landing-section { width: min(100% - 32px, 1120px); margin: 0 auto; padding: 88px 0; border-top: 1px solid var(--line); }
.landing-section > h2 { max-width: 680px; margin: 7px 0 34px; font-size: clamp(28px, 4vw, 43px); line-height: 1.25; letter-spacing: -.05em; }
.landing-features { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.landing-features article { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: #fff; }
.feature-number { color: var(--orange); font-size: 11px; font-weight: 900; letter-spacing: .12em; }
/*
 * 特徴カードのスマホ見本。デモ画面をiPhone相当の幅(390px)で実際に撮ったもの。
 * 表示幅の2倍(320px)で書き出してあるので、高精細ディスプレイでもぼけない。
 * 撮り直しの手順は README の「デモ（/demo）」を参照。
 */
.feature-shot { display: block; width: 100%; max-width: 160px; margin: 2px auto 15px; }
.feature-shot img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 28px rgba(84,57,31,.14); }
.landing-features h3 { margin: 16px 0 7px; font-size: 18px; }
.landing-features p { margin: 0; color: var(--muted); font-size: 13px; }
/*
 * 30秒プロモ。押されるまで iframe を作らないので、開いただけでは何も落ちてこない。
 * 差し込みは assets/landing.js が行う。
 */
.landing-video { width: min(100% - 32px, 1120px); margin: 0 auto; padding: 0 0 88px; }
.landing-video > h2 { max-width: 680px; margin: 7px 0 26px; font-size: clamp(28px, 4vw, 43px); line-height: 1.25; letter-spacing: -.05em; }
.promo-slot { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(150deg, #fffdf9, #f4efe6); box-shadow: var(--shadow); }
.promo-play { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; width: 100%; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.promo-play-icon { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; background: var(--orange); color: #fff; font-size: 21px; padding-left: 4px; box-shadow: 0 10px 24px rgba(217,119,6,.3); transition: transform .15s; }
.promo-play:hover .promo-play-icon { transform: scale(1.06); }
.promo-play-label { font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.promo-play small { color: var(--muted); font-size: 11px; }
.promo-frame { display: block; width: 100%; height: 100%; border: 0; }
.landing-note { width: min(100% - 32px, 1120px); display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin: 0 auto 88px; padding: 34px; border-radius: 24px; background: #f7f3ed; }
.landing-note h2 { margin: 5px 0 0; font-size: clamp(22px, 3vw, 32px); line-height: 1.3; letter-spacing: -.04em; }
.landing-note > p { margin: 0; color: var(--muted); font-size: 13px; }
.landing-cta { width: min(100% - 32px, 1120px); margin: 0 auto; padding: 68px 24px; border-radius: 28px; background: #29231e; color: #fff; text-align: center; }
.landing-cta h2 { margin: 0 0 24px; font-size: clamp(27px, 4vw, 44px); letter-spacing: -.05em; }
.landing-cta .button { text-decoration: none; }
.landing-footer { width: min(100% - 32px, 1120px); display: flex; justify-content: space-between; gap: 18px; margin: 0 auto; padding: 34px 0; color: var(--muted); font-size: 11px; }
.landing-footer span { color: var(--ink); font-weight: 800; }
/*
 * 説明文は keep-all で折り返さないため、カラムが細いと行がはみ出す。
 * 横に並べたままにできる幅を下回ったら、どの段組みも縦へ積む。
 * ヒーローは見本カードの最小幅(320px)、特徴は3枚ぶんの行の長さで決まる。
 * 基礎の定義より後に置くこと。同じ詳細度なので、前に置くと上書きされない。
 */
@media (max-width: 900px) {
  .landing-hero { grid-template-columns: 1fr; min-height: 0; }
  .landing-features { grid-template-columns: 1fr; }
  .landing-note { grid-template-columns: 1fr; gap: 14px; }
}

@media (min-width: 760px) {
  .app-shell { display: grid; grid-template-columns: 238px minmax(0,1fr); }
  .sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px; background: #fff; border-right: 1px solid var(--line); }
  .sidebar-copy { margin: 5px 0 28px 42px; color: var(--muted); font-size: 10px; }
  .desktop-nav { display: grid; gap: 7px; }
  .desktop-nav .nav-item { min-height: 46px; display: flex; align-items: center; gap: 11px; padding: 6px 10px; border-radius: 13px; text-align: left; font-size: 13px; }
  .desktop-nav .nav-item.active { background: var(--orange-soft); }
  .desktop-nav .nav-icon { background: transparent; }
  .desktop-nav .nav-item.active .nav-icon { background: var(--orange); }
  .sidebar-user { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
  .sidebar-user span { display: block; color: var(--ink); font-weight: 700; }
  .sidebar-user form { margin-top: 5px; }
  .sidebar-user button { padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
  .mobile-header, .bottom-nav { display: none; }
  .main-content { padding-bottom: 40px; }
  .topbar { top: 0; justify-content: flex-start; height: 70px; padding: 0 max(28px, calc((100% - 1040px) / 2)); }
  .view { padding-top: 38px; }
  .settings-layout { grid-template-columns: 210px minmax(0,1fr); align-items: start; gap: 18px; }
  .settings-menu { position: sticky; top: 20px; flex-direction: column; overflow: visible; }
  .settings-menu-item { width: 100%; justify-content: space-between; }
  .settings-panel { min-height: 230px; }
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { width: min(100%, 560px); border-radius: 24px; }
  .toast { bottom: 30px; }
  /* PCは自動拡大が起きないので、入力欄を元の詰まった見た目へ戻す。 */
  .field input, .field select { font-size: 14px; }

  /* PCは横幅に余裕があるので、月の指定と「表示」を1行へ戻す。 */
  .custom-period { flex-direction: row; align-items: flex-end; }
  .bulk-period { grid-template-columns: minmax(0,210px) minmax(0,210px) auto; justify-content: start; }
  .bulk-period .button { grid-column: auto; width: auto; }
  .bulk-period .period-tabs { justify-self: start; }

  /* PCはExcelのような表。月が多いときは横スクロールし、項目列と月見出しは固定する。 */
  .bulk-cards { display: none; }
  .bulk-table-wrap { display: block; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
  .bulk-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; }
  .bulk-table th, .bulk-table td { padding: 7px 9px; border-bottom: 1px solid var(--line); }
  .bulk-table tbody tr:last-child th, .bulk-table tbody tr:last-child td { border-bottom: 0; }
  .bulk-table thead th { position: sticky; top: 0; z-index: 3; background: #faf6f0; color: var(--muted); font-size: 11px; font-weight: 800; text-align: right; white-space: nowrap; }
  .bulk-table thead th small { display: block; color: #a1968a; font-size: 9px; font-weight: 700; }
  .bulk-table .bulk-cell-item { position: sticky; left: 0; z-index: 2; min-width: 216px; max-width: 260px; background: var(--paper); box-shadow: 1px 0 0 var(--line); text-align: left; vertical-align: middle; }
  .bulk-table thead .bulk-cell-item { z-index: 4; background: #faf6f0; }
  .bulk-table tbody tr.archived .bulk-cell-item { background: #fbf8f3; }
  .bulk-table .bulk-item-name { display: block; font-size: 13px; font-weight: 750; letter-spacing: -.02em; }
  .bulk-table .bulk-row-tools { margin-top: 5px; }
  .bulk-table .bulk-input { width: 122px; min-height: 38px; padding: 6px 9px; border-radius: 9px; font-size: 14px; }
  .bulk-table .bulk-yen { display: none; }
  .bulk-actions { bottom: 18px; }
}

@media (max-width: 560px) {
  .landing-header { min-height: 64px; }
  .landing-header nav { gap: 9px; }
  .landing-login { font-size: 11px; }
  /* 見本のカードが最初の画面に入るよう、縦の余白を詰める。 */
  .landing-hero { grid-template-columns: 1fr; min-height: 0; gap: 26px; padding: 28px 0 56px; }
  .landing-hero-copy h1 { margin: 6px 0 14px; }
  .landing-assurance { margin-top: 10px; }
  /* 見出しの1行（9文字）が折り返さない大きさに収める。 */
  .landing-hero-copy h1 { font-size: clamp(28px, 9.2vw, 42px); }
  /*
   * スマホは横に並ばないので、flex-wrap で1つずつ折り返って縦に積まれる。
   * flex-direction: column にすると flex-basis が高さへ効いてボタンが縦に伸びるため使わない。
   */
  .landing-actions { max-width: none; margin-top: 20px; }
  .landing-preview { padding: 18px; border-radius: 22px; transform: none; }
  .landing-preview-grid { grid-template-columns: 1fr; }
  .landing-section { padding: 64px 0; }
  .landing-features { grid-template-columns: 1fr; }
  .landing-features article { padding: 20px; }
  .landing-note { grid-template-columns: 1fr; gap: 14px; margin-bottom: 64px; padding: 24px; }
  .landing-cta { padding: 48px 18px; }
  .landing-footer { flex-direction: column; gap: 3px; }
  .view { width: min(100% - 24px, 1040px); }
  .page-heading { gap: 10px; }
  .page-heading p:not(.eyebrow) { font-size: 11px; }
  .page-heading-actions { flex-direction: column; align-items: stretch; gap: 6px; }
  .page-heading-actions .button { min-height: 36px; }
  .monthly-notice { flex-wrap: wrap; }
  .monthly-notice-actions { width: 100%; padding-left: 32px; }
  .forecast-record-row { grid-template-columns: auto minmax(0,1fr) auto; }
  .forecast-record-actions { grid-column: 2 / -1; justify-content: flex-end; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .funds-summary { padding: 14px; }
  .funds-summary-heading { display: block; }
  .funds-summary-heading small { display: block; margin-top: 4px; text-align: left; }
  .funds-summary-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .funds-summary-grid > div { padding: 10px; }
  .funds-summary-grid strong { font-size: clamp(14px, 4.25vw, 18px); }
  .funds-summary-grid .total { grid-column: 1 / -1; }
  .forecast-main { padding: 16px; }
  .forecast-title-row { gap: 8px; }
  .forecast-title-actions { flex-direction: column; align-items: flex-end; gap: 5px; }
  .forecast-balance-button { min-height: 26px; padding: 2px 8px; }
  .forecast-hero { grid-template-columns: 1fr; gap: 8px; margin: 15px 0 11px; }
  .metric { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 1px 10px; padding: 10px 12px; }
  .metric-label { min-width: 0; }
  .metric-value { grid-column: 2; grid-row: 1; margin-top: 0; font-size: clamp(17px, 5vw, 21px); }
  .metric-sub { grid-column: 1 / -1; margin-top: 1px; }
  .forecast-stat strong { font-size: clamp(10px, 3.1vw, 12px); }
  .overview-summary, .overview-trend, .overview-timeline { padding: 14px; }
  .overview-trend-header .period-tabs { margin-bottom: 0; }
  .overview-trend-header .period-tab { flex: 0 0 auto; padding: 6px 10px; }
  .overview-primary { grid-template-columns: 1fr; gap: 7px; }
  .overview-primary > div { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 1px 10px; padding: 10px 12px; }
  .overview-primary strong { grid-column: 2; grid-row: 1; margin-top: 0; font-size: clamp(17px, 5vw, 22px); }
  .overview-primary small { grid-column: 1 / -1; }
  .overview-metrics { gap: 7px; }
  .overview-metrics strong { font-size: clamp(13px, 3.6vw, 16px); }
  .overview-metrics small, .overview-primary small { font-size: 9px; }
  .bottom-nav .nav-item { font-size: 9px; }
  .money-flow-day { display: block; padding-bottom: 16px; }
  .money-flow-date { min-height: 28px; padding-top: 2px; font-size: 12px; }
  .money-flow-day-content { width: calc(100% - 26px); margin-left: 26px; }
  .money-flow-entry { display: grid; grid-template-columns: 1fr; gap: 5px; min-height: 0; padding: 10px 11px; }
  .money-flow-entry-main > strong { font-size: 12px; }
  .money-flow-entry-main > small { font-size: 8px; }
  .money-flow-change { text-align: left; font-size: 13px; }
  .money-flow-balance-placeholder { display: none; }
  .money-flow-balance { text-align: left; }
  .money-flow-balance strong { font-size: 12px; }
  .money-flow-day-total { display: flex; min-height: 0; flex-direction: column; align-items: stretch; gap: 2px; padding: 9px 11px; }
  .money-flow-day-total .money-flow-change { margin-bottom: 5px; }
  .money-flow-day-total .money-flow-balance { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-top: 5px; border-top: 1px solid var(--line); }
  .money-flow-day-total .money-flow-balance strong { margin-top: 0; }
  .money-flow-boundary strong { font-size: 16px; }
  .trend-value, .trend-month { font-size: 15px; }
  .forecast-note { font-size: 10px; }
  .monthly-timeline-details > summary { padding: 12px 13px; }
  .monthly-timeline-content { padding: 0 13px 12px; }
  .timeline { padding-right: 10px; padding-left: 10px; }
  .timeline-header, .timeline-row { grid-template-columns: 34px minmax(0,1fr) 80px 86px; gap: 4px; }
  .timeline-header span:nth-child(3) { display: none; }
  .timeline-header span:nth-child(4), .timeline-header span:nth-child(5) { text-align: right; }
  .timeline-row { min-height: 50px; font-size: 10px; }
  .timeline-status { display: none; }
  .timeline-status-mobile { display: inline-flex; }
  .timeline-amount, .timeline-balance { font-size: clamp(8px, 2.6vw, 10px); }
  .entry-row { grid-template-columns: 38px minmax(0,1fr); }
  .entry-actions { grid-column: 2; justify-content: space-between; margin-top: -5px; }
  .entry-actions { flex-wrap: wrap; justify-content: flex-start; }
  .entry-amount { margin-right: auto; text-align: left; }
  /* デモは操作ボタンが無いぶん、金額を折り返さず行の右端へ戻す。 */
  body[data-demo] .entry-row { grid-template-columns: 38px minmax(0,1fr) auto; }
  body[data-demo] .entry-actions { grid-column: auto; margin-top: 0; justify-content: flex-end; }
  body[data-demo] .entry-amount { margin-right: 0; text-align: right; }
  .bill-summary { grid-template-columns: 1fr 1fr; }
  .bill-summary .primary { grid-column: 1 / -1; }
  .bill-summary > div { padding: 11px 12px; }
  .bill-summary strong { font-size: clamp(15px, 4.5vw, 18px); }
  .bill-group-summary { padding: 10px 12px; }
  .bill-group-heading { gap: 6px; }
  .bill-group-heading strong { font-size: 13px; }
  .bill-group-total { font-size: clamp(13px, 4vw, 15px); }
  .bill-row { grid-template-columns: 38px minmax(0,1fr) auto; gap: 8px; padding: 11px 12px; }
  .bill-amount { font-size: clamp(12px, 3.8vw, 14px); }
  .period-tabs { gap: 2px; }
  .period-tab { min-width: 0; flex: 1 1 0; padding: 6px 4px; font-size: 10px; }
  .custom-period { flex-wrap: wrap; }
  .custom-period .button { width: 100%; }
  .analytics-card-header { display: block; }
  .analytics-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; text-align: left; }
  .analytics-metrics > div { min-width: 0; padding: 7px 9px; border-radius: 9px; background: #f9f6f1; }
  .analytics-metrics strong { font-size: clamp(12px, 3.8vw, 14px); }
  .bar-chart-wrap { overflow-x: hidden; padding: 13px 8px 10px; }
  .bar-chart-wrap.is-scrollable { overflow-x: auto; }
  .bar-chart { width: 100%; min-width: 0; height: 162px; gap: 2px; }
  .bar-chart.is-long-range { width: auto; min-width: 540px; }
  .bar-column { min-width: 0; gap: 3px; }
  .bar-chart:not(.is-long-range) .bar-value { display: none; }
  .bar-track { width: min(16px, 78%); height: 128px; }
  .bar-label { font-size: 8px; letter-spacing: -.08em; }
  .bar-chart.is-long-range .bar-value { font-size: 7px; }
  .inline-notice { align-items: stretch; flex-direction: column; }
  .settings-layout { gap: 12px; }
  .settings-menu { position: sticky; z-index: 12; top: 6px; display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 4px; overflow: visible; padding: 5px; background: rgba(255,255,255,.96); box-shadow: 0 8px 22px rgba(84,57,31,.08); backdrop-filter: blur(12px); }
  .settings-menu-item { width: 100%; min-width: 0; min-height: 38px; grid-column: span 2; justify-content: center; gap: 5px; padding: 6px 4px; font-size: 10px; white-space: nowrap; }
  .settings-menu-item:nth-child(n+4) { grid-column: span 3; }
  .settings-menu-item strong { min-width: 18px; padding: 1px 5px; font-size: 9px; }
  .settings-panels, .settings-panel { width: 100%; min-width: 0; }
  .settings-panel-header { align-items: flex-start; }
  .settings-panel-header p { max-width: 190px; }
  .settings-item { align-items: flex-start; flex-wrap: wrap; }
  .settings-body { flex-basis: calc(100% - 52px); }
  .settings-actions { width: 100%; padding-left: 50px; justify-content: flex-start; }
}

/* 見出し・合計・操作ボタンを残し、本文だけを折り畳む共通部品。 */
.fold-heading { display: flex; align-items: center; gap: 4px; min-width: 0; }
.fold-heading > :first-child { flex: 1; min-width: 0; }
.fold-section-title { margin: 0; padding: 8px 0 12px; font-size: 14px; }
.fold-toggle { flex: 0 0 44px; width: 44px; height: 44px; align-self: flex-start; display: grid; place-items: center; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; font-size: 21px; }
.fold-toggle:hover { background: var(--orange-soft); color: var(--orange-dark); }
.fold-toggle > span { display: block; transition: transform 180ms ease-out; }
.fold-toggle[aria-expanded="true"] > span { transform: rotate(180deg); }
.fold-toggle:focus-visible, details > summary:focus-visible { outline: 2px solid var(--orange); outline-offset: -3px; }
.fold-body { min-width: 0; }
.fold-body[hidden] { display: none !important; }
.balance-history { display: block; }
.balance-history > summary { min-height: 36px; padding: 8px 0; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 750; }
.balance-history > div { display: flex; flex-wrap: wrap; gap: 4px 9px; padding-bottom: 6px; }
.account-ledger > summary { min-height: 44px; list-style-position: inside; }
.bulk-help { margin-bottom: 14px; }
.bulk-help > summary { min-height: 44px; padding: 10px 0; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.bulk-desktop-fold { display: none; min-width: 0; }
@media (min-width: 760px) {
  .bulk-desktop-fold { display: block; }
}
@media (max-width: 599px) {
  .fold-heading .overview-trend-header, .fold-heading .forecast-title-row,
  .fold-heading .bulk-card-head, .fold-heading .settings-panel-header {
    flex-wrap: wrap;
  }
}

/* 短い減速で統一。数値・軸・レイアウトは動かさず、装飾だけを補間する。 */
@keyframes surface-enter {
  from { opacity: .55; }
  to { opacity: 1; }
}
@keyframes panel-enter {
  from { opacity: .65; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes trend-reveal {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 -1% 0 -1%); }
}
@keyframes bar-rise {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
@media (prefers-reduced-motion: no-preference) {
  .fold-body:not([hidden]), details[open] > :not(summary) {
    animation: surface-enter 180ms ease-out;
  }
  .view.active, .settings-panel.active {
    animation: surface-enter 240ms cubic-bezier(.22, 1, .36, 1);
  }
  .view.active > .page-heading {
    animation: panel-enter 280ms cubic-bezier(.22, 1, .36, 1);
  }
  .modal-overlay:not([hidden]) { animation: surface-enter 180ms ease-out; }
  .modal-overlay:not([hidden]) .modal {
    animation: panel-enter 260ms cubic-bezier(.22, 1, .36, 1);
  }
  .chart-enter .trend-line, .chart-enter .trend-area {
    animation: trend-reveal 560ms cubic-bezier(.25, .65, .3, 1);
  }
  .chart-enter .bar-fill {
    transform-box: fill-box;
    transform-origin: center bottom;
    animation: bar-rise 420ms cubic-bezier(.22, 1, .36, 1) backwards;
  }
  /* 長期間のグラフも待ち時間を増やさない。最大80msのゆるい時間差。 */
  .chart-enter .bar-column:nth-child(2) .bar-fill { animation-delay: 20ms; }
  .chart-enter .bar-column:nth-child(3) .bar-fill { animation-delay: 40ms; }
  .chart-enter .bar-column:nth-child(4) .bar-fill { animation-delay: 60ms; }
  .chart-enter .bar-column:nth-child(n+5) .bar-fill { animation-delay: 80ms; }
  .nav-item, .period-tab, .settings-menu-item {
    transition: background-color 180ms ease-out, color 180ms ease-out;
  }
  .nav-icon { transition: background-color 180ms ease-out, color 180ms ease-out, transform 220ms cubic-bezier(.22, 1, .36, 1); }
  .nav-item.active .nav-icon { transform: translateY(-2px); }
  .bar-column { transition: background-color 160ms ease-out, border-color 160ms ease-out; }
  .bar-fill { transition: fill 160ms ease-out; }
  .bar-readout > * { animation: surface-enter 180ms ease-out; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
