/* ============================================================
   Stake. — Design System (clean rewrite 2026-05-22)
   - Mobile-first PWA (light/dark/auto)
   - One accent (green), one danger (red), one Pro (purple)
   - 8pt spacing, 14px base, generous whitespace
   ============================================================ */

:root {
  /* color (DARK theme — default) */
  --bg: #0d0d12;
  --bg-elev: #1c1c24;
  --bg-elev2: #25252f;
  --bg-primary: #0d0d12;
  --text-base-rgb: 255, 255, 255;  /* テキスト/ボーダー用ベース RGB ([data-theme="light"] で反転) */
  --border: rgba(var(--text-base-rgb), 0.14);
  --border-strong: rgba(var(--text-base-rgb), 0.22);
  --border-subtle: rgba(var(--text-base-rgb), 0.08);
  --text: rgb(var(--text-base-rgb));
  --text-primary: rgb(var(--text-base-rgb));
  --text-secondary: rgba(var(--text-base-rgb), 0.85);
  --text-tertiary: rgba(var(--text-base-rgb), 0.62);
  --accent: #00e676;
  --accent-success: #00e676;
  --accent-dark: #00b85e;
  --accent-soft: rgba(0, 230, 118, 0.18);
  --danger: #ff5252;
  --accent-danger: #ff5252;
  --danger-soft: rgba(255, 82, 82, 0.10);
  --warning: #ffa726;
  --accent-warning: #ffa726;
  --info: #29b6f6;
  --accent-info: #29b6f6;
  --pro: #ba68c8;
  --pro-soft: rgba(186, 104, 200, 0.10);
  /* tab nav 背景 (theme で変える) */
  --tabnav-bg: rgba(13, 13, 18, 0.96);

  /* spacing (8pt) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* radius (全体的に丸みを増やしてカクカク感を解消) */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;

  /* typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============ LIGHT theme ============ */
/* --text-base-rgb を 0,0,0 に切り替えるだけで border/text 系は自動反転。
 * bg 系と accent 系のみ明示上書き。 */
:root[data-theme="light"] {
  --bg: #f7f7fa;
  --bg-elev: #ffffff;
  --bg-elev2: #f0f0f5;
  --bg-primary: #f7f7fa;
  --text-base-rgb: 0, 0, 0;
  --accent: #16a866;
  --accent-success: #16a866;
  --accent-dark: #0e8a50;
  --accent-soft: rgba(22, 168, 102, 0.12);
  --danger: #d32f2f;
  --accent-danger: #d32f2f;
  --danger-soft: rgba(211, 47, 47, 0.08);
  --warning: #ed6c02;
  --accent-warning: #ed6c02;
  --info: #0288d1;
  --accent-info: #0288d1;
  --pro: #9c27b0;
  --pro-soft: rgba(156, 39, 176, 0.08);
  --tabnav-bg: rgba(255, 255, 255, 0.96);
}

/* Auto: OS のダーク/ライト設定追従 (data-theme="auto" 指定時) */
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f7f7fa;
    --bg-elev: #ffffff;
    --bg-elev2: #f0f0f5;
    --bg-primary: #f7f7fa;
    --text-base-rgb: 0, 0, 0;
    --accent: #16a866;
    --accent-success: #16a866;
    --accent-dark: #0e8a50;
    --accent-soft: rgba(22, 168, 102, 0.12);
    --danger: #d32f2f;
    --danger-soft: rgba(211, 47, 47, 0.08);
    --tabnav-bg: rgba(255, 255, 255, 0.96);
  }
}

/* ============ Reset ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html {
  height: 100%;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}
input, textarea, select { user-select: text; -webkit-user-select: text; font-family: inherit; font-size: inherit; color: inherit; }
.quote-text, .book-row-title, .book-row-author, .recent-exercise-name,
.list-item, .card p, .card div[x-text] { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; cursor: pointer; }
[x-cloak] { display: none !important; }

/* ============ Accessibility ============ */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ App shell (mobile-first ≤480px) ============ */
#app { min-height: 100vh; display: flex; flex-direction: column; position: relative; }
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}
.app-header {
  padding: 18px 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}
