/* ==========================================================
   深呼吸モード（breath.html 専用）
   ・えらぶ画面：アプリ共通の、明るい紙のトーン
   ・呼吸中（body.is-breathing）：暗く沈めて、オーブのふくらみで導く
   ========================================================== */

:root {
  --breath-bg: #14100E;
  --breath-line: rgba(255, 226, 196, .14);
  --breath-text: #F3E7DA;
  --breath-dim: rgba(243, 231, 218, .58);
  --breath-glow: #F0B478;
  --breath-glow2: #E98F6A;
  --breath-in: #8FC0D2;
  --breath-out: #E2A177;
  --breath-hold: #C9A2D6;
}

/* ==========================================================
   1. えらぶ画面
   ========================================================== */
.bp-intro { margin-top: 12px; }
.bp-intro h2 { font-size: 1.58rem; margin-top: 2px; }
.bp-intro .lead { margin-top: 8px; font-size: .9rem; color: var(--muted); }

.breathe-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.breathe-card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 14px 16px 15px 20px;
  box-shadow: 0 1px 3px rgba(80, 60, 45, .04);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  overflow: hidden;
}
.breathe-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: var(--tone, var(--clay));
}
.breathe-card[data-tone="sage"] { --tone: var(--sage); }
.breathe-card[data-tone="clay"] { --tone: var(--clay); }
.breathe-card[data-tone="lav"] { --tone: var(--lav); }
.breathe-card[data-tone="night"] { --tone: var(--night); }

.breathe-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.breathe-card[aria-pressed="true"] {
  border-color: var(--tone, var(--clay));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tone, var(--clay)) 26%, transparent);
}

.breathe-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.breathe-card__pat {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--tone, var(--clay-deep));
  font-variant-numeric: tabular-nums;
}
.breathe-card__min {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg-deep);
  padding: 2px 10px;
  border-radius: 999px;
}
.breathe-card__title {
  display: block;
  font-family: var(--font-display);
  font-size: .98rem;
  margin-top: 2px;
}
.breathe-card__catch {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.65;
  margin-top: 1px;
}

/* セット数・開始 */
.bp-setup { margin-top: 18px; }
.bp-stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.bp-step-label strong { display: block; font-size: .92rem; }
.bp-step-label small { display: block; font-size: .74rem; color: var(--muted); margin-top: 1px; }

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-deep);
  border-radius: 999px;
  padding: 4px;
  flex: 0 0 auto;
}
.stepper__btn {
  width: 38px; height: 38px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink-soft);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(80, 60, 45, .12);
  transition: background .16s ease;
}
.stepper__btn:hover { background: var(--clay-soft); }
.stepper__btn:disabled { opacity: .38; pointer-events: none; }
.stepper__val {
  min-width: 44px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.06rem;
  font-variant-numeric: tabular-nums;
}

.bp-total {
  margin-top: 12px;
  font-size: .8rem;
  color: var(--clay-deep);
  font-weight: 700;
  text-align: center;
  background: var(--clay-soft);
  border-radius: 999px;
  padding: 6px 12px;
}
.bp-setup .btn { margin-top: 14px; }

.bp-guide {
  margin-top: 26px;
  background: #FFF6E9;
  border: 1px solid #F3E2C4;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: #7A5A2C;
}
.bp-guide h3 {
  font-size: .84rem;
  font-family: var(--font-body);
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.bp-guide ul { margin: 0; padding-left: 1.1em; font-size: .8rem; line-height: 1.8; }
.bp-guide li + li { margin-top: 4px; }

/* ==========================================================
   2. 呼吸ステージ（呼吸中だけ表示）
   ========================================================== */
.bp-stage {
  position: relative;
  margin: 4px -20px 0;
  padding: 18px 20px 22px;
  min-height: 74vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--breath-text);
  background:
    radial-gradient(ellipse 78% 52% at 50% 60%, rgba(240, 180, 120, .14), transparent 70%),
    radial-gradient(ellipse 64% 40% at 50% 104%, rgba(233, 143, 106, .18), transparent 72%),
    radial-gradient(ellipse 130% 76% at 50% 106%, #2C211B 0%, var(--breath-bg) 62%);
  transition: background 1.2s ease;
}

/* フェーズごとに、かすかに色味が変わる */
.bp-stage[data-key="in"] {
  background:
    radial-gradient(ellipse 78% 54% at 50% 60%, rgba(143, 192, 210, .17), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 104%, rgba(240, 180, 120, .12), transparent 70%),
    var(--breath-bg);
}
.bp-stage[data-key="hold"] {
  background:
    radial-gradient(ellipse 74% 50% at 50% 62%, rgba(201, 162, 214, .14), transparent 72%),
    var(--breath-bg);
}
.bp-stage[data-key="out"] {
  background:
    radial-gradient(ellipse 82% 56% at 50% 66%, rgba(226, 161, 119, .18), transparent 72%),
    var(--breath-bg);
}

.bp-particles, .bp-candles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.bp-particle {
  position: absolute;
  border-radius: 50%;
  background: var(--breath-glow);
  filter: blur(.4px);
  animation-name: bpFloat;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}
@keyframes bpFloat {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translateY(-22px) scale(1.3); }
}
.bp-candle {
  position: absolute;
  bottom: -30px;
  width: 40px; height: 40px;
  margin-left: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 208, 150, .8), rgba(233, 143, 106, .26) 46%, transparent 72%);
  filter: blur(2.5px);
  animation: candleFlicker 3.4s ease-in-out infinite;
}
@keyframes candleFlicker {
  0%, 100% { opacity: .45; transform: scale(1); }
  38% { opacity: .88; transform: scale(1.14); }
  62% { opacity: .6; transform: scale(.95); }
}

