/* =====================================================================
   01 Onboarding
   ===================================================================== */
.onboarding .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 20px 8px;
  gap: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.onboarding .footer-cta {
  flex-shrink: 0;
  padding: 10px 20px calc(18px + env(safe-area-inset-bottom));
}
.onboarding-error {
  margin-top: 8px;
  text-align: center;
  font-size: 0.75rem;
  color: #c14e58;
}
.onboarding .hero {
  border-radius: 20px;
  overflow: hidden;
  flex-shrink: 0;
  display: block;
  box-shadow: 0 6px 20px rgba(20, 30, 60, .06);
}
.onboarding .hero img {
  width: 100%;
  height: auto;
  display: block;
}
.onboarding h1 {
  font-size: 0.875rem;
  font-weight: 500;
  color: #4a5168;
  line-height: 1.7;
  text-align: center;
  letter-spacing: .02em;
}
.onboarding .lead {
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--sub);
  text-align: center;
}
.onboarding .steps {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  padding: 6px 4px;
}
.onboarding .step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.onboarding .step .num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.onboarding .step.s1 .num { background: linear-gradient(135deg, var(--aqua), var(--aqua-deep)); }
.onboarding .step.s2 .num { background: linear-gradient(135deg, #f4b9c9, #e89aae); }
.onboarding .step.s3 .num { background: linear-gradient(135deg, #bce0cf, #83c4a4); }
.onboarding .step .lbl { font-size: 0.6875rem; font-weight: 700; color: var(--ink); }
.onboarding .step .sub { font-size: 0.625rem; color: var(--sub); line-height: 1.4; }
.onboarding .arrow {
  color: var(--aqua-deep);
  opacity: .55;
  font-size: 0.6875rem;
  align-self: flex-start;
  margin-top: 16px;
  flex-shrink: 0;
}
.onboarding .cam-notice {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1.5px solid #cfe2f1;
  border-radius: 12px;
  padding: 12px 14px;
}
.onboarding .cam-notice .ic {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--aqua), var(--aqua-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(30, 111, 184, .12);
}
.onboarding .cam-notice .ic svg { width: 30px; height: 30px; display: block; }
.onboarding .cam-notice .ttl { font-size: 0.8125rem; font-weight: 700; color: var(--ink); }
.onboarding .cam-notice .sub { font-size: 0.6875rem; color: var(--sub); line-height: 1.5; margin-top: 2px; }
.consent {
  font-size: 0.6875rem;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--ink);
  line-height: 1.5;
  cursor: pointer;
}
.consent .cb {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #fff;
  border: 1.5px solid #cfd4dc;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.consent .cb::before { content: '✓'; }
.consent .cb[aria-pressed="true"] {
  background: var(--aqua-deep);
  border-color: var(--aqua-deep);
  color: #fff;
}
.consent-label { flex: 1; }
.consent a { color: var(--aqua-deep); text-decoration: underline; cursor: pointer; }

/* =====================================================================
   02 Camera
   ===================================================================== */
.camera { background: transparent; color: var(--ink); }
.camera .topbar,
.confirm .topbar,
.tryon .topbar,
.result .topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}
.camera .topbar .ttl,
.confirm .topbar .ttl,
.tryon .topbar .ttl,
.result .topbar .ttl { font-size: 0.875rem; font-weight: 600; color: var(--ink); }

/* 撮影プレビュー：3:4 フレームを中央寄せする外箱
   cam-controls が margin-top: -22 で被るので padding-bottom で同等のクリアランスを確保 */
.cam-preview {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 16px;
  padding-bottom: 22px;
}
/* 表示フレーム：縦横比は端末サイズに応じて 3:4 〜 9:16 の間で可変
   (frame-aspect.js が --frame-aspect を更新) */
.cam-frame {
  position: relative;
  aspect-ratio: var(--frame-aspect, 3 / 4);
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  background: linear-gradient(180deg, #e8f0fa 0%, #f4faff 100%);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(20, 30, 60, .06);
}
.cam-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .4);
  pointer-events: none;
  z-index: 1;
}
#camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);  /* preview is mirrored (selfie convention) */
}
.face-oval {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  aspect-ratio: 3/4;
  border: 2px dashed rgba(255, 255, 255, .85);
  border-radius: 50%;
  z-index: 1;
}
.cam-hint {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, .95);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .4);
  z-index: 2;
}

.cam-controls {
  flex-shrink: 0;
  padding: 18px 20px calc(22px + env(safe-area-inset-bottom));
  background: #fff;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: 0 -4px 16px rgba(20, 30, 60, .03);
  margin-top: -22px;
  position: relative;
  z-index: 1;
}

.brightness { margin-bottom: 18px; }
.brightness .label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.brightness .label-row .l {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--sub);
}
.brightness .label-row .v { font-size: 0.8125rem; font-weight: 700; color: var(--ink); }
.brightness .icon-sun { width: 16px; height: 16px; color: var(--ink); flex-shrink: 0; display: block; }
.brightness .bright-note { font-size: 0.6875rem; color: var(--sub); line-height: 1.5; margin-top: 10px; }

