/* よっ家計簿 — スマホ縦向き・片手操作を前提にしたスタイル
   CLAUDE.md: 支出 #ef4444 / 収入 #10b981、タップできる所は 44px 以上（ここでは 48px を基本にする）
   支出・収入の「文字」は同じ色合いの濃い色（--expense-ink / --income-ink）にして読みやすさを確保する。 */

:root {
  color-scheme: light;
  --bg: #fcf3de;            /* AI イラストの背景と同じクリーム色（画像が浮かずになじむ） */
  --surface: #fffdf8;
  --surface-2: #f7eedc;
  --line: #eadcc2;
  --ink: #3b2f2a;
  --ink-2: #66564b;
  --muted: #8a7a6c;
  --accent: #5b4fd6;
  --accent-ink: #ffffff;
  --accent-soft: #ece9ff;
  --expense: #ef4444;       /* 支出（CLAUDE.md） */
  --income: #10b981;        /* 収入（CLAUDE.md） */
  --expense-ink: #dc2626;   /* 支出の文字 */
  --income-ink: #047857;    /* 収入の文字 */
  --expense-soft: #fdeaea;
  --income-soft: #ddf4ea;
  --warn-ink: #b45309;
  --meter-track: #f5e4db;
  --meter-1: #f4a3a3;
  --meter-2: #f87171;
  --meter-3: #ef4444;
  --grid: #eadfcd;
  --axis: #cdbfa8;
  --shadow: 0 1px 2px rgba(80, 50, 20, .06), 0 8px 22px rgba(80, 50, 20, .07);
  --scrim: rgba(40, 28, 18, .42);
  --toast: #2f2721;
  --radius: 20px;
  --radius-sm: 14px;
  --tap: 48px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic UI', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1d1915; --surface: #27221c; --surface-2: #332c24; --line: #40372d;
    --ink: #f5ede2; --ink-2: #d6c8b7; --muted: #a99886;
    --accent: #6d5fe6; --accent-ink: #ffffff; --accent-soft: #302b52;
    --income: #059669;       /* 暗い画面用に一段濃く（配色チェックで確認済み） */
    --expense-ink: #f87171; --income-ink: #34d399;
    --expense-soft: #3a2323; --income-soft: #173329; --warn-ink: #fbbf24;
    --meter-track: #3b2e28; --meter-1: #8c4040; --meter-2: #c44a4a; --meter-3: #ef4444;
    --grid: #3a3229; --axis: #54493c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .25);
    --scrim: rgba(0, 0, 0, .55); --toast: #f2e9dc;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1d1915; --surface: #27221c; --surface-2: #332c24; --line: #40372d;
  --ink: #f5ede2; --ink-2: #d6c8b7; --muted: #a99886;
  --accent: #6d5fe6; --accent-ink: #ffffff; --accent-soft: #302b52;
  --income: #059669;
  --expense-ink: #f87171; --income-ink: #34d399;
  --expense-soft: #3a2323; --income-soft: #173329; --warn-ink: #fbbf24;
  --meter-track: #3b2e28; --meter-1: #8c4040; --meter-2: #c44a4a; --meter-3: #ef4444;
  --grid: #3a3229; --axis: #54493c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .25);
  --scrim: rgba(0, 0, 0, .55); --toast: #f2e9dc;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- 画面の枠 ---- */
.view {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--tabbar-h) + var(--safe-b) + 28px);
  outline: none;
}
.view.no-tabbar { padding-bottom: calc(var(--safe-b) + 28px); }
.stack > * + * { margin-top: 14px; }

.topbar { display: flex; align-items: center; gap: 8px; min-height: var(--tap); margin-bottom: 6px; }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 800; letter-spacing: .02em; flex: 1; }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.brand b { font-size: 18px; font-weight: 800; }
.brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.2; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 10px; font-weight: 800; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.card h2 .more { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--accent); background: none; border: 0; min-height: 44px; padding: 0 4px; display: inline-flex; align-items: center; text-decoration: none; }
.card h2 svg { width: 18px; height: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---- 金額（CLAUDE.md: 支出=赤系 / 収入=緑系、表示は必ず yen() を通す） ---- */
.amt { font-weight: 800; white-space: nowrap; }
.amt.out { color: var(--expense-ink); }
.amt.in { color: var(--income-ink); }
.amt.zero { color: var(--ink-2); }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--expense-ink); border-color: var(--line); }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 56px; font-size: 17px; border-radius: 16px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 14px; background: transparent; color: var(--ink-2);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }

svg.i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- 月の切り替え ---- */
.month-switch { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin: 2px 0 12px; }
.month-switch b { font-size: 19px; font-weight: 800; }
.month-switch .icon-btn { background: var(--surface); box-shadow: var(--shadow); }

/* ---- 下のタブ ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar .tabs { max-width: 560px; margin: 0 auto; height: var(--tabbar-h); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; min-height: var(--tap);
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 700;
  background: none; border: 0;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab.add { position: relative; }
.tab.add span.fab {
  width: 58px; height: 58px; border-radius: 50%; margin-top: -22px;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(91, 79, 214, .35), 0 0 0 5px var(--bg);
}
.tab.add span.fab svg { width: 28px; height: 28px; stroke-width: 2.6; }
.tab.add .label { color: var(--ink-2); }

/* ---- ホーム ---- */
.hero { position: relative; }
.hero img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; background: var(--surface-2); }
.hero .goal { padding: 12px 16px 14px; }
.hero .goal .label { font-size: 12px; font-weight: 700; color: var(--muted); }
.hero .goal .text { font-size: 18px; font-weight: 800; margin: 2px 0 0; }
.hero .goal .cta { margin-top: 8px; }
.progress { height: 10px; border-radius: 99px; background: var(--income-soft); overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--income); }
.progress-caption { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }

.savings .label { font-size: 13px; font-weight: 700; color: var(--muted); }
.savings .hero-num { font-size: 44px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; margin: 2px 0 10px; }
.savings .hero-num.in { color: var(--income-ink); }
.savings .hero-num.out { color: var(--expense-ink); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat .k { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 18px; font-weight: 800; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.in { background: var(--income); }
.dot.out { background: var(--expense); }
.breakdown { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.breakdown span { background: var(--surface-2); border-radius: 99px; padding: 4px 10px; }

.notice { display: flex; align-items: center; gap: 12px; border: 1.5px dashed var(--accent); background: var(--accent-soft); }
.notice .grow b { display: block; font-size: 15px; }
.notice .grow span { font-size: 13px; color: var(--ink-2); }

/* 予算の残り（メーター: 使った分を赤系で。超えたら濃い赤＋「オーバー」の文字） */
.budget-list { display: grid; gap: 4px; }
.budget-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 4px 10px; padding: 8px 4px; min-height: var(--tap); border: 0; background: none; text-align: left; border-radius: 12px; width: 100%; }
.budget-row:active { background: var(--surface-2); }
.budget-row .emo { grid-row: span 2; font-size: 22px; text-align: center; }
.budget-row .name { font-weight: 700; font-size: 15px; }
.budget-row .rest { font-size: 13px; font-weight: 700; text-align: right; color: var(--ink-2); }
.budget-row .rest.over { color: var(--expense-ink); }
.meter { grid-column: 2 / 4; height: 8px; border-radius: 99px; background: var(--meter-track); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--meter-1); }
.meter.l2 > i { background: var(--meter-2); }
.meter.l3 > i { background: var(--meter-3); }
.budget-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.budget-total b { font-size: 17px; color: var(--ink); }

/* ---- 記録の一覧 ---- */
.tx-list { display: grid; }
.tx {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 8px 4px;
  border: 0; background: none; text-align: left; border-radius: 12px;
}
.tx:active { background: var(--surface-2); }
.tx + .tx { border-top: 1px solid var(--line); border-radius: 0; }
.tx .emo { width: 42px; height: 42px; border-radius: 14px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 22px; flex: none; }
.tx .emo.in { background: var(--income-soft); }
.tx .t { font-weight: 700; font-size: 15px; line-height: 1.3; }
.tx .s { font-size: 12px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .amt { font-size: 16px; }
.pending-tag { font-size: 11px; font-weight: 700; color: var(--warn-ink); background: color-mix(in srgb, var(--warn-ink) 14%, transparent); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }

.day-group { margin-top: 14px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.day-group .card { padding: 4px 12px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 99px;
  border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"], .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip svg { width: 18px; height: 18px; }

.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.summary-strip .stat { padding: 10px; min-width: 0; }
.summary-strip .stat .v { font-size: 14px; letter-spacing: -.02em; }

.empty { text-align: center; padding: 8px 8px 20px; }
.empty img { width: min(220px, 60%); margin: 0 auto 6px; border-radius: 24px; }
.empty p { margin: 0 0 14px; color: var(--ink-2); font-weight: 700; }

/* ---- 下から出るシート ---- */
.sheet-scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); opacity: 0; transition: opacity .2s ease; }
.sheet-scrim.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto;
  max-height: calc(100dvh - var(--safe-t) - 16px);
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .18);
  display: flex; flex-direction: column;
  transform: translateY(105%); transition: transform .24s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-b);
}
.sheet.show { transform: none; }
.sheet.tall { height: calc(100dvh - var(--safe-t) - 16px); }
.sheet-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 4px 16px; flex: none; }
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 800; flex: 1; }
.sheet-body { padding: 4px 16px 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 10px 16px 12px; flex: none; border-top: 1px solid var(--line); background: var(--surface); }