.app-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.app-title-dot { color: var(--accent); }
.app-header-actions { display: flex; gap: var(--space-2); align-items: center; }
.app-header-action {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 16px;
}
.app-greeting { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.view {
  flex: 1;
  /* 下端 buffer を増量: tab nav (64px) + FAB (52px+下マージン) + 余裕 = 140px+
   * 「下までスクロールできない」「最下部要素が tab/FAB に被る」問題の解消 */
  padding: var(--space-3) var(--space-4) calc(140px + env(safe-area-inset-bottom, 0px));
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ============ Typography ============ */
h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
h3 { font-size: 15px; font-weight: 700; line-height: 1.35; }
h4 { font-size: 13px; font-weight: 700; line-height: 1.4; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12.5px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 19px; }
.text-2xl { font-size: 24px; }
.text-3xl { font-size: 30px; }
.text-4xl { font-size: 38px; }
.font-mono { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--accent-success); }
.text-danger { color: var(--accent-danger); }
.text-warning { color: var(--accent-warning); }
.text-info { color: var(--accent-info); }
.text-center { text-align: center; }

/* ============ Layout utilities ============ */
.flex { display: flex; }
.flex-1 { flex: 1; min-width: 0; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.ml-2 { margin-left: var(--space-2); }
.ml-3 { margin-left: var(--space-3); }
.section { margin-bottom: var(--space-5); }
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: var(--space-4) 0 var(--space-2);
}

/* ============ Card ============ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4);
}
.card p { line-height: 1.6; }
.card-elevated {
  background: var(--bg-elev2);
  border-color: var(--border-strong);
}
.card-interactive {
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.card-interactive:active { transform: scale(0.99); background: var(--bg-elev2); }
.info-card {
  background: rgba(41, 182, 246, 0.06);
  border-color: rgba(41, 182, 246, 0.22);
  width: 100%;
  text-align: left;
}
.success-card {
  background: var(--accent-soft);
  border-color: rgba(0, 230, 118, 0.25);
  width: 100%;
  text-align: left;
}
details summary { cursor: pointer; }

/* ============ Button ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 11px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.1s, background 0.15s, opacity 0.15s;
  min-height: 44px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { display: flex; width: 100%; }
.btn-primary {
  /* アクセント変更に追従するグラデ (store.applyThemeColor が
   * --accent-grad-start / --accent-grad-end をセット) */
  background: linear-gradient(180deg, var(--accent-grad-start, #1cd17e) 0%, var(--accent-grad-end, #16a866) 100%);
  color: #001a08;
  border-color: var(--accent-grad-start, rgba(28, 209, 126, 0.55));
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}
.btn-primary:not(:disabled):hover { filter: brightness(1.05); }
.btn-primary:not(:disabled):active {
  background: linear-gradient(180deg, var(--accent-grad-end, #16a866) 0%, var(--accent-dark, #0e8a50) 100%);
  filter: none;
}
.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:active { background: var(--bg-elev2); }
.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(255, 82, 82, 0.3);
  color: var(--danger);
}
.btn-small {
  padding: 7px 12px;
  font-size: 12px;
  min-height: 32px;
  border-radius: var(--r-sm);
}
.btn-large {
  padding: 16px 22px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--r-md);
}
.btn-large.btn-primary {
  background: linear-gradient(180deg, var(--accent-grad-start, #1cd17e) 0%, var(--accent-grad-end, #16a866) 100%);
  color: #001a08;
}
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}
.btn-link:active { opacity: 0.7; }

/* ============ Form ============ */
.field { margin-bottom: var(--space-3); }
.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s;
  min-height: 44px;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { min-height: 80px; resize: vertical; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='rgba(255,255,255,0.5)' d='M6 8L2 4h8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ============ Hero CTA (Today's check) ============ */
.hero-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  padding: 22px 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  cursor: pointer;
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s, border-color 0.15s;
  margin-bottom: var(--space-3);
}
.hero-cta:active { transform: scale(0.99); }
.hero-cta::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top right, rgba(0, 230, 118, 0.08) 0%, transparent 60%);
  pointer-events: none;
}
.hero-success::before { background: radial-gradient(ellipse at top right, rgba(0, 230, 118, 0.15) 0%, transparent 60%); }
.hero-warning::before { background: radial-gradient(ellipse at top right, rgba(255, 167, 38, 0.12) 0%, transparent 60%); }
.hero-danger::before { background: radial-gradient(ellipse at top right, rgba(255, 82, 82, 0.12) 0%, transparent 60%); }
.hero-cta-left { position: relative; z-index: 1; flex: 1; }
.hero-cta-time {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.hero-cta-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 6px;
  color: var(--text-primary);
}
.hero-cta-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.hero-cta-baseline {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  background: rgba(41, 182, 246, 0.22);
  color: #81d4fa;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
}
.baseline-up { background: var(--accent-soft); color: var(--accent); }
.baseline-down { background: rgba(255, 167, 38, 0.14); color: var(--warning); }
.hero-cta-ring { position: relative; z-index: 1; width: 76px; height: 76px; }
.hero-cta-ring svg { width: 100%; height: 100%; color: var(--accent); }
.hero-success .hero-cta-ring svg { color: var(--accent); }
.hero-warning .hero-cta-ring svg { color: var(--warning); }
.hero-danger .hero-cta-ring svg { color: var(--danger); }
.hero-cta-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  font-feature-settings: 'tnum' 1;
  /* % が背景に溶けて見えなくなる問題を解消: 明示的に primary text */
  color: var(--text-primary);
}
.home-complete .hero-cta { animation: pulseGlow 1.6s ease-in-out 2; }
@keyframes pulseGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(0,230,118,0); } 50% { box-shadow: 0 0 0 8px rgba(0,230,118,0.10); } }

/* ============ Inline checks ============ */
.inline-checks {
  margin-bottom: var(--space-3);
}
.inline-checks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
  padding: 0 4px;
}
.inline-checks-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.inline-check {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14.5px;
  margin-bottom: 6px;
  min-height: 52px;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
  cursor: pointer;
}
.inline-check:active { background: var(--bg-elev2); }
.inline-check.checked {
  background: rgba(0, 230, 118, 0.10);
  border-color: rgba(0,230,118,0.45);
}
.inline-check-box {
  width: 24px; height: 24px;
  border: 2px solid rgba(var(--text-base-rgb), 0.45);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  transition: all 0.15s;
  flex-shrink: 0;
  background: rgba(var(--text-base-rgb), 0.02);
}
.inline-check.checked .inline-check-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #001a08;
}
.inline-check-box svg { width: 14px; height: 14px; }
.inline-check-icon { font-size: 16px; flex-shrink: 0; }
.inline-check-label { flex: 1; font-weight: 500; }

/* ============ Routine pills (check view) ============ */
.routine-pill-wrap {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 8px;
}
.check-pill, .number-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.12s, border-color 0.15s;
  min-height: 56px;
}
.check-pill:active { background: var(--bg-elev2); }
.check-pill.checked, .number-pill.checked {
  background: rgba(0, 230, 118, 0.10);
  border-color: rgba(0,230,118,0.45);
}
.check-pill-label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.check-pill-icon { font-size: 20px; flex-shrink: 0; }
.check-indicator {
  width: 24px; height: 24px;
  border: 2px solid rgba(var(--text-base-rgb), 0.45);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  flex-shrink: 0;
  transition: all 0.15s;
  background: rgba(var(--text-base-rgb), 0.02);
}
.check-pill.checked .check-indicator {
  background: var(--accent);
  border-color: var(--accent);
  color: #001a08;
}
.check-indicator svg { width: 14px; height: 14px; }
.weekly-badge {
  padding: 3px 9px;
  background: rgba(var(--text-base-rgb), 0.06);
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  font-feature-settings: 'tnum' 1;
}
.weekly-badge.done {
  background: var(--accent-soft);
  color: var(--accent);
}
.weekly-done { border-color: rgba(0,230,118,0.4); }
.check-time { font-size: 10.5px; color: var(--text-tertiary); font-family: var(--font-mono); margin-right: 8px; }