.shutter-row { display: flex; align-items: center; justify-content: center; }
.shutter {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .6);
  border: 4px solid rgba(255, 255, 255, .85);
  cursor: pointer;
  position: relative;
  padding: 0;
  box-shadow: 0 4px 12px rgba(30, 111, 184, .1);
}
.shutter::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aqua-deep) 0%, var(--aqua) 100%);
}
.shutter:disabled { opacity: 0.4; cursor: not-allowed; }

/* =====================================================================
   03 Photo Confirm
   ===================================================================== */
.confirm .topbar { padding: 0 12px; }
/* 確認画面：3:4 フレームを中央寄せする外箱 */
.confirm .photo {
  flex: 1;
  min-height: 0;
  margin: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 確認画面：cam-frame と同じ縦横比 (--frame-aspect) */
.photo-frame {
  position: relative;
  aspect-ratio: var(--frame-aspect, 3 / 4);
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  background: linear-gradient(180deg, #e8f0fa 0%, #f4faff 100%);
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(20, 30, 60, .04);
  overflow: hidden;
}
#confirm-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;       /* 撮影プレビュー (#camera-video の cover) と同じ中央クロップで揃える */
  transform: scaleX(-1);   /* display mirrored (selfie convention); canvas data is real */
}
.confirm .body {
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  gap: 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.confirm .label { font-size: 0.75rem; color: var(--sub); text-align: center; }
.confirm .row { display: flex; gap: 10px; }
.confirm .row .btn { flex: 1; padding: 14px; }

/* =====================================================================
   04 Try-on
   ===================================================================== */
.tryon { background: transparent; }
.tryon .topbar { padding: 0 12px; background: transparent; z-index: 3; }
/* 試着画面：3:4 フレームを中央寄せする外箱
   panel が margin-top: -22 で被るので padding-bottom で同等のクリアランスを確保 */
.tryon .face-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 22px;
}
/* 試着画面：cam-frame と同じ縦横比 (--frame-aspect)
   タイトルバーと panel (濃さスライダー / swatches / ボタン) の間に空いている領域に、
   比率を保ったまま最大サイズで収まるようにする (固定%倍率はかけない)
   border-radius は確認画面の .photo-frame と揃えて視覚的な連続性を保つ */
.face-frame {
  position: relative;
  aspect-ratio: var(--frame-aspect, 3 / 4);
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  overflow: hidden;
}
#tryon-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;       /* 撮影プレビューと同じ中央クロップ。canvas の aspect は --frame-aspect と一致 */
  transform: scaleX(-1);   /* display mirrored */
}

/* 試着画面の panel は内部要素を dvh 連動の clamp でスケールし、
   背の低い端末でもスクロールなしで全要素が収まるように圧縮する。
   目安は画面全体の1/3前後（要素数の多い demo は 35〜40% 程度）。 */
.tryon .panel {
  flex-shrink: 0;
  padding: clamp(8px, 1.8dvh, 18px) 16px calc(clamp(12px, 2.4dvh, 22px) + env(safe-area-inset-bottom));
  background: #fff;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: 0 -4px 16px rgba(20, 30, 60, .03);
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.8dvh, 18px);
  margin-top: -22px;
  position: relative;
  z-index: 1;
}
.tryon .panel .btn {
  margin-top: clamp(0px, 0.6dvh, 8px);
  padding: clamp(8px, 1.8dvh, 16px) 20px;
}
/* swatch も dvh で追従。基底 .sw の 48px を tryon 文脈で上書き */
.tryon .swatches .sw {
  width: clamp(32px, 6dvh, 48px);
  height: clamp(32px, 6dvh, 48px);
}
/* スライダー thumb (18px) は track から下に約7px はみ出す。
   背の低い端末では panel gap が縮んで thumb と中央 swatch の被りが出るため、
   小画面時のみ swatches 行の上に小さなマージンを追加する。 */
@media (max-height: 750px) {
  .tryon .swatches { margin-top: 4px; }
}

.alpha-control { display: flex; flex-direction: column; gap: 8px; }
.alpha-control .lbl {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--sub);
}
.alpha-control .lbl .v { color: var(--ink); font-weight: 700; }

/* =====================================================================
   05 Result
   ===================================================================== */
.result { background: transparent; }
.result .topbar { padding: 0 12px; background: transparent; }
.result .scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}
.result .scroll > * { flex-shrink: 0; }

/* 保存対象領域（POP〜使い方アドバイスをまとめて html2canvas でキャプチャ）
   html2canvas v1.4.1 が flex + gap を正しく描画しないため、block + 隣接マージンに切替。 */
