/* ========================================
   音の処方箋 — melta UI Design System
   声を張らずに伝わるUI — 機能的な黒子で、たまに微笑む
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Serif+JP:wght@300;400;500&display=swap');

:root {
  /* ── Mode Accents ── */
  --c-binaural: #BF5AF2;
  --c-alpha: #64D2FF;
  --c-beta: #FF9F0A;
  --c-theta: #5AC8FA;
  --c-brown: #AC8E68;
  --c-gamma: #FF375F;
  --c-delta: #7B68EE;

  /* ── melta Watch Palette「墨と月明かり」── */
  --bg: #000000;               /* bgPage: 純黒 */
  --surface: #1A1A1E;          /* bgSurface: 微温黒 */
  --surface-alt: #252528;      /* bgSurfaceAlt: 浅墨 */
  --text: #F5F0E8;             /* textHeading: 和紙の白 */
  --text-2: #C4BEB4;           /* textDefault: 生成り */
  --text-3: #7A756C;           /* textMuted: 灰茶 */
  --fill: rgba(245,240,232,0.04);    /* Layered fill */
  --fill-2: rgba(245,240,232,0.07);
  --fill-3: rgba(245,240,232,0.11);
  --separator: #2E2D30;              /* borderDefault */
  --border-strong: #3D3B40;

  /* ── melta Spacing (4px base, 8px recommended) ── */
  --sp-xs: 4px;   --sp-sm: 8px;   --sp-md: 12px;
  --sp-base: 16px; --sp-lg: 20px;  --sp-xl: 24px;  --sp-xxl: 32px;

  /* ── melta Radius ── */
  --radius-sm: 4px;  --radius-md: 8px;  --radius-lg: 12px;  --radius-full: 9999px;

  /* ── melta Motion (Tactile) ── */
  --motion-fast: 0.15s;  --motion-normal: 0.2s;  --motion-slow: 0.3s;  --motion-gentle: 0.5s;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Active accent — changes per mode */
  --accent: var(--c-binaural);
}

/* Mode accents */
.app[data-mode="binaural"] { --accent: var(--c-binaural); }
.app[data-mode="alpha"]    { --accent: var(--c-alpha); }
.app[data-mode="beta"]     { --accent: var(--c-beta); }
.app[data-mode="theta"]    { --accent: var(--c-theta); }
.app[data-mode="gamma"]    { --accent: var(--c-gamma); }
.app[data-mode="delta"]    { --accent: var(--c-delta); }
.app[data-mode="brown"]    { --accent: var(--c-brown); }

/* ========== Reset ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.hidden { display: none !important; }

.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
}

/* ========== Main Screen ========== */
.main-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: calc(var(--safe-top) + 20px) 24px calc(var(--safe-bottom) + 24px);
  position: relative;
}

/* Status pill */
.status-pill {
  position: absolute;
  top: calc(var(--safe-top) + var(--sp-base));
  right: var(--sp-lg);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-xs) var(--sp-md);
  background: var(--fill);
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  z-index: 10;
  letter-spacing: 0.3px;
  transition: all var(--motion-normal) var(--ease);
}

.status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  transition: background var(--motion-gentle) var(--ease);
}

.status-pill.warning { color: var(--c-beta); }
.status-pill.warning .status-dot { background: var(--c-beta); }
.status-pill.expired { color: #FF453A; }
.status-pill.expired .status-dot { background: #FF453A; }

/* ========== Orb Visualization ========== */
.viz-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.orb-container {
  position: relative;
  width: 260px; height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Visualizer Canvas */
.viz-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
}

.viz-canvas.active {
  opacity: 1;
}

.orb-glow {
  position: absolute;
  width: 350px; height: 350px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 18%, transparent) 0%, transparent 70%);
  animation: breathe-glow 8.5s ease-in-out infinite;
}

@keyframes breathe-glow {
  0%, 100% { transform: scale(0.6); opacity: 0.3; }
  50% { transform: scale(1.4); opacity: 0.8; }
}

.app.playing .orb-glow {
  animation: breathe-glow-active 8.5s ease-in-out infinite;
}