/* Number pill (daily-min / daily-max) */
.number-pill { padding: 8px 10px 8px 14px; flex-wrap: wrap; }
.min-max-pill { padding: 0; }
.min-max-tap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 12px 14px;
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.number-pill-label-wrap { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.number-pill-label { font-size: 14px; font-weight: 500; }
.number-pill-diff { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.min-max-check-indicator {
  width: 22px; height: 22px;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  flex-shrink: 0;
  margin-right: 8px;
}
.number-pill.checked .min-max-check-indicator {
  background: var(--accent);
  border-color: var(--accent);
  color: #001a08;
}
.min-max-check-indicator svg { width: 14px; height: 14px; }
.number-pill-input {
  width: 64px;
  padding: 7px 10px;
  background: var(--bg-elev2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  font-feature-settings: 'tnum' 1;
  text-align: center;
  -moz-appearance: textfield;
}
.number-pill-input:focus {
  border-color: var(--accent);
  background: var(--bg-elev);
}
.number-pill-input::-webkit-outer-spin-button,
.number-pill-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.number-pill-unit { font-size: 11px; color: var(--text-tertiary); margin-right: 8px; }
.timer-toggle-btn {
  width: 32px; height: 32px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 11px;
  margin-right: 8px;
}
.timer-toggle-btn.running { background: var(--accent); color: #001a08; border-color: var(--accent); }
.timer-display {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  margin-top: 4px;
  background: rgba(0,230,118,0.05);
  border: 1px solid rgba(0,230,118,0.2);
  border-radius: var(--r-sm);
  font-size: 12px;
  flex: 1 1 100%;
}
.timer-time { font-family: var(--font-mono); font-weight: 700; color: var(--accent); }
.timer-state { color: var(--text-tertiary); flex: 1; }

.routine-pill-wrap .violation { border-color: rgba(255, 82, 82, 0.4); }
.routine-pill-wrap .pass { border-color: rgba(0, 230, 118, 0.3); }

.routine-edit-btn {
  width: 40px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: rgba(var(--text-base-rgb), 0.65);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  min-height: 44px;
}
.routine-edit-btn:active { background: var(--bg-elev2); color: var(--text-primary); }

/* ============ Tab nav (bottom) ============ */
.tab-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--tabnav-bg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 40;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0;
  background: none;
  border: none;
  color: rgba(var(--text-base-rgb), 0.55);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}
.tab-item:active { transform: scale(0.95); }
.tab-item.active {
  color: #1cd17e;
  font-weight: 700;
}
.tab-item.active::before {
  /* active タブを視覚的に明確に: 上端に細い緑バー */
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 2.5px;
  background: #1cd17e;
  border-radius: 0 0 3px 3px;
}
.tab-item-icon {
  font-size: 22px;
  line-height: 1;
  filter: saturate(1.1);
}

/* ============ FAB ============ */
/* デスクトップ表示 (viewport > 480): FAB を 480 中央コンテナの外側 (右側) に逃がして
 * コンテンツとの重なりを解消。モバイルでは従来通りコンテナ内右下に固定。 */
.fab {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  right: max(18px, calc((100vw - 480px) / 2 - 76px));
  width: 52px; height: 52px;
  background: var(--accent);
  border: 2px solid rgba(255,255,255,0.92);
  border-radius: 50%;
  color: #001a08;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 230, 118, 0.35);
  z-index: 30;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.fab:hover { opacity: 0.92; }
.fab:active { transform: scale(0.94); }
.fab-icon { font-size: 20px; font-weight: 800; line-height: 1; }
.fab-label { font-size: 9px; font-weight: 700; margin-top: 1px; opacity: 0.75; }

/* ============ Balance strip (always-visible) ============ */
.balance-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: var(--space-3);
}
.balance-strip-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  text-align: center;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s;
}
.balance-strip-cell:active { transform: scale(0.97); }
.balance-strip-cell.balance-streak { cursor: default; }
.balance-strip-cell.balance-reward .balance-strip-amount { color: var(--accent); }
.balance-strip-cell.balance-fine .balance-strip-amount { color: var(--danger); }
.balance-strip-icon { font-size: 18px; line-height: 1; margin-bottom: 3px; }
.balance-strip-amount {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  color: var(--text-primary);
}
.balance-strip-cell.balance-reward { background: rgba(0, 230, 118, 0.06); border-color: rgba(0, 230, 118, 0.25); }
.balance-strip-cell.balance-fine { background: rgba(255, 82, 82, 0.06); border-color: rgba(255, 82, 82, 0.25); }
.balance-strip-cell.balance-streak { background: rgba(255, 167, 38, 0.05); border-color: rgba(255, 167, 38, 0.18); }
.balance-strip-cell.balance-streak .balance-strip-amount { color: #ffb74d; }
.balance-strip-label { font-size: 10.5px; color: rgba(var(--text-base-rgb), 0.75); font-weight: 600; }

/* ============ Balance (detail) ============ */
.balance-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.balance-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.balance-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.balance-side { flex: 1; text-align: center; }
.balance-amount { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; font-family: var(--font-mono); }
.balance-side-label { font-size: 10px; color: var(--text-tertiary); margin-top: 2px; }
.balance-divider { color: var(--text-tertiary); font-size: 14px; font-weight: 700; }

/* ============ Metrics ============ */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: var(--space-3);
}
.metric {
  padding: 10px 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-align: center;
}
.metric-icon { font-size: 14px; line-height: 1; }
.metric-value { font-size: 16px; font-weight: 800; font-family: var(--font-mono); margin-top: 2px; }
.metric-label { font-size: 9.5px; color: var(--text-tertiary); margin-top: 2px; }
.metric-danger { cursor: pointer; }
.metric-danger .metric-value { color: var(--danger); }
.metric-success { cursor: pointer; }
.metric-success .metric-value { color: var(--accent); }

/* ============ Date nav ============ */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: var(--space-3);
}
.date-nav-btn {
  width: 40px; height: 40px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.date-nav-btn:active { background: var(--bg-elev2); }
.date-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.date-nav-input {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  text-align: center;
}
.editing-past-banner {
  background: rgba(255, 167, 38, 0.08);
  border: 1px solid rgba(255, 167, 38, 0.22);
  color: var(--warning);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 12px;
  margin: 0 16px 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.editing-past-banner strong { color: var(--warning); font-weight: 700; }

/* ============ Sick button ============ */
.sick-button {
  width: 100%;
  padding: 13px 18px;
  background: rgba(186, 104, 200, 0.14);
  border: 1px solid rgba(186, 104, 200, 0.45);
  border-radius: var(--r-md);
  color: #e1bee7;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}
.sick-button:active { background: rgba(186, 104, 200, 0.20); }

/* ============ Mood strip ============ */
.mood-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--space-3);
}
.mood-strip-label { font-size: 11px; color: var(--text-tertiary); margin-right: 4px; }
.mood-emoji {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
}
.mood-emoji:active { transform: scale(0.92); }
.mood-emoji.active { opacity: 1; background: rgba(var(--text-base-rgb), 0.06); }

/* ============ Details toggle ============ */
.details-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: var(--space-2);
}
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: var(--space-2);
  text-align: left;
}

/* ============ Phase banner / Countdown chips ============ */
.phase-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: var(--space-3);
}
.countdown-chip {
  padding: 3px 9px;
  background: rgba(var(--text-base-rgb), 0.05);
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 600;
}
.countdown-chip.urgent { background: rgba(255, 82, 82, 0.15); color: var(--danger); }

/* ============ List item ============ */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
}

/* ============ Empty state ============ */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}
.empty-icon { font-size: 36px; opacity: 0.5; margin-bottom: 12px; }

