/* ==========================================
   PilaCarte v2 — Global Reset & Design Tokens
   ========================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* === UI刷新トークン：ジェイドの一点アクセント === */
  --jade:        #166A6B;
  --jade-mid:    #1E7E80;
  --jade-dark:   #0F4F50;
  --jade-tint:   #F1F4F2;
  --jade-ink:    #1E4E4F;

  /* 旧 terracotta 系はジェイドへ寄せる（既存利用箇所をそのまま活かす） */
  --terracotta:       #166A6B;
  --terracotta-light: #F1F4F2;
  --terracotta-mid:   #1E7E80;
  --terracotta-dark:  #0F4F50;

  --sage:             #4F8F84;
  --sage-light:       #EAF2F0;
  --sage-mid:         #7BA89E;
  --sage-dark:        #2E6A60;

  --warm-white:       #FCFBF8;
  --bg:               #FCFBF8;
  --surface:          #FFFFFF;
  --surface-warm:     #FCFBF8;
  --off-white:        #FCFBF8;

  /* Risk colors（信号機の価値づけを避け、ドット＋言葉で使う） */
  --risk-red:         #A32D2D;
  --risk-red-light:   #F6EAEA;
  --risk-red-dark:    #7A2020;
  --risk-red-border:  rgba(163,45,45,0.18);

  --risk-yellow:      #B98A2F;
  --risk-yellow-light:#F7F1E3;
  --risk-yellow-dark: #7A5A18;
  --risk-yellow-border:rgba(185,138,47,0.18);

  --risk-green:       #6F8F73;
  --risk-green-light: #EEF2EE;
  --risk-green-dark:  #4A6650;
  --risk-green-border:rgba(111,143,115,0.16);

  /* Neutrals */
  --ink-primary:    #262826;
  --ink-secondary:  #5C5B55;
  --ink-muted:      #8E8C85;
  --ink-faint:      #B8B6AE;
  --ink-border:     #EAE8E2;
  --line-faint:     #F0EEE8;

  /* Typography */
  --font-sans:  'IBM Plex Sans JP', 'Noto Sans JP', sans-serif;
  --font-serif: 'Zen Old Mincho', serif;

  /* Spacing / shape — ピル基調をやめ、角丸10-12px基調へ */
  --radius-sm:  10px;
  --radius-md:  12px;
  --radius-lg:  14px;
  --radius-xl:  16px;
  --radius-pill:9999px;

  /* Shadows — 刷新方針は影を使わない（後方互換のため極薄で残置） */
  --shadow-xs:  0 1px 2px rgba(30,40,40,0.04);
  --shadow-sm:  0 1px 2px rgba(30,40,40,0.05);
  --shadow-md:  0 2px 6px rgba(30,40,40,0.06);
  --shadow-lg:  0 6px 18px rgba(30,40,40,0.08);

  --transition: 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ====================================================================
   UI刷新 M1：ホーム＋ランディング（ジェイド一点／明朝見出し／絵文字なし）
   ==================================================================== */

/* --- ブランドマーク＋監修レターマーク --- */
.brandmark-name{ font-family:var(--font-serif); font-weight:700; font-size:29px; letter-spacing:.03em; color:var(--ink-primary); line-height:1; -webkit-text-stroke:0.3px var(--ink-primary); }
.brandmark-sup{ display:flex; align-items:center; gap:7px; margin-top:7px; font-size:10.5px; letter-spacing:.16em; color:var(--jade); }
.brandmark-rule{ display:inline-block; width:16px; height:0; border-top:.5px solid var(--jade); }

/* --- ホーム --- */
#screen-top.screen{ background:var(--bg); }
.home{ width:100%; max-width:500px; margin:0 auto; padding:14px 20px 36px; box-sizing:border-box; }
.home-head{ display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:20px; }
.home-menu-btn{ background:none; border:none; padding:6px; cursor:pointer; color:var(--ink-primary); line-height:0; }
.home-menu-btn svg{ width:22px; height:22px; stroke:currentColor; fill:none; }
.home-menu{ position:fixed; right:22px; top:58px; background:var(--surface); border:1px solid var(--ink-border); border-radius:var(--radius-md); padding:6px; z-index:1000; min-width:150px; box-shadow:var(--shadow-md); }
.home-menu button{ display:block; width:100%; text-align:left; background:none; border:none; padding:10px 12px; font-size:13.5px; color:var(--ink-primary); font-family:var(--font-sans); cursor:pointer; border-radius:8px; }
.home-menu button:hover{ background:var(--jade-tint); }

