/* おかえりトレ — アートディレクション「朝の光」
   温かい紙の世界。クリーム地＋和紙テクスチャ、珊瑚/柿色のインク、
   Zen Maru Gothic の見出しが主役。責めない・急かさないトーン。 */

/* ---------- デザイントークン ---------- */

:root {
  /* 紙とインク */
  --paper-warm: #fdf3e3;
  --paper-base: #faf0e1;
  --card: #fffdf8;
  --card-deep: #fff9ef;
  --ink: #33241a;
  /* 小サイズ二次テキスト用。紙地#faf0e1上で約5.8:1・accent-100上でも4.5:1超を確保 */
  --ink-soft: #6e5a47;
  --ink-faint: #b3a190;
  --hairline: rgba(122, 84, 56, 0.12);

  /* 珊瑚/柿色 アクセント段階 */
  --accent-050: #fff0e5;
  --accent-100: #ffe3d1;
  --accent-300: #ffa478;
  --accent-500: #ff6f47;
  --accent-600: #e1592f;
  /* 温色カード地（#ffe4cbなど）の上でも小テキストが4.5:1を超える深さ */
  --accent-700: #a93d1d;
  /* 主ボタン。白文字18px/700（大文字基準18.66px未満）に対し
     グラデ全域でWCAG AA 4.5:1以上（上端#c8492a≒4.7:1、下端#b8431f≒5.4:1） */
  --grad-accent: linear-gradient(180deg, #c8492a 0%, #b8431f 100%);
  --grad-glow: radial-gradient(closest-side, rgba(255, 199, 138, 0.55), rgba(255, 199, 138, 0));

  /* 互換エイリアス */
  --bg: var(--paper-base);
  --card-bg: var(--card);
  --accent: var(--accent-500);
  --accent-dark: var(--accent-600);
  --accent-soft: var(--accent-100);
  --text: var(--ink);
  --text-muted: var(--ink-soft);
  --dot-off: #ece0cd;
  --dot-on: var(--accent-500);

  /* 形・影（環境光＋接地影の2層） */
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --shadow-card:
    0 1px 2px rgba(58, 42, 30, 0.05),
    0 14px 32px -10px rgba(128, 86, 54, 0.16);
  --shadow-chip:
    0 1px 2px rgba(58, 42, 30, 0.05),
    0 5px 14px -6px rgba(128, 86, 54, 0.14);
  --shadow-btn:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 3px rgba(184, 67, 31, 0.28),
    0 12px 24px -8px rgba(233, 90, 45, 0.55);
  --shadow-btn-press:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 1px 2px rgba(184, 67, 31, 0.3),
    0 4px 10px -4px rgba(233, 90, 45, 0.4);

  /* 型スケール */
  --fs-xs: 11.5px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 17px;
  --fs-lg: 19px;
  --fs-xl: 26px;
  --fs-hero: 32px;
  --fs-display: 68px;

  --font-display: "Zen Maru Gothic", "Hiragino Maru Gothic ProN",
    "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  --font-body: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper-base);
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 朝の光: 上からこぼれる金色のグラデーション */
body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background-color: var(--paper-base);
  background-image:
    radial-gradient(130% 46% at 50% -6%, rgba(255, 224, 176, 0.85) 0%, rgba(255, 224, 176, 0) 70%),
    linear-gradient(180deg, var(--paper-warm) 0%, var(--paper-base) 60%);
  background-repeat: no-repeat;
}

/* 和紙テクスチャ（SVGノイズ、ごく淡く紙全体に） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
}

.app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  padding: 30px 20px 52px;
  position: relative;
}

/* デスクトップ幅: 中央カラム左右の余白に、既存の日の出モチーフ（SVG_HORIZON と同系の
   円+光条+地平線）を淡く敷く。固定配置の装飾のみでコンテンツ幅・レイアウトは変えない */
@media (min-width: 1024px) {
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    opacity: 0.2;
    pointer-events: none;
    background-repeat: no-repeat, no-repeat;
    background-position: left -70px center, right -70px center;
    background-size: 320px 320px, 320px 320px;
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Ccircle cx='100' cy='120' r='46' fill='%23ff9d6e'/%3E%3Cpath d='M100 44v-16M55 65l-12-12M145 65l12-12M38 108l-16-6M162 108l16-6' stroke='%23ffb98f' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M10 168h180' stroke='%23ecd2b2' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E"),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Ccircle cx='100' cy='120' r='46' fill='%23ff9d6e'/%3E%3Cpath d='M100 44v-16M55 65l-12-12M145 65l12-12M38 108l-16-6M162 108l16-6' stroke='%23ffb98f' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M10 168h180' stroke='%23ecd2b2' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E");
  }
}