/* ============ Modal ============ */
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: backdropFade 0.2s ease;
}
@keyframes backdropFade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  background: var(--bg-elev);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--space-3) var(--space-4) calc(env(safe-area-inset-bottom, 0px) + var(--space-5));
  overflow-y: auto;
  position: relative;
  animation: modalSlideUp 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modalSlideUp { from { transform: translateY(20px); } to { transform: translateY(0); } }
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 0 auto var(--space-3);
  cursor: grab;
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  background: var(--bg-elev2);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ============ Onboarding ============ */
.onboarding-logo {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.onboarding-headline {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 16px;
}
.onboarding-sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ============ Onboard hero (empty state) ============ */
.onboard-hero {
  margin: 0 0 var(--space-3);
  padding: 26px 22px;
  border-radius: var(--r-xl);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.onboard-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, var(--accent-soft) 0%, transparent 65%);
  pointer-events: none;
  opacity: 0.6;
}
.onboard-hero > * { position: relative; z-index: 1; }
.onboard-hero-eyebrow {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.onboard-hero-title {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}
.onboard-hero-sub { font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 18px; }
.onboard-hero-cta {
  display: block;
  width: 100%;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 700;
}
.onboard-hero-options { margin-top: 14px; font-size: 12px; }

/* ============ Settings ============ */
/* v78: #113 設定タブの視認性強化 — sticky + 大きめ pill + active 強調 */
.settings-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-3);
  padding: 4px 0 8px;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
  padding: 10px 16px;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
}
.settings-tab:active { transform: scale(0.96); }
.settings-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.settings-tab.active { background: var(--accent-soft); border-color: rgba(0,230,118,0.3); color: var(--accent); }
.settings-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
/* v78: 危険ゾーン警告色 */
.settings-card.danger-zone,
.danger-zone {
  background: rgba(255, 91, 91, 0.04);
  border: 1.5px solid rgba(255, 91, 91, 0.30);
  border-radius: var(--r-lg);
  padding: var(--space-3);
}
.danger-zone-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: #ff8a80;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
  text-align: left;
}
.danger-zone-toggle:hover { color: #ff5b5b; }
.danger-zone-body { padding-top: 10px; }
.settings-card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: var(--space-2);
  letter-spacing: -0.01em;
}
.settings-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0;
  text-align: left;
}
.settings-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  margin-bottom: 6px;
  min-height: 44px;
}
.quick-settings {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.quick-setting {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.quick-setting-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-top: 2px; }

/* ============ Premium page ============ */
.premium-hero {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 28px 22px;
  text-align: center;
  margin-top: var(--space-2);
  position: relative;
  overflow: hidden;
}
.premium-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, var(--pro-soft) 0%, transparent 65%);
  pointer-events: none;
}
.premium-hero > * { position: relative; z-index: 1; }
.premium-hero-paid::before { background: radial-gradient(circle at top, rgba(255, 213, 79, 0.13) 0%, transparent 65%); }
.premium-hero-trial::before { background: radial-gradient(circle at top, var(--accent-soft) 0%, transparent 65%); }
.premium-hero-icon { font-size: 38px; line-height: 1; margin-bottom: 8px; }
.premium-hero-title { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 6px; }
.premium-hero-sub { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.premium-feature-row { display: flex; gap: 12px; align-items: flex-start; }
.premium-feature-icon { font-size: 20px; line-height: 1.1; flex-shrink: 0; }
.premium-feature-label { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.premium-feature-desc { font-size: 11.5px; color: var(--text-tertiary); line-height: 1.5; }

.billing-tabs { display: flex; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px; gap: 4px; }
.billing-tab { flex: 1; padding: 10px 6px; background: transparent; border: none; color: var(--text-tertiary); font-size: 12.5px; font-weight: 700; border-radius: var(--r-sm); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: background 0.15s, color 0.15s; }
.billing-tab.active { background: var(--pro-soft); color: var(--pro); }
.billing-tab-badge { background: #ec407a; color: var(--text-primary); font-size: 9px; font-weight: 800; padding: 2px 5px; border-radius: var(--r-sm); line-height: 1; }

.price-card { background: var(--bg-elev); border: 1px solid rgba(186, 104, 200, 0.3); border-radius: var(--r-lg); padding: 22px 20px; text-align: center; }
.price-card-eyebrow { font-size: 11px; font-weight: 700; color: var(--pro); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 10px; }
.price-card-price { font-size: 36px; font-weight: 800; letter-spacing: -0.025em; line-height: 1; margin: 0; font-feature-settings: 'tnum' 1; }
.price-card-currency { font-size: 0.55em; vertical-align: 0.45em; font-weight: 700; opacity: 0.7; margin-right: 2px; }
.price-card-period { font-size: 0.4em; vertical-align: 0.45em; opacity: 0.55; font-weight: 600; margin-left: 6px; }
.price-card-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; }

.comparison-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr; padding: 12px 16px; align-items: center; font-size: 12.5px; color: var(--text-secondary); border-bottom: 1px solid var(--border-subtle); }
.comparison-row:last-child { border-bottom: none; }
.comparison-row.comparison-header { background: var(--bg-elev2); font-size: 10.5px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 16px; }
.comparison-row.comparison-row-alt { background: rgba(var(--text-base-rgb), 0.015); }
.cmp-check { display: inline-block; width: 18px; height: 18px; text-align: center; line-height: 18px; border-radius: 50%; background: rgba(var(--text-base-rgb), 0.08); color: rgba(var(--text-base-rgb), 0.5); font-weight: 800; font-size: 11px; }
.cmp-check.cmp-check-pro { background: var(--pro-soft); color: var(--pro); }
.cmp-cross { display: inline-block; width: 18px; height: 18px; text-align: center; line-height: 18px; color: rgba(var(--text-base-rgb), 0.2); font-weight: 700; font-size: 13px; }

.checkout-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 200; }
.checkout-overlay-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px; text-align: center; max-width: 320px; }