.home-cover{ display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin:14px 0 26px; }
.home-cover-main{ flex:1; min-width:0; }
.home-greet{ font-size:11.5px; color:var(--ink-muted); letter-spacing:.04em; white-space:nowrap; }
.home-date{ font-family:var(--font-serif); font-weight:600; font-size:23px; color:var(--ink-primary); margin:2px 0 6px; white-space:nowrap; }
.home-date-dow{ font-size:13px; color:var(--ink-primary); font-weight:500; margin-left:4px; }
.home-kotoba{ font-family:var(--font-sans); font-size:12.5px; color:var(--jade); margin-top:12px; line-height:1.55; }
.home-tagline{ flex-shrink:0; display:flex; gap:8px; align-items:flex-start; font-family:var(--font-serif); font-size:14px; }
.home-tagline span{ writing-mode:vertical-rl; letter-spacing:.18em; line-height:1; }
.home-tagline .tl-1{ color:var(--jade); }
.home-tagline .tl-2{ color:#B0AEA5; padding-top:48px; }

.home-cta{ display:flex; align-items:center; justify-content:space-between; width:100%; padding:18px 20px; background:var(--jade); color:#fff; border:none; border-radius:var(--radius-md); font-family:var(--font-sans); font-size:16px; font-weight:500; letter-spacing:.04em; cursor:pointer; margin-top:16px; margin-bottom:16px; }
.home-cta .home-cta-arrow{ width:20px; height:20px; stroke:currentColor; fill:none; }
.home-cta-text{ display:flex; flex-direction:column; align-items:flex-start; }
.home-cta-name{ font-size:16px; font-weight:600; }
.home-cta-sub{ font-size:11.5px; font-weight:400; opacity:.85; margin-top:3px; letter-spacing:.02em; }
.home-cta:active{ transform:scale(.99); }

.home-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:22px; }
.home-card{ display:flex; flex-direction:column; gap:11px; align-items:flex-start; background:var(--surface); border:1px solid var(--ink-border); border-radius:var(--radius-md); padding:16px; cursor:pointer; font-family:var(--font-sans); }
.home-card .home-card-ic svg{ width:22px; height:22px; stroke:var(--jade); fill:none; }
.home-card-name{ font-size:14px; font-weight:500; color:var(--ink-primary); }
.home-card-text{ display:flex; flex-direction:column; gap:3px; }
.home-card-sub{ font-size:11.5px; color:var(--ink-muted); }
.home-card:active{ transform:scale(.99); }

.home-links{ border-top:.5px solid var(--ink-border); margin-bottom:22px; }
.home-link{ display:flex; align-items:center; gap:12px; width:100%; padding:15px 4px; background:none; border:none; border-bottom:.5px solid var(--line-faint); cursor:pointer; font-family:var(--font-sans); text-align:left; }
.home-link:last-child{ border-bottom:none; }
.home-link-ic svg{ width:19px; height:19px; stroke:var(--jade); fill:none; }
.home-link-name{ flex:1; font-size:14px; color:var(--ink-primary); }
.home-link-arrow{ width:16px; height:16px; stroke:var(--ink-faint); fill:none; }

.home-note{ font-size:11px; color:var(--ink-faint); text-align:left; margin:0; line-height:1.6; }

/* ====================================================================
   UI刷新 M2a：クライアント一覧（行リスト＋回数バッジ）
   ==================================================================== */
.clients-add{ background:none; border:none; color:var(--jade); font-size:13.5px; font-weight:500; cursor:pointer; font-family:var(--font-sans); padding:6px 2px; white-space:nowrap; }
.client-search-wrap{ display:flex; align-items:center; gap:8px; background:var(--surface); border:1px solid var(--ink-border); border-radius:10px; padding:0 12px; }
.client-search-wrap svg{ width:16px; height:16px; stroke:var(--ink-muted); fill:none; flex-shrink:0; }
.client-search-input{ flex:1; border:none; background:none; padding:11px 0; font-family:var(--font-sans); font-size:14px; color:var(--ink-primary); outline:none; }
.client-list-card{ background:var(--surface); border:1px solid var(--ink-border); border-radius:12px; overflow:hidden; }
.client-row{ display:flex; align-items:center; justify-content:space-between; gap:12px; width:100%; padding:14px 16px; background:none; border:none; border-bottom:.5px solid var(--line-faint); cursor:pointer; text-align:left; font-family:var(--font-sans); }
.client-row:last-child{ border-bottom:none; }
.client-row:active{ background:var(--jade-tint); }
.client-row-main{ display:flex; flex-direction:column; gap:3px; min-width:0; }
.client-row-name{ font-size:15px; font-weight:500; color:var(--ink-primary); }
.client-row-meta{ font-size:11.5px; color:var(--ink-muted); }
.client-row-badge{ flex-shrink:0; font-size:11px; font-weight:600; padding:4px 10px; border-radius:8px; }
.client-row-badge.has{ color:var(--jade-ink); background:#EEF4F3; }
.client-row-badge.zero{ color:var(--ink-muted); background:#F4F3EE; }

/* ===== 今日のクライアント ===== */
/* ホームの枠（home-cover と CTA の間。元の余白感を保つため上に余白） */
.today-sec{ margin-top:40px; }
/* 空：しれっと控えめな点線ボタン */
.today-empty-btn{ width:100%; text-align:left; font-size:13px; color:var(--ink-muted); background:none; border:1px dashed var(--ink-border); border-radius:10px; padding:11px 14px; cursor:pointer; font-family:var(--font-sans); }
.today-empty-btn:active{ background:var(--jade-tint); }
.today-empty-btn .today-plus{ color:var(--jade); font-weight:700; margin-right:6px; }
/* 選択後：コンパクトな1行 */
.today-bar{ width:100%; display:flex; align-items:center; justify-content:space-between; background:var(--surface); border:1px solid var(--ink-border); border-radius:10px; padding:12px 14px; cursor:pointer; font-family:var(--font-sans); }
.today-bar:active{ background:var(--jade-tint); }
.today-bar-l{ display:flex; align-items:baseline; gap:8px; }
.today-bar-t{ font-size:13px; font-weight:700; color:var(--ink-primary); }
.today-bar-c{ font-size:12px; color:var(--ink-muted); }
.today-bar-arw{ color:var(--ink-faint); font-size:18px; line-height:1; }

/* 今日のクライアント画面：カード */
.today-list{ display:flex; flex-direction:column; gap:10px; padding:4px 16px 16px; }
.today-card{ display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; background:var(--surface); border:1px solid var(--ink-border); border-radius:12px; padding:14px 16px; cursor:pointer; text-align:left; font-family:var(--font-sans); }
.today-card:active{ background:var(--jade-tint); }
.today-card-l{ display:flex; flex-direction:column; gap:3px; min-width:0; }
.today-card-name{ font-size:16px; font-weight:700; color:var(--ink-primary); font-family:var(--font-serif); }
.today-card-meta{ font-size:11.5px; color:var(--ink-muted); }
.today-card-right{ display:flex; align-items:center; gap:8px; flex-shrink:0; }
.today-cnt{ font-size:12px; font-weight:700; color:var(--ink-secondary); background:var(--jade-tint); border-radius:8px; padding:2px 9px; }
.today-pill{ font-size:11px; font-weight:600; border-radius:8px; padding:2px 8px; }
.today-pill.pill-yellow{ background:var(--risk-yellow-light); color:var(--risk-yellow-dark); }
.today-pill.pill-red{ background:var(--risk-red-light); color:var(--risk-red-dark); }

/* 選択モード：チェックボックス付き行 */
.client-pick-row{ display:flex; align-items:center; gap:12px; width:100%; padding:14px 16px; background:none; border:none; border-bottom:.5px solid var(--line-faint); cursor:pointer; text-align:left; font-family:var(--font-sans); }
.client-pick-row:last-child{ border-bottom:none; }
.client-pick-row:active{ background:var(--jade-tint); }
.client-pick-box{ width:22px; height:22px; border-radius:6px; border:2px solid var(--ink-border); flex-shrink:0; display:flex; align-items:center; justify-content:center; color:#fff; font-size:14px; }
.client-pick-box.on{ background:var(--jade); border-color:var(--jade); }
/* 選択モードのバー */
.today-pick-bar{ gap:10px; padding:12px 16px 0; }
.today-pick-cancel{ background:none; border:1px solid var(--ink-border); color:var(--ink-secondary); border-radius:12px; padding:13px 20px; font-size:14px; cursor:pointer; font-family:var(--font-sans); }
.today-pick-done{ flex:1; background:var(--jade); color:#fff; border:none; border-radius:12px; padding:13px; font-size:15px; font-weight:600; cursor:pointer; font-family:var(--font-sans); }

/* AI相談メモ：折りたたみ（チェブロン回転） */
.ai-conv-item > summary::-webkit-details-marker{ display:none; }
.ai-conv-chev{ transition: transform .15s ease; }
.ai-conv-item[open] .ai-conv-chev{ transform: rotate(90deg); }

/* --- ランディング（login.html） --- */
.lp{ max-width:430px; margin:0 auto; min-height:100vh; padding:38px 28px 28px; box-sizing:border-box; display:flex; flex-direction:column; }
.lp-brand{ text-align:center; }
.lp-name{ font-family:var(--font-serif); font-weight:600; font-size:32px; letter-spacing:.04em; color:var(--ink-primary); }
.lp-sup{ display:flex; align-items:center; justify-content:center; gap:9px; margin-top:8px; font-size:11px; letter-spacing:.16em; color:var(--jade); }
.lp-rule{ display:inline-block; width:18px; height:0; border-top:.5px solid var(--jade); }
.lp-tagline{ font-family:var(--font-serif); font-weight:600; font-size:23px; line-height:1.5; text-align:center; color:var(--ink-primary); margin:36px 0 14px; }
.lp-sub{ text-align:center; font-size:13px; color:var(--ink-muted); margin:0 0 34px; }
.lp-features{ border-top:.5px solid var(--ink-border); margin-bottom:auto; }
.lp-feat{ display:flex; align-items:flex-start; gap:13px; padding:16px 2px; border-bottom:.5px solid var(--line-faint); }
.lp-feat-ic{ padding-top:2px; }
.lp-feat-ic svg{ width:20px; height:20px; stroke:var(--jade); fill:none; }
.lp-feat-name{ font-size:14.5px; font-weight:500; color:var(--ink-primary); }
.lp-feat-desc{ font-size:12px; color:var(--ink-muted); margin-top:3px; }
.lp-cta{ display:block; width:100%; text-align:center; padding:16px; background:var(--jade); color:#fff; border:none; border-radius:var(--radius-md); font-family:var(--font-sans); font-size:15px; font-weight:500; letter-spacing:.06em; cursor:pointer; margin-top:24px; }
.lp-cta:active{ transform:scale(.99); }
.lp-login{ text-align:center; font-size:13px; color:var(--ink-muted); margin:16px 0 0; }
.lp-login a{ color:var(--jade); font-weight:500; text-decoration:none; cursor:pointer; }
.lp-note{ text-align:center; font-size:11px; color:var(--ink-faint); margin:18px 0 0; }

/* ホームの登場演出は画面共通の screenFadeUp に任せる（メニューのtransform干渉を避けるため per-child アニメは廃止） */

html {
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--warm-white);
  color: var(--ink-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ==========================================
   Screen Management
   ========================================== */
.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: screenFadeUp 0.35s ease both;
}

@keyframes screenFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateX(var(--slide-dx, 28px)); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes popIn {
  0%   { transform: scale(0.75); opacity: 0; }
  65%  { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,79,79,0.3); }
  50%       { box-shadow: 0 0 0 12px rgba(217,79,79,0); }
}
@keyframes floatUp {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ==========================================
   TOP SCREEN
   ========================================== */
#screen-top {
  justify-content: center;
  padding: 48px 24px 36px;
  position: relative;
  overflow: hidden;
  background: var(--warm-white);
}

/* Decorative circles */
.top-bg-deco { position: absolute; inset: 0; pointer-events: none; }

.deco-circle {
  position: absolute;
  border-radius: 50%;
}
.deco-circle-1 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(193,121,73,0.09) 0%, transparent 70%);
  top: -80px; right: -60px;
  animation: floatUp 8s ease-in-out infinite;
}
.deco-circle-2 {
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(122,158,126,0.08) 0%, transparent 70%);
  bottom: -40px; left: -50px;
  animation: floatUp 10s ease-in-out infinite 2s;
}
.deco-circle-3 {
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(193,121,73,0.06) 0%, transparent 70%);
  top: 40%; left: -30px;
}

.top-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

/* Logo area */
.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 36px;
}

.logo-icon {
  width: 96px;
  height: 96px;
  background: var(--surface);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(193,121,73,0.12);
  margin-bottom: 22px;
  padding: 14px;
  animation: popIn 0.7s cubic-bezier(0.4,0,0.2,1) 0.1s both;
}

.logo-svg { width: 100%; height: 100%; }

.brand-name-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  animation: screenFadeUp 0.5s ease 0.25s both;
}

.app-title {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 700;
  color: var(--terracotta-dark);
  letter-spacing: -0.5px;
}

.app-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--sage-dark);
  background: var(--sage-light);
  border: 1px solid rgba(122,158,126,0.35);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  white-space: nowrap;
}

.app-catchcopy {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink-primary);
  text-align: center;
  line-height: 1.65;
  letter-spacing: 0.1px;
  margin-bottom: 12px;
  animation: screenFadeUp 0.5s ease 0.35s both;
}

.app-description {
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink-secondary);
  text-align: center;
  line-height: 1.85;
  animation: screenFadeUp 0.5s ease 0.45s both;
}

/* Info cards */
.info-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-bottom: 32px;
  animation: screenFadeUp 0.5s ease 0.5s both;
}

.info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  padding: 13px 18px;
  box-shadow: var(--shadow-xs);
}

.info-card-icon { font-size: 18px; flex-shrink: 0; }

.info-card-text {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-secondary);
}

/* 3 value pillars on top screen */
.top-pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin-bottom: 28px;
  animation: screenFadeUp 0.5s ease 0.5s both;
}
.pillar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  box-shadow: var(--shadow-xs);
}
.pillar-icon { font-size: 22px; line-height: 1; }
.pillar-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-primary);
  line-height: 1.3;
  white-space: nowrap;
}
.pillar-sub {
  font-size: 10.5px;
  color: var(--ink-muted);
  line-height: 1.35;
}

