/* =====================================================
 * KINETIC LAB-Link — Light Theme (Sporty Precision)
 * ===================================================== */

:root {
  --brand: #0EA5E9;
  --brand-dark: #0284C7;
  --teal: #14B8A6;
  --accent: #6366F1;
  --ink: #0F172A;
  --ink-2: #1E293B;
  --text: #334155;
  --text-2: #475569;
  --muted: #64748B;
  --line: #E2E8F0;
  --line-2: #F1F5F9;
  --bg: #F8FAFC;
  --bg-soft: #F0F9FF;
  --danger: #EF4444;
  --success: #10B981;
  --warn: #F59E0B;
  --header-h: 56px;
  --nav-h: 84px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: linear-gradient(180deg, #F0F9FF 0%, #FFFFFF 30%, #F8FAFC 100%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, svg { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: var(--brand-dark); text-decoration: none; }

/* ===== App shell (mobile-first) ===== */
.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: #FFFFFF;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 0 60px rgba(15, 23, 42, 0.06);
}
.app.no-nav { padding-bottom: 32px; }
.app-body { padding: 16px; }

/* ===== Page transition ===== */
.page-enter      { animation: slideInRight 280ms cubic-bezier(.22,.61,.36,1) both; }
.page-enter-back { animation: slideInLeft 280ms cubic-bezier(.22,.61,.36,1) both; }
@keyframes slideInRight { from { transform: translateX(28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideInLeft  { from { transform: translateX(-28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Tap feedback ===== */
.tap { transition: transform 120ms ease, box-shadow 120ms ease, background 150ms; }
.tap:active { transform: scale(0.97); }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 12px;
  gap: 8px;
}
.app-header-back {
  width: 40px; height: 40px; border-radius: 50%;
  background: transparent; border: 0; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.app-header-back:active { background: var(--line-2); }
.app-header-title {
  font-size: 16px; font-weight: 700; color: var(--ink);
  letter-spacing: 0.02em;
}
.app-header-logo { height: 22px; width: auto; margin-left: auto; }
.app-header-spacer { width: 40px; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--nav-h);
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 6px 8px calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
}
.nav-item {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px;
  font-size: 9px; font-weight: 600; letter-spacing: 0;
  color: var(--muted);
  text-decoration: none;
  transition: color 150ms;
}
.nav-item.active { color: var(--brand-dark); }
.nav-item svg { width: 21px; height: 21px; }
.nav-item span {
  max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-fab {
  flex: 0 0 auto;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: 0 10px 26px rgba(14, 165, 233, 0.4), 0 0 0 5px white;
  transform: translateY(-22px);
  text-decoration: none;
  position: relative;
}
.nav-fab svg { width: 28px; height: 28px; color: white; }
.nav-fab:active { transform: translateY(-22px) scale(0.95); }
.nav-fab-label {
  position: absolute; bottom: -14px;
  font-size: 10px; font-weight: 700;
  color: var(--brand-dark);
  background: white;
  padding: 2px 8px; border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ===== Cards ===== */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}
.card-flat { border: 1px solid var(--line); border-radius: 20px; padding: 18px; background: #fff; }
.card-title { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 12px; }
.card-section-title { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }

/* ===== Inputs ===== */
.input {
  width: 100%; height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 16px; color: var(--ink);
  font-family: inherit;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
}
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.12);
}
.input.error { border-color: var(--danger); background: #FEF2F2; }
.input[readonly] { background: var(--line-2); color: var(--text); }
textarea.input { padding: 14px 16px; height: auto; min-height: 92px; resize: vertical; line-height: 1.6; }
.input-label { display: block; font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.input-help { font-size: 12px; color: var(--muted); margin-top: 6px; }
.input-error {
  font-size: 12px; color: var(--danger); margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
  font-weight: 600;
}
.input-error::before { content: ""; display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--danger); color: #fff; text-align: center; font-size: 10px; line-height: 14px; }
.input-error::before { content: "!"; color: white; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  width: 100%; min-height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 15px; font-weight: 700;
  border: 0;
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 150ms ease, background 150ms;
  letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.32);
}
.btn-primary:active { box-shadow: 0 2px 8px rgba(14, 165, 233, 0.32); }

/* QRスキャン画面「カメラを起動する」など、迷わず押してほしい最重要CTA用。
   通常の btn-primary より一回り大きく、ゆっくり光るグローで視線を誘導する。 */
.btn-cta {
  min-height: 60px;
  font-size: 17px;
  animation: ctaGlow 2.2s ease-in-out infinite;
}
@keyframes ctaGlow {
  0%, 100% { box-shadow: 0 4px 14px rgba(14, 165, 233, 0.32); }
  50% { box-shadow: 0 6px 26px rgba(14, 165, 233, 0.55), 0 0 0 6px rgba(14, 165, 233, 0.14); }
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-ghost { background: transparent; color: var(--brand-dark); }
.btn-danger { background: #fff; color: var(--danger); border: 1.5px solid #FECACA; }

/* SNS ログインボタン。隣に並ぶ Google の GIS ボタン（幅 320 / 高さ 44 /
   角丸 4px）と寸法を揃えて、2 つが同じ部品に見えるようにする。 */
.btn-sns {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  width: 100%; max-width: 320px; height: 44px;
  margin: 0 auto;
  padding: 0 12px;
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.02em;
  /* 「Appleでロ / グイン」と折り返さないようにする */
  white-space: nowrap;
  border: 1.5px solid var(--line);
  cursor: pointer;
  transition: transform 100ms ease;
}
.btn-sns:active { transform: scale(0.97); }
.btn-sns:disabled { opacity: 0.45; cursor: not-allowed; }

/* サイズ指定が無いと SVG が既定サイズまで広がってテキストを押し出す */
.btn-sns .logo {
  width: 17px; height: 17px;
  flex: 0 0 auto;
  display: block;
}

/* Apple のガイドラインで認められている黒スタイル。ロゴは currentColor で
   文字色に追従させる（白地に白ロゴで消えるのを防ぐ） */
.btn-apple { background: #000; color: #fff; border-color: #000; }

/* ===== Chip select ===== */
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 13px; color: var(--text);
  cursor: pointer; user-select: none;
  transition: all 150ms ease;
  min-height: 40px;
}
.chip:active { transform: scale(0.96); }
.chip.selected {
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  border-color: transparent;
  color: #fff; font-weight: 700;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}

/* ===== Body balance bar ===== */
.balance-bar {
  position: relative;
  height: 32px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--line-2);
  display: flex;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.balance-left {
  background: linear-gradient(90deg, #6366F1 0%, #818CF8 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: flex-start;
  padding-left: 14px;
}
.balance-right {
  background: linear-gradient(90deg, #14B8A6 0%, #0EA5E9 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 14px;
}
.balance-legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--muted); font-weight: 600; }

/* ===== Stat row ===== */
.stat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
}
.stat-row:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-row:first-child { padding-top: 0; }
.stat-label { font-size: 13px; color: var(--text-2); }
.stat-value { font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: 0.02em; }
.stat-unit { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 2px; }

/* ===== Condition cards (ホーム「継続状況／今週の変化」・履歴「あなたの変化」) =====
   スマートフォン優先。狭い端末では列を減らして横スクロールを起こさない。 */
.home-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 14px;
}
/* iPhone SE 級（375px 未満）では 2 枚並べると数字が潰れるので縦積みにする。 */
@media (max-width: 374px) {
  .home-duo { grid-template-columns: 1fr; }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
@media (max-width: 379px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Finding text ===== */
.finding-block { margin-bottom: 14px; }
.finding-block:last-child { margin-bottom: 0; }
.finding-heading {
  font-size: 12px; font-weight: 700; color: var(--brand-dark);
  margin: 0 0 4px;
  letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 6px;
}
.finding-heading::before {
  content: ""; display: inline-block; width: 4px; height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, #0EA5E9, #14B8A6);
}
.finding-body { font-size: 14px; color: var(--text); margin: 0; line-height: 1.7; }

/* AI 所見のうち、体の歪み・傾き・左右差など体の状態そのものの指摘。
   生成時に [[ ... ]] で囲ませた部分（utils/aiText.js）をここで赤字にする。 */
.ai-emph { color: var(--danger); font-weight: 700; }

/* ===== Date banner ===== */
.date-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(14,165,233,0.08), rgba(20,184,166,0.08));
  border: 1px solid rgba(14, 165, 233, 0.2);
  color: var(--ink);
  font-size: 14px; font-weight: 600;
  margin-bottom: 16px;
}
.date-banner .icon { font-size: 18px; }

/* ===== Progress dots (register) ===== */
.progress-dots { display: flex; gap: 6px; justify-content: center; padding: 14px 0 6px; }
.progress-dot { width: 26px; height: 6px; border-radius: 3px; background: var(--line); transition: background 200ms; }
.progress-dot.active { background: linear-gradient(90deg, #0EA5E9, #14B8A6); }
.progress-dot.done { background: var(--brand-dark); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 80px; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  z-index: 200;
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Scan UI ===== */
.scan-stage {
  background: linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
  color: #fff;
  border-radius: 24px;
  padding: 28px 20px 24px;
  position: relative;
  overflow: hidden;
}
.scan-stage::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(800px 200px at 50% 0%, rgba(20, 184, 166, 0.18), transparent 60%),
    radial-gradient(500px 300px at 100% 100%, rgba(99, 102, 241, 0.15), transparent 60%);
  pointer-events: none;
}
.scan-frame {
  width: 78%; max-width: 280px;
  aspect-ratio: 1;
  position: relative;
  margin: 24px auto 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 24px;
}
.scan-corner {
  position: absolute; width: 40px; height: 40px;
  border-color: #14B8A6;
}
.scan-corner.tl { top: -2px; left: -2px; border-top: 4px solid; border-left: 4px solid; border-top-left-radius: 18px; }
.scan-corner.tr { top: -2px; right: -2px; border-top: 4px solid; border-right: 4px solid; border-top-right-radius: 18px; }
.scan-corner.bl { bottom: -2px; left: -2px; border-bottom: 4px solid; border-left: 4px solid; border-bottom-left-radius: 18px; }
.scan-corner.br { bottom: -2px; right: -2px; border-bottom: 4px solid; border-right: 4px solid; border-bottom-right-radius: 18px; }
.scan-line {
  position: absolute; left: 8%; right: 8%; height: 2px;
  background: linear-gradient(90deg, transparent, #14B8A6 50%, transparent);
  box-shadow: 0 0 18px #14B8A6;
  animation: scanMove 2.4s ease-in-out infinite;
}
@keyframes scanMove {
  0% { top: 8%; opacity: 0.4; }
  50% { top: 92%; opacity: 1; }
  100% { top: 8%; opacity: 0.4; }
}

/* カメラ未起動時、QR表示エリア（.scan-frame）に重ねて被せる正方形の起動ボタン。
   ボタン自体が「今どこを見ればいいか」を示すビューファインダーを兼ねる。 */
.scan-cta-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 82%;
  aspect-ratio: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  border-radius: 20px;
  z-index: 2;
  animation: ctaGlow 2.2s ease-in-out infinite;
}
.scan-cta-overlay span { font-size: 16px; }

/* ===== Survey radio ===== */
.radio-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 160ms;
  font-weight: 600;
  color: var(--ink);
}
.radio-card.selected {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(14,165,233,0.06), rgba(20,184,166,0.06));
}
.radio-circle {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex-shrink: 0; position: relative;
  transition: all 150ms;
}
.radio-card.selected .radio-circle { border-color: var(--brand); }
.radio-card.selected .radio-circle::after {
  content: ""; position: absolute; inset: 4px;
  background: linear-gradient(135deg, #0EA5E9, #14B8A6);
  border-radius: 50%;
}

/* ===== Period tabs ===== */
.period-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 16px 10px;
}
.period-tab {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  color: var(--muted);
  background: #fff;
  border: 1.5px solid var(--line);
  cursor: pointer; white-space: nowrap;
  transition: all 150ms;
  min-height: 36px;
}
.period-tab:active { transform: scale(0.96); }
.period-tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* ===== Chat bubbles ===== */
.chat-row { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-end; }
.chat-row.user { justify-content: flex-end; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  background: var(--line-2);
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-bubble {
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 14px; line-height: 1.65;
  max-width: 80%;
  word-break: break-word;
}
.chat-bubble.ai {
  background: var(--line-2); color: var(--ink);
  border-bottom-left-radius: 6px;
}
.chat-bubble.user {
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.chat-time { font-size: 10px; opacity: 0.7; margin-top: 4px; }
.chat-bubble.ai .chat-time { color: var(--muted); }
.chat-bubble.user .chat-time { color: rgba(255,255,255,0.85); }
.chat-sender { font-size: 11px; font-weight: 700; color: var(--brand-dark); margin-bottom: 2px; }
.chat-system {
  text-align: center; font-size: 11px; color: var(--muted);
  margin: 12px 0;
  padding: 4px 0;
}
.chat-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted); opacity: 0.5;
  animation: typingBlink 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBlink { 0%,80%,100% { opacity: 0.3; } 40% { opacity: 1; } }

.chat-input-bar {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; gap: 8px; align-items: center;
  z-index: 50;
}
/* AIアドバイス画面はフッターナビを常時表示するため、入力バーをナビの真上に積む。
 * ナビ中央の QRスキャン FAB は上に約 21px（円 22px 持ち上げ＋白リング 5px）飛び出すので、
 * 入力欄が隠れないよう下側に余白を確保する（余白部分は入力バーの背景で塞ぐ）。 */
.chat-input-bar.with-nav {
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: 30px;
  z-index: 45; /* .bottom-nav (50) より下 = FAB が入力バーの上に描画される */
}
.app.chat-with-nav {
  padding-bottom: calc(var(--nav-h) + 108px + env(safe-area-inset-bottom, 0px));
}

.chat-input {
  flex: 1; height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: 1.5px solid var(--line);
  background: var(--line-2);
  font-size: 15px; color: var(--ink);
}
.chat-input:focus { outline: none; border-color: var(--brand); background: #fff; }
.chat-icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0;
  background: var(--line-2); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.chat-icon-btn.mic.recording { background: #FEE2E2; color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.chat-send-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.chat-send-btn svg { width: 18px; height: 18px; }
.chat-context-card {
  background: linear-gradient(135deg, rgba(14,165,233,0.08), rgba(20,184,166,0.08));
  border: 1px solid rgba(14, 165, 233, 0.25);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
  font-size: 13px;
}
.chat-context-card .label {
  font-size: 11px; font-weight: 700; color: var(--brand-dark);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 4px;
}

/* ===== Auth (login) hero ===== */
.auth-hero {
  text-align: center;
  padding: 52px 24px 32px;
}
.auth-logo {
  width: 80px; height: auto; margin: 0 auto 18px;
}
.auth-tagline {
  font-size: 13px; color: var(--muted); font-weight: 600;
  letter-spacing: 0.08em;
}
.auth-title {
  font-size: 22px; font-weight: 800; color: var(--ink);
  margin: 14px 0 6px; letter-spacing: 0.02em;
}

/* ===== 3D body image carousel ===== */
.carousel { position: relative; }
.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 12px;
  padding: 0 4px;
  scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide {
  flex: 0 0 86%;
  scroll-snap-align: center;
  background: linear-gradient(180deg, #F8FAFC, #FFFFFF);
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 12px;
  text-align: center;
}
.carousel-slide img { margin: 0 auto; max-height: 280px; }
.carousel-slide .label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: 6px;
}
.carousel-dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.carousel-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: all 200ms; }
.carousel-dot.active { background: var(--brand); width: 18px; border-radius: 3px; }

/* Swipe hint */
.carousel-hint {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  font-size: 11px; font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  padding: 4px 8px;
  background: linear-gradient(135deg, rgba(14,165,233,0.06), rgba(20,184,166,0.06));
  border-radius: 999px;
  border: 1px solid rgba(14,165,233,0.15);
  width: max-content;
  margin-left: auto; margin-right: auto;
}
.carousel-hint .arr-l { animation: hintLeft 1.4s ease-in-out infinite; }
.carousel-hint .arr-r { animation: hintRight 1.4s ease-in-out infinite; }
@keyframes hintLeft  { 0%,100% { transform: translateX(0); opacity: 0.5; } 50% { transform: translateX(-3px); opacity: 1; } }
@keyframes hintRight { 0%,100% { transform: translateX(0); opacity: 0.5; } 50% { transform: translateX(3px); opacity: 1; } }

/* ===== Exercise list ===== */
.ex-card {
  display: flex; align-items: center; gap: 12px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 160ms;
}
.ex-card:active { transform: scale(0.99); }
.ex-card.done {
  background: linear-gradient(135deg, rgba(16,185,129,0.06), rgba(20,184,166,0.06));
  border-color: rgba(16,185,129,0.4);
}
.ex-card-icon {
  width: 60px; height: 60px; border-radius: 12px;
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.ex-card-icon .emoji-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.ex-card-icon .thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 2;
}
.ex-card-icon .play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(15,23,42,0.05) 30%, rgba(15,23,42,0.55));
  z-index: 3;
}
.ex-card-icon .play-overlay svg {
  width: 18px; height: 18px;
  color: #fff;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}
.ex-card.done .ex-card-icon::after {
  content: "✓";
  position: absolute; inset: 0;
  background: rgba(16,185,129,0.92);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 30px; font-weight: 800;
  z-index: 5;
}
.ex-card-body { flex: 1; min-width: 0; }
.ex-card-title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 0; }
.ex-card-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ex-card-status {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
}
.ex-card-status.todo { background: var(--line-2); color: var(--muted); }
.ex-card-status.done { background: #D1FAE5; color: #065F46; }

/* ===== Moon row ===== */
.moon-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 4px;
  margin: 6px 0 12px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}
.moon-row::-webkit-scrollbar { display: none; }
.moon-cell {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center;
  font-size: 10px; color: var(--muted);
  min-width: 42px;
  padding: 4px 2px;
  border-radius: 10px;
  position: relative;
}
.moon-cell.active {
  background: linear-gradient(180deg, rgba(14,165,233,0.10), rgba(20,184,166,0.05));
  color: var(--brand-dark);
  font-weight: 700;
}
.moon-cell img { width: 32px; height: 32px; margin-bottom: 4px; }

/* ===== Section divider ===== */
.section-title {
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
  padding: 0 4px;
}

/* ===== Quick actions row ===== */
.qa-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.qa-card {
  display: flex; align-items: center; gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px; font-weight: 700;
  transition: all 150ms;
}
.qa-card:active { transform: scale(0.97); }
.qa-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(14,165,233,0.12), rgba(20,184,166,0.12));
  color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* ===== External site card (Kinetic Lab ストア / help サイト) ===== */
/* アイコン＋サイト名を縦積みにした、外部サイトへの大きめタップ領域。
   Icons の SVG は width/height を持たないので、ここでサイズを与える。 */
.ext-site-link {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 6px 0 2px;
  text-decoration: none;
}
.ext-site-icon {
  width: 76px; height: 76px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.28);
  transition: transform 150ms;
}
.ext-site-link:active .ext-site-icon { transform: scale(0.95); }
.ext-site-icon svg { width: 40px; height: 40px; }
.ext-site-name {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 15px; font-weight: 800; color: var(--brand-dark);
}

/* ===== Misc ===== */
.muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.kb-tag {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  color: #fff;
  letter-spacing: 0.04em;
}

/* ===== Streak/connect badge ===== */
.streak-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #F59E0B 0%, #F97316 100%);
  color: #fff;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.04em;
}

/* ===== Sport icon hero ===== */
.sport-icon-hero {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(14,165,233,0.12), rgba(20,184,166,0.12));
  border: 1px solid rgba(14,165,233,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 20px;
  padding: 22px;
  max-width: 380px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
  font-size: 13px;
}

/* ===== Plan card ===== */
.plan-card {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #fff;
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.plan-card::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 100px at 100% 0, rgba(20,184,166,0.25), transparent 60%);
  pointer-events: none;
}
.plan-card .label { font-size: 11px; opacity: 0.7; letter-spacing: 0.08em; text-transform: uppercase; }
.plan-card .name { font-size: 22px; font-weight: 800; margin: 4px 0 4px; letter-spacing: 0.02em; }
.plan-card .meta { font-size: 12px; opacity: 0.85; }

/* ===== List rows ===== */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line-2);
  text-decoration: none;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
.list-row:active { background: var(--line-2); }
.list-row:first-child { border-radius: 14px 14px 0 0; }
.list-row:last-child { border-bottom: 0; border-radius: 0 0 14px 14px; }
.list-group { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 14px; }
.list-row .arrow { margin-left: auto; color: var(--muted); }
.list-row .icon { width: 36px; height: 36px; border-radius: 10px; background: var(--line-2); display: flex; align-items: center; justify-content: center; font-size: 18px; }

/* ===== AI Chat page extras ===== */
.video-attach {
  width: 100%; aspect-ratio: 16/10;
  border-radius: 14px;
  overflow: hidden;
  background: #0F172A;
  margin: 8px 0 4px;
  position: relative;
}
.video-attach iframe { position: absolute; inset: 0; width:100%; height:100%; border:0; }
.img-attach {
  max-width: 100%;
  border-radius: 14px;
  margin: 8px 0 4px;
  border: 1px solid var(--line);
  background: #fff;
}

/* ===== Exercise complete overlay ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* ===== Auth pages (login / register / verify) — white-blue theme ===== */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 18px 40px;
  background: linear-gradient(180deg, #F0F9FF 0%, #FFFFFF 30%, #F8FAFC 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 4px 30px rgba(15,23,42,0.06);
  padding: 32px 26px;
}
@media (max-width: 380px) { .auth-card { padding: 26px 20px; } }
.auth-card h2 { margin: 0 0 18px; font-size: 18px; font-weight: 700; text-align: center; color: var(--ink); }

/* Form fields (auth pages) */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  letter-spacing: 0.02em; margin-bottom: 6px; color: var(--text-2);
}
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; font-size: 15px; font-family: inherit;
  background: #fff; color: var(--ink); transition: border-color 150ms, box-shadow 150ms;
}
.field input::placeholder { color: #94A3B8; }
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14,165,233,0.12); }
.required { color: var(--danger); margin-left: 4px; font-size: 10px; font-weight: 700; }

