:root {
  --sakura-50: #FFF0F5;
  --sakura-100: #FFD6E7;
  --sakura-200: #FFB3CF;
  --sakura-400: #F472A8;
  --sakura-600: #C44D87;
  --sakura-800: #7D1F52;
  --sakura-900: #3D0A26;
  --leaf-500: #5BA25B;
  --leaf-600: #3E7D3E;
  --amber-500: #D97706;
  --red-500: #DC2626;
  --bg: #FEF6F9;
  --surface: #FFFAFC;
  --border: rgba(196, 77, 135, 0.15);
  --border-mid: rgba(196, 77, 135, 0.28);
  --text-primary: #2D1018;
  --text-secondary: #7D4560;
  --text-muted: #B088A0;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
}

body.dark-mode {
  --bg: #1a0d12;
  --surface: #241018;
  --border: rgba(244, 114, 168, 0.18);
  --border-mid: rgba(244, 114, 168, 0.32);
  --text-primary: #f8e4ef;
  --text-secondary: #e0a0c8;
  --text-muted: #9a6080;
  --sakura-50: #2a1020;
  --sakura-100: #3d1830;
  --sakura-200: #5a2444;
}
body.dark-mode .card { background: rgba(42, 16, 32, 0.72); }
body.dark-mode .howto-box { background: #241018; color: var(--text-primary); }
body.dark-mode .file-drop { background: rgba(42, 16, 32, 0.72); }
body.dark-mode .result-card { background: rgba(42, 16, 32, 0.72); }
body.dark-mode .result-ok, body.dark-mode .result-healthy { background: rgba(13, 42, 26, 0.72) !important; border-color: #2a6a44 !important; color: #6ee7a8 !important; }
body.dark-mode .result-mid { background: rgba(42, 24, 0, 0.72) !important; border-color: #8a4400 !important; color: #ffb066 !important; }
body.dark-mode .result-severe { background: rgba(42, 8, 8, 0.72) !important; border-color: #8a1a1a !important; color: #ff8888 !important; }
body.dark-mode .result-not-sakura { background: rgba(26, 26, 42, 0.72) !important; border-color: #4a4a8a !important; color: #aaaaee !important; }
body.dark-mode .model-status { background: rgba(26, 13, 18, 0.72); }

/* デフォルト背景色（季節ごと） */
body.season-spring { --bg: #FEF6F9; }
body.season-summer { --bg: #EEF9EE; }
body.season-autumn { --bg: #FFF2E2; }
body.season-winter { --bg: #FFFFFF; }
body.dark-mode.season-spring { --bg: #1a0d12; }
body.dark-mode.season-summer { --bg: #0d1a10; }
body.dark-mode.season-autumn { --bg: #241505; }
body.dark-mode.season-winter { --bg: #17181a; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Zen Maru Gothic', sans-serif;
  background: var(--bg);
  min-height: 100dvh;
  color: var(--text-primary);
  padding: 0;
  overflow-x: hidden;
}

/* 桜の花びら背景 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(244,114,168,0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 70%, rgba(244,114,168,0.05) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 50%, rgba(255,214,231,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* 季節の背景画像 */
.season-bg-img {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
  transition: opacity 0.5s ease;
  pointer-events: none;
  display: none;
}
body.dark-mode .season-bg-img { opacity: 0.3; }

/* 浮かぶ花びらアニメ */
.petal {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  animation: petalFall linear infinite;
}
.petal svg { fill: rgba(244,114,168,0.3); }
@keyframes petalFall {
  0% { transform: translateY(-40px) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 0.6; }
  100% { transform: translateY(100dvh) rotate(720deg); opacity: 0; }
}

/* レイアウト */
.app {
  position: relative;
  z-index: 1;
  max-width: 440px;
  margin: 0 auto;
  padding: 0 0 3rem;
}

/* ヘッダー */
.app-header {
  padding: 1.2rem 1.5rem 1.5rem;
  text-align: center;
  background: rgba(255, 250, 252, 0.72);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin: 0 0.5rem;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.dark-mode .app-header {
  background: rgba(26, 13, 18, 0.72);
}
.header-top-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}
.header-col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.header-col-left  { align-items: flex-start; justify-self: start; }
.header-col-right { align-items: flex-end;   justify-self: end; }
.howto-reopen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(0,0,0,0.05);
  border: 1.5px solid var(--border-mid);
  border-radius: 99px;
  padding: 0.28rem 0.75rem;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.howto-reopen-btn:hover { background: rgba(0,0,0,0.1); }
.header-emblem {
  width: 68px;
  height: 68px;
  margin: 0;
  align-self: center;
  background: linear-gradient(135deg, var(--sakura-100) 0%, var(--sakura-200) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 4px 20px rgba(196,77,135,0.18), inset 0 1px 0 rgba(255,255,255,0.7);
  border: 1.5px solid var(--border-mid);
}
.app-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.6rem;
  font-weight: 300;
  color: var(--sakura-800);
  letter-spacing: 0.12em;
}
.app-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  letter-spacing: 0.05em;
}

/* カード */
.card {
  background: rgba(255, 250, 252, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin: 0 1rem 1rem;
  overflow: hidden;
}
.card-section {
  padding: 1.25rem 1.25rem 0;
}
.card-section:last-child { padding-bottom: 1.25rem; }

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* ファイル入力 */
.file-drop {
  border: 1.5px dashed var(--border-mid);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  background: rgba(255, 240, 245, 0.72);
}
.file-drop:hover { border-color: var(--sakura-400); background: rgba(255, 240, 248, 0.72); }
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-drop-icon { font-size: 1.8rem; margin-bottom: 0.4rem; }
.file-drop-text { font-size: 0.82rem; color: var(--text-secondary); }

/* カメラ起動ボタン */
.btn-open-camera {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  text-align: center;
  justify-content: center;
}

/* iOSカメララッパー（全画面） */
.ios-camera-wrap {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}
/* 全画面中は背景スクロール禁止（iOSのゴム弾性スクロールで背景がチラつくのを防ぐ） */
body.camera-open {
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* カメラ表示中はホーム画面のUIを隠し、カメラと背景だけにする */
body.camera-open .app-header,
body.camera-open .model-status,
body.camera-open .footer-note,
body.camera-open .result-card,
body.camera-open .btn-submit,
body.camera-open .petal,
body.camera-open .card > .card-section {
  display: none;
}
/* カメラ表示中は装飾用のピンクのグラデーション演出も消す */
body.camera-open::before {
  display: none;
}
body.camera-open .card {
  background: transparent;
  border: none;
  margin: 0;
}
/* カメラ本体：幅100%・高さ16:9・上下余白なし */
.ios-camera-inner {
  /* 上下余白なし: 高さ=画面全高、幅=9/16（画面幅を超えない） */
  height: 100dvh;
  width: min(100vw, calc(100dvh * 9 / 16));
  display: flex;
  flex-direction: column;
  background: #000;
  border-radius: 0;
  overflow: hidden;
}
/* 映像エリアはコントロールバー以外の残り全体 */
.ios-camera-wrap .video-wrapper {
  flex: 1;
  width: 100%;
  aspect-ratio: unset;
}
/* カメラ切替中フラッシュ */
.cam-switching-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.cam-switching-overlay.flash {
  opacity: 1;
}

/* カメラボタン群（旧・互換用に残す） */
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.btn {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.6rem 0.4rem;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--sakura-600);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}
.btn:hover:not(:disabled) { background: var(--sakura-50); border-color: var(--sakura-400); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.active { background: var(--sakura-600); color: #fff; border-color: var(--sakura-600); }

/* カメラビュー */
.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  overflow: hidden;
}
video.main {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  min-width: 100%; min-height: 100%;
  width: auto; height: auto;
  display: none;
  will-change: transform;
}
.overlay-preview {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: fill;   /* 撮影画像のアスペクト比=wrapper比なのでfillで完全一致 */
  display: none;
  z-index: 5;
  cursor: pointer;
}

/* スライダーコントロール */
/* iOSズームバー */
.ios-zoom-bar {
  background: rgba(0,0,0,0.85);
  padding: 0.5rem 1rem;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.ios-zoom-pills {
  display: flex;
  gap: 0.5rem;
}
.zoom-pill {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 99px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
}
.zoom-pill.active { background: rgba(255,220,0,0.85); color: #000; }
.ios-zoom-slider {
  width: 80%;
  height: 2px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.25);
  border-radius: 1px;
  outline: none;
}
.ios-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}
.ios-zoom-val {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.55);
}

/* 縦明るさスライダー（映像内右端） */
.ios-brightness-wrap {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.ios-brightness-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.ios-bright-icon { font-size: 0.85rem; }
/* 縦スライダー：カスタムドラッグUI（writing-modeはマウス操作不可なので使わない） */
.ios-brightness-slider { display: none; } /* 値の保持用・UIは非表示 */

.ios-bright-track {
  width: 4px;
  height: 110px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  position: relative;
  cursor: ns-resize;
  touch-action: none;
}
.ios-bright-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #FFD60A;
  border-radius: 2px;
  transition: height 0.05s;
}
.ios-bright-thumb {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  cursor: ns-resize;
  touch-action: none;
}
.ios-bright-val {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.4);
  border-radius: 4px;
  padding: 0.1rem 0.2rem;
  text-align: center;
  margin-top: 2px;
}

/* iOSコントロールバー */
.ios-controls {
  background: #000;
  padding: 1rem 1.5rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* 左サムネイル */
.ios-thumb-wrap {
  width: 52px; height: 52px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.15);
  background: transparent;
  flex-shrink: 0;
  cursor: default;
  position: relative;   /* mini-cameraのabsolute基準 */
}
.ios-thumb-wrap.has-image {
  border-color: rgba(255,255,255,0.4);
  background: #111;
  cursor: pointer;
}
.ios-thumb-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* srcが空・未設定のときは完全に非表示 */
.ios-thumb-img:not([src]),
.ios-thumb-img[src=""],
.ios-thumb-img[src^="data:"]:not([src]) {
  display: none !important;
}
/* altテキストと壊れたアイコンを隠す */
.ios-thumb-img:-moz-broken { display: none !important; }
.ios-thumb-wrap:not(:has(img[src])) {
  background: transparent;
  border-color: transparent;
}

/* シャッターボタン */
.ios-shutter {
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255,255,255,0.92);
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  position: relative;
  flex-shrink: 0;
}
.ios-shutter::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff;
}
.ios-shutter:active { transform: scale(0.93); background: rgba(200,200,200,0.9); }
.ios-shutter:disabled { opacity: 0.35; cursor: not-allowed; }

/* カメラ切替ボタン */
.ios-switch {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.ios-switch:hover { background: rgba(255,255,255,0.25); }
.ios-switch:disabled { opacity: 0.3; cursor: not-allowed; }

/* 閉じるボタン：カメラ映像内の左上にオーバーレイ */
.ios-close-btn {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  z-index: 40;
  background: rgba(0,0,0,0.45);
  border: none;
  color: #fff;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: 99px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* タップ領域を広げる */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s;
}
.ios-close-btn:hover { background: rgba(0,0,0,0.65); }

/* 右上バスターボタン */
.ios-buster-btn {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top)); right: 12px;
  z-index: 40;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.4);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
}
.ios-buster-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ios-buster-btn.on {
  background: rgba(251,191,36,0.85);
  border-color: #FCD34D;
}
.ios-buster-status {
  position: absolute;
  top: 52px; right: 8px;
  z-index: 20;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.62rem;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  max-width: 120px;
  text-align: right;
  backdrop-filter: blur(4px);
  line-height: 1.4;
}

/* 旧スライダー関連（互換） */
.slider-group { display: none; }
.slider-row { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.4rem; }
.slider-label { font-size: 0.68rem; color: var(--text-muted); min-width: 40px; }
.slider-val { font-size: 0.72rem; color: var(--text-secondary); min-width: 38px; text-align: right; }

/* 逆光バスター */
.backlight-panel {
  margin-top: 0.75rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-mid);
  overflow: hidden;
  background: var(--sakura-50);
}
.backlight-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem 0.5rem;
}
.backlight-icon { font-size: 1.1rem; flex-shrink: 0; }
.backlight-title-wrap { flex: 1; }
.backlight-title {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.backlight-sub {
  display: block;
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}
.backlight-toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0 0.75rem 0.65rem;
}
.buster-choice {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.55rem 0.4rem;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.buster-choice.active {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border-color: #F59E0B;
  color: #78350F;
}
.backlight-status {
  padding: 0 0.75rem 0.55rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  min-height: 1em;
  line-height: 1.5;
}
.backlight-canvas { display: none; }

/* 撮影ガイドオーバーレイ */
.guide-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
/* フレーム枠（中央75%の正方形） */
.guide-frame {
  position: absolute;
  top: 12.5%; left: 12.5%;
  width: 75%; height: 75%;
  transition: border-color 0.3s;
}
.frame-corner {
  position: absolute;
  width: 22px; height: 22px;
  border-color: rgba(255,255,255,0.85);
  border-style: solid;
}
.frame-corner.tl { top:0; left:0;  border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.frame-corner.tr { top:0; right:0; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.frame-corner.bl { bottom:0; left:0;  border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.frame-corner.br { bottom:0; right:0; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
/* OK時は緑 */
.guide-frame.ok .frame-corner { border-color: #4ADE80; }
/* NG時はオレンジ */
.guide-frame.warn .frame-corner { border-color: #FB923C; }

/* メッセージバナー */
.guide-banner {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border-radius: 99px;
  padding: 0.35rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  transition: opacity 0.3s;
}
.guide-icon { font-size: 0.9rem; }
.guide-msg {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}
/* OKバッジ（中央） */
.guide-ok {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(74, 222, 128, 0.25);
  border: 2px solid #4ADE80;
  border-radius: 99px;
  padding: 0.3rem 1rem;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  animation: okPulse 1.2s ease-in-out infinite;
}
@keyframes okPulse {
  0%,100% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  50%      { opacity: 0.7; transform: translate(-50%,-50%) scale(1.05); }
}

/* サムネイル */
.preview-thumb {
  display: none;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
}
.thumb-img {
  width: 76px; height: 76px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-mid);
  cursor: pointer;
  flex-shrink: 0;
}
.mini-camera {
  width: 100%; height: 100%;
  border-radius: 0;
  overflow: hidden;
  background: #000;
  border: none;
  display: none;
  cursor: pointer;
  position: absolute;
  inset: 0;
}
.mini-camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-info { flex: 1; }
.thumb-info p { font-size: 0.75rem; color: var(--text-secondary); }
.btn-download {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.72rem;
  padding: 0.35rem 0.6rem;
  border: 1.5px solid #B5D4F4;
  border-radius: var(--radius-sm);
  background: #E6F1FB;
  color: #185FA5;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-download:disabled { opacity: 0.45; cursor: not-allowed; }

/* 判定ボタン */
.btn-submit {
  display: block;
  width: calc(100% - 2rem);
  margin: 1.25rem 1rem 0;
  padding: 1rem;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--sakura-600) 0%, var(--sakura-400) 100%);
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(196,77,135,0.25);
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(196,77,135,0.3); }
.btn-submit:active { transform: scale(0.98) translateY(0); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* 結果エリア */
.result-card {
  margin: 1rem 1rem 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: none;
}
.result-inner {
  padding: 1.5rem 1.25rem;
  text-align: center;
}
.result-icon { font-size: 2.4rem; margin-bottom: 0.5rem; }
.result-label {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.6;
}
.result-sub { font-size: 0.78rem; margin-top: 0.4rem; opacity: 0.75; }
.result-badge {
  display: inline-block;
  padding: 0.25rem 0.9rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 0.6rem;
  letter-spacing: 0.05em;
}

/* 結果タイプ別スタイル */
.result-healthy  { background: rgba(240, 250, 240, 0.72); border: 1.5px solid #86EFAC; color: #166534; }
.result-not-sakura { background: rgba(255, 247, 237, 0.72); border: 1.5px solid #FCD34D; color: #92400E; }
.result-early    { background: rgba(255, 251, 235, 0.72); border: 1.5px solid #FCD34D; color: #78350F; }
.result-mid      { background: rgba(255, 244, 230, 0.72); border: 1.5px solid #FDBA74; color: #9A3412; }
.result-severe   { background: rgba(254, 242, 242, 0.72); border: 1.5px solid #FCA5A5; color: #991B1B; }

/* 病気時の連絡先ブロック */
.contact-block {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: rgba(255,255,255,0.7);
  border-radius: var(--radius-md);
  border: 1px solid rgba(0,0,0,0.08);
  text-align: center;
}
.contact-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}
.contact-tel {
  margin-bottom: 0.6rem;
}
.tel-link {
  display: inline-block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--sakura-800);
  text-decoration: none;
  padding: 0.4rem 1rem;
  border: 1.5px solid var(--sakura-200);
  border-radius: 99px;
  background: var(--sakura-50);
  transition: background 0.15s;
}
.tel-link:hover { background: var(--sakura-100); }
.contact-form-btn {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--sakura-600), var(--sakura-400));
  padding: 0.5rem 1.1rem;
  border-radius: 99px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(196,77,135,0.2);
  transition: opacity 0.15s;
}
.contact-form-btn:hover { opacity: 0.88; }

/* ヒートマップ */
.heatmap-section {
  margin: 1rem 1.25rem 1.25rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1.5px solid rgba(220,38,38,0.25);
  background: rgba(255,255,255,0.6);
}
.heatmap-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.8rem;
  background: rgba(220,38,38,0.07);
  border-bottom: 1px solid rgba(220,38,38,0.12);
}
.heatmap-header-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: #991B1B;
  flex: 1;
}
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.62rem;
  color: #9CA3AF;
}
.legend-bar {
  width: 48px; height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #3B82F6, #22C55E, #EAB308, #EF4444);
}
.heatmap-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1/1;
  background: #111;
}
.heatmap-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#hmOrigCanvas { opacity: 1; }
#hmHeatCanvas { opacity: 0.62; mix-blend-mode: screen; }
.heatmap-note {
  padding: 0.45rem 0.8rem;
  font-size: 0.66rem;
  color: #6B7280;
  line-height: 1.6;
}
.result-loading  { background: rgba(255, 240, 245, 0.72); border: 1.5px solid var(--border-mid); color: var(--sakura-800); }
.result-error    { background: rgba(248, 248, 248, 0.72); border: 1.5px solid #E5E7EB; color: #374151; }

/* 撮影場所マップ */
.location-section {
  margin: 1rem 1.25rem 1.25rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1.5px solid var(--border-mid);
  background: rgba(255,255,255,0.6);
}
.location-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.8rem;
  background: var(--sakura-50);
  border-bottom: 1px solid var(--border-mid);
}
.location-header-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex: 1;
}
.location-map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/10;
  background: #eee;
}
.location-map-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.location-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.68rem;
  color: #6B7280;
}
.location-coords { font-variant-numeric: tabular-nums; }
.location-open-link {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--sakura-700);
  text-decoration: none;
  white-space: nowrap;
}
.location-open-link:hover { text-decoration: underline; }

/* モデルステータス */
.model-status {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.5rem 1rem 0.9rem;
  margin: 0 0.5rem;
  background: rgba(255, 250, 252, 0.72);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 0.3rem;
  background: var(--text-muted);
  vertical-align: middle;
}
.status-dot.ok { background: var(--leaf-500); }
.status-dot.err { background: var(--red-500); }
.status-dot.loading {
  background: var(--sakura-400);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }



.footer-note {
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0.9rem 1.25rem;
  line-height: 1.8;
  margin: 1.5rem 1rem 0;
  background: rgba(255, 250, 252, 0.72);
  border-radius: var(--radius-md);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.dark-mode .footer-note {
  background: rgba(26, 13, 18, 0.72);
}

/* てんぐ巣病マップ：桜の名所ピン */
.sakura-spot-icon {
  font-size: 18px;
  line-height: 22px;
  text-align: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* 複数枚まとめて判定 */
.batch-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}
.batch-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-mid);
  background: rgba(0,0,0,0.03);
}
.batch-item img, .batch-item-noimg {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.05);
  font-size: 1.3rem;
}
.batch-item-info { flex: 1; min-width: 0; }
.batch-item-name {
  font-size: 0.64rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.batch-item-result { font-size: 0.8rem; font-weight: 700; }
.batch-item-conf { font-size: 0.68rem; color: var(--text-muted); }

/* バッジ */
.badge-summary {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: -0.4rem 0 0.4rem;
}
.badge-note {
  text-align: center;
  font-size: 0.66rem;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
}
.badge-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 1rem 0 0.5rem;
}
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.6rem;
}
.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.6rem 0.3rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-mid);
  background: rgba(0,0,0,0.03);
  transition: transform 0.12s;
}
.badge-item.earned {
  background: linear-gradient(160deg, rgba(255,240,245,0.9), rgba(255,224,235,0.9));
  border-color: var(--sakura-400);
}
body.dark-mode .badge-item.earned {
  background: linear-gradient(160deg, rgba(80,30,50,0.7), rgba(60,20,35,0.7));
}
.badge-item.locked { opacity: 0.55; }
.badge-item-icon { font-size: 1.6rem; line-height: 1.2; }
.badge-item-label {
  font-size: 0.64rem;
  font-weight: 700;
  margin-top: 0.3rem;
  line-height: 1.3;
}
.badge-item-sub {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.badge-item.earned .badge-item-sub { color: var(--sakura-600); }

/* バッジ獲得トースト */
.badge-toast {
  position: fixed;
  left: 50%;
  bottom: -100px;
  transform: translateX(-50%);
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1.5px solid var(--sakura-400);
  border-radius: 99px;
  padding: 0.55rem 1.1rem 0.55rem 0.7rem;
  box-shadow: 0 10px 32px rgba(0,0,0,0.25);
  transition: bottom 0.35s ease, opacity 0.35s ease;
  opacity: 0;
  max-width: 90vw;
}
.badge-toast.show { bottom: 24px; opacity: 1; }
.badge-toast-icon { font-size: 1.6rem; }
.badge-toast-title { font-size: 0.72rem; font-weight: 700; color: var(--sakura-600); }
.badge-toast-desc { font-size: 0.78rem; font-weight: 700; color: var(--text-primary); }

/* 使い方モーダル */
.howto-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  transition: opacity 0.12s;
}
.howto-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 400px;
  max-height: 88dvh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 12px 48px rgba(0,0,0,0.3);
  padding: 1.75rem 1.5rem 1.5rem;
}
.howto-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.08);
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.howto-close:hover { background: rgba(0,0,0,0.14); }
.howto-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.1rem;
  color: var(--sakura-800);
  margin-bottom: 1.2rem;
  padding-right: 2rem;
  line-height: 1.5;
}
.howto-step {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.howto-step:last-child { margin-bottom: 0; }
.howto-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sakura-600), var(--sakura-400));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.howto-step-body { flex: 1; }
.howto-step-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}
.howto-step-desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.65;
}
.howto-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}
.howto-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.7;
  text-align: center;
}
/* 設定トグル */
.settings-toggle {
  flex-shrink: 0;
  cursor: pointer;
}
.settings-toggle input { display: none; }
.toggle-track {
  display: block;
  width: 44px;
  height: 26px;
  border-radius: 99px;
  background: var(--border-mid);
  position: relative;
  transition: background 0.2s;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 0.2s;
}
.settings-toggle input:checked + .toggle-track { background: var(--sakura-400); }
.settings-toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }

