/* Ambient Breath: full-screen scene, quiet glass controls that fade away. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  --ink: #eef1f6;
  --muted: rgba(226, 232, 244, 0.62);
  --line: rgba(255, 255, 255, 0.12);
  --glass: rgba(14, 17, 28, 0.42);
  --glass-strong: rgba(14, 17, 28, 0.78);
  --accent: #9fe3cf;
  position: fixed; inset: 0; overflow: hidden;
  background: #06080f; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

/* auto-hiding chrome */
.ui { transition: opacity 0.9s ease, transform 0.9s ease; }
body.idle .ui { opacity: 0; pointer-events: none; }
body.idle .top { transform: translateY(-8px); }
body.idle .bottom { transform: translate(-50%, 8px); }
body.idle { cursor: none; }

/* phase guidance: small, soft, never a big countdown */
.guide {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 118px); transform: translateX(-50%);
  z-index: 1; text-align: center; pointer-events: none; opacity: 0; transition: opacity 1.2s ease;
}
.guide.on { opacity: 1; }
body.idle .guide { bottom: calc(env(safe-area-inset-bottom) + 72px); transition: opacity 1.2s ease, bottom 1.2s ease; }
.phase {
  margin: 0 0 10px; font-size: 17px; font-weight: 400; letter-spacing: 0.32em; text-transform: uppercase; text-indent: 0.32em;
  color: rgba(244, 246, 250, 0.82); text-shadow: 0 1px 14px rgba(0, 0, 0, 0.7);
}
.phase.swap { animation: phaseIn 1.1s ease; }
@keyframes phaseIn { from { opacity: 0; letter-spacing: 0.22em; } to { opacity: 1; letter-spacing: 0.32em; } }
.prog { width: 92px; height: 2px; margin: 0 auto; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.prog i { display: block; height: 100%; background: rgba(255, 255, 255, 0.55); transform-origin: left; transform: scaleX(0); }

/* top bar */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 14px) 8px calc(env(safe-area-inset-left) + 10px);
  background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0));
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; letter-spacing: 0.02em; white-space: nowrap; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
.brand img { display: block; border-radius: 6px; }
.home { display: grid; place-items: center; width: 26px; height: 34px; color: var(--muted); }
.home svg { width: 18px; height: 18px; stroke-width: 2; }
.home:hover { color: var(--ink); }

.scenes { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.scene-btn { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; white-space: nowrap; }
.scene-btn svg { width: 18px; height: 18px; flex: none; }
.scene-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.scene-btn[aria-checked="true"] { color: var(--ink); background: rgba(255, 255, 255, 0.14); }

.pill {
  display: flex; align-items: center; gap: 7px; height: 42px; padding: 0 12px 0 16px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 14px; white-space: nowrap;
}
.pill small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pill svg { width: 16px; height: 16px; color: var(--muted); }
.pill:hover { background: rgba(30, 34, 50, 0.6); }

/* bottom bar */
.bottom {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 14px); transform: translateX(-50%); z-index: 3;
  display: flex; gap: 2px; padding: 5px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.tb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 62px; height: 54px; padding: 0 8px; border: 0; border-radius: 15px; background: transparent; color: var(--muted); font-size: 11px; white-space: nowrap; }
.tb svg { width: 21px; height: 21px; }
.tb svg circle { fill: rgba(10, 12, 20, 0.9); }
.tb:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.tb[aria-expanded="true"] { color: var(--ink); background: rgba(255, 255, 255, 0.12); }
.tb.toggle[aria-pressed="true"] { color: var(--accent); }
#muteBtn .cross { display: none; }
#muteBtn[aria-pressed="true"] { color: #ffb4a8; }
#muteBtn[aria-pressed="true"] .cross { display: inline; }
#muteBtn[aria-pressed="true"] .wave { display: none; }
#muteBtn[aria-pressed="false"] { color: var(--muted); }
#muteBtn[aria-pressed="false"]:hover { color: var(--ink); }

/* corner links to sister tools */
.corner {
  position: fixed; z-index: 2; left: calc(env(safe-area-inset-left) + 16px); bottom: calc(env(safe-area-inset-bottom) + 20px);
  display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; letter-spacing: 0.03em;
}
.corner a { color: rgba(226, 232, 244, 0.42); text-decoration: none; }
.corner a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* popovers */
.pop {
  position: fixed; z-index: 4; width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - 170px); overflow: auto;
  padding: 16px; border-radius: 20px; background: var(--glass-strong); border: 1px solid var(--line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  animation: popIn 0.22s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(6px); } }
.pop h2 { margin: 2px 4px 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.pop-top { top: calc(env(safe-area-inset-top) + 62px); right: calc(env(safe-area-inset-right) + 12px); }
.pop-bottom { left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 86px); animation: none; }