@keyframes breathe-glow-active {
  0%, 100% { transform: scale(0.5); opacity: 0.4; }
  50% { transform: scale(1.6); opacity: 1; }
}

/* Apple Watch Breathe-style petals */
.mindful-petals {
  position: relative;
  width: 200px;
  height: 200px;
  z-index: 2;
}

.mindful-petal {
  position: absolute;
  width: 100px;
  height: 100px;
  top: 50%;
  left: 50%;
  margin-top: -50px;
  margin-left: -50px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,
    color-mix(in srgb, var(--accent) 60%, white),
    var(--accent),
    color-mix(in srgb, var(--accent) 40%, black)
  );
  mix-blend-mode: screen;
}

/* Color shifts per petal */
.mindful-petal:nth-child(1) { filter: hue-rotate(-30deg); }
.mindful-petal:nth-child(2) { filter: hue-rotate(-15deg); }
.mindful-petal:nth-child(3) { filter: hue-rotate(-5deg); }
.mindful-petal:nth-child(4) { filter: hue-rotate(5deg); }
.mindful-petal:nth-child(5) { filter: hue-rotate(15deg); }
.mindful-petal:nth-child(6) { filter: hue-rotate(25deg); }
.mindful-petal:nth-child(7) { filter: hue-rotate(35deg); }

/* Idle: petals breathe gently */
.mindful-petal:nth-child(1) { animation: idle-p0 8.5s ease-in-out infinite; }
.mindful-petal:nth-child(2) { animation: idle-p1 8.5s ease-in-out 0.1s infinite; }
.mindful-petal:nth-child(3) { animation: idle-p2 8.5s ease-in-out 0.2s infinite; }
.mindful-petal:nth-child(4) { animation: idle-p3 8.5s ease-in-out 0.3s infinite; }
.mindful-petal:nth-child(5) { animation: idle-p4 8.5s ease-in-out 0.4s infinite; }
.mindful-petal:nth-child(6) { animation: idle-p5 8.5s ease-in-out 0.5s infinite; }
.mindful-petal:nth-child(7) { animation: idle-p6 8.5s ease-in-out 0.6s infinite; }

/* Playing: full bloom */
.app.playing .mindful-petal:nth-child(1) { animation: bloom-p0 8.5s ease-in-out infinite; }
.app.playing .mindful-petal:nth-child(2) { animation: bloom-p1 8.5s ease-in-out 0.1s infinite; }
.app.playing .mindful-petal:nth-child(3) { animation: bloom-p2 8.5s ease-in-out 0.2s infinite; }
.app.playing .mindful-petal:nth-child(4) { animation: bloom-p3 8.5s ease-in-out 0.3s infinite; }
.app.playing .mindful-petal:nth-child(5) { animation: bloom-p4 8.5s ease-in-out 0.4s infinite; }
.app.playing .mindful-petal:nth-child(6) { animation: bloom-p5 8.5s ease-in-out 0.5s infinite; }
.app.playing .mindful-petal:nth-child(7) { animation: bloom-p6 8.5s ease-in-out 0.6s infinite; }

/* ---- IDLE: gentle 25px spread, then gather at center ---- */
@keyframes idle-p0 {
  0%,100% { transform: translate(0,0) scale(0.75); opacity:0.6; }
  50%     { transform: translate(25px, 0) scale(1.0); opacity:0.45; }
}
@keyframes idle-p1 {
  0%,100% { transform: translate(0,0) scale(0.75); opacity:0.6; }
  50%     { transform: translate(15px, 19px) scale(1.0); opacity:0.45; }
}
@keyframes idle-p2 {
  0%,100% { transform: translate(0,0) scale(0.75); opacity:0.6; }
  50%     { transform: translate(-6px, 24px) scale(1.0); opacity:0.45; }
}
@keyframes idle-p3 {
  0%,100% { transform: translate(0,0) scale(0.75); opacity:0.6; }
  50%     { transform: translate(-22px, 11px) scale(1.0); opacity:0.45; }
}
@keyframes idle-p4 {
  0%,100% { transform: translate(0,0) scale(0.75); opacity:0.6; }
  50%     { transform: translate(-22px, -11px) scale(1.0); opacity:0.45; }
}
@keyframes idle-p5 {
  0%,100% { transform: translate(0,0) scale(0.75); opacity:0.6; }
  50%     { transform: translate(-6px, -24px) scale(1.0); opacity:0.45; }
}
@keyframes idle-p6 {
  0%,100% { transform: translate(0,0) scale(0.75); opacity:0.6; }
  50%     { transform: translate(15px, -19px) scale(1.0); opacity:0.45; }
}