.trial-banner { padding: 9px 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); font-size: 12px; color: var(--text-secondary); margin-bottom: var(--space-2); }
.trial-banner-urgent { background: rgba(255, 87, 34, 0.08); border-color: rgba(255, 87, 34, 0.25); color: #ff7043; }

/* ============ Plan grid (legacy) ============ */
.plan-grid { display: grid; gap: 10px; margin-bottom: var(--space-3); }
.plan-card { padding: 18px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); text-align: center; }
.plan-recommended { border-color: rgba(186,104,200,0.45); }
.plan-tier { font-size: 11px; color: var(--text-tertiary); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.plan-price { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.plan-currency { font-size: 0.6em; vertical-align: 0.3em; }
.plan-period { font-size: 0.5em; opacity: 0.6; margin-left: 4px; }
.plan-sub { font-size: 11px; color: var(--text-tertiary); margin: 6px 0 10px; }
.plan-badge { font-size: 9px; background: var(--pro); color: var(--text-primary); padding: 2px 6px; border-radius: var(--r-sm); margin-left: 6px; vertical-align: 1px; }

/* ============ Workout ============ */
.workout-steps { display: flex; align-items: center; gap: 6px; margin-bottom: var(--space-3); padding: 0 4px; }
.workout-step { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.workout-step-num { width: 26px; height: 26px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--text-tertiary); }
.workout-step.is-active .workout-step-num { background: var(--accent); color: #001a08; border-color: var(--accent); }
.workout-step.is-done .workout-step-num { background: var(--accent-soft); color: var(--accent); border-color: rgba(0,230,118,0.3); }
.workout-step-label { font-size: 10px; color: var(--text-tertiary); }
.workout-step.is-active .workout-step-label { color: var(--accent); font-weight: 700; }
.workout-step-bar { flex: 1; height: 2px; background: var(--border); margin-top: -14px; }
.workout-step-bar.is-done { background: var(--accent); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat-card { padding: 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); }
.bp-card { cursor: pointer; transition: background 0.15s; }
.bp-card:active { background: var(--bg-elev2); }
.bp-meta { display: flex; gap: 8px; font-size: 11px; color: var(--text-tertiary); margin-top: 4px; flex-wrap: wrap; }
.bp-stale { color: var(--warning); }

.today-volume-card { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: var(--space-3); }
.today-volume-icon { font-size: 26px; }
.today-volume-label { font-size: 11px; color: var(--text-tertiary); }
.today-volume-value { font-size: 20px; font-weight: 800; font-family: var(--font-mono); letter-spacing: -0.02em; }
.today-volume-unit { font-size: 13px; opacity: 0.7; margin-left: 2px; }
.today-volume-meta { font-size: 11px; color: var(--text-tertiary); font-weight: 500; }

.recent-exercise { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 6px; cursor: pointer; }
.recent-exercise-name { flex: 1; font-size: 13px; font-weight: 500; }
.recent-exercise-meta { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); }

.pb-section { margin: var(--space-4) 0; }
.pb-grid { display: flex; flex-direction: column; gap: 6px; }
.pb-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); }
.pb-rank { font-size: 11px; color: var(--text-tertiary); font-weight: 800; font-family: var(--font-mono); width: 24px; }
.pb-info { flex: 1; min-width: 0; }
.pb-name { font-size: 13px; font-weight: 600; }
.pb-meta { font-size: 10.5px; color: var(--text-tertiary); font-family: var(--font-mono); }
.pb-oneRM { font-size: 14px; font-weight: 800; color: var(--accent); font-family: var(--font-mono); }
.pr-badge { font-size: 9px; background: var(--accent); color: #001a08; padding: 2px 5px; border-radius: var(--r-sm); margin-left: 4px; font-weight: 800; }

/* ============ Yearly reading chart ============ */
.yearly-chart { padding: 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: var(--space-3); }
.yearly-chart-header { margin-bottom: 12px; }
.yearly-chart-title { font-size: 12px; font-weight: 700; }
.yearly-chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 80px; }
.yearly-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.yearly-bar { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; transition: opacity 0.15s; }
.yearly-bar-label { font-size: 9px; color: var(--text-tertiary); }
.yearly-bar-count { font-size: 9px; color: var(--text-secondary); font-family: var(--font-mono); }

/* ============ Sort bar ============ */
.sort-bar { display: flex; align-items: center; gap: 8px; margin-bottom: var(--space-3); }
.sort-label { font-size: 11px; color: var(--text-tertiary); }

/* ============ Rank row (fines reason ranking) ============ */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 6px; font-size: 12.5px; }
.rank-pos { color: var(--text-tertiary); font-weight: 800; font-family: var(--font-mono); width: 22px; }
.rank-name { flex: 1; }
.rank-count { font-size: 11px; color: var(--text-tertiary); }
.rank-amount { color: var(--danger); font-family: var(--font-mono); font-weight: 700; }

/* ============ Suggestion / Smart card ============ */
.suggestion-dismiss { position: absolute; top: 10px; right: 12px; background: none; border: none; color: var(--text-tertiary); font-size: 18px; cursor: pointer; padding: 4px; }

/* ============ Progress bar ============ */
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); transition: width 0.4s; }

/* ============ Goal categories ============ */
.goal-category-label { font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }

/* ============ Birthday / Reel / Memo rows ============ */
.birthday-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 6px; font-size: 12.5px; }

/* Reel: ホーム下部の「直近7日」スクロールカード */
.reel-wrap { margin-bottom: var(--space-3); }
.reel-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 4px 6px;
}
.reel-title {
  font-size: 13px; font-weight: 700;
  color: var(--text-primary);
}
.reel-hint {
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  opacity: 0.85;
}
.reel-scroll {
  display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 0 4px;
}
.reel-card {
  width: 80px; min-height: 100px; padding: 10px 6px;
  background: var(--bg-elev); border: 1.5px solid var(--border);
  border-radius: var(--r-md); text-align: center; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.reel-card:hover { border-color: var(--border-strong); }
.reel-card:active { transform: scale(0.96); }
.reel-card.reel-empty { opacity: 0.45; }
.reel-day {
  font-size: 11px; font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}
.reel-date {
  font-size: 18px; font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  font-feature-settings: 'tnum' 1;
}
.reel-pct {
  font-size: 11px; font-weight: 700;
  color: var(--accent);
  font-feature-settings: 'tnum' 1;
}
.reel-mood { font-size: 16px; line-height: 1; }
.reel-empty-mark { font-size: 24px; color: var(--text-tertiary); line-height: 1; }

.memo-inline-input { width: 100%; padding: 10px 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); font-size: 14px; min-height: 60px; }

/* ============ Hibernation ============ */
.hibernation-sub { font-size: 11px; color: var(--text-tertiary); }

/* ============ Trend rows ============ */
.trend-row { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; }
.trend-label { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; width: 80px; }
.trend-canvas-wrap { flex: 1; height: 40px; }