.mode-item { display: block; width: 100%; text-align: left; padding: 10px 12px; margin: 2px 0; border: 1px solid transparent; border-radius: 13px; background: transparent; }
.mode-item:hover { background: rgba(255, 255, 255, 0.06); }
.mode-item[aria-checked="true"] { background: rgba(159, 227, 207, 0.1); border-color: rgba(159, 227, 207, 0.35); }
.mi-name { display: block; font-size: 15px; font-weight: 600; }
.mi-name small { margin-left: 4px; color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; }
.mi-desc { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.custom { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.stepper { padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); font-size: 12px; color: var(--muted); }
.stepper > div { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.stepper button { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font-size: 18px; line-height: 1; }
.stepper button:hover { background: rgba(255, 255, 255, 0.12); }
.stepper output { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }

.mix-row { display: grid; grid-template-columns: 98px 1fr 42px; align-items: center; gap: 10px; padding: 7px 4px; font-size: 14px; }
.mix-row output { text-align: right; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
input[type="range"] {
  --v: 50%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; margin: 0; touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--v), rgba(255, 255, 255, 0.15) var(--v)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #f4f7fb; border: 0; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #f4f7fb; border: 0; }
.pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 10px 4px 0; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.link-btn { white-space: nowrap; border: 0; background: none; padding: 6px 0; color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

.preset { display: block; width: 100%; text-align: left; margin: 0 0 8px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); }
.preset:last-child { margin-bottom: 0; }
.preset:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(159, 227, 207, 0.35); }
.preset b { display: block; font-size: 15px; }
.preset span { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; }

/* start overlay (needed anyway: browsers only allow sound after a tap) */
.start {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at center, rgba(6, 8, 15, 0.35), rgba(6, 8, 15, 0.82));
  transition: opacity 0.9s ease;
}
.start.gone { opacity: 0; pointer-events: none; }
.start-card { max-width: 420px; text-align: center; }
.start-card img { border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.start h1 { margin: 18px 0 8px; font-size: clamp(28px, 6vw, 38px); font-weight: 600; letter-spacing: 0.01em; }
.start .sub { margin: 0 auto 18px; color: var(--muted); font-size: 15.5px; line-height: 1.55; }
.recipe { margin: -4px auto 18px; padding: 10px 14px; border-radius: 14px; background: rgba(159, 227, 207, 0.1); border: 1px solid rgba(159, 227, 207, 0.3); font-size: 13.5px; line-height: 1.5; }
.btn { height: 52px; padding: 0 34px; border-radius: 999px; border: 0; background: #eef6f3; color: #0b1016; font-size: 16px; font-weight: 650; box-shadow: 0 8px 30px rgba(159, 227, 207, 0.25); animation: breathe 6s ease-in-out infinite; }
.btn:hover { background: #fff; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.05); } }
.tiny { margin: 14px 0 4px; color: var(--muted); font-size: 12px; }

/* learn sheet (also the page's readable content for search engines) */
.sheet-back { position: fixed; inset: 0; z-index: 12; display: grid; place-items: center; padding: 16px; background: rgba(3, 4, 8, 0.6); }
.sheet {
  position: relative; width: min(680px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 28px 28px 22px;
  border-radius: 22px; background: rgba(13, 16, 26, 0.96); border: 1px solid var(--line); line-height: 1.6;
  -webkit-user-select: text; user-select: text;
}
.sheet h2 { margin: 0 36px 10px 0; font-size: 22px; }
.sheet h3 { margin: 22px 0 6px; font-size: 16px; }
.sheet p, .sheet li { color: rgba(232, 236, 244, 0.82); font-size: 14.5px; }
.sheet ul { padding-left: 20px; }
.sheet li { margin: 5px 0; }
.sheet details { border-bottom: 1px solid var(--line); }
.sheet summary { padding: 11px 0; cursor: pointer; font-weight: 600; font-size: 15px; }
.sheet details p { margin: 0 0 12px; }
.sheet a { color: var(--accent); }
.sheet .more { margin-top: 18px; font-size: 13.5px; }
.close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); }
.close svg { width: 18px; height: 18px; }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 70px); transform: translateX(-50%); z-index: 20;
  padding: 9px 16px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--line); font-size: 13.5px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); pointer-events: none; white-space: nowrap;
}
.toast.show { animation: toast 2.2s ease forwards; }
@keyframes toast { 0% { opacity: 0; } 10%, 75% { opacity: 1; } 100% { opacity: 0; } }
.nojs { position: fixed; inset: auto 0 40% 0; text-align: center; z-index: 30; }

/* narrower screens: icon-only scenes, compact bars */
@media (max-width: 900px) {
  .scene-btn span { display: none; }
  .scene-btn { padding: 0 10px; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; row-gap: 8px; }
  .brand { flex: 1 1 0; min-width: 0; font-size: 14px; }
  .brand span { overflow: hidden; text-overflow: ellipsis; }
  .top { flex-wrap: wrap; }
  .scenes { order: 3; width: 100%; justify-content: space-between; }
  .scene-btn { flex: 1; justify-content: center; }
  .pill { height: 38px; padding: 0 10px 0 13px; font-size: 13px; }
  .pill #modeName { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
  .pop-top { top: calc(env(safe-area-inset-top) + 104px); }
  .bottom { width: calc(100vw - 16px); justify-content: space-between; bottom: calc(env(safe-area-inset-bottom) + 8px); padding: 4px; }
  .tb { min-width: 0; flex: 1; padding: 0 2px; font-size: 10px; height: 52px; }
  .tb svg { width: 20px; height: 20px; }
  .corner { bottom: calc(env(safe-area-inset-bottom) + 72px); left: calc(env(safe-area-inset-left) + 14px); flex-direction: row; gap: 12px; }
  .guide { bottom: calc(env(safe-area-inset-bottom) + 132px); }
  .pop-bottom { bottom: calc(env(safe-area-inset-bottom) + 70px); }
  .sheet { padding: 24px 18px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn { animation: none; }
}