@media (min-width: 560px) {
  body {
    padding: 40px 0 56px;
  }
  .app {
    min-height: auto;
    /* body の flex stretch から外し、余白があれば上下中央に置く。
       これがないとコンテンツの短い画面（復帰画面など）でカード下半分が
       空白のまま引き伸ばされる。margin auto なので、コンテンツが
       ビューポートより高い画面では上端が切れずそのまま流れる。 */
    margin-block: auto;
    background: linear-gradient(180deg, var(--card) 0%, var(--card-deep) 100%);
    border: 1px solid var(--hairline);
    border-radius: 28px;
    box-shadow:
      0 2px 4px rgba(58, 42, 30, 0.05),
      0 32px 64px -24px rgba(128, 86, 54, 0.28);
    padding: 40px 30px 52px;
  }
}

h1, h2, p {
  margin: 0;
}

/* ---------- ブランドヘッダー（全画面共通の顔） ---------- */

.app-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-700); /* 13px帯はaccent-700で4.5:1超 */
}

.app-brand .brand-mark {
  stroke: var(--accent-500);
  stroke-width: 1.5;
  flex: 0 0 auto;
}

/* Step1のブランドヒーローが名乗る間、固定ヘッダーは席だけ残して控える */
.app-brand.quiet {
  visibility: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  color: inherit;
}

input[type="text"] {
  font-family: inherit;
}

button:focus-visible,
input[type="text"]:focus-visible {
  outline: 3px solid rgba(255, 111, 71, 0.6);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-100);
}

/* ---------- 共通: 画面・見出し ---------- */

.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ホーム・復帰のみ、ひと呼吸の入場（オンボは選択のたび再描画されるので除外） */
.home-screen,
.comeback-screen {
  animation: screen-in 0.5s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

/* 復帰画面の退場: big祝祭の余韻中にハードカットせず300msで抜ける
   （退場300ms→ホームの screen-in 500msでクロスが成立する） */
.comeback-screen.leaving {
  animation: screen-out 0.3s ease both;
}

@keyframes screen-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-indicator {
  font-size: var(--fs-sm);
  color: var(--accent-700); /* 13px帯はaccent-700で4.5:1超 */
  letter-spacing: 0.14em;
  font-weight: 700;
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-indicator::after {
  content: "";
  height: 1px;
  flex: 0 0 32px;
  background: linear-gradient(90deg, var(--accent-300), rgba(255, 164, 120, 0));
}

.ob-title, .if-then, .comeback-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: var(--ink);
}

/* 見出し・主要文の折り返しは文節単位に（非対応ブラウザは現状維持） */
.ob-title, .if-then, .comeback-title, .plan-text, .if-then-preview,
.celebrate-message, .unlock-desc {
  word-break: auto-phrase;
}

/* オンボは1画面構図: CTAを下端にアンカーし、下半分の中空を消す */
.onboarding-screen {
  min-height: calc(100dvh - 130px);
}

.onboarding-screen .main-btn {
  margin-top: auto;
}

/* Step1: CTA直上の朝日装飾。下半分の空白を構図に変える。
   下端アンカーの margin-top: auto はこの要素が引き受ける */
.onboarding-screen .ob-horizon {
  margin-top: auto;
  opacity: 0.5;
  pointer-events: none;
}

.onboarding-screen .ob-horizon ~ .main-btn {
  margin-top: 0;
}

@media (min-width: 560px) {
  .onboarding-screen {
    min-height: auto;
  }
}

/* ステップ切替の入場（同一ステップ内の選択再描画では付与されない） */
.onboarding-screen.step-enter {
  animation: step-in 0.28s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

@keyframes step-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 祝祭後の同一画面再レンダーでは入場フェードを再生しない */
.home-screen.no-anim {
  animation: none;
}

/* ---------- Step1 ブランドヒーロー ---------- */

.ob-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2px;
}

.brand-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-600);
}

/* ヘッダーと同じ朝日マーク（顔の一貫性） */
.brand-name .brand-mark {
  stroke: var(--accent-500);
  stroke-width: 1.5;
  flex: 0 0 auto;
}

.brand-tagline {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-700); /* ベタ置き（opacity減光はAA未達になるため使わない） */
}

.ob-sub, .comeback-sub {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.75;
}