/* ============ Celebration overlay ============ */
.celeb-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  animation: celebFadeIn 0.4s ease, celebFadeOut 0.6s ease 2s forwards;
  pointer-events: none;
}
@keyframes celebFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes celebFadeOut { to { opacity: 0; visibility: hidden; } }
.celeb-overlay-inner { text-align: center; animation: celebPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes celebPop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.celeb-overlay-emoji { font-size: 80px; line-height: 1; margin-bottom: 16px; }
.celeb-overlay-title { font-size: 28px; font-weight: 800; margin-bottom: 8px; color: var(--accent); }
.celeb-overlay-sub { font-size: 14px; color: var(--text-secondary); }

/* ============ Bonus row (設定 - ボーナス・罰金) ============ */
.bonus-row-wrap { margin-bottom: 10px; }
.bonus-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
}
.bonus-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.bonus-unit { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.bonus-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin-top: 2px;
  padding-left: 2px;
}

/* ============ 罰金/ご褒美 強度プリセット (初回セットアップ) ============ */
.bonus-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bonus-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.bonus-preset-btn:hover { border-color: var(--border-strong); }
.bonus-preset-btn.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-primary);
}
.bonus-preset-icon { font-size: 22px; line-height: 1; }
.bonus-preset-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 2px;
}
.bonus-preset-btn.selected .bonus-preset-title { color: var(--accent); }
.bonus-preset-fine,
.bonus-preset-reward {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  font-feature-settings: 'tnum' 1;
}
.bonus-preset-fine strong { color: var(--danger); font-weight: 800; }
.bonus-preset-reward strong { color: var(--accent); font-weight: 800; }

/* ============ 興味選択グリッド (初回セットアップ) ============ */
.interest-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.interest-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.interest-btn:hover { border-color: var(--border-strong); }
.interest-btn.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-primary);
  font-weight: 700;
}
.interest-icon { font-size: 22px; line-height: 1; }
.interest-label { flex: 1; }
.interest-btn.selected::after {
  content: '✓';
  color: var(--accent);
  font-weight: 800;
}

/* ============ Weekly activity (今週のアクティビティ) ============ */
.weekly-activity {
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.weekly-activity-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.weekly-activity-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.weekly-activity-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.weekly-activity-grid::-webkit-scrollbar { display: none; }
.weekly-activity-cell {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  min-width: 80px;
  transition: all 0.15s;
}
.weekly-activity-cell:hover { border-color: var(--accent); }
.weekly-activity-cell:active { transform: scale(0.95); }
.weekly-activity-icon { font-size: 18px; line-height: 1; }
.weekly-activity-value {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  color: var(--text-primary);
  line-height: 1;
}
.weekly-activity-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ============ Quick add grid (FAB 長押し) ============ */
.quick-add-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.quick-add-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 4px;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 76px;
}
.quick-add-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.quick-add-btn:active { transform: scale(0.95); background: var(--accent-soft); }
.quick-add-icon { font-size: 26px; line-height: 1; }

/* ============ Media status segment + filter row ============ */
/* v87: 色味と枠を最小限にした segment / filter-chip 統一デザイン */
.status-segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  background: rgba(var(--text-base-rgb), 0.04);
  border-radius: 10px;
}
.status-segment-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.status-segment-btn:hover { color: var(--text-secondary); }
.status-segment-btn.active {
  background: var(--bg);
  color: var(--text-primary);
  font-weight: 700;
}
.status-segment-label { font-size: 12px; line-height: 1.2; }
.status-segment-count {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
}
.status-segment-btn.active .status-segment-count { color: var(--accent); font-weight: 700; }

/* ============ Book row (本一覧) ============ */
/* v89: 以前は CSS 未定義で区切りも余白も無かった */
.book-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.12s;
}
.book-row:hover { background: rgba(var(--text-base-rgb), 0.03); }
.book-row:active { background: rgba(var(--text-base-rgb), 0.05); }
.book-row:last-child { border-bottom: none; }
.book-row-cover {
  flex: 0 0 48px;
  width: 48px;
  height: 66px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-elev2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.book-row-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-row-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--accent);
  color: #001a08;
  font-size: 10px;
  padding: 0 5px;
  border-radius: 8px;
  font-weight: 800;
  line-height: 1.4;
}
.book-row-info { flex: 1; min-width: 0; }
.book-row-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text-primary);
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
}
.book-row-author {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.book-row-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}
.want-to-own-mini { font-size: 12px; }
.quote-badge {
  flex: 0 0 auto;
  background: rgba(var(--text-base-rgb), 0.06);
  border: 1px solid rgba(var(--text-base-rgb), 0.12);
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  align-self: center;
}
.quote-badge:hover { color: var(--text-primary); border-color: rgba(var(--text-base-rgb), 0.22); }

/* ============ Filter bar (chips for 読書/視聴/ライフ) ============ */
/* v87: 以前は CSS 未定義で素の <button> が出ていたため色味と枠の見た目が悪かった */
.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 0;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid rgba(var(--text-base-rgb), 0.12);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  min-height: 30px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  white-space: nowrap;
}
.filter-chip:hover {
  color: var(--text-primary);
  border-color: rgba(var(--text-base-rgb), 0.22);
}
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #001a08;
  font-weight: 700;
}
.filter-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.media-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.media-type-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  scrollbar-width: none;
}
.media-type-scroll::-webkit-scrollbar { display: none; }
.media-type-scroll .filter-chip { flex: 0 0 auto; white-space: nowrap; }
.media-filter-row .sort-select {
  flex: 0 0 auto;
  width: auto;
  padding: 6px 28px 6px 10px;
  font-size: 11px;
  min-height: 34px;
}

/* ============ Welcome ツアー ============ */
.welcome-progress { display: flex; gap: 6px; justify-content: center; padding: 12px 0 4px; }
.welcome-progress-dot {
  width: 28px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.2s;
}
.welcome-progress-dot.active { background: var(--accent); }

.welcome-page {
  text-align: center;
  padding: 8px 4px 4px;
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.welcome-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 16px;
}
.welcome-page h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.welcome-lead {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 14px;
  max-width: 340px;
}
.welcome-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
  line-height: 1.6;
}

.welcome-domain-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
  width: 100%;
  max-width: 340px;
}
.welcome-domain {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.welcome-domain span { font-size: 24px; }

.welcome-engine-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
  width: 100%;
  max-width: 340px;
}
.welcome-engine-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
}