/* Divider ("or" line) */
.divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0; color: var(--muted); font-size: 11px; letter-spacing: 0.05em;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Tabs (email / SNS) */
.tabs {
  display: flex; background: var(--line-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 3px; margin-bottom: 18px;
}
.tabs .tab {
  flex: 1; text-align: center; padding: 8px 0; font-size: 12px; font-weight: 700;
  color: var(--muted); border-radius: 10px; cursor: pointer; transition: background 150ms, color 150ms; user-select: none;
}
.tabs .tab.active {
  background: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
  color: #fff; box-shadow: 0 2px 8px rgba(14,165,233,0.3);
}

/* Page footer */
.page-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 22px; }

/* Error / success messages */
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; text-align: center; min-height: 1em; }
.success-msg { color: var(--success); font-size: 13px; margin-top: 8px; text-align: center; min-height: 1em; }

/* Button row */
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* Notice block */
.notice {
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25);
  border-radius: 12px; padding: 12px 14px; font-size: 12px;
  color: #92400E; margin-bottom: 14px; line-height: 1.55;
}

/* Result block */
.result-block {
  background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(14,165,233,0.06));
  border: 1px solid rgba(16,185,129,0.3); border-radius: 16px;
  padding: 20px; margin-top: 16px; text-align: center;
}
.result-block .icon { font-size: 32px; margin-bottom: 6px; }
.result-block .msg { font-weight: 800; color: var(--success); margin-bottom: 14px; font-size: 15px; }
.result-block .detail {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; text-align: left;
}

