/* ワリピタ 刷新UI v2 — スタイル（CDOミオ UI仕様v2 §1〜§11 / 実装：CTOコウ）
   方針：既存トークンを継承（色は変えない）。スマホ専用＝--app-w:440px中央寄せ・PCレイアウト無し。
   7ビュー（lp/home/create/done/group/expense/settle）を .app 内で data-view 切替。
   影が主役・罫線は淡く・8pxグリッド・数字は等幅。ダークは色トークンだけ上書き。
   reduced-motionで全演出無効。外部依存なし（システムフォントのみ・埋め込み画像なし）。 */

:root {
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-ink: #ffffff;
  --accent-tint: #EEF1FE;
  --done-tint: #ECF6F1;
  --bg: #FBFBFD;
  --card: #ffffff;
  --ink: #14181F;
  --ink-soft: #5A6472;
  --line: #ECEEF3;
  --plus: #0F7A4F;
  --minus: #C23A36;
  --row-bg: #FBFCFE;

  /* 広告枠（§10）・画像プレースホルダ（§9）の地味色：既存中立色から作る */
  --ad-bg: #F4F5F8;

  --radius: 16px;
  --radius-inner: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 10px 30px -12px rgba(20, 24, 40, .10);
  --shadow-hover: 0 2px 4px rgba(20, 24, 40, .06), 0 18px 40px -14px rgba(20, 24, 40, .18);

  --focus-ring: 0 0 0 3px rgba(79, 70, 229, .40);
  --focus-ring-soft: 0 0 0 3px rgba(79, 70, 229, .16);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --app-w: 440px;   /* §1-1 コンテンツ最大幅（PCでも中央でこの幅） */
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #8B9CFF;
    --accent-hover: #A3B0FF;
    --accent-ink: #14181F;
    --accent-tint: #20243A;
    --done-tint: #15281F;
    --bg: #0F1218;
    --card: #171B22;
    --ink: #E6E9EF;
    --ink-soft: #9AA4B2;
    --line: #2A303B;
    --plus: #4FD08A;
    --minus: #FF6B66;
    --row-bg: #1B2029;
    --ad-bg: #1B2029;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px -14px rgba(0, 0, 0, .5);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 18px 40px -16px rgba(0, 0, 0, .6);
    --focus-ring: 0 0 0 3px rgba(139, 156, 255, .50);
    --focus-ring-soft: 0 0 0 3px rgba(139, 156, 255, .22);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 数字は等幅 */
.summary-total, .summary-self, .expense-amt, .s-amt, .badge-num,
.bal, .amount-input, .stepper-value, .split-row-preview, .count,
.recent-meta, .per-person-amt {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================ アプリ土台（スマホ専用） */
/* §1-1：.app は max-width:var(--app-w) 中央寄せ。PCでも横に余白（地）が出るだけ。 */
.app {
  width: 100%;
  max-width: var(--app-w);
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
}

/* 1つの .app 内でビュー差し替え（data-view） */
.view { display: none; }
.view.is-active { display: block; }

/* スクロール領域を持つビューは、下部固定バー/FAB分の余白を空ける */
.view-scroll { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ============================================================ 共通ボタン */
.btn-primary, .btn-soft, .btn-ghost, .btn-ghost-danger {
  font: inherit; cursor: pointer; border-radius: var(--radius-inner);
  border: 1px solid transparent; transition: background-color .15s, box-shadow .15s, transform .05s;
}
.btn-primary {
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  border: none; min-height: 52px; padding: 0 20px; font-size: 16px;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-block { display: block; width: 100%; }

.btn-soft {
  background: var(--card); color: var(--accent); border: 1px solid var(--line);
  min-height: 44px; padding: 0 16px; font-size: 15px; font-weight: 600;
}
.btn-soft:hover { background: var(--accent-tint); }
.btn-soft:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost {
  background: none; color: var(--ink-soft); border: none; min-height: 44px;
  font-size: 14px; padding: 8px 12px;
}
.btn-ghost:hover { color: var(--ink); text-decoration: underline; }

.btn-ghost-danger {
  background: none; color: var(--minus); border: none; min-height: 44px;
  font-size: 13px; padding: 8px 12px; align-self: center;
}
.btn-ghost-danger:hover { text-decoration: underline; }

.icon-btn {
  font: inherit; background: none; border: none; cursor: pointer; color: var(--ink);
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center;
  justify-content: center; border-radius: var(--radius-inner); font-size: 18px;
}
.icon-btn:hover { background: var(--accent-tint); }

:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-primary:focus-visible, .btn-soft:focus-visible { box-shadow: var(--focus-ring), var(--shadow); }

/* ============================================================ 共通入力 */
input[type="text"], input[type="url"] {
  font: inherit; font-size: 16px; /* iOSズーム防止 */
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-inner); background: var(--card); color: var(--ink);
}
input:focus-visible { box-shadow: var(--focus-ring-soft); border-color: var(--accent); outline: none; }
input::placeholder { color: var(--ink-soft); opacity: .7; }
select {
  font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-inner); background: var(--card); color: var(--ink); cursor: pointer;
}
select:focus-visible { box-shadow: var(--focus-ring-soft); border-color: var(--accent); outline: none; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field + .field { margin-top: 16px; }
.field-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.field-error { margin: 4px 0 0; font-size: 12px; color: var(--minus); }
.field-error[hidden] { display: none; }

.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}

.section-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; margin: 20px 0 8px; }
.count { color: var(--ink-soft); font-weight: 600; }

/* ============================================================ §9 画像プレースホルダ */
.img-ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 4px;
  background: var(--accent-tint);
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius-inner);
  color: var(--accent); font-size: 13px; font-weight: 600; padding: 12px;
}
.img-ph .img-ph-dim { font-size: 11px; color: var(--ink-soft); font-weight: 500; }
/* LP（夜背景）の上では地を白カードにして浮かせる */
.view-lp .img-ph { background: var(--card); }