#result-capture { display: block; }
#result-capture > * + * { margin-top: 14px; }
.result-pop {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(20, 30, 60, .04);
  background: #fff;
}
.result-pop img { width: 100%; height: auto; display: block; }
/* html2canvas v1.4.1 が Flexbox + gap を正しく描画しないため、
   block + text-align: center + 子要素の margin で組み直す。
   .color ピルは inline-block にして親の text-align: center で中央寄せされる。 */
.result-name {
  text-align: center;
  padding: 10px 4px 0;
}
.result-name .tagline {
  font-size: 0.8125rem;
  color: var(--aqua-deep);
  font-weight: 600;
  line-height: 1.5;
}
.result-name .name {
  font-size: 0.6875rem;
  color: var(--sub);
  font-weight: 500;
  letter-spacing: .04em;
  margin-top: 6px;
}
.result-name .color {
  /* 外枠は display: table で shrink-to-fit + auto マージン中央寄せ。
     内側の <span> を table-cell + vertical-align: middle にすることで
     html2canvas でも確実にテキストが縦中央に来る (古典的かつ最も枯れた手法)。 */
  display: table;
  margin: 10px auto 0;
  height: 28px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid transparent;  /* white だけ border ありで高さがズレるのを防ぐ */
}
.result-name .color > span {
  display: table-cell;
  vertical-align: middle;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1;
  white-space: nowrap;
}
.result-name .color.white    { background: rgba(255, 255, 255, .9); color: var(--ink); border-color: rgba(20, 30, 60, .1); }
.result-name .color.lavender { background: rgba(193, 168, 227, .28); color: #6e4dab; }
.result-name .color.blue     { background: rgba(148, 194, 237, .32); color: #1f6cc1; }
.result-name .color.pink     { background: rgba(245, 163, 168, .30); color: #c14e58; }
.result-name .color.mint     { background: rgba(146, 216, 168, .32); color: #2a8e5a; }

.advice-card {
  background: #fff;
  border: 1.5px solid #cfe2f1;
  border-radius: 12px;
  padding: 16px;
}
.advice-card h3 {
  font-size: 0.875rem;
  color: var(--aqua-deep);
  margin-bottom: 8px;
  font-weight: 700;
}
.advice-card p { font-size: 0.75rem; color: #333; line-height: 1.7; }

/* ===== Whisper advice (使い方アドバイスの下に追加) ===== */
.advice-whisper {
  background: #fff;
  border: 1.5px solid #cfe2f1;     /* .advice-card と揃える */
  border-radius: 18px;
  padding: 22px 16px;
  box-shadow: 0 4px 16px rgba(91, 160, 212, .08);
  text-align: center;              /* flex 廃止：text-align + ブロックの auto マージンで中央寄せ */
}
.whisper-illust {
  width: 150px;
  margin: 0 auto -6px;             /* auto 左右マージンで中央寄せ */
}
.whisper-illust img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 50%;
  background: linear-gradient(135deg, #fef0f5, #eef5ff);
}
.whisper-bubble {
  width: 100%;
  position: relative;
  margin-top: 14px;
  background: linear-gradient(135deg, #f4faff 0%, #fdf3f7 100%);
  border: 1px solid #e4eef8;
  border-radius: 14px;
  padding: 14px 16px 16px;
}
.whisper-bubble::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -7px;
  width: 14px;
  height: 14px;
  background: #f4faff;
  border-left: 1px solid #e4eef8;
  border-top: 1px solid #e4eef8;
  transform: translateX(-50%) rotate(45deg);
}
.whisper-bubble .ttl {
  font-size: 0.96875rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 10px;
  text-align: center;
  letter-spacing: .01em;
}
.whisper-bubble .ttl .accent { color: #5BA0D4; }
.whisper-bubble .sub {
  font-size: 0.78125rem;
  line-height: 1.8;
  color: #4b566e;
}
.whisper-bubble .sub strong {
  color: var(--ink);
  font-weight: 600;
}

.link-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1.5px solid #cfe2f1;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.8125rem;
  color: var(--aqua-deep);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.link-btn .arrow { font-size: 0.875rem; }

.share-row {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}
.share-btn {
  flex: 1;
  background: #fff;
  border: 1.5px solid #cfe2f1;
  border-radius: 12px;
  padding: 10px 0;
  font-size: 0.6875rem;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.share-btn .ic {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .7);
  color: var(--ink);
  border: 1px solid rgba(20, 30, 60, .12);
}
.share-btn .ic svg { width: 20px; height: 20px; display: block; }

/* ブランドガイドラインに準拠した SNS ブランドカラー */
#share-x .ic {
  background: #000;            /* X 公式：黒地 (light theme での標準) */
  color: #fff;
  border-color: #000;
}
#share-line .ic {
  background: #06C755;         /* LINE GREEN (LINE Brand Guidelines 2020〜) */
  color: #fff;
  border-color: #06C755;
}

.result .footer-cta {
  flex-shrink: 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: transparent;
}
