/* ═════════════════════════════════════════════════════════════════
   Ambiência: misturador de sons de ambiente (views/apps/ambiencia.eta)
   Só tema escuro (a página é uma noite com fundo animado). Os pares de cor que importam (texto, botão, rótulos de campo, foco) ficam no bloco
   `@theme`: test/ambiencia-page.test.js mede o contraste de cada par. A cor do projeto vem de --accent e --accent-2 (catálogo, no <html>).
   O movimento comum (pop, confete) vem de juice.css; juice.js põe data-motion="reduced" no <html>. Sem fontes de terceiros: o app abre sem internet.
   ═════════════════════════════════════════════════════════════════ */

/* @theme */
:root {
	color-scheme: dark;
	--bg: #0b1220;
	--bg-2: #111b30;
	--panel: #0f1a2e;
	--ink: #e9eff8;
	--ink-2: #b4c3d8;
	--ink-3: #8fa1bb;
	--line: #2a3a56;
	--field: #0a1322;
	--btn: var(--accent);
	--btn-ink: #1b1308;
	--focus: #ffe0b8;
	--danger-ink: #ff9d94;
	--track: #3a4b69;
	--shadow: 0 1px 2px rgb(0 0 0 / .3), 0 14px 34px -16px rgb(0 0 0 / .6);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
	margin: 0; min-height: 100vh; color: var(--ink);
	background: radial-gradient(120% 80% at 50% -10%, #1a2742 0%, var(--bg) 60%) fixed;
	font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.i { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.22em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); text-decoration: none; }
.skip:focus { top: 12px; }

.scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.top, .main, .foot { position: relative; z-index: 1; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* ── cabeçalho ── */
.top { padding: max(10px, env(safe-area-inset-top)) 0 6px; }
.top__in { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand__mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--btn-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.top__tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tool, .pill { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: rgb(15 26 46 / .7); text-decoration: none; font-size: .9rem; }
.tool { width: 40px; padding: 0; justify-content: center; }
.tool[aria-pressed="false"] { color: var(--ink-3); }
.tool[aria-pressed="false"] .i { opacity: .55; }
.tool:hover, .pill:hover { border-color: var(--accent); }

/* ── texto de abertura ── */
.main { padding-bottom: 120px; }
.intro { padding: 26px 0 18px; }
.intro h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 4.5vw, 2.4rem); line-height: 1.15; letter-spacing: -.02em; }
.lead { margin: 0; max-width: 46ch; color: var(--ink-2); }
.notice { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.shared { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.shared[hidden] { display: none; }

/* ── grade principal ── */
.grid { display: grid; gap: 18px; align-items: start; }
.side { display: grid; gap: 18px; }
@media (min-width: 960px) {
	.grid { grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr); }
	.main { padding-bottom: 48px; }
}
.panel { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgb(15 26 46 / .86); box-shadow: var(--shadow); }
.panel__title { margin: 0 0 12px; font-size: .8rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-2); }
.hint { margin: 12px 0 6px; font-size: .85rem; color: var(--ink-3); }
.empty { margin: 4px 0 0; font-size: .88rem; color: var(--ink-3); }
.empty[hidden] { display: none; }

/* ── barras de volume ── */
.bars { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.bar {
	display: grid; grid-template-columns: 44px minmax(0, 1fr) 40px; gap: 4px 12px; align-items: center; padding: 8px 10px; border-radius: 14px;
	background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 16%, transparent) var(--v), transparent var(--v));
	transition: background-color .2s;
}
.bar[data-on="true"] { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.bar__icon { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--field); color: var(--ink-2); transition: background-color .2s, color .2s, transform .15s; }
.bar__icon:hover { border-color: var(--accent); color: var(--ink); }
.bar__icon .i { width: 1.4em; height: 1.4em; }
.bar[data-on="true"] .bar__icon { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.bar__body { display: grid; min-width: 0; }
.bar__name { font-weight: 600; line-height: 1.2; }
.bar__hint { font-size: .78rem; line-height: 1.3; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__value { font-size: .85rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.bar[data-on="true"] .bar__value { color: var(--ink); }

.bar__range { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer; --v: 0%; }
.bar__range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--v), var(--track) var(--v)); }
.bar__range::-moz-range-track { height: 6px; border-radius: 999px; background: var(--track); }
.bar__range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
.bar__range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; border: 3px solid var(--accent); background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .5); }
.bar__range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--accent); background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .5); }

