/* ============================================================
   わが家の資産簿 — アプリ画面のスタイル
   ============================================================ */

/* ---- アプリの器(モバイル/デスクトップ共通) ----------- */
.app { display: flex; width: 100%; height: 100%; background: var(--page); overflow: hidden; }

/* モバイル: 1カラム + 下部ナビ */
.app.mobile { flex-direction: column; }
.app.mobile .viewport { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.app.mobile .content { padding: 14px 16px 26px; display: flex; flex-direction: column; gap: 14px; }

/* デスクトップ: サイドバー + 広い本文 */
.app.desktop { flex-direction: row; }
.app.desktop .viewport { flex: 1; overflow-y: auto; overflow-x: hidden; }
.app.desktop .content { padding: 26px 34px 40px; max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* ---- アプリヘッダ(対象年月など) ----------------------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: blur(10px);
  padding: 14px 16px 10px;
  display: flex; flex-direction: column; gap: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.app.mobile .appbar { padding-top: 44px; }
.appbar-top { display: flex; align-items: center; gap: 10px; }
.appbar-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; white-space: nowrap; }
.month-pill {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 12px 7px 14px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow-soft);
}
.month-pill svg { width: 15px; height: 15px; color: var(--ink-faint); }
.month-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; background: var(--card);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft); transition: .15s;
}
.icon-btn:hover { background: var(--card-2); }
.icon-btn svg { width: 19px; height: 19px; color: var(--ink-soft); }

/* ---- scope タブ(家族全体/ママ/パパ) ------------------- */
.scope-tabs { display: flex; gap: 6px; background: var(--card); padding: 5px; border-radius: 999px; border: 1px solid var(--line); box-shadow: var(--shadow-soft); }
.scope-tabs button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 700; font-size: 13.5px; color: var(--ink-soft);
  padding: 9px 8px; border-radius: 999px; transition: .18s; white-space: nowrap;
}
.scope-tabs button .ava { width: 20px; height: 20px; border-radius: 99px; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.scope-tabs button.on { color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.scope-tabs button.on.family { background: var(--family); }
.scope-tabs button.on.mama   { background: var(--mama); }
.scope-tabs button.on.papa   { background: var(--papa); }

/* ---- 総資産メインカード -------------------------------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl);
  padding: 22px 22px 20px;
  color: #fff;
  box-shadow: var(--shadow-card);
}
.hero.family { background: linear-gradient(150deg, #E7B486 0%, #E0A877 60%, #D89A66 100%); }
.hero.mama   { background: linear-gradient(150deg, #E6A2B5 0%, #DB8FA3 60%, #CE7E94 100%); }
.hero.papa   { background: linear-gradient(150deg, #94B7D6 0%, #7FA8C9 60%, #6E9AC0 100%); }
.hero .blob { position: absolute; border-radius: 999px; background: rgba(255,255,255,.16); }
.hero .blob.b1 { width: 150px; height: 150px; right: -40px; top: -50px; }
.hero .blob.b2 { width: 90px; height: 90px; right: 60px; bottom: -44px; background: rgba(255,255,255,.1); }
.hero-label { font-size: 13px; font-weight: 700; opacity: .92; display: flex; align-items: center; gap: 7px; }
.hero-total { font-size: 40px; font-weight: 800; letter-spacing: -.5px; margin: 6px 0 2px; line-height: 1; }
.hero-total .yen { font-size: 24px; margin-right: 2px; opacity: .9; }
.app.desktop .hero-total { font-size: 48px; }
.hero-deltas { display: flex; gap: 10px; margin-top: 16px; }
.hero-delta {
  flex: 1; background: rgba(255,255,255,.18); border-radius: var(--r-md);
  padding: 11px 13px; backdrop-filter: blur(2px);
}
.hero-delta .lab { font-size: 11.5px; opacity: .9; font-weight: 700; }
.hero-delta .val { font-size: 17px; font-weight: 800; margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.hero-delta .val svg { width: 14px; height: 14px; }

/* ---- セクション見出し ---------------------------------- */
.sec-head { display: flex; align-items: center; gap: 8px; padding: 2px 2px 0; }
.sec-head h3 { font-family: var(--font-display); font-size: 15.5px; margin: 0; font-weight: 700; white-space: nowrap; }
.sec-head .hint { font-size: 12px; color: var(--ink-faint); margin-left: auto; font-weight: 700; }

/* ---- 内訳カード(分類リスト) --------------------------- */
.breakdown { padding: 6px; }
.bd-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border-radius: var(--r-md); transition: .15s;
}
.bd-row:hover { background: var(--card-2); }
.bd-icon { width: 40px; height: 40px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex: none; }
.bd-icon svg { width: 21px; height: 21px; }
.bd-main { flex: 1; min-width: 0; }
.bd-name { font-weight: 700; font-size: 14.5px; }
.bd-bar { height: 6px; border-radius: 99px; background: var(--line-soft); margin-top: 7px; overflow: hidden; }
.bd-bar > span { display: block; height: 100%; border-radius: 99px; }
.bd-right { text-align: right; flex: none; }
.bd-amt { font-weight: 800; font-size: 15px; }
.bd-pct { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin-top: 2px; }
.bd-sep { height: 1px; background: var(--line-soft); margin: 0 12px; }

/* 構成比リング(合計の帯) */
.ratio-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; margin: 4px 6px 10px; }
.ratio-bar > span { height: 100%; }