/* ---- 入力シート ---- */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 11px; background: transparent; font-weight: 800; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }
.seg button.out[aria-pressed="true"] { color: var(--expense-ink); }
.seg button.in[aria-pressed="true"] { color: var(--income-ink); }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg.plain button[aria-pressed="true"] { color: var(--accent); }

.amount-display {
  display: flex; align-items: baseline; justify-content: flex-end; gap: 4px;
  font-size: 38px; font-weight: 800; padding: 4px 4px 2px; min-height: 58px; letter-spacing: -.01em;
  border-bottom: 2px solid var(--line); margin: 4px 0 0;
}
.amount-display.out { color: var(--expense-ink); }
.amount-display.in { color: var(--income-ink); }
.amount-display.placeholder { color: var(--muted); }

.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 68px; padding: 6px 2px; border-radius: 14px;
  border: 2px solid transparent; background: var(--surface-2);
  font-size: 12px; font-weight: 700; line-height: 1.2; text-align: center; word-break: keep-all; overflow-wrap: anywhere;
}
.cat .e { font-size: 24px; line-height: 1.1; }
.cat[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.more-toggle { margin: 10px 0 0; min-height: 44px; width: 100%; border: 0; background: none; color: var(--accent); font-weight: 700; }
.field-label { font-size: 12px; font-weight: 800; color: var(--muted); margin: 14px 0 6px; }
.date-row { display: flex; gap: 8px; }
.date-row .chip { min-height: 44px; }
.date-pick { position: relative; }
.date-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }

.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap);
  padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface-2);
  font-size: 16px; /* iOS で拡大されない大きさ */
}
.input:focus { border-color: var(--accent); outline: none; background: var(--surface); }
textarea.input { min-height: 88px; resize: vertical; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  min-height: 50px; border-radius: 14px; border: 0;
  background: var(--surface-2); font-size: 22px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.keypad button:active { background: var(--line); }
.keypad svg { width: 26px; height: 26px; }
.save-row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; margin-top: 8px; }
.sheet.typing .keypad { display: none; }