/* ---- BLOOM: dramatic 60px spread, then power-gather at center ---- */
@keyframes bloom-p0 {
  0%,100% { transform: translate(0,0) scale(0.7); opacity:0.7; }
  50%     { transform: translate(60px, 0) scale(1.15); opacity:0.5; }
}
@keyframes bloom-p1 {
  0%,100% { transform: translate(0,0) scale(0.7); opacity:0.7; }
  50%     { transform: translate(37px, 47px) scale(1.15); opacity:0.5; }
}
@keyframes bloom-p2 {
  0%,100% { transform: translate(0,0) scale(0.7); opacity:0.7; }
  50%     { transform: translate(-13px, 58px) scale(1.15); opacity:0.5; }
}
@keyframes bloom-p3 {
  0%,100% { transform: translate(0,0) scale(0.7); opacity:0.7; }
  50%     { transform: translate(-54px, 26px) scale(1.15); opacity:0.5; }
}
@keyframes bloom-p4 {
  0%,100% { transform: translate(0,0) scale(0.7); opacity:0.7; }
  50%     { transform: translate(-54px, -26px) scale(1.15); opacity:0.5; }
}
@keyframes bloom-p5 {
  0%,100% { transform: translate(0,0) scale(0.7); opacity:0.7; }
  50%     { transform: translate(-13px, -58px) scale(1.15); opacity:0.5; }
}
@keyframes bloom-p6 {
  0%,100% { transform: translate(0,0) scale(0.7); opacity:0.7; }
  50%     { transform: translate(37px, -47px) scale(1.15); opacity:0.5; }
}

/* ========== Mode Info ========== */
.main-info {
  text-align: center;
  padding: 24px 0 16px;
  flex-shrink: 0;
}

/* Mode selector button — melta Whisper principle */
.mode-selector {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-base) var(--sp-sm) var(--sp-md);
  background: var(--fill);
  border: 1px solid var(--separator);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--motion-normal) var(--ease);
  font-family: inherit;
  color: var(--text);
}

.mode-selector:hover {
  background: var(--fill-2);
}

.mode-selector:active {
  transform: scale(0.97);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.mode-selector-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  transition: background var(--motion-gentle) var(--ease);
}

/* Whisper: serif heading, controlled weight */
.mode-name {
  font-family: 'Noto Serif JP', serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.5px;
  transition: opacity var(--motion-slow) var(--ease);
}

.mode-chevron {
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform var(--motion-normal) var(--ease);
}

.mode-selector:hover .mode-chevron {
  transform: translateY(2px);
}

/* Timer display — Whisper: thin, tabular */
.timer-display {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-3);
  margin-top: var(--sp-xs);
  font-variant-numeric: tabular-nums;
  font-weight: 300;
  letter-spacing: 2px;
}

/* ========== Play Button — melta Tactile ========== */
.play-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--fill);
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--motion-normal) var(--spring);
  flex-shrink: 0;
  position: relative;
}

.play-btn::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1px solid var(--separator);
  transition: border-color var(--motion-slow) var(--ease);
}

.play-btn:hover { background: var(--fill-2); }
.play-btn:active { transform: scale(0.93); }

.app.playing .play-btn {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.app.playing .play-btn::after {
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

.play-btn svg { width: 28px; height: 28px; }
.play-icon { margin-left: 2px; }

/* ========== Volume — melta Quiet Precision ========== */
.volume-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  width: 180px;
  margin-top: var(--sp-xxl);
  flex-shrink: 0;
  opacity: 0.35;
  transition: opacity var(--motion-slow) var(--ease);
}

.volume-bar:hover,
.volume-bar:focus-within { opacity: 0.7; }

.vol-icon { color: var(--text-3); flex-shrink: 0; }

.volume-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  border-radius: 1px;
  background: var(--fill-3);
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.volume-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  cursor: pointer;
}