/* ---------- ボタン ---------- */

.main-btn {
  width: 100%;
  min-height: 58px;
  padding: 17px 20px;
  background-color: #c8492a; /* グラデ非対応時も白文字4.5:1以上のフォールバック */
  background-image: var(--grad-accent);
  color: #fff;
  border-radius: var(--radius-lg);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: var(--shadow-btn);
  transition:
    transform 0.12s ease,
    filter 0.12s ease,
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
}

.main-btn:hover {
  filter: brightness(1.04);
}

.main-btn:active {
  transform: translateY(2px) scale(0.99);
  box-shadow: var(--shadow-btn-press);
  filter: brightness(0.98);
}

/* 未選択のあいだは減彩して「まだ押せない」を伝える（選択で点灯する）。
   「押せないが存在は分かる」水準のコントラスト（約3.6:1）を確保する */
.main-btn[aria-disabled="true"] {
  background-image: none;
  background-color: #e6d8c2;
  color: var(--ink-soft);
  box-shadow: 0 1px 2px rgba(58, 42, 30, 0.06);
}

.main-btn.done {
  background-color: #c3d9b7;
  background-image: linear-gradient(160deg, #d4e5c9 0%, #b9d2ac 100%);
  color: #3d5a35;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 6px 16px -8px rgba(96, 128, 82, 0.5);
}

.ghost-btn {
  width: 100%;
  min-height: 44px;
  padding: 12px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border-radius: var(--radius-md);
  transition: color 0.12s ease, background 0.12s ease;
}

.ghost-btn:hover {
  color: var(--ink);
  background: rgba(122, 84, 56, 0.06);
}

.ob-error {
  color: var(--accent-700);
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* ---------- ピッカー（選択チップ＋自由入力） ---------- */

/* 主要3ステップは全幅の行型リストで揃える（行律動の不揃いを避ける） */
.picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.picker-btn {
  min-height: 46px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  text-align: left;
  background: var(--card);
  border: 1.5px solid var(--hairline);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: var(--shadow-chip);
  transition:
    border-color 0.14s ease,
    background 0.14s ease,
    color 0.14s ease,
    box-shadow 0.14s ease,
    transform 0.1s ease;
}

.picker-btn:hover {
  border-color: var(--accent-300);
}

.picker-btn:active {
  transform: scale(0.96);
  box-shadow: 0 1px 3px rgba(58, 42, 30, 0.08);
}

.picker-btn.small {
  min-height: 44px;
  padding: 9px 15px;
  font-size: 13px;
}

/* プロフィールの小チップ群（年代・性別）は従来どおりピル型の折返し配置 */
.picker.picker-inline {
  display: flex;
  flex-wrap: wrap;
  row-gap: 10px;
  column-gap: 9px;
}

.picker-inline .picker-btn {
  border-radius: var(--radius-pill);
  text-align: center;
}

/* 「回答しない」は行末に固定し、孤立折返しを起こしにくくする */
.picker-inline .none-btn {
  order: 99;
}

/* 「回答しない」の選択状態は中立配色にする（accentは実際の年代・性別を選んだ時だけ） */
.picker-btn.none-btn.selected {
  background: transparent;
  border: 1.5px solid var(--ink-faint);
  color: var(--ink-soft);
  box-shadow: none;
}

.picker-btn.none-btn.selected::before {
  color: var(--ink-soft);
}

.picker-btn.selected {
  background: linear-gradient(160deg, #fff0e5 0%, #ffe0cb 100%);
  border-color: var(--accent-500);
  color: var(--accent-700);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 4px 12px -4px rgba(233, 90, 45, 0.35);
}

.picker-btn.selected::before {
  content: "✓";
  font-weight: 900;
  margin-right: 0.45em;
  font-size: 0.88em;
  color: var(--accent-600);
}

.picker-btn.other-btn {
  border-style: dashed;
  color: var(--ink-soft);
  background: transparent;
  box-shadow: none;
}

.picker-btn.other-btn.selected {
  border-style: solid;
  color: var(--accent-700);
  background: linear-gradient(160deg, #fff0e5 0%, #ffe0cb 100%);
}

.picker-custom {
  width: 100%;
  min-height: 50px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--accent-300);
  background: var(--card);
  font-size: var(--fs-base);
  color: var(--ink);
  box-shadow: inset 0 2px 4px rgba(58, 42, 30, 0.04);
  transition: border-color 0.14s ease;
}

.picker-custom::placeholder {
  color: var(--ink-faint);
}

.picker-custom:focus {
  outline: none;
  border-color: var(--accent-500);
  box-shadow:
    inset 0 2px 4px rgba(58, 42, 30, 0.04),
    0 0 0 3px rgba(255, 111, 71, 0.18);
}

/* ---------- Step2: If-Then プレビュー ---------- */

.if-then-preview-card {
  background: linear-gradient(160deg, var(--accent-050) 0%, var(--accent-100) 100%);
  border: 1px solid rgba(225, 89, 47, 0.16);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.preview-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-700); /* 小サイズラベルはaccent-700で4.5:1超 */
  margin-bottom: 8px;
}

.if-then-preview {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.6;
  color: var(--ink);
}

/* ---------- Step3: プロフィール ---------- */

.profile-section {
  border-top: 1px solid var(--hairline);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 折りたたみ時の展開トリガー（Step3の認知負荷を下げる） */
.profile-toggle {
  border-top: 1px solid var(--hairline);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-top: 4px;
  padding-top: 16px;
}

.profile-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.profile-note {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.7;
  margin-bottom: 4px;
}

/* 年代・性別チップの直前に置く行ラベル */
.picker-row-label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: -2px;
}

/* ---------- ホーム画面 ---------- */

.eyebrow {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent-700); /* 13px帯はaccent-700で4.5:1超 */
  letter-spacing: 0.14em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow::after {
  content: "";
  height: 1px;
  flex: 0 0 32px;
  background: linear-gradient(90deg, var(--accent-300), rgba(255, 164, 120, 0));
}

.if-then {
  font-size: 24px;
}

/* 復帰宣言当日のホーム: If-Thenと「やった」の間に添える補助ピル */
.comeback-plan-pill {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--accent-700);
  background: var(--accent-050);
  border: 1px solid rgba(225, 89, 47, 0.18);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
}

.done-msg {
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  font-weight: 600;
}

/* 紙のカードの物質感: 環境光＋接地影＋上端ハイライト */
.metric-card, .nudge-card, .unlock-card, .plan-card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-deep) 100%);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.metric-total-label {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* ゼロ状態（オンボ完了直後）: 数字とドットの壁のかわりの前向きな一言 */
.metric-zero-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-600);
}