/* ── controles gerais ── */
.deck { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px 16px; align-items: center; }
.play {
	display: grid; place-items: center; width: 68px; height: 68px; border: 0; border-radius: 50%; color: var(--btn-ink);
	background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent-2))); box-shadow: 0 8px 22px -8px var(--accent);
	transition: transform .15s;
}
.play:hover { transform: scale(1.05); }
.play .i { width: 1.9em; height: 1.9em; }
.play[aria-pressed="true"] { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent), 0 8px 22px -8px var(--accent); }
.deck__main { display: grid; gap: 2px; min-width: 0; }
.deck__label { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-2); }
.deck__status { margin: 0; font-size: .85rem; color: var(--ink-3); min-height: 1.3em; }
.deck > .btn { grid-column: 1 / -1; }

/* ── botões e campos ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--btn); color: var(--btn-ink); font-weight: 700; text-decoration: none; transition: transform .12s, filter .12s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn--small { min-height: 36px; padding: 0 14px; }
.btn--ghost { border: 1px solid var(--line); background: transparent; color: var(--ink); font-weight: 600; }
.btn--ghost:hover { border-color: var(--accent); }
.field { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); color: var(--ink); }
.field::placeholder { color: var(--ink-3); }
.field--mono { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: .8rem; }
.savebox, .sharebox { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--field); font-size: .9rem; transition: border-color .15s, background-color .15s; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--field)); }
.saved { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.saved:empty { display: none; }
.saved li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.saved .chip { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--field); color: var(--ink-2); }
.icon-btn:hover { border-color: var(--accent); color: var(--ink); }
.icon-btn--danger:hover { border-color: var(--danger-ink); color: var(--danger-ink); }
.saved .field { min-height: 38px; }

/* ── timer e opções ── */
.sleep__status { margin: 0 0 10px; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sleep .btn--ghost { margin-top: 10px; }
.sleep[data-active="true"] .sleep__status { color: var(--accent); }
.switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__box { position: relative; width: 46px; height: 26px; margin-top: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--field); transition: background-color .2s; }
.switch__box::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink-2); transition: transform .2s, background-color .2s; }
.switch input:checked + .switch__box { background: var(--btn); border-color: var(--btn); }
.switch input:checked + .switch__box::after { transform: translateX(20px); background: var(--btn-ink); }
.switch input:focus-visible + .switch__box { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch__text { display: grid; gap: 2px; }
.switch__text small { color: var(--ink-3); font-size: .82rem; line-height: 1.35; }

.usage { margin-top: 22px; color: var(--ink-2); }
.foot { padding: 18px 0 calc(110px + env(safe-area-inset-bottom)); font-size: .85rem; color: var(--ink-3); }
.foot__in { display: grid; gap: 6px; }
@media (min-width: 960px) { .foot { padding-bottom: 28px; } .foot__in { grid-auto-flow: column; justify-content: space-between; } }

/* ── avisos ── */
.toasts { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: 8px; width: min(440px, 100% - 32px); transform: translateX(-50%); pointer-events: none; }
@media (min-width: 960px) { .toasts { bottom: 24px; } }
.toast { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: #16233b; box-shadow: var(--shadow); pointer-events: auto; animation: toast-in .25s ease-out both; }
.toast button { flex: none; min-height: 32px; padding: 0 12px; border: 1px solid var(--accent); border-radius: 10px; background: transparent; color: var(--accent); font-weight: 700; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
html[data-motion="reduced"] .toast { animation: none; }

/* ── celular: a barra de controles fica presa embaixo ── */
@media (max-width: 959px) {
	.deck {
		position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40;
		grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px 12px; background: rgb(12 21 38 / .96);
	}
	.deck > .btn { grid-column: auto; width: 44px; padding: 0; }
	.deck .txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
	.play { width: 56px; height: 56px; }
	.bar { grid-template-columns: 40px minmax(0, 1fr) 36px; gap: 2px 10px; }
	.bar__icon { width: 40px; height: 40px; }
	.top__tools .pill:not(#install) { display: none; }
}

@media (prefers-reduced-motion: reduce) { .bar, .bar__icon, .play, .btn, .chip { transition: none; } }
html[data-motion="reduced"] .bar, html[data-motion="reduced"] .play, html[data-motion="reduced"] .btn { transition: none; }
