:root {
  color-scheme: dark;
  --bg: #0f1220;
  --bg2: #151a2e;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-b: rgba(255, 255, 255, 0.1);
  --text: #ecebf3;
  --muted: #a3a6bd;
  --gold: #e8b76a;
  --gold-d: #c9944a;
  --rose: #ee9a8f;
  --r: 16px;
  --bar-h: 76px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body {
  font-family: var(--sans); color: var(--text); background: var(--bg);
  min-height: 100dvh; line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 24px);
}
.glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 50vh at 15% 0%, rgba(232, 183, 106, 0.12), transparent 70%),
    radial-gradient(50vw 50vh at 100% 30%, rgba(110, 120, 220, 0.13), transparent 70%),
    linear-gradient(180deg, var(--bg), var(--bg2));
}
h2, h3, h4, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; max-width: 1240px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--gold); }
.brand div { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; color: var(--text); }
.brand span { font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.top-actions { display: flex; gap: 6px; }

/* Buttons */
.btn {
  border: 1px solid var(--panel-b); background: rgba(255, 255, 255, 0.08); color: var(--text);
  padding: 10px 18px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background 0.2s, transform 0.1s, border-color 0.2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.15); }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 14px; font-size: 0.86rem; }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-d)); color: #241806; border-color: transparent; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.duck { border-color: rgba(238, 154, 143, 0.6); color: var(--rose); background: rgba(238, 154, 143, 0.08); font-weight: 600; }