/* ---- レポート ---- */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(84px, 34%) 1fr auto; align-items: center; gap: 10px; min-height: 32px; }
.bar-row .lbl { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 12px; }
.bar-row .track > i { display: block; height: 100%; min-width: 3px; border-radius: 0 4px 4px 0; background: var(--expense); }
.bar-row .track > i.in { background: var(--income); }
.bar-row .val { font-size: 14px; font-weight: 800; text-align: right; }
.bar-row .val small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.chart-readout { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-height: 44px; margin-bottom: 4px; }
.chart-readout b { font-size: 15px; }
.chart-readout .v { font-size: 20px; font-weight: 800; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 10px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .col-pos { fill: var(--income); }
.chart .col-neg { fill: var(--expense); }
.chart .sel-band { fill: var(--accent-soft); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .line { fill: none; stroke: var(--income); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--income); opacity: .1; }
.chart .end-dot { fill: var(--income); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--ink); font-size: 11px; font-weight: 800; font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.legend .hint { margin-left: auto; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; }
.legend i.in { background: var(--income); }
.legend i.out { background: var(--expense); }
.groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 100%; }
table.grid th, table.grid td { padding: 7px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.grid th:first-child, table.grid td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.grid thead th { color: var(--muted); font-weight: 700; }
table.grid tbody th { font-weight: 700; }
table.grid tr.total td, table.grid tr.total th { font-weight: 800; }
table.grid td.zero { color: var(--muted); }

/* ---- 設定 ---- */
.menu { display: grid; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 6px 14px; width: 100%;
  border: 0; background: none; text-align: left; text-decoration: none; font-weight: 700; color: var(--ink);
}
.menu-item + .menu-item { border-top: 1px solid var(--line); }
.menu-item:active { background: var(--surface-2); }
.menu-item .ic { width: 36px; height: 36px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.menu-item .ic svg { width: 20px; height: 20px; }
.menu-item .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.menu-item .chev { color: var(--muted); width: 20px; height: 20px; }
.menu-item.danger { color: var(--expense-ink); }
.menu-item.danger .ic { background: var(--expense-soft); color: var(--expense-ink); }

.goal-preview { border-radius: var(--radius); overflow: hidden; background: var(--surface-2); aspect-ratio: 1 / 1; position: relative; }
.goal-preview img { width: 100%; height: 100%; object-fit: cover; }
.goal-preview .busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: color-mix(in srgb, var(--surface) 78%, transparent); font-weight: 800; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-row { display: grid; grid-template-columns: 36px 1fr 132px; align-items: center; gap: 10px; min-height: 56px; }
.form-row + .form-row { border-top: 1px solid var(--line); }
.form-row .emo { font-size: 22px; text-align: center; }
.form-row .input { text-align: right; }
.yen-input { position: relative; }
.yen-input::before { content: '¥'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.yen-input .input { padding-left: 26px; }

.cat-edit-row { display: flex; align-items: center; gap: 6px; min-height: 56px; }
.cat-edit-row + .cat-edit-row { border-top: 1px solid var(--line); }
.cat-edit-row .name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: var(--tap); border: 0; background: none; text-align: left; font-weight: 700; }
.cat-edit-row .name .e { font-size: 22px; width: 32px; text-align: center; }
.cat-edit-row.hidden-cat .name { opacity: .45; }
.cat-edit-row .icon-btn svg { width: 20px; height: 20px; }

.steps { margin: 6px 0 0; padding-left: 22px; }
.steps li { margin: 4px 0; }
.guide.current { outline: 2px solid var(--accent); }
.callout { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.callout.warn { background: color-mix(in srgb, var(--warn-ink) 12%, var(--surface)); color: var(--ink); }

/* ---- ログイン ---- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; padding: calc(var(--safe-t) + 24px) 20px calc(var(--safe-b) + 24px); }
.login img { width: min(260px, 70%); margin: 0 auto; border-radius: 32px; }
.login h1 { text-align: center; font-size: 28px; font-weight: 800; margin: 8px 0 2px; }
.login p { text-align: center; color: var(--ink-2); margin: 0 0 20px; }
.login .err { color: var(--expense-ink); font-weight: 700; text-align: center; min-height: 24px; margin: 8px 0 0; font-size: 14px; }

/* ---- お知らせ ---- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); z-index: 60; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; max-width: 528px; width: 100%;
  display: flex; align-items: center; gap: 10px;
  background: var(--toast); color: var(--bg);
  border-radius: 16px; padding: 8px 8px 8px 16px; min-height: 52px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .25);
  font-weight: 700; font-size: 14px;
  transform: translateY(20px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
.toast.show { transform: none; opacity: 1; }
.toast .grow { padding: 6px 0; }
.toast button { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 0; background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); font-weight: 800; }

.offline-bar { position: sticky; top: 0; z-index: 30; padding: calc(var(--safe-t) + 6px) 16px 6px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 700; text-align: center; border-bottom: 1px solid var(--line); }

.loading { display: flex; justify-content: center; padding: 48px 0; }
.error-card { text-align: center; }
.error-card p { color: var(--ink-2); }

/* クリーム色の背景のイラストは、周りをふんわり消して背景になじませる（四角い縁を見せない） */
.login img, .empty img {
  border-radius: 0;
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ai-img { filter: brightness(.88); }
}
:root[data-theme="dark"] .ai-img { filter: brightness(.88); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