.metric-zero-note {
  margin-top: 8px;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.75;
}

/* 累計日数: この画面の主役。柿色のインクで大きく置く
   （グラデは数字span側に持たせ、カウントアップのtransformでも欠けないようにする） */
.metric-total-value {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  margin: 2px 0 16px;
  color: var(--accent-600);
}

.metric-num {
  display: inline-block;
  background-image: linear-gradient(170deg, #ff8a55 8%, #f0511f 88%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  transform-origin: left bottom;
}

.metric-total-value .unit {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-left: 5px;
}

/* ドットカレンダー: 押印のならび。1行7個＝週の意味を持つグリッド。今日は輪でしるす */
.dots {
  display: grid;
  grid-template-columns: repeat(7, 16px);
  gap: 8px;
  justify-content: start;
  padding: 2px;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--dot-off);
  box-shadow: inset 0 1px 2px rgba(58, 42, 30, 0.1);
}

.dot.on {
  background: radial-gradient(circle at 32% 30%, #ff9d6e 0%, #f4571f 78%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.35),
    0 1px 3px rgba(233, 90, 45, 0.28);
}

/* 並びの最後＝今日。未実施状態でも視認できるよう強めの二重リングを添える */
.dots .dot:last-child {
  box-shadow:
    inset 0 1px 2px rgba(58, 42, 30, 0.1),
    0 0 0 2px var(--card),
    0 0 0 4px var(--accent-600);
}

.dots .dot.on:last-child {
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.35),
    0 1px 3px rgba(233, 90, 45, 0.28),
    0 0 0 2px var(--card),
    0 0 0 4px var(--accent-600);
}

/* 記録直後、いちばん新しい押印がぽんと現れる */
.dot.pop {
  animation: dot-pop 0.35s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

@keyframes dot-pop {
  0% {
    transform: scale(0);
  }
  60% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}

.dots-caption {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.comeback-count {
  margin-top: 10px;
  align-self: flex-start;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-700);
  background: var(--accent-050);
  border: 1px solid rgba(225, 89, 47, 0.18);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
}

/* 統計ナッジ: 静かなしおり。左に柿色の栞紐 */
.nudge-card {
  position: relative;
  overflow: hidden;
  padding-left: 26px;
}

.nudge-card::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-300), var(--accent-500));
}