/* Primary CTA */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  padding: 18px 32px;
  background: var(--terracotta);
  color: white;
  font-family: var(--font-sans);
  font-size: 16.5px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(193,121,73,0.38);
  transition: all var(--transition);
  letter-spacing: 0.3px;
  margin-bottom: 20px;
  animation: screenFadeUp 0.5s ease 0.55s both;
}
.btn-primary:hover {
  background: var(--terracotta-dark);
  box-shadow: 0 8px 26px rgba(193,121,73,0.48);
  transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(0); }

.btn-arrow { width: 20px; height: 20px; }

.top-disclaimer {
  font-size: 11px;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.7;
  animation: screenFadeUp 0.5s ease 0.6s both;
}

/* ==========================================
   CHECK SCREEN
   ========================================== */
#screen-check {
  padding-bottom: 40px;
  background: var(--warm-white);
}

.check-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 500px;
  padding: 0 20px;
}

/* Header */
.check-header {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 20px 0 22px;
  gap: 14px;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px 8px 10px;
  border: 1.5px solid var(--ink-border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.btn-back svg { width: 18px; height: 18px; }
.btn-back:hover {
  border-color: var(--terracotta);
  color: var(--terracotta);
  background: var(--terracotta-light);
}

.back-label { letter-spacing: 0.2px; }

/* ヘッダー右上のホームボタン（深い閲覧画面で一発ホーム） */
.btn-home { width: 40px; height: 36px; display: flex; align-items: center; justify-content: center; background: none; border: none; color: var(--ink-secondary); cursor: pointer; border-radius: 8px; padding: 0; }
.btn-home:hover { background: var(--jade-tint); color: var(--jade); }
.btn-home svg { width: 21px; height: 21px; }

.progress-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-track {
  height: 4px;
  background: var(--ink-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--terracotta), var(--terracotta-mid));
  border-radius: var(--radius-pill);
  transition: width 0.45s cubic-bezier(0.4,0,0.2,1);
  width: 6.67%;
}

.progress-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-align: right;
}
.progress-sep { margin: 0 2px; color: var(--ink-border); }

/* Category */
.category-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  align-self: flex-start;
}
.category-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition);
}
.category-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--ink-secondary);
  text-transform: uppercase;
}

/* Question card */
.question-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 36px 30px 30px;
  width: 100%;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--ink-border);
  margin-bottom: 28px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.question-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-accent, var(--terracotta));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  transition: background 0.3s ease;
}

.question-risk-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
  align-self: flex-start;
}
.risk-tag-red {
  background: var(--risk-red-light);
  color: var(--risk-red-dark);
  border: 1px solid var(--risk-red-border);
}
.risk-tag-yellow {
  background: var(--risk-yellow-light);
  color: var(--risk-yellow-dark);
  border: 1px solid var(--risk-yellow-border);
}

.question-text {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink-primary);
  line-height: 1.65;
  letter-spacing: -0.1px;
  margin-bottom: 14px;
}

.question-note {
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.7;
  padding: 10px 14px;
  background: var(--warm-white);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--ink-border);
}

/* Answer buttons */
.answer-buttons {
  display: flex;
  gap: 14px;
  width: 100%;
  margin-bottom: 14px;
}

/* 回答ボタンは中立（はい/いいえに良し悪しの色づけをしない）。アプリが判定しない思想。 */
.btn-no, .btn-yes {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 16px;
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.answer-label { font-size: 15px; }
.btn-no:hover, .btn-yes:hover { border-color: var(--jade); }
.btn-no:active, .btn-yes:active { background: var(--jade-tint); }
.answer-hint { font-size: 11px; color: var(--ink-muted); text-align: center; margin: 0 0 28px; }

/* ==========================================
   POSTURE MANUAL LANDMARK EDIT SCREEN
   ========================================== */
.posture-manual-edit-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  position: relative;
  background: var(--ink-primary);
  color: white;
  padding: 8px 8px 12px;
  box-sizing: border-box;
}
.manual-edit-canvas-wrap {
  flex: 1;
  min-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
#manual-edit-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  touch-action: none;
  cursor: grab;
}
#manual-edit-canvas:active { cursor: grabbing; }

/* ==========================================
   POSTURE CAMERA SCREEN
   ========================================== */
.posture-camera-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh; /* iOS のアドレスバーを除いた実高さ */
  position: relative;
  background: var(--ink-primary);
  color: white;
  padding: 8px 4px 12px;
  box-sizing: border-box;
}

.posture-header {
  display: flex;
  align-items: center;
  padding: 8px 4px;
  background: transparent;
  position: relative;
  z-index: 5;
  flex-shrink: 0;
}

/* 撮影のコツ details: PC でもクリック反応するように list-style を完全に除去 */
.posture-tips-details > summary {
  list-style: none;
}
.posture-tips-details > summary::-webkit-details-marker {
  display: none;
}
.posture-tips-details > summary::marker {
  content: '';
}

/* ===== Posture Edit Screen ===== */
.edit-tab {
  padding: 10px 8px;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: 8px;
  color: var(--ink-secondary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.edit-tab.active {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
}

.edit-panel {
  background: var(--surface);
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--ink-border);
}

.edit-aspect-btn,
.edit-action-btn,
.filter-btn {
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--ink-border);
  border-radius: 6px;
  color: var(--ink-primary);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}
.edit-aspect-btn.active,
.filter-btn.active {
  background: var(--terracotta-light, #f0d4c2);
  border-color: var(--terracotta);
  color: var(--terracotta-dark, var(--terracotta));
}
.edit-action-btn {
  flex: 1;
  min-width: 0;
}

/* 並べて微調整モーダル */
.align-canvases {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.align-side {
  flex: 1;
  position: relative;
  background: #e8e8e3;
  border-radius: 8px;
  overflow: hidden;
}
.align-side canvas {
  display: block;
  width: 100%;
  height: auto;
}
.align-side-cap {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  border-radius: 4px;
  pointer-events: none;
}
.align-toggle {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: 8px;
  margin-bottom: 12px;
}
.align-toggle label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-primary);
  cursor: pointer;
  margin: 0;
}
.align-side-controls {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: 8px;
  margin-bottom: 10px;
}
.align-side-controls h4 {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--ink-primary);
  font-weight: 700;
}
.align-slider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.align-slider > span:first-child {
  width: 46px;
  font-size: 12px;
  color: var(--ink-secondary);
  flex-shrink: 0;
}
.align-slider input[type="range"] {
  flex: 1;
  min-width: 0;
}
.align-val {
  width: 54px;
  text-align: right;
  font-size: 12px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.posture-header .records-title {
  color: white;
  margin: 0 auto;
}

.posture-header .btn-back {
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
}

.posture-header .btn-back:hover {
  background: rgba(255,255,255,0.3);
}

.posture-step-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 6px;
}
.posture-step-item {
  background: rgba(0,0,0,0.5);
  color: rgba(255,255,255,0.5);
  padding: 1px 9px;
  border-radius: var(--radius-pill);
  font-size: 9.5px;
  font-weight: 700;
  transition: all var(--transition);
}
.posture-step-item.active {
  background: var(--terracotta);
  color: white;
  box-shadow: 0 1px 4px rgba(193,121,73,0.4);
}
.posture-step-line {
  width: 26px;
  height: 2px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
}
.posture-step-fill {
  width: 0%;
  height: 100%;
  background: var(--terracotta);
  transition: width 0.4s ease;
}

.camera-wrapper {
  flex: 1 1 auto;
  min-height: 66vh; /* カメラを大きく確保（contain の縦長映像が小さくなりすぎないように） */
  position: relative;
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#posture-video, #posture-canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  /* 全身を切り取らずに表示（見たまま＝解析範囲。頭〜足先を収めやすい） */
  object-fit: contain;
}

/* 撮影/アップロードの2択（コンパクト・カメラ枠を圧迫しない） */
.posture-mode-switch {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.posture-mode-btn {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  color: #fff;
  user-select: none;
  box-sizing: border-box;
}
.posture-mode-btn.active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: #fff;
}

/* 姿勢ラインの色チップ */
.posture-color-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.55);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.posture-swatch-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: block;
}
.posture-color-swatch.active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0,0,0,0.25);
}

/* 方法選択画面（撮る/アップロードの2択のみ）。ホームと同じ明るい背景 */
.posture-choose-screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--ink-primary);
}
.posture-choose-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 20px 18px 36px;
  box-sizing: border-box;
}
.posture-choose-lead {
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  margin: 0 0 4px;
}
.posture-choose-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 24px 16px;
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  box-sizing: border-box;
  border: 1.5px solid var(--ink-border);
  background: var(--surface);
  color: var(--ink-primary);
}
.posture-choose-btn.primary {
  background: var(--jade);
  border-color: var(--jade);
  color: #fff;
}
.posture-choose-btn:active { filter: brightness(0.97); }
.posture-choose-emoji { font-size: 30px; line-height: 1; }
.posture-choose-main { font-size: 17px; font-weight: 700; }
.posture-choose-sub { font-size: 12px; color: var(--ink-muted); }
.posture-choose-btn.primary .posture-choose-sub { color: rgba(255,255,255,0.85); }

#posture-canvas {
  z-index: 2;
}