.welcome-flow {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  width: 100%;
  max-width: 320px;
}
.welcome-flow-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.welcome-flow-step span {
  width: 26px; height: 26px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.welcome-tip {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  max-width: 340px;
  text-align: left;
}

.welcome-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.welcome-nav .btn-primary { flex: 1; }

/* ============ Workout stepper (重量/回数/セット) ============ */
/* タップで増減できる stepper。スマホでキーボード出さなくても値変更できる */
.stepper-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  min-height: 60px;
}
.stepper-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stepper-prev {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}
.stepper-btn {
  width: 44px;
  height: 44px;
  background: var(--bg-elev2);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s, background 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.stepper-btn:hover { background: rgba(var(--text-base-rgb), 0.12); }
.stepper-btn:active { transform: scale(0.92); background: var(--accent-soft); }
.stepper-input {
  width: 70px;
  height: 44px;
  text-align: center;
  background: var(--bg);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  outline: none;
  /* スマホで数字キーボードを出す */
  -moz-appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stepper-input:focus { border-color: var(--accent); }
.stepper-unit {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 22px;
  text-align: left;
}

/* 前回比 diff バッジ */
.diff-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font-mono);
  margin-bottom: 10px;
  margin-left: 4px;
}
.diff-badge.diff-up { background: var(--accent-soft); color: var(--accent); }
.diff-badge.diff-down { background: rgba(255, 167, 38, 0.18); color: var(--warning); }

/* セット数は pill ボタンも追加 */
.stepper-set-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 12px;
}
.stepper-set-pill {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper-set-pill.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 800;
}
.stepper-set-pill:active { transform: scale(0.9); }