/* Swipe hint */
.swipe-hint {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 8px);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.3px;
  animation: hint-fade 4s ease infinite;
}

@keyframes hint-fade {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.2; }
}

/* ========== Bottom Sheet — melta Layered ========== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 200;
  animation: fadeIn var(--motion-slow) var(--ease);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 430px;
  max-height: 80vh;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--sp-md) var(--sp-lg) calc(var(--safe-bottom) + var(--sp-lg));
  z-index: 201;
  transition: transform var(--motion-gentle) var(--ease-out);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--separator);
}

.bottom-sheet.open {
  transform: translateX(-50%) translateY(0);
}

.sheet-handle {
  width: 32px; height: 4px;
  border-radius: 2px;
  background: var(--text-3);
  margin: 0 auto var(--sp-base);
  opacity: 0.5;
}

/* Whisper: Serif heading in sheet */
.sheet-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 18px;
  font-weight: 400;
  margin-bottom: var(--sp-base);
  letter-spacing: 0.5px;
  color: var(--text);
}

.sheet-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--sp-sm);
}

.sheet-divider {
  height: 1px;
  background: var(--separator);
  margin: var(--sp-base) 0;
}

/* Mode rows — melta card style */
.mode-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--separator);
}

.mode-row {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-base);
  background: var(--surface);
  border: none;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--motion-fast) var(--ease);
  text-align: left;
  width: 100%;
}

.mode-row:hover { background: var(--fill-2); }
.mode-row:active { background: var(--fill-3); }

.mode-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mode-row-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mode-row-name {
  font-family: 'Noto Serif JP', serif;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.3px;
}
.mode-row-desc { font-size: 11px; color: var(--text-3); letter-spacing: 0.2px; }

.check-icon {
  width: 16px; height: 16px;
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0;
  transition: all var(--motion-normal) var(--spring);
}

.mode-row.active .check-icon {
  opacity: 1;
}

/* Science link — separated from mode selection area */
.science-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--motion-normal) var(--ease);
  letter-spacing: 0.3px;
}

.science-link:hover { color: var(--accent); }
.science-chevron { font-size: 16px; font-weight: 300; }

/* Tuning pills — melta Ordered spacing */
.tuning-pills {
  display: flex;
  gap: var(--sp-sm);
}

.tuning-pill {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-md) var(--sp-sm);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  border: 1px solid var(--separator);
  color: var(--text-3);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--motion-normal) var(--ease);
}

.tuning-pill:hover { background: var(--fill-2); }

.tuning-pill.active {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
}

.tuning-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.tuning-freq {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.tuning-pill.active .tuning-freq {
  color: var(--accent);
}

/* Science Modal */
.science-sheet {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  padding: 30px 24px 24px;
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: sheet-up 0.4s var(--spring);
}

.science-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.science-emoji {
  font-size: 48px;
  text-align: center;
}

.science-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.science-intro {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-2);
  text-align: center;
}

.science-section {
  background: var(--fill);
  border-radius: 12px;
  padding: 16px;
}

.science-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.science-section p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
}

.science-research-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--separator);
}

.science-research-card:last-child { border-bottom: none; }

.science-finding {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.science-source {
  font-size: 11px;
  color: var(--text-3);
  font-style: italic;
}

.science-caution {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 12px;
  background: color-mix(in srgb, #FF9500 12%, transparent);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}

.science-caution-icon {
  flex-shrink: 0;
  font-size: 16px;
}

/* Timer pills — melta Ordered */
.timer-pills {
  display: flex;
  gap: var(--sp-sm);
}

.timer-pill {
  flex: 1;
  padding: var(--sp-sm) var(--sp-xs);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 1px solid var(--separator);
  color: var(--text-3);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--motion-normal) var(--ease);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.timer-pill:hover { background: var(--fill-2); color: var(--text-2); }

.timer-pill.active {
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
  font-weight: 600;
}

/* Scene rows — melta card */
.scene-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--separator);
}

.scene-row {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-base);
  background: var(--surface);
  border: none;
  color: var(--text-2);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--motion-fast) var(--ease);
}