.posture-loading {
  position: absolute;
  z-index: 3;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 20px 40px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.posture-instruction {
  max-width: 360px;
  color: rgba(255,255,255,0.85);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
}
/* テキストがある時だけ余白を取る（空の正面ステップではスペースを使わない） */
.posture-instruction:not(:empty) {
  margin: 8px auto 0;
  padding: 4px 12px;
}

.posture-actions {
  display: flex;
  justify-content: center;
  margin-top: 10px;
  margin-bottom: 6px;
}

.btn-measure {
  width: auto;
  min-width: 200px;
  max-width: 280px;
  padding: 12px 28px !important;
  font-size: 14.5px !important;
  margin-bottom: 0 !important;
  animation: none !important;
  box-shadow: 0 3px 12px rgba(0,0,0,0.35);
}
.btn-measure:disabled {
  background: rgba(255,255,255,0.2) !important;
  color: rgba(255,255,255,0.5) !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

/* ==========================================
   POSTURE RESULT SCREEN
   ========================================== */
.metrics-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.metric-result-item {
  background: var(--surface);
  border: 1px solid var(--ink-border);
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.m-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.m-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-primary);
}

.m-badge {
  font-size: 11px;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}
.badge-neutral {
  background: #E2E8F0;
  color: #4A5568;
}

.badge-amber {
  background: #FEF3C7;
  color: #92400E;
}

.badge-quality {
  background: #F3F4F6;
  color: #6B7280;
  border: 1px solid #D1D5DB;
}

/* Old badges for retro-compatibility if used elsewhere */
.badge-ok {
  background: var(--sage-light);
  color: var(--sage-dark);
}

.badge-warn {
  background: var(--risk-red-light);
  color: var(--risk-red-dark);
}

.badge-mild {
  background: #FFF3CD;
  color: #856404;
  border: 1px solid #FFDCA5;
}

.m-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--ink-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 8px;
}

.m-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.m-val {
  font-size: 12px;
  color: var(--ink-muted);
  text-align: right;
  font-family: var(--font-sans);
  font-weight: 500;
}

/* Stepper dots */
.stepper-wrap {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 380px;
}
.step-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-border);
  transition: all 0.28s ease;
  flex-shrink: 0;
}
.step-dot.done-yes  { background: var(--terracotta); transform: scale(1.05); }
.step-dot.done-no   { background: var(--sage); transform: scale(1.05); }
.step-dot.current   { background: var(--terracotta-dark); width: 18px; border-radius: var(--radius-pill); }

/* ==========================================
   RESULT SCREEN
   ========================================== */
#screen-result {
  padding: 0 24px 60px;
  background: var(--warm-white);
  overflow-y: auto;
}

.result-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 460px;
}

/* Top accent bar */
.result-top-bar {
  width: 100vw;
  height: 6px;
  margin-bottom: 40px;
  flex-shrink: 0;
}

/* Header */
.result-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
  animation: popIn 0.5s cubic-bezier(0.4,0,0.2,1) both;
}

.result-icon-ring {
  width: 100px; height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.result-icon-ring.risk-red {
  background: linear-gradient(135deg, #E05555, #C03535);
  box-shadow: 0 8px 28px rgba(217,79,79,0.36);
  animation: pulseRing 2.8s ease-in-out infinite;
}
.result-icon-ring.risk-yellow {
  background: linear-gradient(135deg, #E5981F, #C07010);
  box-shadow: 0 8px 28px rgba(212,136,26,0.32);
}
.result-icon-ring.risk-green {
  background: linear-gradient(135deg, #56A060, #32703A);
  box-shadow: 0 8px 28px rgba(78,139,85,0.32);
}

.result-icon-svg { width: 52px; height: 52px; }

.result-level-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.result-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
  letter-spacing: -0.2px;
}
.result-title.risk-red    { color: var(--risk-red-dark); }
.result-title.risk-yellow { color: var(--risk-yellow-dark); }
.result-title.risk-green  { color: var(--risk-green-dark); }

/* Message box */
.result-message-box {
  width: 100%;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1.5px solid transparent;
}
.result-message-box.risk-red {
  background: var(--risk-red-light);
  border-color: var(--risk-red-border);
}
.result-message-box.risk-yellow {
  background: var(--risk-yellow-light);
  border-color: var(--risk-yellow-border);
}
.result-message-box.risk-green {
  background: var(--risk-green-light);
  border-color: var(--risk-green-border);
}

.result-message {
  font-size: 14px;
  line-height: 1.7;
  font-weight: 400;
}
.risk-red    .result-message { color: var(--risk-red-dark); }
.risk-yellow .result-message { color: var(--risk-yellow-dark); }
.risk-green  .result-message { color: var(--risk-green-dark); }

/* Sections */
.result-section {
  width: 100%;
  margin-bottom: 14px;
}
.result-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--ink-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-left: 2px;
}
.green-title { color: var(--sage-dark); }

/* Flagged item */
.flagged-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  border: 1px solid transparent;
  font-size: 13.5px;
  line-height: 1.6;
  font-weight: 500;
}
/* 表示名のトピック（太字）／理由（小さく薄く）／配慮文（インライン） */
.flagged-item .fi-topic { font-weight: 600; }
.flagged-item .fi-reason { font-size: 12px; opacity: 0.8; margin-top: 3px; line-height: 1.5; font-weight: 400; }
.flagged-item .fi-note { font-size: 12px; opacity: 0.85; margin-top: 5px; line-height: 1.55; font-weight: 400; }
/* 黄項目に積む詳細分類（選択ラベル＋配慮文） */
.flagged-item .fi-detail { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(0,0,0,0.10); }
.flagged-item .fi-detail-heading { font-size: 11px; font-weight: 700; letter-spacing: 0.3px; opacity: 0.7; margin-bottom: 6px; }
/* 詳細メモは白カードに分け、濃色・高コントラストで可読性を上げる */
.flagged-item .fi-dcard { background: #fff; border: 1px solid var(--ink-border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.flagged-item .fi-dcard:last-child { margin-bottom: 0; }
.flagged-item .fi-dlabel { font-size: 13px; font-weight: 700; color: var(--ink-primary); line-height: 1.45; }
.flagged-item .fi-dnote { font-size: 12.5px; color: var(--ink-secondary); margin: 4px 0 0; line-height: 1.65; font-weight: 400; }
/* 詳細分類の折りたたみ（初期は閉じる。読みやすさ向上が目的） */
.flagged-item .fi-detail-collapse { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(0,0,0,0.10); }
.flagged-item .fi-detail-summary { font-size: 11.5px; font-weight: 700; letter-spacing: 0.3px; opacity: 0.75; cursor: pointer; list-style: none; user-select: none; }
.flagged-item .fi-detail-summary::-webkit-details-marker { display: none; }
.flagged-item .fi-detail-summary::before { content: '▶'; font-size: 9px; margin-right: 6px; }
.flagged-item .fi-detail-collapse[open] .fi-detail-summary::before { content: '▼'; }
.flagged-item .fi-detail-collapse .fi-detail { margin-top: 8px; padding-top: 0; border-top: none; }

/* 詳細分類画面 */
.detail-stage { padding: 0 4px; margin: 4px 0 10px; }
.detail-stage-label {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
  color: #9a5a31; background: rgba(193,121,73,0.12);
  border: 1px solid rgba(193,121,73,0.25); border-radius: 14px; padding: 4px 12px;
}
.detail-stage-note { font-size: 12px; color: var(--ink-secondary); line-height: 1.55; margin: 8px 0 0; }
.detail-screen-title { font-size: 18px; font-weight: 700; padding: 0 4px; margin: 8px 0 6px; color: var(--ink-primary); }
.detail-screen-intro { font-size: 13px; color: var(--ink-secondary); line-height: 1.6; padding: 0 4px; margin: 0 0 18px; }
.detail-group { margin-bottom: 18px; padding: 0 4px; }
.detail-region { font-size: 12px; font-weight: 700; letter-spacing: 0.5px; color: var(--terracotta); margin: 0 0 8px; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-chip {
  font-size: 13px; padding: 9px 14px; border-radius: 22px;
  border: 1.5px solid var(--ink-border); background: #fff; color: var(--ink-primary);
  cursor: pointer; font-family: inherit; line-height: 1.3;
}
.detail-chip.selected { background: rgba(193,121,73,0.10); border-color: var(--terracotta); color: #9a5a31; font-weight: 600; }
.detail-next-btn { width: 100%; margin-top: 8px; }
.flagged-item.risk-red {
  background: var(--risk-red-light);
  border-color: var(--risk-red-border);
  color: var(--risk-red-dark);
}
.flagged-item.risk-yellow {
  background: var(--risk-yellow-light);
  border-color: var(--risk-yellow-border);
  color: var(--risk-yellow-dark);
}

.flagged-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.risk-red    .flagged-dot { background: var(--risk-red); }
.risk-yellow .flagged-dot { background: var(--risk-yellow); }

/* Caution box */
.result-caution-box {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #FFFBF0;
  border: 1.5px solid rgba(212,136,26,0.22);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}
/* 赤の注意文：黄（クリーム）と区別するため赤系に */
.result-caution-box.caution-red {
  background: var(--risk-red-light);
  border-color: var(--risk-red-border);
}
.result-caution-box.caution-red .caution-text { color: var(--risk-red-dark); }
.caution-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.caution-text {
  font-size: 13px;
  color: var(--risk-yellow-dark);
  line-height: 1.55;
  font-weight: 500;
}

/* Clear items (green) */
.clear-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.clear-item::before {
  content: '✓';
  color: var(--sage);
  font-weight: 700;
  flex-shrink: 0;
  font-size: 14px;
}

/* Actions */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-bottom: 28px;
}

.btn-retry {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  background: var(--terracotta);
  color: white;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(193,121,73,0.32);
  transition: all var(--transition);
  letter-spacing: 0.3px;
}
.btn-retry:hover {
  background: var(--terracotta-dark);
  box-shadow: 0 6px 22px rgba(193,121,73,0.42);
  transform: translateY(-2px);
}
.btn-retry:active { transform: translateY(0); }

.btn-icon-sm { width: 16px; height: 16px; }

.btn-top {
  width: 100%;
  padding: 14px;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--ink-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-top:hover {
  border-color: var(--terracotta);
  color: var(--terracotta);
  background: var(--terracotta-light);
}

/* Bottom disclaimer */
.result-disclaimer-box {
  width: 100%;
  padding: 16px 20px;
  background: var(--surface-warm);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  text-align: center;
}
.result-disclaimer-text {
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.8;
}

/* Result message box color variants */
.result-msg-green  { background: var(--sage-light); border: 1px solid rgba(122,158,126,0.3); }
.result-msg-yellow { background: rgba(212,168,67,0.08); border: 1px solid rgba(212,168,67,0.3); }
.result-msg-red    { background: var(--risk-red-light); border: 1px solid var(--risk-red-border); }

/* ==========================================
   STAGE TRANSITION SCREEN
   ========================================== */
#screen-transition {
  background: var(--warm-white);
}

#screen-transition.active {
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
}

.transition-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  max-width: 340px;
  width: 100%;
  animation: screenFadeUp 0.4s ease both;
}

.transition-icon {
  font-size: 48px;
  margin-bottom: 4px;
}

.transition-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink-primary);
  line-height: 1.5;
}