/* ---- 入力状況カード ------------------------------------ */
.status-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 13px; }
.status-row { display: flex; align-items: center; gap: 12px; }
.status-ava { width: 38px; height: 38px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex: none; }
.status-name { font-weight: 700; font-size: 14.5px; }
.status-sub { font-size: 12px; color: var(--ink-soft); }
.pill-state { margin-left: auto; font-size: 12.5px; font-weight: 800; padding: 5px 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.pill-state.done { color: var(--up); background: var(--up-bg); }
.pill-state.todo { color: var(--accent-ink); background: var(--accent-soft); }
.pill-state svg { width: 13px; height: 13px; }

/* ---- 主要ボタン ---------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: 15px; padding: 15px 20px; border-radius: var(--r-md);
  transition: .16s; white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(219,143,163,.4); }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--card-2); }
.btn svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }

/* ============================================================
   下部ナビ(モバイル)
   ============================================================ */
.bottom-nav {
  flex: none; display: flex; align-items: stretch;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--ink-faint); font-size: 10.5px; font-weight: 700; padding: 4px 0; transition: .15s; position: relative;
}
.bottom-nav button svg { width: 23px; height: 23px; }
.bottom-nav button.on { color: var(--accent); }
.bottom-nav .fab-wrap { flex: none; width: 64px; display: flex; justify-content: center; }
.bottom-nav .fab {
  width: 56px; height: 56px; border-radius: 20px; margin-top: -22px;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 18px rgba(219,143,163,.5); border: 4px solid var(--page);
}
.bottom-nav .fab svg { width: 26px; height: 26px; }

/* ============================================================
   サイドバー(デスクトップ)
   ============================================================ */