/* ============================================================ §10 広告枠 */
.ad-slot {
  position: relative;
  background: var(--ad-bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius-inner);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: 12px;
  /* 高さ固定でレイアウトシフト防止 */
}
.ad-slot::before {
  content: "広告";
  position: absolute; top: 4px; left: 6px;
  font-size: 10px; font-weight: 600; color: var(--ink-soft);
  background: var(--card); border-radius: 4px; padding: 1px 5px;
}
.ad-slot[data-ad] { margin-top: 16px; }            /* 主CTA/FABから16px離す（§10原則①） */
.ad-banner { height: 100px; }                       /* 320×100 大バナー */
.ad-banner-sm { height: 50px; }                     /* 320×50 小バナー */

/* ============================================================ §2 LP（夜） */
.view-lp {
  background: linear-gradient(160deg, #2A2563 0%, #4F46E5 60%, #3730A3 100%);
  color: #fff; min-height: 100dvh;
  padding: calc(20px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
}
.lp-logo { margin: 0 0 28px; font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -.01em; }
.lp-hero-title { margin: 0; font-size: 26px; font-weight: 800; line-height: 1.25; color: #fff; }
.lp-hero-sub { margin: 12px 0 20px; font-size: 15px; color: rgba(255,255,255,.70); }
.lp-hero-img { width: 100%; aspect-ratio: 16 / 10; margin-bottom: 20px; }

/* LP主CTA：白地×インディゴ文字の反転ボタン（唯一の塗りCTA） */
.lp-cta {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 54px; border: none; border-radius: var(--radius-inner);
  background: #fff; color: var(--accent); font: inherit; font-size: 17px; font-weight: 800;
  cursor: pointer; box-shadow: 0 10px 30px -12px rgba(0,0,0,.4);
}
.lp-cta:active { transform: translateY(1px); }
.lp-cta:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.6); }
.lp-note { margin: 8px 0 0; text-align: center; font-size: 12px; color: rgba(255,255,255,.60); }

.lp-divider { margin: 32px 0 12px; font-size: 13px; color: rgba(255,255,255,.65); font-weight: 600; text-align: center; }

/* LP上の白カード（特長・最近のグループ） */
.lp-card {
  background: var(--card); color: var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
  margin-bottom: 12px;
}
.lp-feature { display: flex; gap: 14px; align-items: center; }
.lp-feature .img-ph { width: 64px; height: 64px; flex-shrink: 0; }
.lp-feature-title { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.lp-feature-text { margin: 0; font-size: 14px; color: var(--ink-soft); }

.lp-foot { margin-top: 28px; text-align: center; font-size: 12px; color: rgba(255,255,255,.55); }
.lp-foot p { margin: 2px 0; }

/* ============================================================ §3 ホーム */
.view-home { padding: calc(20px + var(--safe-top)) 16px calc(28px + var(--safe-bottom)); }
.home-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.app-logo { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.home-sub { margin: 4px 0 24px; font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.home-cta-wrap { margin-bottom: 8px; }
.home-cta .btn-primary { min-height: 56px; }

/* 最近のグループ（LP/ホーム共通部品） */
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.recent-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; cursor: pointer; font: inherit; color: var(--ink);
  min-height: 44px;
}
.recent-item:hover { box-shadow: var(--shadow-hover); }
.recent-body { flex: 1; min-width: 0; }
.recent-name { display: block; font-size: 16px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { display: block; font-size: 13px; color: var(--ink-soft); }
.recent-chevron { color: var(--ink-soft); font-size: 18px; flex-shrink: 0; }

/* リンク参加（従） */
.home-join { margin-top: 20px; }
.home-join .inline-add { margin-top: 8px; }
.home-join .btn-soft { flex-shrink: 0; }

/* ============================================================ 上部バー（戻る付き） */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-top)) 8px 8px; border-bottom: 1px solid var(--line);
}
.topbar-title { margin: 0; font-size: 16px; font-weight: 700; flex: 1; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { min-width: 44px; }

/* ============================================================ §4 作成 */
.view-create { display: none; }
.view-create.is-active { display: flex; flex-direction: column; min-height: 100dvh; }
.create-body { flex: 1; overflow-y: auto; padding: 20px 16px; }

/* メンバーチップ（核：入力→即チップ） */
.member-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; min-height: 8px; }
.member-chips:empty { display: none; }
.member-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-tint); color: var(--ink);
  border-radius: 999px; padding: 6px 8px 6px 6px; font-size: 14px;
  animation: fade-up .24s ease both;
}
.member-chip.is-self { box-shadow: inset 3px 0 0 var(--accent); padding-left: 10px; }
.chip-avatar {
  width: 22px; height: 22px; border-radius: 999px; background: var(--accent);
  color: var(--accent-ink); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.member-chip-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-chip-x {
  border: none; background: none; cursor: pointer; color: var(--ink-soft);
  min-width: 28px; min-height: 28px; border-radius: 999px; font-size: 15px; line-height: 1; padding: 0;
}
.member-chip-x:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.member-self-tag { font-size: 11px; color: var(--accent); font-weight: 600; padding-right: 4px; }

/* 外貨（Phase C・実機能） */
.currency-select-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.currency-select { min-height: 44px; }
.currency-select-line .currency-select { width: 100%; }
.currency-note { margin: 6px 0 0; font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.currency-note[hidden] { display: none; }
/* 立替入力：金額欄の右に通貨セレクト */
.amount-currency { flex-shrink: 0; padding: 10px 10px; min-width: 84px; }
.amount-currency:disabled { opacity: 0.7; cursor: default; }
/* 換算プレビュー（原通貨≠基準のとき・参考値） */
.amount-convert {
  margin: 8px 0 0; font-size: 13px; color: var(--accent); font-weight: 600;
  font-variant-numeric: tabular-nums; line-height: 1.5;
}
.amount-convert[hidden] { display: none; }
/* 精算/一覧の外貨注記（鮮度・参考値・免責） */
.fx-note {
  margin: 0 0 12px; font-size: 12px; color: var(--ink-soft); line-height: 1.6;
  background: var(--accent-tint); border-radius: var(--radius-inner); padding: 10px 12px;
}
.fx-note[hidden] { display: none; }
/* 外貨支出の一覧金額（原通貨＋換算併記） */
.expense-amt.is-foreign { font-size: 14px; line-height: 1.35; text-align: right; }

/* 下部固定CTAバー（共通） */
.bottom-bar {
  position: sticky; bottom: 0; z-index: 15;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
  border-top: 1px solid var(--line);
}
.bottom-bar-ghost { display: block; width: 100%; text-align: center; margin-top: 2px; }

/* ============================================================ §5 完了 */
.view-done { padding: calc(40px + var(--safe-top)) 20px calc(28px + var(--safe-bottom)); text-align: center; }
.done-badge {
  width: 56px; height: 56px; border-radius: 999px; background: var(--accent);
  color: var(--accent-ink); font-size: 30px; line-height: 56px; margin: 0 auto 16px;
  animation: badge-in .3s ease both;
}
.done-title { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.done-group-name { margin: 0 0 24px; font-size: 15px; color: var(--ink-soft); }
.done-share { text-align: left; margin-bottom: 20px; }
.done-share .share-url-line { display: flex; gap: 8px; margin-top: 8px; }
.done-share .share-url-line input { flex: 1; font-size: 13px; }
.done-share-note { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); }
.done-share .field-error { margin: 8px 0 0; }
.done-qr-wrap { display: flex; justify-content: center; margin: 0 auto 8px; }
/* 実QR：白地・余白(quiet zone)・高コントラストでスマホが読み取れる体裁。
   一辺240px・padding16px＝コード本体208pxへ十分なquiet zoneを確保。 */
.done-qr {
  display: grid; width: 240px; height: 240px; padding: 16px; box-sizing: border-box;
  background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius-inner);
}
.done-qr i { display: block; width: 100%; height: 100%; }
.done-qr i.on { background: #000000; }
.done-qr.is-loading {
  align-items: center; justify-content: center; color: var(--ink-soft); font-size: 13px;
}
.done-qr-fallback { margin: 0; font-size: 13px; color: var(--minus); text-align: center; }
/* done画面の下部CTA群（静的配置：done画面はスクロールしない短い画面のため固定せず流す） */
.view-done .bottom-bar--static { position: static; margin-top: 24px; padding: 0; background: none; border: none; }

/* ============================================================ §6 グループ画面 */
.view-group { display: none; }
.view-group.is-active { display: block; }
.group-header {
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + var(--safe-top)) 12px 4px;
}
.group-name-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.group-name { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-name-edit {
  font: inherit; font-size: 18px; font-weight: 700; flex: 1;
  padding: 4px 8px; border: 1px solid var(--accent); border-radius: 8px; background: var(--card); color: var(--ink);
}
.group-share { font-size: 22px; color: var(--accent); }

.avatar-row {
  display: flex; align-items: center; gap: 8px; background: none; border: none;
  cursor: pointer; padding: 4px 16px 12px; width: 100%; min-height: 44px; color: var(--ink-soft);
}
.avatars { display: inline-flex; }
.avatar {
  width: 28px; height: 28px; border-radius: 999px; background: var(--accent-tint);
  color: var(--accent); font-size: 12px; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center; border: 2px solid var(--bg); margin-left: -8px;
}
.avatar:first-child { margin-left: 0; }
.avatar-count { font-size: 13px; }
.avatar-edit { margin-left: auto; font-size: 13px; color: var(--accent); }

.group-main { padding: 0 16px; }
/* グループ削除（T-042）：一覧の下・控えめな危険操作 */
.group-danger { margin: 28px 0 12px; text-align: center; }
.group-delete-btn { font-size: 14px; }

.summary-card { display: flex; flex-direction: column; gap: 8px; }
.summary-row { display: flex; align-items: baseline; justify-content: space-between; }
.summary-label { font-size: 13px; color: var(--ink-soft); }
.summary-total { font-size: 26px; font-weight: 700; }
.summary-self { font-size: 18px; font-weight: 700; }
.summary-self.is-plus { color: var(--plus); }
.summary-self.is-minus { color: var(--minus); }

.expense-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.expense-item {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; cursor: pointer; text-align: left; width: 100%; font: inherit; color: var(--ink);
  animation: fade-up .28s ease both;
}
.expense-item:hover { box-shadow: var(--shadow-hover); }
.expense-emoji { font-size: 24px; line-height: 1; flex-shrink: 0; width: 28px; text-align: center; }
.expense-body { flex: 1; min-width: 0; }
.expense-desc { display: block; font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-meta { display: block; font-size: 13px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-amt { font-size: 16px; font-weight: 700; flex-shrink: 0; }

.split-tag {
  display: inline-block; font-size: 11px; font-weight: 600; border-radius: 6px;
  padding: 1px 6px; margin-left: 6px; vertical-align: 1px;
}
.split-tag-equal { background: var(--line); color: var(--ink-soft); }
.split-tag-amount, .split-tag-ratio { background: var(--accent-tint); color: var(--accent); }

/* 空状態（§6 支出ゼロ） */
.empty-state { text-align: center; padding: 32px 16px 8px; }
.empty-state .img-ph { width: 240px; max-width: 100%; aspect-ratio: 4 / 3; margin: 0 auto 16px; }
.empty-title { margin: 4px 0; font-size: 16px; font-weight: 600; }
.empty-sub { margin: 0; font-size: 13px; color: var(--ink-soft); }

/* FAB（§6 主アクション） */
.fab {
  position: fixed; right: calc(50% - var(--app-w) / 2 + 16px); bottom: calc(88px + var(--safe-bottom));
  width: 56px; height: 56px; border-radius: 999px; border: none;
  background: var(--accent); color: var(--accent-ink); font-size: 28px; line-height: 1;
  cursor: pointer; box-shadow: var(--shadow-hover); z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.fab:hover { background: var(--accent-hover); }
.fab:active { transform: translateY(1px); }
@media (max-width: 471px) { .fab { right: 16px; } }

/* ============================================================ §7 立替入力 */
.view-expense { display: none; }
.view-expense.is-active { display: flex; flex-direction: column; min-height: 100dvh; }
.expense-form-body { flex: 1; overflow-y: auto; padding: 16px; }

/* タブ（セグメント） */
.split-tabs {
  display: flex; gap: 4px; background: var(--row-bg); border: 1px solid var(--line);
  border-radius: var(--radius-inner); padding: 4px; margin-bottom: 16px;
}
.split-tab {
  flex: 1; font: inherit; font-size: 14px; font-weight: 600; background: none; border: none;
  border-radius: 8px; padding: 8px; min-height: 44px; cursor: pointer; color: var(--ink-soft);
}
.split-tab.is-selected { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

/* カテゴリチップ（横スクロール） */
.category-chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.category-chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; font: inherit;
  font-size: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; min-height: 44px; cursor: pointer; color: var(--ink);
}
.category-chip:hover { background: var(--accent-tint); }
.category-chip.is-selected { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.cat-emoji { font-size: 16px; }

/* 払った人・対象者チップ */
.single-chips, .multi-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  min-height: 44px; cursor: pointer; background: var(--card); user-select: none; color: var(--ink);
}
.chip-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-toggle:has(input:checked) { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-toggle:has(input:focus-visible) { box-shadow: var(--focus-ring-soft); }
.chip-all { font-weight: 600; }

/* 金額input（テキスト・inputmode=decimal） */
.amount-line { display: flex; align-items: center; gap: 8px; }
.amount-input {
  font: inherit; font-size: 22px; font-weight: 700; width: 100%;
  padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-inner); background: var(--card); color: var(--ink);
}
.amount-input:focus-visible { box-shadow: var(--focus-ring-soft); border-color: var(--accent); outline: none; }
.amount-unit { font-size: 15px; color: var(--ink-soft); flex-shrink: 0; }

/* かんたん入力プレビュー（1人あたり） */
.per-person {
  margin: 14px 0 0; font-size: 15px; color: var(--accent); font-weight: 600;
}
.per-person.is-muted { color: var(--ink-soft); font-weight: 500; }
.per-person-amt { font-weight: 700; }

/* こだわり入力：割り方サブ切替 */
.detail-split-tabs {
  display: flex; gap: 4px; background: var(--row-bg); border: 1px solid var(--line);
  border-radius: var(--radius-inner); padding: 4px; margin-bottom: 12px;
}
.detail-split-tab {
  flex: 1; font: inherit; font-size: 13px; font-weight: 600; background: none; border: none;
  border-radius: 8px; padding: 8px; min-height: 40px; cursor: pointer; color: var(--ink-soft);
}
.detail-split-tab.is-selected { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

.share-rows { display: flex; flex-direction: column; gap: 10px; }
.split-row { display: flex; align-items: center; gap: 10px; }
.split-row-name { flex: 1; font-size: 15px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-row-input { width: 110px; text-align: right;
  font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-inner); background: var(--card); color: var(--ink); }
.split-row-input:focus-visible { box-shadow: var(--focus-ring-soft); border-color: var(--accent); outline: none; }
.split-row-unit { font-size: 13px; color: var(--ink-soft); }

/* ○人分ステッパー */
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper-btn {
  width: 44px; height: 44px; border: 1px solid var(--line); background: var(--card);
  border-radius: var(--radius-inner); font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink);
}
.stepper-btn:hover { background: var(--accent-tint); }
.stepper-btn:disabled { opacity: .35; cursor: not-allowed; }
.stepper-value {
  width: 56px; text-align: center; padding: 8px 4px;
  font: inherit; font-size: 16px; border: 1px solid var(--line);
  border-radius: var(--radius-inner); background: var(--card); color: var(--ink);
}
.stepper-value:focus-visible { box-shadow: var(--focus-ring-soft); border-color: var(--accent); outline: none; }
.split-row--ratio { flex-wrap: wrap; }
.split-row-preview { font-size: 13px; color: var(--ink-soft); min-width: 64px; text-align: right; }
.split-row-preview.has-amount { color: var(--accent); font-weight: 600; }

.split-status { margin: 10px 0 0; font-size: 12px; color: var(--ink-soft); }
.split-status.is-ok { color: var(--plus); font-weight: 600; }
.split-status.is-ng { color: var(--minus); }

.detail-field + .detail-field { margin-top: 12px; }

/* ============================================================ §8 精算結果 */
.view-settle { display: none; }
.view-settle.is-active { display: block; }
.settle-main { padding: 16px; }

.settle-badge {
  border-radius: var(--radius); padding: 16px 20px; font-size: 15px; text-align: center;
  margin-bottom: 16px; animation: badge-in .3s ease both;
}
.settle-badge.is-active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.settle-badge.is-done { background: var(--done-tint); color: var(--plus); font-weight: 600; }
.settle-badge.is-done::before { content: "✓ "; }
.settle-badge.is-empty { background: var(--row-bg); color: var(--ink-soft); }
.badge-num { font-size: 20px; font-weight: 700; }

.settle-list { list-style: none; margin: 0; padding: 0; }
.s-row {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-inner);
  box-shadow: var(--shadow); margin-bottom: 8px; animation: fade-up .28s ease both;
}
.s-row.is-self { box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
.s-from, .s-to { font-size: 15px; }
.s-arrow { color: var(--ink-soft); }
.s-amt { margin-left: auto; font-size: 16px; font-weight: 700; color: var(--ink); }
.settle-empty { text-align: center; color: var(--ink-soft); font-size: 14px; padding: 24px 0; }

.balance-list { list-style: none; margin: 0; padding: 0; }
.balance-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; border-top: 1px solid var(--line);
}
.balance-list li:first-child { border-top: none; }
.balance-list li.is-self {
  background: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent);
  border-radius: 8px; padding-left: 10px; border-top-color: transparent;
}
.bal { font-size: 15px; font-weight: 700; }
.bal.is-plus { color: var(--plus); }
.bal.is-minus { color: var(--minus); }
.bal.is-zero { color: var(--ink-soft); }

/* staggered fade-up（やり過ぎない） */
.s-row:nth-child(1) { animation-delay: 0ms; }
.s-row:nth-child(2) { animation-delay: 50ms; }
.s-row:nth-child(3) { animation-delay: 100ms; }
.s-row:nth-child(4) { animation-delay: 150ms; }
.s-row:nth-child(n+5) { animation-delay: 200ms; }

/* ============================================================ モーダル（メンバー編集・自分は誰） */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 20, .45); animation: fade-in .2s ease both; }
.sheet-panel {
  position: relative; width: 100%; max-width: var(--app-w); background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow-hover);
  max-height: 88vh; display: flex; flex-direction: column;
  animation: sheet-up .26s cubic-bezier(.2,.8,.2,1) both;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 12px 8px 20px; flex-shrink: 0;
}
.modal-header--center { justify-content: center; text-align: center; padding-bottom: 4px; }
.modal-title { margin: 0; font-size: 17px; font-weight: 700; }
.modal-sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); }
.modal-body { padding: 8px 20px calc(20px + var(--safe-bottom)); overflow-y: auto; }