.transition-message {
  font-size: 14px;
  color: var(--ink-secondary);
  line-height: 1.75;
}

.transition-stage-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  width: 100%;
}

.stage-detail {
  font-size: 13px;
  color: var(--ink-secondary);
  font-weight: 500;
}

.transition-btn {
  margin-top: 4px;
}

/* Stage badges */
.stage-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: white;
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.stage-badge-1 { background: var(--terracotta); }
.stage-badge-2 { background: var(--sage-dark); }

/* Category label update for stages */
.category-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  letter-spacing: 0.3px;
}





/* ==========================================
   AI Posture Check Card
   ========================================== */
.ai-posture-card {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid rgba(193,121,73,0.28);
  border-radius: var(--radius-lg);
  padding: 22px 20px 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(193,121,73,0.07);
  position: relative;
  overflow: hidden;
}

/* subtle background shimmer */
.ai-posture-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(193,121,73,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.ai-posture-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ai-posture-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-primary);
  letter-spacing: -0.1px;
}

.ai-posture-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: white;
  background: var(--terracotta);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  flex-shrink: 0;
}

.ai-posture-desc {
  font-size: 13px;
  color: var(--ink-secondary);
  line-height: 1.8;
  margin-bottom: 16px;
}

.ai-posture-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--terracotta-light);
  border-radius: var(--radius-md);
  border: 1px solid rgba(193,121,73,0.15);
}

.ai-posture-features li {
  font-size: 12.5px;
  color: var(--terracotta-dark);
  font-weight: 500;
  line-height: 1.5;
}

.ai-posture-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.btn-ai-posture {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: #D5CFC8;
  color: #9A8F84;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-pill);
  cursor: not-allowed;
  letter-spacing: 0.3px;
  transition: all var(--transition);
  position: relative;
}

.btn-ai-posture::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-primary);
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.btn-ai-posture:hover::after {
  opacity: 1;
}

.btn-arrow-sm {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.ai-posture-soon-note {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 380px) {
  .app-title        { font-size: 28px; }
  .app-catchcopy    { font-size: 16px; }
  .question-text    { font-size: 17px; }
  .question-card    { padding: 28px 22px 24px; }
  .btn-no, .btn-yes { padding: 16px 10px; }
  .result-title     { font-size: 19px; }
}

/* ==========================================
   CONSENT SCREEN (overlay modal)
   ========================================== */
.screen-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(44, 34, 24, 0.55);
  backdrop-filter: blur(4px);
  align-items: flex-end;
  justify-content: center;
}
.screen-overlay.active {
  display: flex;
  animation: overlayIn 0.3s ease both;
}
@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.consent-container {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.38s cubic-bezier(0.4,0,0.2,1) both;
  box-shadow: 0 -8px 40px rgba(44,34,24,0.18);
}
@keyframes sheetUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.consent-scroll {
  overflow-y: auto;
  padding: 36px 28px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* Onboarding dots */
.onb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-border, #e1e4e8);
  transition: background 0.2s ease, transform 0.2s ease;
}
.onb-dot.active {
  background: var(--sage-dark, #6a9a7b);
  transform: scale(1.2);
}

.consent-icon {
  font-size: 36px;
  margin-bottom: 16px;
}

.consent-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-primary);
  text-align: center;
  margin-bottom: 24px;
}

.consent-body {
  width: 100%;
  margin-bottom: 28px;
}

.consent-lead {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-secondary);
  margin-bottom: 14px;
}

.consent-section {
  background: var(--warm-white);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  border-left: 3px solid var(--terracotta);
}

.consent-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--terracotta-dark);
  margin-bottom: 6px;
}

.consent-section p {
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-secondary);
}

.consent-check-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--warm-white);
  border: 1.5px solid var(--ink-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), background var(--transition);
}
.consent-check-wrap:has(input:checked) {
  border-color: var(--sage);
  background: var(--sage-light);
}

.consent-check-wrap input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.consent-check-box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--ink-border);
  border-radius: 6px;
  flex-shrink: 0;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  margin-top: 1px;
}
.consent-check-wrap input:checked ~ .consent-check-box {
  background: var(--sage);
  border-color: var(--sage);
}
.consent-check-wrap input:checked ~ .consent-check-box::after {
  content: '';
  width: 12px;
  height: 7px;
  border-left: 2.5px solid white;
  border-bottom: 2.5px solid white;
  transform: rotate(-45deg) translate(1px, -1px);
  display: block;
}

.consent-check-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-primary);
  line-height: 1.5;
}

.btn-consent {
  width: 100%;
  padding: 18px;
  background: var(--terracotta);
  color: white;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(193,121,73,0.35);
  transition: all var(--transition);
  letter-spacing: 0.3px;
}
.btn-consent:disabled {
  background: #D5CFC8;
  color: #9A8F84;
  box-shadow: none;
  cursor: not-allowed;
}
.btn-consent:not(:disabled):hover {
  background: var(--terracotta-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(193,121,73,0.44);
}

/* ==========================================
   TOP — Expanded AI Posture Card
   ========================================== */
.top-posture-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1.5px solid rgba(193,121,73,0.28);
  border-radius: var(--radius-lg);
  padding: 20px 20px 18px;
  margin-bottom: 14px;
  box-shadow: 0 2px 12px rgba(193,121,73,0.07);
  animation: screenFadeUp 0.5s ease 0.6s both;
  position: relative;
  overflow: hidden;
}
.top-posture-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(193,121,73,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.top-posture-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.top-posture-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-primary);
}

.top-posture-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: white;
  background: var(--terracotta);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  flex-shrink: 0;
}

.top-posture-desc {
  font-size: 12.5px;
  color: var(--ink-secondary);
  line-height: 1.75;
  margin-bottom: 12px;
}

.top-posture-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--terracotta-light);
  border-radius: var(--radius-md);
  border: 1px solid rgba(193,121,73,0.14);
}

.top-posture-features li {
  font-size: 12px;
  color: var(--terracotta-dark);
  font-weight: 500;
  line-height: 1.4;
}

.btn-posture-try {
  width: 100%;
  padding: 11px;
  background: var(--terracotta);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  letter-spacing: 0.2px;
  position: relative;
  transition: background 0.18s ease, transform 0.12s ease;
  box-shadow: 0 3px 12px rgba(193,121,73,0.28);
}
.btn-posture-try:hover {
  background: var(--terracotta-dark);
  transform: translateY(-1px);
}
.btn-posture-try::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-primary);
  color: white;
  font-size: 10px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.btn-posture-try:hover::after { opacity: 1; }

/* ==========================================
   TOP — Clinical Reasoning Button
   ========================================== */
.btn-clinical {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  padding: 16px 24px;
  background: var(--surface);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: 15.5px;
  font-weight: 700;
  border: 1.5px solid rgba(122,158,126,0.4);
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(122,158,126,0.1);
  transition: all var(--transition);
  letter-spacing: 0.2px;
  margin-bottom: 20px;
  animation: screenFadeUp 0.5s ease 0.7s both;
}
.btn-clinical:hover {
  background: var(--sage-light);
  border-color: var(--sage);
  color: var(--sage-dark);
  box-shadow: 0 4px 16px rgba(122,158,126,0.22);
  transform: translateY(-2px);
}
.btn-clinical:active { transform: translateY(0); }

/* ==========================================
   CHAT SCREEN
   ========================================== */
#screen-chat {
  background: var(--warm-white);
  padding: 0;
}

.chat-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  min-height: 100vh; /* fallback */
  height: 100vh;     /* fallback */
  height: 100dvh;    /* iOS のアドレスバー/キーボードに追従する実高さ */
  max-height: 100dvh;
  overflow: hidden;  /* 横スクロール・はみ出し防止 */
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--ink-border);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.chat-header-icon { font-size: 22px; }

.chat-header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-primary);
  line-height: 1.2;
}

.chat-header-sub {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 400;
}

/* Notice bar */
.chat-notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: var(--jade-tint);
  border-bottom: 1px solid var(--ink-border);
  padding: 9px 16px;
  flex-shrink: 0;
}

.chat-notice-icon { flex-shrink: 0; margin-top: 2px; line-height: 0; }
.chat-notice-icon svg { width: 15px; height: 15px; stroke: var(--jade); fill: none; }

.chat-notice-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--terracotta-dark);
  margin-bottom: 3px;
  letter-spacing: 0.4px;
}

.chat-notice-text {
  font-size: 11.5px;
  color: var(--ink-secondary);
  line-height: 1.6;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-welcome {
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  max-width: 85%;
  align-self: flex-start;
}

.chat-welcome-text {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-secondary);
}