.scene-row:hover { background: var(--fill-2); }
.scene-row:active { background: var(--fill-3); }
.scene-icon { font-size: 16px; }

/* Breathing shortcut — melta accent hint */
.breathing-shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--sp-md) var(--sp-base);
  background: var(--surface-alt);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease);
}

.breathing-shortcut:hover { background: var(--fill-2); }
.shortcut-arrow { font-size: 16px; opacity: 0.5; }

/* Sheet option (toggle rows) — melta */
.sheet-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-xs) 0;
}

.sheet-option-name { font-size: 14px; color: var(--text-2); }
.sheet-option-desc { font-size: 11px; color: var(--text-3); display: block; margin-top: 2px; }

/* Apple toggle */
.apple-toggle {
  position: relative;
  width: 51px; height: 31px;
  flex-shrink: 0;
}

.apple-toggle input { opacity: 0; width: 0; height: 0; }

.apple-toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(120, 120, 128, 0.32);
  border-radius: 15.5px;
  cursor: pointer;
  transition: background 0.25s ease;
}

.apple-toggle-track::before {
  content: '';
  position: absolute;
  width: 27px; height: 27px;
  left: 2px; top: 2px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.25s ease;
}

.apple-toggle input:checked + .apple-toggle-track {
  background: #34C759;
}

.apple-toggle input:checked + .apple-toggle-track::before {
  transform: translateX(20px);
}

/* ========== Breathing Overlay ========== */
.breathing-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease;
}

.breathing-close {
  position: absolute;
  top: calc(var(--safe-top) + 16px);
  left: 20px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--fill-2);
  border: none;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.breathing-close:hover { background: var(--fill-3); }

/* Petal container */
.petal-container {
  position: relative;
  width: 200px; height: 200px;
}

.petal {
  position: absolute;
  top: 50%; left: 50%;
  width: 60px; height: 100px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--accent) 50%, transparent),
    color-mix(in srgb, var(--accent) 15%, transparent)
  );
  transform-origin: center 0%;
  opacity: 0.6;
  transition: all 1.5s ease-in-out;
  mix-blend-mode: screen;
}

.petal.collapsed {
  transform: translate(-50%, -50%) rotate(var(--r)) scale(0.3);
  opacity: 0.2;
}

.petal.expanded {
  transform: translate(-50%, -50%) rotate(var(--r)) translateY(-40px) scale(1);
  opacity: 0.7;
}

.breathing-label {
  text-align: center;
  margin-top: 48px;
}

.breath-phase {
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 2px;
  transition: opacity 0.5s ease;
}

.breath-timer {
  font-size: 14px;
  color: var(--text-2);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.breath-dots {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 40px);
  display: flex;
  gap: 8px;
}

.breath-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  transition: all 0.5s ease;
}

.breath-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ========== Premium Modal — melta Layered ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 800;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn var(--motion-slow) var(--ease);
}

.premium-sheet {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--sp-xl) var(--sp-lg) calc(var(--safe-bottom) + var(--sp-xl));
  width: 100%;
  max-width: 430px;
  position: relative;
  animation: sheetUp 0.4s var(--ease-out);
  border-top: 1px solid var(--separator);
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-close-btn {
  position: absolute;
  top: 16px; right: 16px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--fill-2);
  border: none;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.premium-sheet h2 {
  font-family: 'Noto Serif JP', serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.3px;
  margin-bottom: var(--sp-xs);
}

.premium-desc {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 20px;
}

/* Incense Promo Icon */
.incense-promo-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}

/* Feature list */
.incense-feature-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--fill);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.incense-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.incense-feature-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.incense-feature-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.incense-feature-name {
  font-size: 15px;
  font-weight: 500;
}

.incense-feature-desc {
  font-size: 12px;
  color: var(--text-2);
}

/* CTA button */
.incense-cta {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: linear-gradient(135deg, #AC8E68, #D4A574);
  color: white;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.incense-cta:hover { opacity: 0.9; transform: scale(0.98); }

/* Later button */
.incense-later {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--text-2);
  transition: all 0.2s ease;
}

.incense-later:hover { color: var(--text); }

/* ========== Transitions ========== */
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ========== Environment Sound Buttons ========== */
.env-buttons {
  display: flex;
  gap: 8px;
}

.env-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border-radius: 12px;
  background: var(--fill);
  border: none;
  color: var(--text-2);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.env-btn:hover { background: var(--fill-2); color: var(--text); }

.env-btn.active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.env-emoji { font-size: 22px; }

/* YouTube Live Link */
.yt-live-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  background: var(--fill);
  border: none;
  border-radius: 12px;
  color: #FF2D55;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
}