.howto-start-btn {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--sakura-600), var(--sakura-400));
  border: none;
  border-radius: 99px;
  cursor: pointer;
  letter-spacing: 0.06em;
  box-shadow: 0 3px 12px rgba(196,77,135,0.25);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.howto-secondary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.7rem;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sakura-700);
  background: var(--sakura-50);
  border: 1.5px solid var(--sakura-200, var(--border-mid));
  border-radius: 99px;
  cursor: pointer;
  letter-spacing: 0.04em;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
}
.howto-secondary-btn:hover { background: var(--sakura-100, var(--sakura-50)); }
.notice-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #EF4444;
  margin-left: 0.15rem;
}
.notice-item {
  background: var(--sakura-50);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}
.notice-item-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.notice-item-body {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-line;
}
.notice-item-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--sakura-700);
  text-decoration: none;
  word-break: break-all;
}
.notice-item-link:hover { text-decoration: underline; }

/* 桜に関する情報コーナー（アコーディオン） */
.sakura-info-item {
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  margin-bottom: 0.6rem;
  overflow: hidden;
  background: rgba(255,255,255,0.6);
}
.sakura-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sakura-info-chevron {
  transition: transform 0.2s;
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 0.5rem;
}
.sakura-info-item.open .sakura-info-chevron { transform: rotate(180deg); }
.sakura-info-body-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}
.sakura-info-item.open .sakura-info-body-wrap { grid-template-rows: 1fr; }
.sakura-info-body {
  overflow: hidden;
  min-height: 0;
}
.sakura-info-body-inner {
  padding: 0 1rem 0.9rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-line;
}

/* 全画面ライトボックス */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.06s;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.lightbox-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 複数枚判定：確認画面の削除ボタン */
.batch-item-remove {
  flex-shrink: 0;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: #B91C1C;
  background: #FEE2E2;
  border: 1.5px solid #FCA5A5;
  border-radius: 99px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.batch-item-remove:hover { background: #FECACA; }
body.dark-mode .batch-item-remove {
  color: #FCA5A5;
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(252, 165, 165, 0.45);
}
.howto-start-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.batch-item-thumb { cursor: pointer; }