/* Bubbles */
.chat-bubble {
  max-width: 86%;
  padding: 13px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.75;
  animation: screenFadeUp 0.22s ease both;
}

.chat-bubble.user {
  background: var(--terracotta);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  background: var(--surface);
  color: var(--ink-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--ink-border);
  white-space: pre-wrap;
  max-width: 94%;
}

.chat-bubble.assistant hr {
  border: none;
  border-top: 1px solid var(--ink-border);
  margin: 10px 0;
}
/* AI回答のマークダウン描画（renderAssistantMarkdown が付与するタグ用） */
.chat-bubble.assistant .md-h { font-weight: 700; margin: 9px 0 3px; line-height: 1.45; }
.chat-bubble.assistant .md-h:first-child { margin-top: 0; }
.chat-bubble.assistant .md-h1 { font-size: 15px; }
.chat-bubble.assistant .md-h2 { font-size: 14.5px; }
.chat-bubble.assistant .md-h3 { font-size: 14px; opacity: 0.85; }
.chat-bubble.assistant ul, .chat-bubble.assistant ol { margin: 3px 0 6px; padding-left: 19px; }
.chat-bubble.assistant li { margin: 1px 0; line-height: 1.65; }
.chat-bubble.assistant > div { line-height: 1.7; }
.chat-bubble.assistant hr { margin: 8px 0; }
.chat-bubble.assistant strong { font-weight: 700; }
.chat-bubble.assistant code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-lg);
  align-self: flex-start;
  animation: screenFadeUp 0.22s ease both;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* Chat error */
.chat-error {
  background: var(--risk-red-light);
  color: var(--risk-red-dark);
  border: 1px solid var(--risk-red-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  align-self: stretch;
}

/* Input area */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border-top: 1px solid var(--ink-border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink-primary);
  background: var(--warm-white);
  border: 1.5px solid var(--ink-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  resize: none;
  line-height: 1.65;
  transition: border-color var(--transition);
  max-height: 130px;
  overflow-y: auto;
}
.chat-input:focus {
  outline: none;
  border-color: var(--terracotta);
}
.chat-input::placeholder { color: var(--ink-muted); }

.chat-send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--terracotta);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 3px 12px rgba(193,121,73,0.32);
}
.chat-send-btn:hover {
  background: var(--terracotta-dark);
  transform: scale(1.06);
}
.chat-send-btn:active { transform: scale(0.97); }
.chat-send-btn:disabled {
  background: #D5CFC8;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.send-icon { width: 18px; height: 18px; color: white; }

/* ==========================================
   Session Records Button (Home Screen)
   ========================================== */
.btn-session {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  padding: 15px 24px;
  background: var(--surface);
  color: var(--sage-dark);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  border: 2px solid var(--sage);
  border-radius: var(--radius-pill);
  cursor: pointer;
  letter-spacing: 0.2px;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
  margin-bottom: 10px;
  animation: screenFadeUp 0.5s ease 0.65s both;
}
.btn-session:hover {
  background: var(--sage-light);
  border-color: var(--sage-dark);
  transform: translateY(-1px);
}
.btn-session:active { transform: scale(0.98); }

/* ==========================================
   Records Screen — Container & Header
   ========================================== */
#screen-records.active,
#screen-record-form.active,
#screen-record-detail.active {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
}

.records-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 32px;
}

.records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--ink-border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.records-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-primary);
  letter-spacing: -0.2px;
}

.btn-new-record {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--terracotta);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}
.btn-new-record:hover { background: var(--terracotta-dark); transform: scale(1.08); }

/* ==========================================
   Records List
   ========================================== */
.records-list-area {
  flex: 1;
  padding: 16px;
}

.records-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  gap: 8px;
}
.records-empty-icon { font-size: 40px; }
.records-empty-text { font-size: 16px; font-weight: 700; color: var(--ink-secondary); }
.records-empty-sub  { font-size: 13px; color: var(--ink-muted); }

.records-list { display: flex; flex-direction: column; gap: 10px; }

.record-card {
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.12s ease;
  animation: screenFadeUp 0.3s ease both;
}
.record-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
.record-card:active { transform: scale(0.99); }

.record-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.record-card-id   { font-size: 15px; font-weight: 700; color: var(--ink-primary); font-family: var(--font-serif); }
.record-card-date { font-size: 12px; color: var(--ink-muted); }

.record-card-bottom { display: flex; align-items: center; gap: 8px; }