/* Card row (for verify, subscription results) */
.card-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line-2); gap: 12px;
}
.card-row:last-child { border-bottom: none; }
.card-row .label { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.card-row .value { font-size: 14px; font-weight: 600; color: var(--ink); text-align: right; word-break: break-all; }

/* Larger screens (desktop) – outside the app */
@media (min-width: 768px) {
  body {
    background: radial-gradient(ellipse at center top, #E0F2FE 0%, #F8FAFC 60%);
  }
}

/* AI chat loading spinner */
@keyframes chatSpin { to { transform: rotate(360deg); } }

/* ===== PWA (update / install / offline) =====
   アプリシェル（max-width:480px）に合わせて中央寄せし、ボトムナビ（z-index:50）より
   手前・トースト（z-index:200）より奥に置く。 */
.pwa-update,
.pwa-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 456px;
  z-index: 120;
  animation: pwaIn 260ms cubic-bezier(.22,.61,.36,1) both;
}
@keyframes pwaIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* 更新のお知らせ（画面上部） */
.pwa-update {
  top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.28);
  animation-name: pwaInTop;
}
@keyframes pwaInTop { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.pwa-update-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pwa-update-text strong { font-size: 13.5px; font-weight: 800; letter-spacing: 0.01em; }
.pwa-update-text span { font-size: 11.5px; color: #CBD5E1; line-height: 1.5; }
.pwa-update-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* 画面下部に出すバー（オフライン表示・インストール案内） */
.pwa-bar { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.pwa-bar-above-nav { bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px)); }

.pwa-offline {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  color: #E2E8F0;
  font-size: 12.5px; font-weight: 600;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.24);
}
.pwa-offline-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.pwa-install {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}
.pwa-install-icon { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; background: var(--bg-soft); }
.pwa-install-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pwa-install-text strong { font-size: 13.5px; font-weight: 800; color: var(--ink); }
.pwa-install-text span { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.pwa-install-share { flex-shrink: 0; color: var(--brand-dark); }
.pwa-install-share svg { width: 22px; height: 22px; }
.pwa-install-close {
  position: absolute; top: -8px; right: -8px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
}

.pwa-btn {
  flex-shrink: 0;
  font: inherit; font-size: 13px; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border: none; border-radius: 11px; padding: 9px 16px;
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.3);
  transition: transform 120ms ease;
}
.pwa-btn:active { transform: scale(0.96); }
.pwa-btn-ghost {
  flex-shrink: 0;
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  background: transparent; border: none; color: #94A3B8; padding: 9px 4px;
}

/* 支払い保留バナー（.pwa-update を土台に警告色へ差し替え）。§8。 */
.payment-pending-banner {
  background: var(--warn);
  color: #1a1200;
}
.payment-pending-banner .pwa-update-text span { color: #4A3600; }
.payment-pending-banner .pwa-btn {
  background: #1a1200; color: #fff;
  box-shadow: 0 6px 16px rgba(26, 18, 0, 0.28);
}