.yt-live-link:hover { background: var(--fill-2); }
.yt-icon { flex-shrink: 0; }

.incense-arrow {
  font-size: 14px;
  color: #E1BEE7;
  margin-left: 4px;
}

/* Scrollbar for sheet */
.bottom-sheet::-webkit-scrollbar { width: 0; }

/* ========== Share Button ========== */
.share-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  background: var(--fill);
  border: none;
  border-radius: 12px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.share-btn:hover { background: var(--fill-2); }
.share-btn svg { flex-shrink: 0; }

/* ========== Custom Presets ========== */
.preset-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.preset-header .sheet-subtitle {
  margin-bottom: 0;
}

.preset-save-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 16px;
  border: none;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-save-btn:hover { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.preset-save-btn:active { transform: scale(0.95); }

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--fill);
  border-radius: 12px;
  overflow: hidden;
}

.preset-empty {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  padding: 16px;
}

.preset-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.preset-apply {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
}

.preset-apply:hover { background: var(--fill-2); }

.preset-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.preset-name {
  font-size: 14px;
  font-weight: 500;
}

.preset-detail {
  font-size: 11px;
  color: var(--text-2);
}

.preset-delete {
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.preset-delete:hover { color: #FF453A; }

/* ========== Pomodoro Badge ========== */
.pomodoro-badge {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  border-radius: 16px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pomodoro-badge.active {
  opacity: 1;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* ========== Dashboard — melta ========== */
.dashboard-sheet {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--sp-xl) var(--sp-lg) calc(var(--safe-bottom) + var(--sp-xl));
  width: 100%;
  max-width: 430px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: sheetUp 0.4s var(--ease-out);
  border-top: 1px solid var(--separator);
}

.dashboard-sheet::-webkit-scrollbar { width: 0; }

.dashboard-sheet h2 {
  font-family: 'Noto Serif JP', serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.3px;
  margin-bottom: var(--sp-base);
}

/* Stats Grid — melta card */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
}

.stat-card {
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  padding: var(--sp-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
  border: 1px solid var(--separator);
}

.stat-value {
  font-family: 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 300;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.5px;
}

/* Heatmap */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-top: 8px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--fill);
  transition: background 0.2s ease;
}

.heatmap-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

/* Notification Settings */
.notify-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.notify-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notify-time-input {
  background: var(--fill);
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  color-scheme: dark;
}

/* ========== Orb Environment Effects ========== */
.orb-container.env-rain .orb-core {
  box-shadow:
    0 0 40px color-mix(in srgb, var(--accent) 40%, transparent),
    0 0 80px color-mix(in srgb, #64D2FF 25%, transparent),
    inset 0 -4px 12px rgba(0,0,0,0.3),
    inset 0 4px 8px rgba(255,255,255,0.2);
}

.orb-container.env-rain .orb-glow {
  background: radial-gradient(circle,
    color-mix(in srgb, #64D2FF 12%, transparent) 0%,
    color-mix(in srgb, var(--accent) 8%, transparent) 50%,
    transparent 70%
  );
}

.orb-container.env-fire .orb-core {
  box-shadow:
    0 0 40px color-mix(in srgb, var(--accent) 40%, transparent),
    0 0 80px color-mix(in srgb, #FF9F0A 25%, transparent),
    inset 0 -4px 12px rgba(0,0,0,0.3),
    inset 0 4px 8px rgba(255,200,100,0.2);
  animation: fire-flicker 2s ease-in-out infinite !important;
}

@keyframes fire-flicker {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.03); }
  50% { transform: scale(0.98); }
  75% { transform: scale(1.05); }
}

.orb-container.env-fire .orb-glow {
  background: radial-gradient(circle,
    color-mix(in srgb, #FF9F0A 12%, transparent) 0%,
    color-mix(in srgb, #FF453A 6%, transparent) 50%,
    transparent 70%
  );
}

.orb-container.env-waves .orb-core {
  box-shadow:
    0 0 40px color-mix(in srgb, var(--accent) 40%, transparent),
    0 0 80px color-mix(in srgb, #5AC8FA 20%, transparent),
    inset 0 -4px 12px rgba(0,0,0,0.3),
    inset 0 4px 8px rgba(255,255,255,0.15);
  animation: wave-sway 6s ease-in-out infinite !important;
}

@keyframes wave-sway {
  0%, 100% { transform: scale(1) translateY(0); }
  25% { transform: scale(1.02) translateY(-3px); }
  50% { transform: scale(0.98) translateY(2px); }
  75% { transform: scale(1.03) translateY(-2px); }
}

.orb-container.env-waves .orb-glow {
  background: radial-gradient(circle,
    color-mix(in srgb, #5AC8FA 10%, transparent) 0%,
    color-mix(in srgb, var(--accent) 8%, transparent) 50%,
    transparent 70%
  );
}

/* ========== Toast Notification ========== */
.toast-notification {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--fill-3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s var(--ease-out);
  pointer-events: none;
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== Onboarding Tutorial ========== */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.6s ease;
  transition: opacity 0.5s ease;
}

.onboarding-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.onboarding-card {
  background: rgba(44, 44, 46, 0.95);
  border-radius: 20px;
  padding: 40px 28px 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  position: relative;
}

.onboarding-step {
  display: none;
  animation: fadeIn 0.4s ease;
}

.onboarding-step.active {
  display: block;
}

.onboarding-emoji {
  font-size: 56px;
  margin-bottom: 16px;
}

.onboarding-card h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}

.onboarding-card p {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 16px;
}

.onboarding-card p strong {
  color: var(--accent);
  font-weight: 600;
}

.onboarding-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 8px;
}

.onboarding-features span {
  padding: 6px 12px;
  background: var(--fill-2);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text);
}

.onboarding-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--separator);
}

.onboarding-dots {
  display: flex;
  gap: 6px;
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fill-3);
  transition: all 0.3s ease;
}