.record-risk-badge {
  font-size: 11px; font-weight: 600;
  border-radius: 8px; padding: 3px 10px; flex-shrink: 0;
}
.risk-badge-green  { background: #F4F3EE;                color: var(--ink-muted); }
.risk-badge-yellow { background: var(--risk-yellow-light); color: var(--risk-yellow-dark); }
.risk-badge-red    { background: var(--risk-red-light);    color: var(--risk-red-dark); }

.record-card-memo {
  font-size: 12.5px; color: var(--ink-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
/* AI相談メモは複数行を全文表示（省略しない） */
#cd-ai-convs-list .record-card-memo {
  white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.6;
}

/* セッション履歴カード（本文は訴えで統一・ラベル付き・体調/痛み併記） */
.sess-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.sess-date { font-size: 15px; font-weight: 700; color: var(--ink-primary); font-family: var(--font-serif); display: flex; align-items: center; flex-shrink: 0; }
.sess-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sess-state { font-size: 12px; color: var(--ink-secondary); white-space: nowrap; }
.sess-mode { font-size: 10.5px; font-weight: 700; color: var(--ink-faint); letter-spacing: .06em; flex-shrink: 0; }
.sess-line { font-size: 12.5px; color: var(--ink-secondary); line-height: 1.5; display: flex; gap: 7px; align-items: baseline; }
.sess-line + .sess-line { margin-top: 3px; }
.sess-label { font-size: 10.5px; font-weight: 700; color: var(--jade-ink); background: var(--jade-tint); border-radius: 5px; padding: 1px 6px; flex-shrink: 0; }
.sess-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-text.muted { color: var(--ink-muted); }
/* 引き継ぎカードの構造化表示（renderHandoffHtml が付与するクラス用） */
#ai-context-body .hc-h { font-weight: 700; color: var(--ink-primary); margin: 9px 0 2px; }
#ai-context-body .hc-h:first-child { margin-top: 0; }
#ai-context-body .hc-li { padding-left: 12px; line-height: 1.55; }
#ai-context-body .hc-p { line-height: 1.55; }
#ai-context-body .hc-sp { height: 6px; }

/* ==========================================
   Record Form
   ========================================== */
.record-form-body { padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label { font-size: 13px; font-weight: 700; color: var(--ink-secondary); letter-spacing: 0.2px; }

.form-hint { font-size: 11.5px; color: var(--risk-red-dark); font-weight: 500; }

.form-input {
  width: 100%; padding: 12px 14px;
  font-family: var(--font-sans); font-size: 15px; color: var(--ink-primary);
  background: var(--surface); border: 1.5px solid var(--ink-border);
  border-radius: var(--radius-md); outline: none; transition: border-color 0.15s ease;
}
.form-input:focus { border-color: var(--terracotta); }

.form-textarea {
  width: 100%; padding: 12px 14px;
  font-family: var(--font-sans); font-size: 14.5px; color: var(--ink-primary);
  background: var(--surface); border: 1.5px solid var(--ink-border);
  border-radius: var(--radius-md); resize: vertical; outline: none;
  line-height: 1.6; transition: border-color 0.15s ease;
}
.form-textarea:focus { border-color: var(--terracotta); }

.form-char-count { font-size: 11px; color: var(--ink-muted); text-align: right; }

.risk-level-selector { display: flex; gap: 8px; }
.risk-option { flex: 1; cursor: pointer; }
.risk-option input[type="radio"] { display: none; }
.risk-option-inner {
  display: block; text-align: center; padding: 10px 6px;
  border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
  border: 2px solid var(--ink-border); background: var(--surface); transition: all 0.15s ease;
}
.risk-option-green  input:checked ~ .risk-option-inner { border-color: var(--sage);     background: var(--sage-light);        color: var(--sage-dark); }
.risk-option-yellow input:checked ~ .risk-option-inner { border-color: #D4A843;          background: rgba(212,168,67,0.1);      color: #7A5800; }
.risk-option-red    input:checked ~ .risk-option-inner { border-color: var(--risk-red);  background: var(--risk-red-light);     color: var(--risk-red-dark); }

.checked-items-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.check-item-label {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--surface); border: 1.5px solid var(--ink-border);
  border-radius: var(--radius-md); cursor: pointer; font-size: 13px;
  color: var(--ink-secondary); font-weight: 500; transition: all 0.12s ease;
}
.check-item-label:has(input:checked) {
  border-color: var(--terracotta); background: var(--terracotta-light); color: var(--terracotta-dark);
}
.check-item-label input[type="checkbox"] { accent-color: var(--terracotta); width: 16px; height: 16px; flex-shrink: 0; }

.form-save-btn { margin-top: 4px; }

.btn-delete-record {
  width: 100%; padding: 12px; background: none; border: none;
  color: var(--risk-red); font-family: var(--font-sans); font-size: 13.5px;
  font-weight: 600; cursor: pointer; text-align: center; text-decoration: underline; margin-top: -8px;
}

/* ==========================================
   Record Detail
   ========================================== */
.record-detail-body { padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; }

/* 記録詳細スリム版：1枚にまとめ、メタは1行・本文は仕切り線で区切る */
.rd-card { background: var(--surface); border: 1px solid var(--ink-border); border-radius: var(--radius-lg); padding: 16px 18px; }
.rd-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.rd-name { font-size: 18px; font-weight: 700; font-family: var(--font-serif); color: var(--ink-primary); }
.rd-meta { font-size: 12.5px; color: var(--ink-muted); margin-top: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line-faint); }
.rd-sec { padding: 13px 0; border-bottom: 1px solid var(--line-faint); }
.rd-sec:last-child { border-bottom: none; padding-bottom: 0; }
.rd-label { font-size: 11px; font-weight: 700; color: var(--jade-ink); letter-spacing: .04em; margin-bottom: 4px; }
.rd-text { font-size: 14px; color: var(--ink-primary); line-height: 1.7; white-space: pre-wrap; }

.detail-section {
  background: var(--surface); border: 1px solid var(--ink-border);
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.detail-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--ink-muted); margin-bottom: 6px;
}
.detail-section-value { font-size: 15px; font-weight: 600; color: var(--ink-primary); }
.detail-items-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.detail-item-tag {
  background: var(--terracotta-light); color: var(--terracotta-dark);
  border-radius: var(--radius-pill); padding: 4px 12px; font-size: 12.5px; font-weight: 600;
}
.detail-memo-text { font-size: 14px; color: var(--ink-primary); line-height: 1.7; white-space: pre-wrap; }

.record-detail-ai-action { padding: 0 16px 10px; }
.btn-ai-consult {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 16px; background: var(--ink-primary); color: #fff;
  border: none; border-radius: var(--radius-pill);
  font-family: var(--font-sans); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: opacity 0.15s ease;
}
.btn-ai-consult:hover { opacity: 0.85; }

.btn-link-inline {
  background: none; border: none; padding: 6px 10px;
  color: var(--terracotta); font-weight: 700; font-size: 13px;
  cursor: pointer; text-align: left;
}
.btn-link-inline:hover { text-decoration: underline; }

/* クライアント詳細：記録を主アクション、AI/リスクを従に（F1） */
.btn-record-primary {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px 20px; background: var(--terracotta); color: #fff;
  border: none; border-radius: var(--radius-pill);
  font-family: var(--font-sans); font-size: 16px; font-weight: 700;
  letter-spacing: 0.3px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(193,121,73,0.32);
  transition: all var(--transition);
}
.btn-record-primary:hover {
  background: var(--terracotta-dark);
  box-shadow: 0 8px 26px rgba(193,121,73,0.42);
  transform: translateY(-2px);
}
.btn-record-primary:active { transform: translateY(0); }

.btn-action-secondary {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; background: transparent; color: var(--ink-secondary);
  border: 1px solid var(--ink-border); border-radius: var(--radius-pill);
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease;
}
.btn-action-secondary:hover { background: var(--surface); color: var(--ink-primary); border-color: var(--ink-muted); }

.record-detail-actions { display: flex; gap: 10px; padding: 0 16px 16px; }

.btn-edit-record {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 16px; background: var(--sage-light); color: var(--sage-dark);
  border: 1.5px solid var(--sage); border-radius: var(--radius-pill);
  font-family: var(--font-sans); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: background 0.15s ease;
}
.btn-edit-record:hover { background: var(--sage); color: white; }

.btn-delete-record-detail {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 16px; background: var(--risk-red-light); color: var(--risk-red-dark);
  border: 1.5px solid var(--risk-red-border); border-radius: var(--radius-pill);
  font-family: var(--font-sans); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: background 0.15s ease;
}
.btn-delete-record-detail:hover { background: var(--risk-red); color: white; }

/* ==========================================
   Client Detail — Header card, risk pill, profile collapsible
   ========================================== */
.client-header-card {
  padding: 16px;
  background: var(--surface-warm);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
}
.client-header-top {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.client-header-name {
  margin: 0;
  font-size: 19px; font-weight: 700;
  color: var(--ink-primary);
  font-family: var(--font-serif);
  letter-spacing: 0.01em;
}
.client-header-meta {
  margin-top: 6px;
  font-size: 12px; color: var(--ink-muted);
  line-height: 1.6;
}
.client-header-meta:empty { display: none; }

/* ヘッダーの編集（✏️）ボタン */
.cd-edit-btn { margin-left: auto; width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border: 1px solid var(--ink-border); background: var(--surface); border-radius: 8px; color: var(--jade); cursor: pointer; padding: 0; }
.cd-edit-btn:hover { background: var(--jade-tint); }
.cd-edit-btn svg { width: 16px; height: 16px; }

/* クライアント詳細だけ、セクション間の余白を整える（他画面の record-form-body は据え置き） */
.record-form-body.cd-body { gap: 16px; }
/* 主役の記録ボタンは上下にわずかに余白を足して引き立てる */
.cd-body .btn-record-primary { margin: 4px 0; }

/* 「そのほか」圧縮折りたたみ（リスクチェック履歴・AI相談メモ） */
.cd-mini { background: var(--surface); border: 1px solid var(--ink-border); border-radius: 10px; overflow: hidden; }
.cd-mini + .cd-mini { margin-top: -6px; }
.cd-mini-sum { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; cursor: pointer; list-style: none; }
.cd-mini-sum::-webkit-details-marker { display: none; }
.cd-mini-l { font-size: 13px; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.cd-mini-l b { font-weight: 700; color: var(--ink-primary); }
.cd-mini-sub { font-size: 12px; color: var(--ink-muted); }
.cd-mini-arw { color: var(--ink-faint); font-size: 18px; line-height: 1; transition: transform .15s ease; }
.cd-mini[open] .cd-mini-arw { transform: rotate(90deg); }
.cd-mini > .records-list { padding: 0 14px 12px; }

/* サブ操作（控えめ2列） */
.cd-subacts { display: flex; gap: 10px; margin-top: 6px; }
.cd-subbtn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 13px; border-radius: 12px; border: 1px solid var(--jade); background: var(--surface); color: var(--jade); font-size: 13.5px; font-weight: 600; font-family: var(--font-sans); cursor: pointer; }
.cd-subbtn:hover { background: var(--jade-tint); }
.cd-subbtn svg { width: 16px; height: 16px; flex-shrink: 0; }

.client-risk-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
/* 該当なしは「緑」を使わない（安全のお墨付きを出さない）＝グレー表示 */
.client-risk-pill[data-risk="green"]  { background: #F4F3EE; color: var(--ink-muted); }
.client-risk-pill[data-risk="yellow"] { background: var(--risk-yellow-light); color: var(--risk-yellow-dark); }
.client-risk-pill[data-risk="red"]    { background: var(--risk-red-light);    color: var(--risk-red-dark); }
.client-risk-pill[data-risk="none"]   { background: #F4F3EE; color: var(--ink-muted); }

/* 信号機の代わりの色ドット（絵文字廃止） */
.risk-dot{ width:8px; height:8px; border-radius:50%; display:inline-block; flex-shrink:0; }
.risk-dot.dot-red{ background:var(--risk-red); }
.risk-dot.dot-yellow{ background:var(--risk-yellow); }
.risk-dot.dot-green{ background:#C6C4BC; }
.risk-dot.dot-none{ background:var(--ink-faint); }

.client-profile-details {
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.client-profile-summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 600;
  color: var(--ink-secondary);
}
.client-profile-summary::-webkit-details-marker { display: none; }
.client-profile-chevron {
  transition: transform 0.2s ease;
  font-size: 10px;
  color: var(--ink-muted);
}
.client-profile-details[open] .client-profile-chevron {
  transform: rotate(180deg);
}
.client-profile-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--ink-border);
  padding-top: 16px;
}
.client-delete-divider {
  margin: 24px 0 16px;
  border-top: 1px dashed var(--ink-border);
}
.btn-delete-client {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 12px;
  background: none;
  border: 1px solid var(--risk-red, #e53e3e);
  border-radius: var(--radius-md);
  color: var(--risk-red, #e53e3e);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-delete-client:hover {
  background: var(--risk-red, #e53e3e);
  color: white;
}

/* ==========================================
   Record Form — Medical Considerations section
   ========================================== */
.rec-medical-details {
  margin: 0 0 20px;
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}
.rec-medical-summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
  color: var(--ink-secondary);
}
.rec-medical-summary::-webkit-details-marker { display: none; }
.rec-medical-label { flex: 1; }
.rec-medical-count {
  font-size: 12px;
  color: var(--terracotta-dark);
  background: var(--surface-warm);
  border: 1px solid var(--ink-border);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.rec-medical-count:empty { display: none; }
.rec-medical-chevron {
  font-size: 10px;
  color: var(--ink-muted);
  transition: transform 0.2s ease;
}
.rec-medical-details[open] .rec-medical-chevron { transform: rotate(180deg); }
.rec-medical-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--ink-border);
  padding-top: 14px;
}

.rec-items-suggestions {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--sage-light, #eef2ec);
  border: 1px solid var(--sage-mid, #c9d4c1);
  border-radius: var(--radius-md);
}
.rec-items-suggestions-label {
  margin: 0 0 2px;
  font-size: 13px; font-weight: 700;
  color: var(--sage-dark, #4a6b3e);
}
.rec-items-suggestions-sub {
  margin: 0 0 10px;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.rec-items-suggestions-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.rec-suggestion-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px;
  background: white;
  border: 1px solid var(--sage-mid, #c9d4c1);
  border-radius: 999px;
  font-size: 12px;
  color: var(--sage-dark, #4a6b3e);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
}
.rec-suggestion-chip:hover {
  background: var(--sage-dark, #4a6b3e);
  color: white;
}
.rec-suggestion-chip-plus { font-size: 14px; line-height: 1; }

.rec-items-group { margin-bottom: 16px; }
.rec-items-group:last-child { margin-bottom: 0; }

/* 配慮したい点の折りたたみ（表示名だけで登録できるよう初期は閉じる） */
.medical-details > summary { list-style: none; display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 0; }
.medical-details > summary::-webkit-details-marker { display: none; }
.medical-details > summary::before { content: '▶'; font-size: 10px; color: var(--ink-muted); transition: transform 0.15s ease; }
.medical-details[open] > summary::before { transform: rotate(90deg); }
.rec-items-group-title {
  margin: 0 0 8px;
  font-size: 12px; font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  text-transform: none;
}
.rec-items-checkboxes {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.rec-item-label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--ink-border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.rec-item-label:hover {
  border-color: var(--terracotta);
}
.rec-item-label:has(input:checked) {
  background: var(--risk-yellow-light);
  border-color: var(--risk-yellow-border);
  color: var(--risk-yellow-dark);
  font-weight: 600;
}
.rec-item-label input[type=checkbox] {
  width: 14px; height: 14px;
  accent-color: var(--risk-yellow-dark);
  cursor: pointer;
}

/* ==========================================
   Clients List — top CTA buttons
   ========================================== */
.clients-cta-area {
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 16px 16px;
}
.btn-clients-primary,
.btn-clients-secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font-sans);
  font-size: 15px; font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.2px;
}
.btn-clients-primary {
  background: var(--terracotta);
  color: white;
  border: none;
  box-shadow: 0 4px 14px rgba(193,121,73,0.28);
}
.btn-clients-primary:hover {
  background: var(--terracotta-dark);
  box-shadow: 0 6px 18px rgba(193,121,73,0.36);
  transform: translateY(-1px);
}
.btn-clients-primary:active { transform: translateY(0); }

.btn-clients-secondary {
  background: var(--surface-warm);
  color: var(--ink-primary);
  border: 1px solid var(--ink-border);
}
.btn-clients-secondary:hover {
  background: var(--surface);
  border-color: var(--terracotta);
  color: var(--terracotta-dark);
}
.btn-clients-primary .cta-icon,
.btn-clients-secondary .cta-icon {
  font-size: 18px; font-weight: 700; line-height: 1;
}
.clients-cta-hint {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.5;
}

/* ==========================================
   Privacy Notice (all record screens)
   ========================================== */
.records-privacy-notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin: auto 16px 0; padding: 14px 16px;
  background: var(--surface-warm); border: 1px solid var(--ink-border); border-radius: var(--radius-md);
}
.records-privacy-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.records-privacy-text { font-size: 11.5px; color: var(--ink-muted); line-height: 1.7; }

/* ==========================================
   Record Form — 3-Mode UI
   ========================================== */

/* Mode selector */
.record-mode-selector {
  display: flex; gap: 8px;
}
.mode-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 10px 6px; border-radius: 12px;
  border: 1.5px solid var(--ink-border); background: var(--surface);
  cursor: pointer; transition: all 0.15s ease;
}
.mode-btn-icon { font-size: 18px; line-height: 1; }
.mode-btn-label { font-size: 13px; font-weight: 700; color: var(--ink-primary); font-family: var(--font-sans); }
.mode-btn-sub { font-size: 10px; color: var(--ink-muted); font-family: var(--font-sans); }
.mode-btn.active {
  border-color: var(--ink-primary); background: var(--ink-primary);
}
.mode-btn.active .mode-btn-label,
.mode-btn.active .mode-btn-sub { color: #fff; }
.mode-btn.active .mode-btn-icon { filter: brightness(10); }

/* Condition selector */
.condition-selector {
  display: flex; gap: 8px;
}
.condition-btn {
  flex: 1; padding: 10px 4px; border-radius: 10px;
  font-size: 13px; font-weight: 700; font-family: var(--font-sans);
  border: 1.5px solid var(--ink-border); background: var(--surface);
  color: var(--ink-secondary); cursor: pointer; transition: all 0.15s ease;
}
.condition-btn.good.active  { background: #e6f4ea; border-color: #4caf50; color: #2e7d32; }
.condition-btn.normal.active{ background: #f0f0f0; border-color: #9e9e9e; color: #424242; }
.condition-btn.poor.active  { background: #fff3e0; border-color: #ff9800; color: #e65100; }
.condition-btn.good:hover  { border-color: #4caf50; }
.condition-btn.normal:hover{ border-color: #9e9e9e; }
.condition-btn.poor:hover  { border-color: #ff9800; }

/* Pain toggle */
.pain-toggle {
  display: flex; gap: 8px;
}
.pain-toggle-btn {
  flex: 1; padding: 9px; border-radius: 10px;
  font-size: 13px; font-weight: 700; font-family: var(--font-sans);
  border: 1.5px solid var(--ink-border); background: var(--surface);
  color: var(--ink-secondary); cursor: pointer; transition: all 0.15s ease;
}
.pain-toggle-btn.selected { border-color: var(--ink-primary); background: var(--ink-primary); color: #fff; }

/* NRS buttons */
.nrs-row {
  display: flex; gap: 4px;
}
.nrs-btn {
  flex: 1; padding: 8px 0; border-radius: 6px; border: 1px solid transparent;
  font-size: 12px; font-weight: 700; font-family: var(--font-sans);
  cursor: pointer; transition: all 0.15s ease; color: #fff;
  text-align: center;
}
.nrs-btn:nth-child(1)  { background: #43a047; }
.nrs-btn:nth-child(2)  { background: #66bb6a; }
.nrs-btn:nth-child(3)  { background: #9ccc65; }
.nrs-btn:nth-child(4)  { background: #d4e157; color: #555; }
.nrs-btn:nth-child(5)  { background: #ffee58; color: #555; }
.nrs-btn:nth-child(6)  { background: #ffca28; color: #555; }
.nrs-btn:nth-child(7)  { background: #ffa726; }
.nrs-btn:nth-child(8)  { background: #ef6c00; }
.nrs-btn:nth-child(9)  { background: #e53935; }
.nrs-btn:nth-child(10) { background: #c62828; }
.nrs-btn:nth-child(11) { background: #7b1fa2; }
.nrs-btn.selected { outline: 3px solid var(--ink-primary); outline-offset: 1px; transform: scale(1.15); }

/* SOAP labels */
.soap-label {
  font-size: 11px; font-weight: 500; color: var(--ink-muted);
  margin-left: 6px; font-family: var(--font-sans);
}

/* Optional badge */
.form-optional {
  font-size: 11px; font-weight: 500; color: var(--ink-muted);
  background: var(--bg-light); border: 1px solid var(--ink-border);
  border-radius: 4px; padding: 1px 5px; margin-left: 6px;
}

/* ===== Toast notifications ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}

.toast-item {
  background: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-primary);
  border-left: 4px solid var(--sage-mid);
  pointer-events: auto;
  white-space: pre-wrap;
  word-break: break-word;
  animation: toastIn 0.28s ease forwards;
}

.toast-item.toast-success { border-left-color: #56a374; }
.toast-item.toast-warning { border-left-color: #d4a553; }
.toast-item.toast-error   { border-left-color: var(--terracotta); }
.toast-item.toast-info    { border-left-color: var(--sage-mid); }

.toast-item.toast-hiding {
  animation: toastOut 0.28s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(110%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(110%); }
}

@media (max-width: 480px) {
  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

/* --- AI chat mobile usability fixes --- */

.chat-container {
  min-height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden;
}

.chat-notice {
  flex-shrink: 0;
  background: var(--jade-tint);
  border-bottom: 1px solid var(--ink-border);
  overflow-x: hidden;
}

.chat-notice-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.chat-notice-summary::-webkit-details-marker {
  display: none;
}

.chat-notice-summary::marker {
  content: "";
}

.chat-notice-icon {
  flex-shrink: 0;
  line-height: 0;
}

.chat-notice-icon svg {
  width: 15px;
  height: 15px;
  stroke: var(--jade);
  fill: none;
}

.chat-notice-short {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-secondary);
}

.chat-notice-toggle {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--jade);
  white-space: nowrap;
}

.chat-notice[open] .chat-notice-toggle::after {
  content: "（閉じる）";
  font-weight: 400;
  color: var(--ink-muted);
}

.chat-notice-detail {
  padding: 0 16px 10px 40px;
}

.chat-notice-text {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-secondary);
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.chat-input-area {
  flex-shrink: 0;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}

.chat-input {
  font-size: 16px !important;
  line-height: 1.5;
  min-height: 44px;
  max-height: 120px;
  resize: none;
}

.chat-send-btn {
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
}

.chat-bubble {
  max-width: 85%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

body,
.chat-container,
.chat-messages {
  overflow-x: hidden;
}

@media (max-width: 600px) {
  .chat-notice-summary {
    padding: 8px 12px;
    gap: 7px;
  }

  .chat-notice-short {
    font-size: 12px;
  }

  .chat-notice-toggle {
    font-size: 12px;
  }

  .chat-notice-detail {
    padding: 0 12px 9px 34px;
  }

  .chat-notice-text {
    font-size: 11.5px;
    line-height: 1.6;
  }

  .chat-input-area {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}


/* --- AI chat notice details layout fix --- */

.chat-notice {
  display: block !important;
  width: 100%;
  box-sizing: border-box;
}

.chat-notice-summary {
  width: 100%;
  box-sizing: border-box;
}

.chat-notice-detail {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.chat-notice[open] .chat-notice-summary {
  align-items: flex-start;
}

.chat-notice[open] .chat-notice-short {
  white-space: normal;
}

@media (max-width: 600px) {
  .chat-notice-summary {
    align-items: flex-start;
  }

  .chat-notice-detail {
    padding: 0 12px 10px 34px;
  }
}