.nudge-card p {
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink);
}

/* 核心の数値を独立行の視覚的主役に（文言・数値そのものは不変） */
.nudge-card .stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-600);
  margin: 2px 0 0;
}

/* 出典括弧はキャプションとして別行に落とす */
.nudge-card .stat-source {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 1px 0 8px;
}

/* ---------- まちへの扉: ロック/解錠を扉のメタファーで ---------- */

.unlock-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 30px;
}

/* 扉の縁。閉じているあいだは木口の色 */
.unlock-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: linear-gradient(180deg, #e6d5bc 0%, #d5bf9e 100%);
  box-shadow: inset -1px 0 0 rgba(122, 84, 56, 0.18);
}

.unlock-card p:first-child {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-base);
  letter-spacing: 0.02em;
}

/* 絵文字のかわりの線画アイコン。テキストと光学的に揃える */
.unlock-icon {
  vertical-align: -4px;
  margin-right: 6px;
}

/* アンロック報酬: TOKYO WALKING MAP のコースカード */
.course-box {
  margin-top: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.75);
  border: 1px solid rgba(225, 89, 47, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.course-name {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  word-break: auto-phrase;
}

.course-meta {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent-700);
}

.course-spots {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-soft);
}

/* 報酬を次の行動へ: コースを開くテキストボタン */
.course-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-top: 2px;
  padding: 8px 4px;
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-700); /* 15px/700は大文字基準未満のため4.5:1を確保 */
  text-decoration: none;
}

.course-link:hover {
  text-decoration: underline;
}

.course-link .course-link-arrow {
  transition: transform 0.14s ease;
}

.course-link:hover .course-link-arrow {
  transform: translateX(3px);
}