.members-list { list-style: none; margin: 0 0 12px; padding: 0; }
.member-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.member-item:first-child { border-top: none; }
.member-name { flex: 1; font-size: 15px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-self-badge {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-tint); border-radius: 6px; padding: 2px 8px;
}
.member-self-set { font: inherit; font-size: 12px; background: none; border: none; cursor: pointer; color: var(--accent); min-height: 44px; padding: 0 8px; }
.members-empty { margin: 0 0 12px; font-size: 13px; color: var(--ink-soft); text-align: center; }
.whoami-divider { margin: 16px 0 8px; font-size: 13px; color: var(--ink-soft); }

/* ============================================================ 共有モーダル（Phase B） */
.share-pre-text { margin: 4px 0 8px; font-size: 14px; line-height: 1.6; }
.share-pre-note { margin: 0 0 16px; font-size: 12px; color: var(--ink-soft); }
.share-url-line { display: flex; gap: 8px; margin-top: 8px; }
.share-url-line input {
  flex: 1; min-width: 0; font-size: 13px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-inner);
  background: var(--row-bg); color: var(--ink);
}
.share-post-note { margin: 10px 0 0; font-size: 12px; color: var(--ink-soft); }
.share-qr-wrap { display: flex; justify-content: center; margin: 18px 0 6px; }
.share-qr {
  display: grid; width: 220px; height: 220px; padding: 12px; box-sizing: border-box;
  background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius-inner);
}
.share-qr i { display: block; width: 100%; height: 100%; }
.share-qr i.on { background: #000000; }
.share-qr-fallback { margin: 8px 0 0; font-size: 13px; color: var(--minus); text-align: center; }

/* ============================================================ 競合モーダル（409/ポーリング） */
.conflict-text { margin: 4px 0 16px; font-size: 14px; line-height: 1.6; }
.conflict-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-block { width: 100%; }

/* ============================================================ トースト */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-hover); z-index: 60;
  animation: badge-in .25s ease both;
}
.toast[hidden] { display: none; }

/* ============================================================ アニメ */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes badge-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