.btn.duck[aria-pressed="true"] { background: var(--rose); color: #2a0d0d; border-color: transparent; }
.btn.duck kbd { margin-left: 4px; color: inherit; border-color: currentColor; opacity: 0.7; }
.link { background: none; border: 0; padding: 0; color: var(--gold); cursor: pointer; font-size: 0.84rem; }
.link:hover { text-decoration: underline; }
kbd { border: 1px solid var(--panel-b); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; font-family: inherit; font-size: 0.8em; color: var(--text); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.panel { background: var(--panel); border: 1px solid var(--panel-b); border-radius: var(--r); padding: 18px; }
.eyebrow { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.eyebrow small { letter-spacing: 0.02em; text-transform: none; font-weight: 400; opacity: 0.85; margin-left: 6px; font-size: 0.8rem; }
.eyebrow.gap { margin-top: 24px; }
.muted { color: var(--muted); font-size: 0.88rem; }

/* Sessions row */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-head .eyebrow { margin: 0; }
.sec-tools { display: flex; align-items: center; gap: 14px; }
.sessions { margin-bottom: 22px; }
.sess-row { list-style: none; margin: 0; padding: 2px 2px 6px; display: flex; gap: 12px; overflow-x: auto; scrollbar-width: thin; }
.sess-row li { position: relative; flex: 0 0 auto; }
.sess { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; text-align: left; min-width: 210px; max-width: 280px;
  padding: 12px 40px 12px 14px; border-radius: 14px; border: 1px solid var(--panel-b); background: var(--panel); cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.sess:hover { border-color: var(--gold); background: rgba(232, 183, 106, 0.08); }
.sess .ico { grid-row: span 2; width: 38px; height: 38px; border-radius: 50%; display: grid; place-content: center; background: var(--gold); color: #241806; font-size: 0.9rem; padding-left: 2px; }
.sess b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess small { color: var(--muted); font-size: 0.78rem; }
.sess-row li.on .sess { border-color: var(--gold); background: rgba(232, 183, 106, 0.12); }
.sess-row .x { position: absolute; right: 8px; top: 8px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.sess-row .x:hover { color: var(--rose); }
.sess-row .none { color: var(--muted); font-size: 0.9rem; padding: 14px 16px; border: 1px dashed var(--panel-b); border-radius: 14px; }

/* Two columns: the mix, and the session */
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 22px; align-items: start; }
.mix { display: grid; gap: 20px; min-width: 0; }
.channels { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.chan { display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.035); border: 1px solid transparent; }
.chan.live { border-color: rgba(232, 183, 106, 0.35); }
.screen { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #070812; }
.screen iframe, .screen > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.chan-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
.chan-top { display: flex; align-items: baseline; gap: 10px; }
.chan-title { font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.chan-state { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.chan.live .chan-state { color: var(--gold); }
.chan-vol { display: grid; grid-template-columns: 1fr 2.4em; gap: 10px; align-items: center; color: var(--muted); font-size: 0.84rem; }
.chan-vol output { text-align: right; font-variant-numeric: tabular-nums; }
.timing summary { cursor: pointer; font-size: 0.8rem; color: var(--muted); }
.timing summary:hover, .timing[open] summary { color: var(--gold); }
.tgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 10px 0 6px; }
.tfield { display: grid; grid-template-columns: 1fr 64px auto; gap: 6px; align-items: center; font-size: 0.82rem; color: var(--muted); }
.tfield input { padding: 6px 8px; text-align: center; }
.tfield em { font-style: normal; font-size: 0.74rem; width: 2em; }
.timing .muted { font-size: 0.76rem; }
.screen .note { display: grid; place-content: center; font-size: 2.4rem; color: var(--gold); opacity: 0.7; }
.screen video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.chan.bad { border-color: rgba(238, 154, 143, 0.5); }
.chan.bad .chan-state { color: var(--rose); }
.chan-help { display: grid; gap: 8px; font-size: 0.84rem; color: var(--text); background: rgba(238, 154, 143, 0.08); border-radius: 10px; padding: 10px 12px; }
.chan-help .row { flex-wrap: wrap; }
.chan-help a.btn { text-decoration: none; }
.add-msg { font-size: 0.9rem; background: rgba(238, 154, 143, 0.1); border: 1px solid rgba(238, 154, 143, 0.4); border-radius: 10px; padding: 10px 12px; }
.dlg-body .row { flex-wrap: wrap; }
.chan-btns { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.chan-btns .btn { padding: 7px 12px; font-size: 0.82rem; }
.chan-empty { text-align: center; padding: 26px 12px; display: grid; gap: 14px; justify-items: center; color: var(--muted); }
.chan-empty p { max-width: 38ch; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.amb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 28px; }
.vol { display: grid; grid-template-columns: 6.5em 1fr 2.6em; gap: 10px; align-items: center; font-size: 0.84rem; color: var(--muted); }
.vol output { text-align: right; font-variant-numeric: tabular-nums; }
input[type="text"], input[type="url"], textarea, input[type="number"] {
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--panel-b); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
textarea { resize: vertical; font-family: var(--serif); font-size: 1.02rem; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #747892; }
input[type="range"] { accent-color: var(--gold); width: 100%; min-width: 0; height: 22px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; gap: 16px; }

/* Session column */
.now { position: sticky; top: 16px; display: grid; gap: 16px; text-align: center; background: var(--panel); border: 1px solid var(--panel-b); border-radius: var(--r); padding: 22px 20px; }
.clock { position: relative; }
.phase { font-size: 0.74rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold); }
.time { font-family: var(--serif); font-size: clamp(3.2rem, 6vw, 4.6rem); font-variant-numeric: tabular-nums; line-height: 1.05; position: relative; }
.breath-cue { font-size: 0.82rem; color: var(--muted); min-height: 1.2em; }
.breath { position: absolute; left: 50%; top: 50%; width: 140px; height: 140px; margin: -70px; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(232, 183, 106, 0.3), rgba(232, 183, 106, 0) 70%); transform: scale(0.6); transition: transform 4s ease-in-out, opacity 1s; }
.breath.on { opacity: 1; }
.breath.in { transform: scale(1.6); transition-duration: 4s; }
.breath.out { transform: scale(0.6); transition-duration: 6s; }
.prompt { font-family: var(--serif); font-size: 1.02rem; opacity: 0.9; min-height: 3em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chips button, .chips .custom input { border: 1px solid var(--panel-b); background: transparent; border-radius: 999px; padding: 7px 0; width: 46px; text-align: center; cursor: pointer; }
.chips .custom input { width: 64px; cursor: text; }
.chips button.on { background: var(--gold); color: #241806; border-color: transparent; font-weight: 700; }
.verse { margin: 0; padding: 18px; border-radius: 14px; background: rgba(232, 183, 106, 0.07); border: 1px solid rgba(232, 183, 106, 0.2); text-align: left; }
.verse blockquote { margin: 0 0 10px; font-family: var(--serif); font-size: 1.12rem; line-height: 1.55; transition: opacity 0.6s; }
.verse figcaption { display: flex; justify-content: space-between; gap: 12px; font-size: 0.84rem; color: var(--gold); }
.more { text-align: left; }
.more summary { cursor: pointer; color: var(--muted); font-size: 0.86rem; padding: 4px 0; }
.more summary:hover { color: var(--text); }
.more-in { display: grid; gap: 10px; padding-top: 10px; }
.more hr { border: 0; border-top: 1px solid var(--panel-b); width: 100%; margin: 4px 0; }
.check { font-size: 0.88rem; color: var(--muted); }
.check input { accent-color: var(--gold); margin-right: 8px; }
.check small { opacity: 0.8; }
.meter { display: block; width: 2.6em; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.1s; }
.meter i.hot { background: var(--rose); }

/* Gallery (inside Add music) */
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px 14px; }
.card { display: grid; gap: 3px; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; width: 100%; }
.card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: #070812; border: 1px solid var(--panel-b); transition: transform 0.2s, border-color 0.2s; }
.card:hover img { transform: translateY(-2px); border-color: var(--gold); }
.card-t { font-size: 0.86rem; font-weight: 500; line-height: 1.3; margin-top: 5px; }
.card small { color: var(--muted); font-size: 0.76rem; }
.card.added { opacity: 0.45; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.stats div { background: rgba(255, 255, 255, 0.04); border-radius: 12px; padding: 10px 4px; }
.stats b { display: block; font-family: var(--serif); font-size: 1.4rem; }
.stats span { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.entries .none { color: var(--muted); font-size: 0.88rem; background: none; padding: 4px 0; }

/* Pinned control bar */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(16, 19, 36, 0.92); backdrop-filter: blur(14px); border-top: 1px solid var(--panel-b);
  padding-bottom: env(safe-area-inset-bottom); transition: opacity 0.4s;
}
.progress { height: 3px; background: rgba(255, 255, 255, 0.07); }
.progress i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 1s linear; }
.bar-in { max-width: 1240px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 12px; }
.bar .btn.primary { min-width: 104px; padding: 12px 22px; font-size: 1rem; }
.bar-time { display: flex; flex-direction: column; line-height: 1.15; margin-right: auto; }
.bar-time b { font-family: var(--serif); font-size: 1.3rem; font-variant-numeric: tabular-nums; font-weight: 500; }
.bar-time span { font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); }
.bar .btn.duck { padding: 12px 20px; }
.master { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.master input { width: 120px; }

/* Dialogs */
.dlg { border: 1px solid var(--panel-b); border-radius: var(--r); background: #171b30; color: var(--text); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: 86dvh; }
.dlg::backdrop { background: rgba(5, 6, 14, 0.7); backdrop-filter: blur(4px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--panel-b); position: sticky; top: 0; background: #171b30; margin: 0; z-index: 1; }
.dlg-head h3 { font-family: var(--serif); font-size: 1.25rem; }
.dlg-head .btn { width: 38px; height: 38px; padding: 0; }
.dlg.wide { width: min(860px, calc(100vw - 32px)); }
.dlg-body { padding: 18px; display: grid; gap: 12px; }
.dlg-body h4 { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.entries li { padding: 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.entries header { display: flex; justify-content: space-between; gap: 10px; font-size: 0.78rem; color: var(--gold); margin-bottom: 4px; }
.entries p { font-family: var(--serif); white-space: pre-wrap; }
.prose p, .prose li { font-size: 0.94rem; }
.prose ol { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 28px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #23284a; border: 1px solid var(--panel-b); padding: 10px 18px; border-radius: 14px; font-size: 0.9rem;
  transition: opacity 0.3s, transform 0.3s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Focus mode: only timer and verse, with a quiet control bar. The mixer stays rendered off-screen so music keeps playing. */
body.focus .top, body.focus .sessions, body.focus .chips, body.focus .more { display: none; }
body.focus .mix { position: absolute; left: -200vw; top: 0; width: 900px; height: 500px; overflow: hidden; visibility: hidden; }
body.focus .cols { grid-template-columns: 1fr; }
body.focus .wrap { min-height: calc(100dvh - var(--bar-h) - 24px); display: grid; align-content: center; }
body.focus .now { position: static; background: none; border: 0; max-width: 760px; margin: 0 auto; gap: 26px; }
body.focus .time { font-size: clamp(5rem, 16vw, 10rem); }
body.focus .prompt { font-size: 1.3rem; }
body.focus .verse blockquote { font-size: 1.5rem; }
body.focus #btnVerse { visibility: hidden; }
body.focus .bar { opacity: 0.4; }
body.focus .bar:hover, body.focus .bar:focus-within { opacity: 1; }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .now { position: static; }
  .prompt { min-height: 0; }
}
@media (max-width: 760px) {
  :root { --bar-h: 124px; }
  .bar-in { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .bar .btn.duck { order: 5; flex: 1 1 100%; padding: 13px; }
  .bar .btn.duck kbd, .master span { display: none; }
  .master { flex: 1; min-width: 80px; } .master input { width: 100%; }
  .chan { grid-template-columns: 150px minmax(0, 1fr); gap: 10px 14px; }
  .chan-btns { grid-column: 1 / -1; flex-direction: row; }
  .chan-btns .btn { flex: 1; }
}
@media (max-width: 620px) {
  .wrap, .top { padding-left: 14px; padding-right: 14px; }
  .chan { grid-template-columns: 120px minmax(0, 1fr); gap: 10px 12px; }
  .chan-btns { grid-column: 1 / -1; flex-direction: row; }
  .chan-btns .btn { flex: 1; }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .sess { min-width: 180px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