.course-link-caption {
  margin: -2px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.course-source {
  margin-top: 4px;
  font-size: var(--fs-xs);
  color: var(--accent-700); /* ベタ置き（opacity減光はAA未達になるため使わない） */
}

.unlock-desc {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.7;
}

.unlock-card.locked {
  background: linear-gradient(180deg, #fbf4e8 0%, #f7efe0 100%);
  box-shadow:
    0 1px 2px rgba(58, 42, 30, 0.04),
    0 8px 20px -10px rgba(128, 86, 54, 0.12);
}

.unlock-card.locked p:first-child {
  color: var(--ink-soft);
}

/* 解錠: 扉の隙間から朝の光がさす */
.unlock-card.unlocked {
  background: linear-gradient(115deg, #fff3e0 0%, #ffe4cb 60%, #ffddc2 100%);
  border-color: rgba(225, 89, 47, 0.22);
}

.unlock-card.unlocked::before {
  background: linear-gradient(180deg, #ffcf96 0%, #ff9159 100%);
  box-shadow:
    inset -1px 0 0 rgba(184, 67, 31, 0.25),
    6px 0 22px 2px rgba(255, 166, 100, 0.6);
}

.unlock-card.unlocked p:first-child {
  color: var(--accent-700);
}

.unlock-card.unlocked .unlock-desc {
  color: var(--accent-700); /* ベタ置き（opacity減光はAA未達になるため使わない） */
}

/* 14日目アンロック専用シーケンス（.unlock-open はその瞬間だけ付与される）:
   (1) 扉縁が透明→光帯へ点灯 → (2) 縁を残して左から開帳 → (3) 中身がスタッガー出現。
   fill-mode は backwards（開帳後は clip-path を外し、カードの接地影を戻す） */
.unlock-card.unlocked.unlock-open {
  animation: unlock-door 0.5s cubic-bezier(0.22, 0.9, 0.3, 1) 0.18s backwards;
}

.unlock-card.unlocked.unlock-open::before {
  animation: unlock-edge 0.4s ease-out backwards;
}

@keyframes unlock-edge {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes unlock-door {
  from {
    clip-path: inset(0 96% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

.unlock-card.unlocked.unlock-open .course-name {
  animation: unlock-item 0.35s ease-out 0.45s backwards;
}

.unlock-card.unlocked.unlock-open .course-meta {
  animation: unlock-item 0.35s ease-out 0.57s backwards;
}

.unlock-card.unlocked.unlock-open .course-spots {
  animation: unlock-item 0.35s ease-out 0.69s backwards;
}

.unlock-card.unlocked.unlock-open .course-link {
  animation: unlock-item 0.35s ease-out 0.81s backwards;
}

@keyframes unlock-item {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.source-note {
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.7;
  padding-top: 4px;
}

/* ---------- 復帰フロー ---------- */

.comeback-screen {
  position: relative;
  z-index: 0;
  padding-top: 44px;
  align-items: stretch;
  text-align: center;
  gap: 16px;
  /* 画面全体をひとつの構図に: 中央配置＋下部の朝日の地平線 */
  min-height: calc(100vh - 170px);
  justify-content: center;
}

.comeback-horizon {
  width: 100%;
  height: 80px;
  margin-top: 14px;
  pointer-events: none;
}

/* 復帰画面のヒーロー: 日の出線画をタイトル直上に据え、
   背景グロー（.comeback-screen::before）のグラデーション中心と重ねる */
.comeback-hero {
  width: min(200px, 64%);
  margin: 0 auto -2px;
  opacity: 0.9;
  pointer-events: none;
}

.comeback-hero .comeback-horizon {
  display: block;
  height: auto;
  margin-top: 0;
}

@media (min-width: 560px) {
  .comeback-screen {
    min-height: auto;
  }
}

/* 見出しの背に、のぼる朝日の暈 */
.comeback-screen::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  height: 260px;
  background: var(--grad-glow);
  pointer-events: none;
}

.comeback-title {
  font-size: var(--fs-hero);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.comeback-sub {
  font-size: var(--fs-base);
}

.plan-card {
  text-align: left;
  background: linear-gradient(160deg, var(--accent-050) 0%, var(--accent-100) 100%);
  border-color: rgba(225, 89, 47, 0.16);
  padding: 20px 22px;
}

.plan-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-700); /* 小サイズラベルはaccent-700で4.5:1超 */
  margin-bottom: 8px;
}

.plan-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
  color: var(--ink);
}

/* 復帰プランを行動に接続する: 本人が設定した合図のリマインド */
.plan-anchor {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.7;
}

/* トーストと交差する要素（カード・見出し）を表示中だけ沈める
   （celebrate()が付与・除去）。白トーストが縁とピクセル重なりして
   「描画ずれ」に見えたり、達成した当の見出しが隠れたりするのを防ぐ */
.plan-card,
.metric-card,
.if-then,
.eyebrow {
  transition: opacity 0.25s ease;
}

.toast-dimmed {
  opacity: 0.25;
}

/* ---------- 祝い演出（CSSアニメーションのみ） ---------- */

/* スクリム(z:98) < 紙吹雪canvas(z:99) < トースト(z:100) の3層 */
.celebrate-scrim {
  position: fixed;
  inset: 0;
  background: rgba(58, 42, 30, 0.28);
  pointer-events: none;
  z-index: 98;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.celebrate-scrim.show {
  opacity: 1;
}

.celebrate-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* 縦位置はJSが直前に押したボタンと交差しない値で上書きする */
  padding-top: 18vh;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.celebrate-message {
  background: linear-gradient(180deg, #fffdf8 0%, #fff7ea 100%);
  border: 1px solid rgba(225, 89, 47, 0.18);
  color: var(--accent-700);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 22px 30px;
  border-radius: var(--radius-lg);
  box-shadow:
    0 2px 4px rgba(58, 42, 30, 0.08),
    0 24px 56px -16px rgba(128, 86, 54, 0.4);
  text-align: center;
  max-width: 82%;
  line-height: 1.55;
  animation: pop-bounce 0.6s ease;
}

.celebrate-overlay.big .celebrate-message {
  font-size: 24px;
  animation: pop-bounce 0.7s ease;
}

@keyframes pop-bounce {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  55% {
    transform: scale(1.12);
    opacity: 1;
  }
  75% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
  border-radius: 2px;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(var(--rot, 200deg));
    opacity: 0.2;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .home-screen,
  .comeback-screen,
  .comeback-screen.leaving,
  .onboarding-screen.step-enter,
  .dot.pop,
  .unlock-card.unlocked.unlock-open,
  .unlock-card.unlocked.unlock-open::before,
  .unlock-card.unlocked.unlock-open .course-name,
  .unlock-card.unlocked.unlock-open .course-meta,
  .unlock-card.unlocked.unlock-open .course-spots,
  .unlock-card.unlocked.unlock-open .course-link {
    animation: none;
  }
  .celebrate-message,
  .confetti-piece {
    animation: none !important;
  }
  .celebrate-scrim {
    transition: none;
  }
  .main-btn,
  .picker-btn,
  .ghost-btn,
  .picker-custom {
    transition: none;
  }
  .main-btn:active,
  .picker-btn:active {
    transform: none;
  }
}