.onboarding-dot.active {
  background: var(--accent);
  width: 20px;
  border-radius: 4px;
}

.onboarding-btn {
  padding: 10px 28px;
  border-radius: 20px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.onboarding-btn:hover { opacity: 0.9; }
.onboarding-btn:active { transform: scale(0.96); }

/* Highlight for mode name during onboarding */
.onboarding-highlight {
  color: var(--accent) !important;
  text-shadow: 0 0 20px var(--accent);
  animation: highlight-pulse 1.5s ease-in-out infinite;
}

@keyframes highlight-pulse {
  0%, 100% { text-shadow: 0 0 20px color-mix(in srgb, var(--accent) 40%, transparent); }
  50% { text-shadow: 0 0 30px color-mix(in srgb, var(--accent) 70%, transparent); }
}

/* ========== iPad / Tablet Layout ========== */
@media (min-width: 768px) {
  .app {
    max-width: 500px;
  }

  .orb-container {
    width: 320px;
    height: 320px;
  }

  .orb-glow {
    width: 420px;
    height: 420px;
  }

  .mindful-petals {
    width: 240px;
    height: 240px;
  }

  .mindful-petal {
    width: 120px;
    height: 120px;
    margin-top: -60px;
    margin-left: -60px;
  }

  .mode-selector {
    font-size: 20px;
    padding: 10px 20px 10px 16px;
  }

  .timer-display {
    font-size: 17px;
  }

  .play-btn {
    width: 72px;
    height: 72px;
  }

  .bottom-sheet {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border-radius: 20px 20px 0 0;
  }

  .bottom-sheet.open {
    transform: translateX(-50%) translateY(0);
  }

  .dashboard-sheet,
  .premium-sheet {
    max-width: 480px;
    max-height: 85vh;
  }
}

/* ========== Accessibility: Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .mindful-petal,
  .orb-glow,
  .orb-ring,
  .orb-core {
    animation: none !important;
  }
}

/* ========== Focus Visible (keyboard navigation) ========== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