.sidebar {
  width: 248px; flex: none; background: var(--card-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px;
}
.sidebar .logo { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.sidebar .logo .mark { width: 40px; height: 40px; border-radius: 13px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; }
.sidebar .logo .mark svg { width: 23px; height: 23px; color: var(--accent); }
.sidebar .logo .txt { font-family: var(--font-display); font-weight: 700; line-height: 1.2; }
.sidebar .logo .txt .sub { font-size: 11px; color: var(--ink-faint); font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 12px 14px; border-radius: var(--r-md); font-weight: 700; font-size: 14.5px;
  color: var(--ink-soft); transition: .15s; margin-bottom: 3px;
}
.nav-item:hover { background: var(--card); color: var(--ink); }
.nav-item.on { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item svg { width: 21px; height: 21px; }
.sidebar .user-foot { margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 12px 12px; background: var(--card); border-radius: var(--r-md); border: 1px solid var(--line); }
.sidebar .user-foot .ava { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.sidebar .user-foot .nm { font-weight: 700; font-size: 13.5px; }
.sidebar .user-foot .lo { font-size: 11.5px; color: var(--ink-faint); font-weight: 700; }

/* グリッド(デスクトップで2カラム化) */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.app.desktop .grid-2 { grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }

/* ============================================================
   グラフ画面
   ============================================================ */
.chart-card { padding: 18px 18px 14px; }
.stacked { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding: 8px 2px 0; }
.app.desktop .stacked { height: 240px; }
.stacked .col-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; min-width: 0; }
.stacked .bar { width: 100%; max-width: 40px; border-radius: 9px 9px 4px 4px; overflow: hidden; display: flex; flex-direction: column-reverse; box-shadow: var(--shadow-soft); transition: .2s; }
.stacked .col-wrap:hover .bar { transform: translateY(-3px); }
.stacked .bseg { display: block; width: 100%; border-radius: 0; padding: 0; }
.stacked .mlab { font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.stacked .col-wrap.cur .mlab { color: var(--accent-ink); }
.stacked .col-wrap.cur .bar { box-shadow: 0 6px 16px rgba(0,0,0,.1); outline: 2px solid #fff; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.legend .lg { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }

/* 増減バー(前月比/前年比) */
.diff-list { display: flex; flex-direction: column; gap: 4px; padding: 4px; }
.diff-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-sm); }
.diff-row:hover { background: var(--card-2); }
.diff-name { font-weight: 700; font-size: 13.5px; width: 96px; flex: none; display: flex; align-items: center; gap: 8px; }
.diff-track { flex: 1; height: 22px; position: relative; display: flex; align-items: center; }
.diff-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); }
.diff-fill { position: absolute; height: 12px; border-radius: 7px; top: 50%; transform: translateY(-50%); }
.diff-val { width: 92px; flex: none; text-align: right; font-weight: 800; font-size: 13.5px; }

/* コメントカード */
.comment-card {
  display: flex; gap: 13px; padding: 16px 18px;
  background: var(--accent-soft); border: 1px solid #F3D9E2; border-radius: var(--r-lg);
}
.comment-card .ic { width: 40px; height: 40px; border-radius: 13px; background: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.comment-card .ic svg { width: 22px; height: 22px; color: var(--accent); }
.comment-card .tx { font-size: 14px; line-height: 1.65; font-weight: 500; }
.comment-card .tx b { color: var(--accent-ink); }

/* ============================================================
   入力画面
   ============================================================ */
.input-group { padding: 6px 6px 10px; }
.ig-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.ig-head .ic { width: 34px; height: 34px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.ig-head .ic svg { width: 19px; height: 19px; }
.ig-head .ti { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; }
.ig-head .gt { margin-left: auto; font-size: 12.5px; font-weight: 800; color: var(--ink-soft); }
.acct-row { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-md); }
.acct-row:hover { background: var(--card-2); }
.acct-info { flex: 1 1 auto; min-width: 0; }
.acct-inst { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-name { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.amt-field {
  display: flex; align-items: baseline; gap: 4px; background: var(--card-2);
  border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 9px 13px;
  transition: .15s; flex: 0 0 148px; width: 148px;
}
.amt-field:focus-within { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.amt-field .cur { color: var(--ink-faint); font-weight: 800; font-size: 16px; }
.amt-field input {
  border: none; outline: none; background: none; text-align: right; flex: 1; width: 100%; min-width: 0;
  font-family: var(--font-num); font-weight: 800; font-size: 19px; color: var(--ink);
}
.amt-field.filled .cur { color: var(--accent); }
.acct-sep { height: 1px; background: var(--line-soft); margin: 0 12px; }
.group-total { display: flex; align-items: center; padding: 10px 14px 4px; }
.group-total .lab { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }
.group-total .val { margin-left: auto; font-weight: 800; font-size: 15px; }

/* 入力サマリーバー(固定保存ボタン上) */
.save-bar {
  position: sticky; bottom: 0; z-index: 25;
  background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
}
.save-bar .tot { line-height: 1.2; }
.save-bar .tot .lab { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; }
.save-bar .tot .val { font-size: 20px; font-weight: 800; }
.save-bar .btn { flex: 1; max-width: 220px; margin-left: auto; }

/* 保存完了オーバーレイ */
.toast-mask {
  position: absolute; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(75,70,64,.32); backdrop-filter: blur(3px); animation: fade .2s ease;
}
.toast-card {
  background: var(--card); border-radius: var(--r-xl); padding: 30px 30px 26px; text-align: center;
  width: min(300px, 80%); box-shadow: var(--shadow-pop); animation: pop .3s cubic-bezier(.2,1.1,.4,1);
}
.toast-check { width: 72px; height: 72px; border-radius: 999px; background: var(--up-bg); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.toast-check svg { width: 38px; height: 38px; color: var(--up); }
.toast-card h3 { font-family: var(--font-display); margin: 0 0 6px; font-size: 19px; }
.toast-card p { margin: 0; color: var(--ink-soft); font-size: 13.5px; line-height: 1.6; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   設定 / 口座一覧
   ============================================================ */
.owner-block { padding: 6px; }
.owner-head { display: flex; align-items: center; gap: 11px; padding: 10px 12px 8px; }
.owner-head .ava { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.owner-head .nm { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.owner-head .ct { font-size: 12px; color: var(--ink-faint); font-weight: 700; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-md); }
.set-row:hover { background: var(--card-2); }
.set-main { flex: 1; min-width: 0; }
.set-inst { font-weight: 700; font-size: 14px; }
.set-name { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.toggle { width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: .18s; flex: none; }
.toggle.on { background: var(--up); }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .18s; }
.toggle.on .knob { left: 21px; }
.state-tag { font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.state-tag.active { color: var(--up); background: var(--up-bg); }
.state-tag.off { color: var(--ink-faint); background: var(--line-soft); }
.add-row { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px; border-radius: var(--r-md); border: 1.5px dashed var(--line); color: var(--accent-ink); font-weight: 800; font-size: 13.5px; margin: 6px; transition: .15s; white-space: nowrap; }
.add-row svg { width: 18px; height: 18px; flex: none; }
.add-row:hover { background: var(--accent-soft); border-color: var(--accent); }

.account-delta-card { padding: 6px; }
.acct-delta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-md);
}
.acct-delta-row:hover { background: var(--card-2); }
.acct-delta-amt {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex: none;
  font-weight: 800;
}
.acct-delta-amt .delta { font-size: 11.5px; padding: 2px 8px 2px 6px; }

/* ============================================================
   ログイン画面
   ============================================================ */
.login-stage {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px; gap: 0; position: relative; overflow: hidden;
  background: radial-gradient(120% 80% at 50% -10%, var(--accent-soft) 0%, var(--page) 55%);
}
.login-deco { position: absolute; border-radius: 999px; opacity: .5; filter: blur(2px); }
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: var(--r-xl);
  box-shadow: var(--shadow-card); padding: 34px 28px 30px; text-align: center; z-index: 2;
  border: 1px solid var(--line);
}
.login-logo { width: 70px; height: 70px; border-radius: 22px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.login-logo svg { width: 38px; height: 38px; color: var(--accent); }
.login-card h1 { font-family: var(--font-display); font-size: 24px; margin: 0 0 6px; letter-spacing: .5px; }
.login-card .sub { color: var(--ink-soft); font-size: 13px; line-height: 1.6; margin: 0 0 26px; }
.user-pick { display: flex; gap: 14px; }
.user-tile {
  flex: 1; background: var(--card-2); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  padding: 20px 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: .18s;
}
.user-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.user-tile .face { width: 62px; height: 62px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.user-tile .nm { font-weight: 800; font-size: 16px; }
.user-tile.mama:hover { border-color: var(--mama); }
.user-tile.papa:hover { border-color: var(--papa); }

/* PIN */
.pin-view { animation: slideUp .25s ease; }
.pin-face { width: 76px; height: 76px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-size: 38px; margin: 0 auto 8px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 22px 0 24px; }
.pin-dot { width: 15px; height: 15px; border-radius: 999px; border: 2px solid var(--line); transition: .15s; }
.pin-dot.f { background: var(--accent); border-color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-key { height: 58px; border-radius: var(--r-md); background: var(--card-2); border: 1px solid var(--line); font-size: 24px; font-weight: 700; font-family: var(--font-num); transition: .12s; }
.pin-key:hover { background: var(--accent-soft); }
.pin-key:active { transform: scale(.95); }
.pin-key.blank { background: none; border: none; }
.pin-key.fn { font-size: 14px; font-weight: 800; color: var(--ink-soft); }
.pin-back { background: none; border: none; color: var(--ink-soft); font-weight: 700; font-size: 13px; margin-top: 18px; }
.pin-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 14px; }
.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-7px)} 40%,80%{transform:translateX(7px)} }

/* 画面遷移(opacity:0 開始にしない=非アクティブ時も必ず見える) */
@keyframes screenIn { from { transform: translateY(12px); } to { transform: translateY(0); } }
.screen-anim { animation: screenIn .28s ease both; }