/* ============ Color mode picker ============ */
.color-mode-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.color-mode-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px;
  background: var(--bg-elev2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.color-mode-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.color-mode-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
}
.color-mode-swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
}
.color-mode-swatch.dark { background: #0d0d12; }
.color-mode-swatch.light { background: #f7f7fa; }
.color-mode-swatch.auto { background: linear-gradient(135deg, #0d0d12 50%, #f7f7fa 50%); }

/* ============ PTR indicator ============ */
.ptr-indicator {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  gap: 6px;
  height: 70px;
  pointer-events: none;
  z-index: 9998;
  transform: translateY(-100%);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s;
  opacity: 0;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}
.ptr-indicator.is-pulling,
.ptr-indicator.is-ready,
.ptr-indicator.is-refreshing { opacity: 1; }
.ptr-spinner {
  width: 22px; height: 22px;
  border: 2px solid rgba(var(--text-base-rgb), 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
}
.ptr-indicator.is-refreshing .ptr-spinner { animation: ptrSpin 0.7s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }
.ptr-label { font-size: 10px; }

/* ============ Toast ============ */
.toast-container {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: 92%;
  max-width: 420px;
}
.toast {
  padding: 12px 16px;
  background: var(--bg-elev2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.toast.success { border-color: rgba(0,230,118,0.4); color: var(--accent); }
.toast.danger { border-color: rgba(255,82,82,0.4); color: var(--danger); }
.toast.undo {
  border-color: var(--border-strong);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px;
  justify-content: space-between;
}
.toast-undo-btn {
  flex: 0 0 auto;
  padding: 6px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.toast-undo-btn:active { transform: scale(0.95); }

/* ============ Comparison row alternating (already defined above) ============ */

/* ============ Long press / pressed state ============ */
.pressed { opacity: 0.7; }

/* ============ Wide screen tweaks ============ */
@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .quick-settings { grid-template-columns: repeat(3, 1fr); }
}

/* ============ Add-modal common (v76: 追加 UI 改善) ============ */
/* 必須マーク */
.required-mark { color: #ff5b5b; font-weight: 700; margin-left: 2px; }

/* 絵文字ピッカー (これまで CSS 未定義だった) */
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
@media (min-width: 380px) {
  .emoji-picker { grid-template-columns: repeat(8, 1fr); }
}
.emoji-pick {
  aspect-ratio: 1;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
  padding: 0;
  line-height: 1;
}
.emoji-pick:hover { background: rgba(255,255,255,0.08); }
.emoji-pick:active { transform: scale(0.92); }
.emoji-pick.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* tier-tile: 分類を 4 つのカードで選ばせる */
.tier-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.tier-tile {
  text-align: left;
  padding: 12px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 76px;
}
.tier-tile:active { transform: scale(0.98); }
.tier-tile:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.18); }
.tier-tile.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.tier-tile-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tier-tile-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  line-height: 1.4;
}
.tier-tile.selected .tier-tile-desc { color: rgba(255,255,255,0.85); }

/* ml-tile (最低ライン種別もタイル化) */
.ml-tiles {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ml-tile {
  text-align: left;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  font-size: 13px;
  transition: all 0.15s;
}
.ml-tile:active { transform: scale(0.99); }
.ml-tile.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.ml-tile-title { font-weight: 700; margin-bottom: 2px; }
.ml-tile-desc { font-size: 11px; color: rgba(255,255,255,0.6); }
.ml-tile.selected .ml-tile-desc { color: rgba(255,255,255,0.85); }

/* 星評価ボタン (44x44 確保) */
.btn-rating {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.4);
  padding: 0;
  line-height: 1;
  transition: transform 0.08s, color 0.15s;
}
.btn-rating:active { transform: scale(0.85); }
.btn-rating:hover { color: rgba(255,193,7,0.7); }
.btn-rating[style*="fill"], button.btn-rating:has(:contains("★")) { color: #ffc107; }
/* fallback: 親要素から判定はできないので Alpine class でカバー */
.btn-rating.is-on { color: #ffc107; }

/* bulk-import ステップインジケータ */
.bulk-steps {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.bulk-step {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.10);
  border-radius: 2px;
  transition: background 0.2s;
}
.bulk-step.active { background: var(--accent); }
.bulk-step.done { background: var(--accent); opacity: 0.5; }

.bulk-step-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.95);
}
.bulk-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* 連絡先フィールド groupwrap (add-person) */
.contact-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.contact-row .contact-icon {
  width: 32px;
  text-align: center;
  font-size: 18px;
  flex-shrink: 0;
}
.contact-row .input { flex: 1; }

/* search-book result card (add-book) */
.book-search-result {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all 0.15s;
}
.book-search-result:hover { background: rgba(255,255,255,0.08); border-color: var(--accent); }
.book-search-result:active { transform: scale(0.99); }
.book-search-result img { width: 44px; height: 60px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.book-search-result-info { flex: 1; min-width: 0; }
.book-search-result-cta {
  align-self: center;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}

/* 折り畳みセクション (add-bucket / 他で再利用) */
.detail-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.detail-toggle:hover { color: var(--accent); }

/* ============ v112: 罰金プレビュー (Stake らしさ) ============ */
.fine-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(244, 67, 54, 0.12);
  color: #ef5350;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 8px;
  letter-spacing: 0.2px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.check-pill.checked .fine-badge,
.number-pill.checked .fine-badge,
.number-pill.pass .fine-badge { display: none; }

/* ホーム: 今夜のままだと罰金 ¥X 確定 (1 行アラート) */
.fine-preview-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-top: 10px;
  background: linear-gradient(135deg, rgba(244,67,54,0.10) 0%, rgba(244,67,54,0.04) 100%);
  border: 1px solid rgba(244,67,54,0.3);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.15s, border-color 0.15s;
}
.fine-preview-bar:hover { border-color: rgba(244,67,54,0.55); transform: translateY(-1px); }
.fine-preview-bar:active { transform: scale(0.99); }
.fine-preview-icon { font-size: 20px; flex-shrink: 0; }
.fine-preview-text { flex: 1; font-size: 13px; line-height: 1.4; }
.fine-preview-text strong {
  color: #ef5350;
  font-size: 15px;
  font-weight: 800;
  margin: 0 2px;
  font-variant-numeric: tabular-nums;
}
.fine-preview-arrow {
  font-size: 20px;
  color: rgba(244,67,54,0.6);
  flex-shrink: 0;
}

/* ============ Trial Hero (Premium page top) ============ */
.trial-hero {
  background: linear-gradient(135deg, rgba(0,230,118,0.18) 0%, rgba(0,200,100,0.10) 100%);
  border: 2px solid rgba(0,230,118,0.45);
  border-radius: 16px;
  padding: 22px 20px 18px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.trial-hero::after {
  content: '';
  position: absolute; top: 0; right: 0; width: 50%; height: 100%;
  background: radial-gradient(ellipse at top right, rgba(0,230,118,0.22) 0%, transparent 70%);
  pointer-events: none;
}
.trial-hero-badge {
  display: inline-block;
  background: var(--accent);
  color: #001a08;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 10px;
  position: relative; z-index: 1;
}
.trial-hero-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
  line-height: 1.35;
  position: relative; z-index: 1;
}
.trial-hero-desc {
  font-size: 12.5px;
  color: rgba(var(--text-base-rgb), 0.75);
  line-height: 1.5;
  margin-bottom: 16px;
  position: relative; z-index: 1;
}
.trial-hero-btn {
  background: var(--accent);
  color: #001a08;
  font-weight: 800;
  font-size: 15px;
  position: relative; z-index: 1;
  box-shadow: 0 4px 12px rgba(0,230,118,0.3);
}
.trial-hero-btn:not(:disabled):active { transform: scale(0.98); }
.trial-hero-foot {
  font-size: 11px;
  color: rgba(var(--text-base-rgb), 0.55);
  margin-top: 10px;
  position: relative; z-index: 1;
}

/* ============ Trial CTA (home) ============ */
.trial-cta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(0,230,118,0.14) 0%, rgba(0,200,100,0.06) 100%);
  border: 1.5px solid rgba(0,230,118,0.4);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s, border-color 0.15s;
}
.trial-cta:hover { border-color: rgba(0,230,118,0.7); transform: translateY(-1px); }
.trial-cta:active { transform: scale(0.99); }
.trial-cta-badge {
  background: var(--accent);
  color: #001a08;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 10px;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}
.trial-cta-text { flex: 1; min-width: 0; }
.trial-cta-title { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.trial-cta-desc { font-size: 12px; color: rgba(var(--text-base-rgb), 0.65); line-height: 1.4; }
.trial-cta-arrow { font-size: 22px; color: rgba(var(--text-base-rgb), 0.35); flex-shrink: 0; }

/* ============ AI Coach CTA (home) ============ */
.coach-cta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(186,104,200,0.14) 0%, rgba(0,230,118,0.08) 100%);
  border: 1px solid rgba(186,104,200,0.35);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  position: relative;
  overflow: hidden;
}
.coach-cta:hover { border-color: rgba(186,104,200,0.6); transform: translateY(-1px); }
.coach-cta:active { transform: scale(0.99); }
.coach-cta::after {
  content: '';
  position: absolute; top: 0; right: -40px; width: 120px; height: 100%;
  background: radial-gradient(ellipse at right, rgba(186,104,200,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.coach-cta-icon { font-size: 28px; flex-shrink: 0; }
.coach-cta-text { flex: 1; min-width: 0; position: relative; z-index: 1; }
.coach-cta-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.coach-cta-badge {
  background: #ce93d8;
  color: #1a1a1a;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.5px;
}
.coach-cta-desc {
  font-size: 12.5px;
  color: rgba(255,255,255,0.65);
  line-height: 1.4;
}
.coach-cta-arrow {
  font-size: 22px;
  color: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

/* ============ AI Chat Coach UI ============ */
/* チャットページ全体を fixed にする
 * チャット表示中は tab nav・FAB 非表示なので画面全体を使う
 * bottom: 0 + safe-area で iOS のホームインジケーター回避 */
.chat-page {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  z-index: 50;
  padding: 14px 16px env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
  /* chat-page 自身はスクロールせず、内部の chat-log だけが scroll する */
  overflow: hidden;
  /* iOS の visual viewport が縮んだ時も自然追従する */
  height: 100dvh;
  max-height: 100dvh;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.chat-header h1 { margin: 0; font-size: 18px; flex: 1; }
.chat-back-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 10px);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}
.chat-back-btn:active { transform: scale(0.94); }
.chat-log {
  flex: 1 1 0;
  min-height: 0;        /* flex child の overflow を有効化 (これがないとスクロールしない) */
  overflow-y: scroll;   /* auto より scroll の方が iOS で安定 (常に scroller を確保) */
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;  /* 縦スクロールを明示的に許可 (他の touch handler の干渉防止) */
}
.chat-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: chatMsgIn 0.25s ease-out;
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 500;
  border-bottom-right-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,230,118,0.18);
}
.chat-msg.ai {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.06);
  border-bottom-left-radius: 6px;
}
.chat-msg-meta {
  font-size: 10.5px;
  color: rgba(255,255,255,0.4);
  margin: 2px 8px 0;
  align-self: flex-start;
}
.chat-msg.user + .chat-msg-meta { align-self: flex-end; }
.chat-typing {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  display: inline-flex;
  gap: 4px;
}
.chat-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  animation: chatTyping 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
  color: rgba(255,255,255,0.55);
}
.chat-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.7; }
.chat-empty-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.chat-empty-desc { font-size: 13px; line-height: 1.55; margin-bottom: 16px; max-width: 320px; }
.chat-suggestions {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  max-width: 380px;
}
.chat-suggestion {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}
.chat-suggestion:hover {
  border-color: var(--accent);
  background: rgba(0,230,118,0.06);
}
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 4px 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-footer-note {
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
  color: rgba(var(--text-base-rgb), 0.45);
  padding: 4px 0 8px;
}
.chat-input-bar .input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 22px;
  font-size: 14.5px;
}
.chat-send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  flex-shrink: 0;
}
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-send-btn:not(:disabled):active { transform: scale(0.93); }
.chat-context-pill {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 8px;
  display: inline-block;
}