.bp-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  max-width: 380px;
  gap: 12px;
}
.bp-name {
  font-size: .78rem;
  letter-spacing: .08em;
  color: rgba(243, 231, 218, .62);
  font-weight: 600;
}
.bp-round-lab {
  font-size: .74rem;
  color: rgba(243, 231, 218, .5);
  font-variant-numeric: tabular-nums;
}

.bp-phase {
  position: relative;
  z-index: 2;
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--breath-in);
  transition: color .5s ease;
}
.bp-phase[data-key="hold"] { color: var(--breath-hold); }
.bp-phase[data-key="out"] { color: var(--breath-out); }

/* オーブ（呼吸する丸） */
.bp-orb-wrap {
  position: relative;
  width: min(266px, 68vw);
  aspect-ratio: 1;
  margin: 6px 0 2px;
  display: grid;
  place-items: center;
}
.bp-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.bp-ring__track {
  fill: none;
  stroke: rgba(255, 226, 196, .11);
  stroke-width: 2.1;
}
.bp-ring__bar {
  fill: none;
  stroke: rgba(243, 231, 218, .5);
  stroke-width: 2.1;
  stroke-linecap: round;
  transition: stroke-dashoffset .2s linear;
}

.bp-orb {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  transform: scale(.56);
  transform-origin: center;
  transition-property: transform;
  transition-timing-function: cubic-bezier(.42, 0, .36, 1);
  background: radial-gradient(circle at 42% 34%,
    rgba(255, 236, 208, .95), rgba(240, 180, 120, .6) 46%, rgba(200, 120, 84, .28) 74%, transparent 78%);
  box-shadow:
    0 0 60px 8px rgba(240, 180, 120, .3),
    inset 0 0 48px rgba(255, 226, 196, .32);
  will-change: transform;
}
.bp-orb[data-key="in"] {
  background: radial-gradient(circle at 42% 34%,
    rgba(228, 247, 255, .95), rgba(143, 192, 210, .55) 46%, rgba(96, 140, 165, .24) 74%, transparent 78%);
  box-shadow: 0 0 60px 8px rgba(143, 192, 210, .28), inset 0 0 48px rgba(200, 235, 245, .3);
}
.bp-orb[data-key="hold"] {
  background: radial-gradient(circle at 42% 34%,
    #F7F0FA, rgba(201, 162, 214, .56) 46%, rgba(150, 116, 168, .24) 74%, transparent 78%);
  box-shadow: 0 0 56px 8px rgba(201, 162, 214, .28), inset 0 0 46px rgba(240, 226, 248, .3);
}

.bp-count {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3rem;
  line-height: 1;
  color: rgba(28, 20, 16, .6);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.bp-count[hidden] { display: none; }

.bp-cue {
  position: relative;
  z-index: 2;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: .05em;
  color: rgba(243, 231, 218, .82);
  min-height: 1.7em;
  text-align: center;
}

.bp-dots {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 280px;
}
.bp-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(243, 231, 218, .2);
  transition: background .3s ease, transform .3s ease;
}
.bp-dot.is-now { background: var(--breath-glow); transform: scale(1.35); }
.bp-dot.is-done { background: rgba(243, 231, 218, .48); }

.bp-controls {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}
.bp-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 1px solid var(--breath-line);
  background: rgba(255, 255, 255, .07);
  color: rgba(243, 231, 218, .82);
  display: grid;
  place-items: center;
  transition: transform .16s ease, background .16s ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.bp-btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, .12); }
.bp-btn--main {
  width: 76px; height: 76px;
  background: linear-gradient(160deg, #F7C998, var(--breath-glow2));
  border-color: transparent;
  color: #3A2318;
  box-shadow: 0 16px 34px -16px rgba(233, 143, 106, .9);
}
.bp-btn--main:hover { background: linear-gradient(160deg, #FFD8AC, #EE9E77); }

.bp-voice {
  position: relative;
  z-index: 2;
  margin-top: 16px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--breath-line);
  background: rgba(255, 255, 255, .05);
  color: rgba(243, 231, 218, .72);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.bp-voice[aria-pressed="false"] { color: rgba(243, 231, 218, .36); }

.bp-note, .bp-hint {
  margin-top: 10px;
  font-size: .75rem;
  line-height: 1.7;
  text-align: center;
  color: rgba(243, 231, 218, .4);
}
.bp-hint { margin-bottom: 6px; }

/* ==========================================================
   3. 呼吸中は、ページ全体を暗く沈める
   ========================================================== */
body.is-breathing {
  background: var(--breath-bg);
  color: var(--breath-text);
  transition: background .6s ease;
}
body.is-breathing::before { opacity: .18; }

body.is-breathing .session-top { color: var(--breath-text); }
body.is-breathing .session-top h1 { color: var(--breath-text); }
body.is-breathing .icon-btn {
  background: rgba(255, 255, 255, .08);
  border-color: var(--breath-line);
  color: var(--breath-text);
}

/* 呼吸に集中できるよう、下部ナビは隠す */
body.is-breathing .bottom-nav {
  display: none;
}
body.is-breathing.page--breath { padding-bottom: 20px; }

/* ==========================================================
   4. 大きめ画面 / 動きの抑制
   ========================================================== */
@media (min-width: 620px) {
  .bp-stage { min-height: 66vh; }
  .bp-orb-wrap { width: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  .bp-particle, .bp-candle { animation: none; }
  .bp-orb { transition-duration: .001ms !important; }
  .bp-stage { transition: none; }
}
