/* Kimi Home Hub — Dieter Rams / Braun flavour.
   Tokens are taken verbatim from the design handoff. Radius is 2px everywhere,
   one accent colour only, no shadows beyond panel lift, no decorative motion. */

:root {
  /* Typography follows the reference display: a light geometric face for numerals
     and headings, a technical mono for every machine value. */
  --f: "Oxanium", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --fd: "Oxanium", "Helvetica Neue", Helvetica, sans-serif;
  --fn: "JetBrains Mono", ui-monospace, monospace;
  --bg: #E9E7E1; --surface: #F5F4F0; --sunk: #E1DED7;
  /* --mute darkened from #7C7A70 (≈3.5:1) to meet WCAG AA (≥4.5:1) on --bg/--surface */
  --ink: #16150F; --mute: #5F5D55;
  --line: rgba(0,0,0,.14); --line2: rgba(0,0,0,.07);
  --signal: #E0491B; --onink: #FFFFFF; --knob: #FAF9F6; --good: #2F7D53;
  --shadow: rgba(0,0,0,.13); --r: 2px;
  --ease: cubic-bezier(.2,.8,.2,1);
}
[data-theme="dark"] {
  --bg: #131311; --surface: #1C1C19; --sunk: #0E0E0C;
  --ink: #EDEBE3; --mute: #8B887E;
  --line: rgba(255,255,255,.15); --line2: rgba(255,255,255,.07);
  --signal: #FF6A2B; --onink: #16150F; --knob: #D9D6CD; --shadow: rgba(0,0,0,.5); --good: #56B487;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 13px/1.45 var(--f);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 0; height: 0; }
.mono { font-family: var(--fn); font-variant-numeric: tabular-nums; }

/* Big readouts take the display face at a light weight, wide-set, like the
   reference clock. Small machine values stay mono. */
.readout {
  font-family: var(--fd); font-weight: 200; letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}

@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes panelIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Theme swap: while .theming is on the root, every colour eases to its new value
   instead of flashing. The class lives only for the ~500ms of the change. */
.theming *, .theming *::before, .theming *::after {
  transition:
    background-color .45s ease, background .45s ease, color .45s ease,
    border-color .45s ease, box-shadow .45s ease, fill .45s ease, stroke .45s ease !important;
}

/* Respect a user's reduced-motion preference: near-instant transitions, no slide/
   fade-in, and — critically — no infinite spin (the record needle). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------- shell */

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#chrome { display: flex; flex: 1; min-height: 0; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
#scroller { flex: 1; min-height: 0; overflow-y: auto; }
/* Album art, out of focus, behind the whole Musik content area. Sits under the
   header + scroller; a gradient toward --bg keeps every text layer readable. */
#artBackdrop {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: center 22%/cover no-repeat;
  filter: blur(26px) saturate(1.2);
  transform: scale(1.15);
  opacity: 0; transition: opacity .6s ease;
}
#artBackdrop.show { opacity: .42; }
[data-theme="dark"] #artBackdrop.show { opacity: .32; }
#artBackdrop::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg,
    color-mix(in srgb, var(--bg) 42%, transparent) 0%,
    color-mix(in srgb, var(--bg) 30%, transparent) 45%,
    color-mix(in srgb, var(--bg) 62%, transparent) 100%);
}
main > header, main > #scroller, main > #transport { position: relative; z-index: 1; }
.view { display: none; animation: viewIn .26s var(--ease); padding: 0 20px 24px; }
.view.active { display: block; }

/* title bar (desktop only) */
#titlebar {
  display: none; height: 38px; flex: none; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--line); background: var(--sunk); display: block; }
#titleText { font: 600 9.5px/1 var(--f); letter-spacing: .18em; text-transform: uppercase; color: var(--mute); }

/* header */
header { padding: calc(18px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) 14px calc(20px + env(safe-area-inset-left)); display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.eyebrow { font: 600 9.5px/1 var(--f); letter-spacing: .18em; text-transform: uppercase; color: var(--mute); }
h1 { font: 300 27px/1.1 var(--fd); letter-spacing: -.01em; margin: 7px 0 0; }
#metrics { display: none; margin-left: auto; gap: 26px; }
#metrics .m-label { font: 600 9px/1 var(--f); letter-spacing: .16em; text-transform: uppercase; color: var(--mute); }
#metrics .m-value {
  font-family: var(--fd); font-weight: 200; font-variant-numeric: tabular-nums;
  font-size: 19px; margin-top: 6px;
}
#metrics .m-value span { font-size: 10px; color: var(--mute); margin-left: 3px; }

/* navigation */
nav { flex: none; background: var(--surface); }
#tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#tabbar .tab {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 0 10px;
  font: 500 9.5px/1 var(--f); letter-spacing: .1em; text-transform: uppercase; color: var(--mute);
  transition: color .25s;
}
#tabbar .tab.on { color: var(--signal); }
.glyph { width: 16px; height: 16px; border: 1px solid currentColor; border-radius: var(--r); position: relative; }
.glyph.g-rum::after, .glyph.g-rum::before { content: ""; position: absolute; background: currentColor; }
.glyph.g-rum::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.glyph.g-rum::after { top: 50%; left: 0; right: 0; height: 1px; }
.glyph.g-musik { border-radius: 50%; }
.glyph.g-musik::after { content: ""; position: absolute; inset: 5px; border: 1px solid currentColor; border-radius: 50%; }
.glyph.g-energi { border: none; }
.glyph.g-energi::after {
  content: ""; position: absolute; left: 4px; top: 0; width: 8px; height: 16px; background: currentColor;
  clip-path: polygon(60% 0, 0 60%, 45% 60%, 30% 100%, 100% 40%, 55% 40%);
}
.glyph.g-mer { border: none; }
.glyph.g-mer::after {
  content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 1px;
  background: currentColor; box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
}

#rail { display: none; width: 196px; flex: none; border-right: 1px solid var(--line); flex-direction: column; }
#rail .brand { padding: 20px 22px 14px; }
#rail .brand .name { font: 400 15px/1 var(--f); letter-spacing: -.01em; margin-top: 6px; }
#rail .tab {
  display: flex; align-items: center; gap: 12px; padding: 11px 22px; width: 100%;
  font: 500 11px/1 var(--f); letter-spacing: .1em; text-transform: uppercase; color: var(--mute);
  transition: color .25s, background .25s;
}
#rail .tab.on { color: var(--signal); background: var(--sunk); }
#railScenes { margin-top: auto; padding: 16px 22px 20px; border-top: 1px solid var(--line); display: none; }

/* ---------------------------------------------------------------- primitives */

.section { margin-top: 22px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--line);
}
.section-title { font: 600 9.5px/1 var(--f); letter-spacing: .18em; text-transform: uppercase; color: var(--mute); }
.link { color: var(--signal); font: 500 11px/1 var(--f); letter-spacing: .08em; text-transform: uppercase; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }

/* Pill switch: recessed capsule, raised round knob, and a small ring on the side
   the knob is not on. The ring carries the state colour — orange when active. */
/* Capsule with a raised puck that overhangs it top and bottom, a debossed "O"
   when off and a white "1" when on — as in the reference renders. */
.toggle {
  /* The puck sits inside the recess with a 2px margin — never overhanging it. */
  --tw: 46px; --th: 24px; --tk: 20px;
  width: var(--tw); height: var(--th); flex: none; position: relative; border: none;
  border-radius: 99px; overflow: visible;
  background: linear-gradient(180deg, #d7d4cd 0%, #eeece7 100%);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,.16),
    inset 0 -1px 0 rgba(255,255,255,.85),
    0 1px 0 rgba(255,255,255,.7);
  transition: background .3s;
}
.toggle.on {
  background: linear-gradient(180deg, #c8390f 0%, var(--signal) 45%, #f4652f 100%);
  box-shadow:
    inset 0 2px 5px rgba(0,0,0,.22),
    inset 0 -1px 0 rgba(255,255,255,.35),
    0 1px 0 rgba(255,255,255,.55);
}

.toggle i {
  position: absolute; top: 50%; left: 2px; width: var(--tk); height: var(--tk); display: block;
  margin-top: calc(var(--tk) / -2); border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #ffffff 0%, #fdfdfc 45%, #eae7e1 100%);
  box-shadow: 0 2px 5px rgba(0,0,0,.22), 0 1px 1px rgba(0,0,0,.14);
  transition: transform .26s var(--ease);
  z-index: 2;
}
.toggle.on i { transform: translateX(calc(var(--tw) - var(--tk) - 4px)); }

/* off: a circle pressed into the surface */
.toggle::after {
  content: ""; position: absolute; top: 50%; right: 7px;
  width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%;
  background: linear-gradient(180deg, #d5d2cb, #e9e7e2);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.28), 0 1px 0 rgba(255,255,255,.75);
  transition: opacity .2s;
}
.toggle.on::after { opacity: 0; }

/* on: a soft white bar */
.toggle::before {
  content: ""; position: absolute; top: 50%; left: 10px;
  width: 3px; height: 10px; margin-top: -5px; border-radius: 2px;
  background: rgba(255,255,255,.95); box-shadow: 0 1px 2px rgba(0,0,0,.18);
  opacity: 0; transition: opacity .2s;
  z-index: 1;
}
.toggle.on::before { opacity: 1; }

/* Dark theme: near-black capsule, bright white puck, the ring pressed into the
   surface — matching the dark render. */
[data-theme="dark"] .toggle {
  background: linear-gradient(180deg, #0c0c0b 0%, #24231f 100%);
  box-shadow:
    inset 0 2px 5px rgba(0,0,0,.85),
    inset 0 -1px 0 rgba(255,255,255,.10),
    0 1px 0 rgba(255,255,255,.06);
}
[data-theme="dark"] .toggle::after {
  background: linear-gradient(180deg, #171614 0%, #2a2825 100%);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.9), 0 1px 0 rgba(255,255,255,.07);
}
[data-theme="dark"] .toggle i {
  background: radial-gradient(circle at 36% 28%, #ffffff 0%, #fbfbfa 50%, #e4e1da 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,.55), 0 1px 1px rgba(0,0,0,.4);
}
[data-theme="dark"] .toggle.on {
  background: linear-gradient(180deg, #b8340d 0%, var(--signal) 45%, #ff7b45 100%);
  box-shadow: inset 0 2px 5px rgba(0,0,0,.5), inset 0 -1px 0 rgba(255,255,255,.25);
}

/* Keep the flip visible on every surface. On the dark default the off-capsule
   sits on a near-black page, so a hairline ring makes the small room toggles on
   a phone unmistakable. Outline follows the pill radius and adds no layout width. */
.toggle { outline: 1px solid rgba(0,0,0,.14); outline-offset: -1px; }
.toggle.on { outline-color: rgba(0,0,0,.22); }
[data-theme="dark"] .toggle {
  background: linear-gradient(180deg, #201f1c 0%, #333029 100%);
  outline: 1px solid rgba(255,255,255,.22);
}
[data-theme="dark"] .toggle.on {
  outline-color: rgba(0,0,0,.35);
}

.fader { position: relative; height: 24px; margin-top: 6px; cursor: pointer; touch-action: none; }
.fader .track { position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: var(--sunk); }
.fader .fill { position: absolute; left: 0; top: 11px; height: 2px; background: var(--signal); }
.fader .knob {
  position: absolute; top: 1px; width: 8px; height: 21px; background: var(--knob);
  border: 1px solid var(--line); border-radius: var(--r); transform: translateX(-50%);
  box-shadow: 0 1px 2px var(--shadow);
}

.btn {
  border: 1px solid var(--line); border-radius: var(--r); padding: 9px 14px; background: transparent;
  font: 500 10.5px/1 var(--f); letter-spacing: .14em; text-transform: uppercase; color: var(--ink);
  transition: background .25s, color .25s, border-color .25s;
}
.btn:hover { border-color: var(--ink); }
.btn.fill { background: var(--signal); border-color: var(--signal); color: var(--onink); }
.btn.fill:hover { border-color: var(--signal); }
.btn:disabled { opacity: .45; cursor: default; }

.chip {
  border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; background: transparent;
  font: 500 9.5px/1 var(--f); letter-spacing: .12em; text-transform: uppercase; color: var(--mute);
  transition: background .25s, color .25s;
}
.chip.on { background: var(--signal); border-color: var(--signal); color: var(--onink); }

.field {
  width: 100%; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 11px; font-size: 12.5px; color: var(--ink); outline: none;
}
.field:focus { border-color: var(--signal); }
/* Keyboard focus gets a clear ring; mouse/touch focus keeps just the border. */
.field:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.field::placeholder { color: var(--mute); }

.note { font: 400 11.5px/1.5 var(--f); color: var(--mute); }
.banner {
  border: 1px solid var(--line); border-left: 2px solid var(--signal); border-radius: var(--r);
  padding: 11px 13px; font-size: 12px; color: var(--ink); background: var(--surface);
  display: flex; gap: 12px; align-items: baseline;
}
.banner button { color: var(--signal); font-weight: 600; white-space: nowrap; }
.banner.mute { border-left-color: var(--line); color: var(--mute); }

.empty { padding: 26px 8px; text-align: center; color: var(--mute); font-size: 12px; }
.skel { background: var(--sunk); animation: fadeIn .3s; }

/* stat grid */
.stats { display: grid; grid-template-columns: 1fr 1fr; }
.stats .cell { padding: 13px 0; border-bottom: 1px solid var(--line2); }
.stats .cell:nth-child(odd) { padding-right: 14px; border-right: 1px solid var(--line2); }
.stats .cell:nth-child(even) { padding-left: 14px; }
.stats .label { font: 600 9px/1 var(--f); letter-spacing: .16em; text-transform: uppercase; color: var(--mute); }
.stats .value {
  font-family: var(--fd); font-weight: 200; font-variant-numeric: tabular-nums;
  font-size: 26px; margin-top: 7px; letter-spacing: .01em;
}
.stats .value span { font-size: 11px; color: var(--mute); margin-left: 4px; }

/* scenes */
.scenes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.scene {
  border: 1px solid var(--line); border-radius: var(--r); padding: 11px 10px 10px; text-align: left;
  transition: background .25s, color .25s, border-color .25s;
}
.scene .num { font-family: var(--fn); font-variant-numeric: tabular-nums; font-size: 15px; }
.scene .lbl { font: 600 9.5px/1 var(--f); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); margin-top: 7px; }
.scene.on { background: var(--signal); border-color: var(--signal); color: var(--onink); }
.scene.on .lbl { color: var(--onink); }

/* room rows */
.room { padding: 10px 0; border-bottom: 1px solid var(--line2); break-inside: avoid; }
.room .top { display: flex; align-items: center; gap: 12px; }
.room .name {
  flex: 1; min-width: 0; font-size: 13.5px; text-align: left; color: var(--mute);
  transition: color .3s; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.room.on .name { color: var(--ink); }
.room .pct { font-family: var(--fn); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--mute); }
.room .meta { font-family: var(--fn); font-size: 10px; color: var(--mute); letter-spacing: .04em; margin-top: 3px; }

/* Rum: all 21 rooms plus 3 floor headers must fit without scrolling, so rows are
   ~50px and the fader shrinks to 18px. */
#allRooms .room { padding: 6px 0; }
#allRooms .fader { height: 18px; margin-top: 3px; }
#allRooms .fader .track, #allRooms .fader .fill { top: 8px; }
#allRooms .fader .knob { top: 0; height: 17px; }
#allRooms .toggle { --tw: 42px; --th: 22px; --tk: 18px; }
#allRooms .toggle::after { right: 6px; width: 8px; height: 8px; margin-top: -4px; }
#allRooms .toggle::before { left: 9px; width: 2.5px; height: 9px; margin-top: -4.5px; }

.floor-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 12px 0 7px; border-bottom: 1px solid var(--line);
  break-inside: avoid; break-after: avoid;
}
.floor-head .f-name { font: 600 9.5px/1 var(--f); letter-spacing: .18em; text-transform: uppercase; color: var(--mute); }
.floor-head .f-count { font-family: var(--fn); font-variant-numeric: tabular-nums; font-size: 10.5px; color: var(--mute); }

/* player */
.art { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); display: flex; align-items: center; justify-content: center; background-size: cover; background-position: center; }
.disc { border-radius: 50%; background: var(--signal); position: relative; }
.disc::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--surface); }
.play {
  width: 44px; height: 44px; flex: none; background: var(--signal); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
}
.tri { width: 0; height: 0; border-style: solid; }
.tri.right { border-width: 8px 0 8px 13px; border-color: transparent transparent transparent var(--onink); margin-left: 2px; }
.pause { display: flex; gap: 4px; }
.pause i { width: 4px; height: 15px; background: var(--onink); display: block; }
.step { width: 34px; height: 34px; position: relative; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--r); }
/* Extend the tap target to ≥44px tall without changing the painted size or the
   horizontal footprint (so adjacent controls never overlap). */
.step::after { content: ""; position: absolute; inset: -5px 0; }
.step .tri.right { border-color: transparent transparent transparent var(--ink); border-width: 6px 0 6px 10px; }
.step .tri.left { border-width: 6px 10px 6px 0; border-color: transparent var(--ink) transparent transparent; }
.rail2 { height: 2px; background: var(--sunk); position: relative; }
.rail2 i { position: absolute; left: 0; top: 0; height: 2px; background: var(--signal); display: block; }

/* ---------------------------------------------------------------- player
   One card, two sizes. A square tile holds the album art, or a line-drawn record
   whose needle turns while something plays — the state is readable without any
   extra chrome. */
.player-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.player-body { display: flex; align-items: center; gap: 18px; }
.player-title { font-size: 19px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-artist { font-size: 13px; color: var(--mute); margin-top: 4px; }
.player-meta { font-family: var(--fn); font-size: 11.5px; color: var(--mute); margin-top: 9px; letter-spacing: .02em; }
.play-square {
  flex: none; background: var(--signal); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
}

.record { flex: none; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; background-size: cover; background-position: center; }
.record .vinyl { position: relative; border-radius: 50%; border: 1.5px solid var(--ink); }
.record .vinyl::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%;
  transform: translate(-50%, -50%); border-radius: 50%; background: var(--signal);
}
.record .needle {
  position: absolute; left: 50%; top: 50%; width: 50%; height: 1.5px; background: var(--signal);
  transform-origin: 0 50%; transform: rotate(-38deg);
  transition: transform .9s cubic-bezier(.65, 0, .35, 1);
}
.record.spin .needle { animation: needle 3.4s linear infinite; transition: none; }
@keyframes needle { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* segmented control */
.segments { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.segments button {
  padding: 10px 0; font: 500 10px/1 var(--f); letter-spacing: .12em; text-transform: uppercase;
  color: var(--mute); border-right: 1px solid var(--line); transition: background .25s, color .25s;
}
.segments button:last-child { border-right: none; }
.segments button.on { background: var(--signal); color: var(--onink); }

/* Player split: cover + transport on the left, the playing context's track list
   on the right. Portrait or narrow → the list stacks under the cover. */
/* Translucent so the Musik backdrop shows through the card, not just around it. */
.player-split {
  display: flex; gap: 26px; align-items: flex-start; position: relative;
  background: var(--surface);   /* fallback for engines without color-mix() */
  background: color-mix(in srgb, var(--surface) 52%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.player-split .ps-main { flex: 1; min-width: 0; position: relative; z-index: 1; }
.player-split .ps-list {
  position: relative; z-index: 1;
  width: 340px; flex: none; max-height: 400px; overflow-y: auto;
  border-left: 1px solid var(--line2); padding-left: 22px;
  /* Visible scrollbar -- the global rule hides all scrollbars, override it here. */
  scrollbar-width: thin; scrollbar-color: var(--signal) transparent;
}
.player-split .ps-list::-webkit-scrollbar { width: 8px; }
.player-split .ps-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--signal) 70%, transparent);
  border-radius: 99px; border: 2px solid transparent; background-clip: padding-box;
}
.player-split .ps-list::-webkit-scrollbar-thumb:hover { background: var(--signal); }
.player-split .ps-list::-webkit-scrollbar-track { background: transparent; }

/* Every card/box eases when it grows, shrinks, fades or moves. */
.section, .panel, .room, .banner, .esugg-row, .two-even > div {
  transition: opacity .4s var(--ease), transform .4s var(--ease), max-height .5s var(--ease);
}

/* When something is really playing, the Musik player takes over: it grows, the
   art backdrop shows behind it, and the secondary zones column eases away so the
   right-hand menu (playlists/queue) sits beside a larger player. */
#musicPlayer { transition: min-height .45s var(--ease), padding .45s var(--ease); }
#view-musik.playing #musicPlayer { min-height: 340px; }
#view-musik.playing .two-even { grid-template-columns: 1fr; }
#view-musik.playing .two-even > div:first-child {
  opacity: 0; max-height: 0; transform: translateX(-16px); overflow: hidden; pointer-events: none;
}
@media (max-width: 900px), (orientation: portrait) {
  .player-split { flex-direction: column; }
  .player-split .ps-list {
    width: 100%; max-height: 320px;
    border-left: none; padding-left: 0;
    border-top: 1px solid var(--line2); padding-top: 14px;
  }
}

/* ---------------------------------------------------------------- presets
   Three assignable slots under the playlist list, shaped like the transport
   buttons on a Braun receiver. The square in a playlist row is the handle:
   press it to store that playlist in the next free slot. */
.preset-source { flex: 1; min-height: 0; }
.presets {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line);
}
.preset {
  position: relative; border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 9px 9px; text-align: left; min-height: 58px;
  transition: background .25s, border-color .25s, color .25s;
}
.preset .p-num { display: block; font-family: var(--fn); font-size: 9.5px; letter-spacing: .16em; color: var(--mute); }
.preset .p-name {
  display: block; font-size: 12px; margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preset.empty { border-style: dashed; }
.preset.empty .p-name { color: var(--mute); }
.preset.on { background: var(--signal); border-color: var(--signal); color: var(--onink); }
.preset.on .p-num { color: var(--onink); }
.preset .p-clear {
  position: absolute; top: 4px; right: 6px; font-size: 13px; line-height: 1; color: var(--mute);
}
.preset.on .p-clear { color: var(--onink); }
.preset.armed { border-color: var(--signal); }
/* drag-and-drop affordances */
.preset.drop { border-color: var(--signal); border-style: solid; background: rgba(224,73,27,.10); }
.qrow[draggable="true"] { cursor: grab; }
.qrow.dragging { opacity: .45; cursor: grabbing; }

.sq {
  width: 26px; height: 26px; flex: none; position: relative; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--sunk) center/cover; transition: background .25s, border-color .25s;
}
.sq::after { content: ""; position: absolute; inset: -9px 0; }   /* ≥44px tap height */
.sq.on { background: var(--signal); border-color: var(--signal); }

/* ---------------------------------------------------------------- weather */
.wx-hero { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; padding: 6px 0 4px; }
.wx-hero-icon { color: var(--signal); display: block; }
.wx-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 22px; }
.wx-stat { border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px; }

/* Forecast cells fill the full width instead of scrolling in a narrow strip. */
.wx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 10px; }
.wx-cell {
  border: 1px solid var(--line); border-radius: var(--r); padding: 14px 8px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.wx-week { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; }
.wx-day {
  border: 1px solid var(--line); border-radius: var(--r); padding: 16px 12px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 11px;
}
.wx-range { display: flex; align-items: baseline; gap: 9px; }

/* charts */
.daycurve { display: flex; align-items: flex-end; gap: 2px; height: 96px; }
.daycurve i { flex: 1; background: var(--sunk); display: block; transition: height .5s var(--ease); }
.daycurve i.cheap { background: var(--signal); }
.axis { display: flex; justify-content: space-between; font-family: var(--fn); font-size: 9.5px; color: var(--mute); margin-top: 7px; }

/* Startup splash — logotype + pay-off, fades to the app on load */
#splash {
  position: fixed; inset: 0; z-index: 500; background: var(--bg); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  transition: opacity .5s ease; padding: 24px;
}
#splash.gone { opacity: 0; pointer-events: none; }
.splash-lock { display: flex; align-items: center; gap: clamp(16px, 4vw, 26px); }
#splash .house { width: clamp(54px, 13vw, 82px); height: auto; display: block; flex: none; }
#splash .house .wall { fill: none; stroke: var(--signal); stroke-width: 2.6; }
#splash .house .win { fill: none; stroke: var(--signal); stroke-width: 2; }
.splash-word { font: 600 clamp(28px, 8.4vw, 50px)/0.92 var(--f); letter-spacing: -.01em; text-transform: uppercase; -webkit-text-stroke: .8px currentColor; }
.splash-pay { font-family: var(--fn); font-size: clamp(10px, 2.6vw, 13px); letter-spacing: .22em; color: var(--signal); text-transform: uppercase; }

/* Screensaver — full-screen Braun clock + now-playing, shown when idle */
#screensaver {
  position: fixed; inset: 0; z-index: 300; display: none;
  background: #08080a; color: #EDEBE3; cursor: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 34px;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
}
#screensaver.on { display: flex; animation: fadeIn .6s ease; }
#saverBody svg { width: min(64vw, 58vh, 460px); height: min(64vw, 58vh, 460px); display: block; }
.saver-digital { text-align: center; font-family: var(--f); }
.saver-digital .t { font-size: min(24vw, 26vh); line-height: 1; letter-spacing: .02em; font-weight: 200; font-variant-numeric: tabular-nums; color: #EDEBE3; }
.saver-date { font-family: var(--f); font-weight: 300; font-size: min(5.4vw, 5vh); letter-spacing: .08em; color: #FF6A2B; text-align: center; }
.saver-np { font-size: 15px; color: #8B887E; letter-spacing: .04em; text-align: center; max-width: 82vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saver-np b { color: #EDEBE3; font-weight: 500; }

/* 24-hour price dial (Braun-style) + suggestions */
.eclock-wrap { display: flex; gap: 24px; align-items: center; justify-content: center; flex-wrap: wrap; }
.eclock { position: relative; width: clamp(148px, 46vw, 196px); aspect-ratio: 1; flex: none; margin-inline: auto; }
.eclock svg { width: 100%; height: 100%; display: block; }
.eclock .tick { font-family: var(--fn); font-size: 9px; fill: var(--mute); }
.eclock-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.eclock-center .lbl { font: 600 8.5px/1 var(--f); letter-spacing: .18em; color: var(--mute); }
.eclock-center .val { font-family: var(--fd); font-weight: 200; font-variant-numeric: tabular-nums; font-size: 24px; margin-top: 4px; }
.eclock-center .unit { font-family: var(--fn); font-size: 9px; color: var(--mute); margin-top: 2px; }
.esugg { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.esugg-row { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r); }
.esugg-row .ic { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.esugg-row .lab { flex: 1; min-width: 0; font-size: 13.5px; }
.esugg-row .lab .note { display: block; margin-top: 2px; }
.esugg-row .time { font-family: var(--fn); font-variant-numeric: tabular-nums; font-size: 12.5px; letter-spacing: .04em; }
.usage { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line2); }
.usage .day { font-family: var(--fn); font-size: 10.5px; color: var(--mute); width: 34px; }
.usage .bar { flex: 1; height: 8px; background: var(--sunk); }
.usage .bar i { display: block; height: 8px; background: var(--signal); transition: width .6s var(--ease); }
.usage .val { font-family: var(--fn); font-variant-numeric: tabular-nums; font-size: 11px; width: 66px; text-align: right; }

/* queue + lists */
.qrow { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line2); width: 100%; text-align: left; }
.qrow .n { font-family: var(--fn); font-size: 10.5px; color: var(--mute); width: 20px; }
.qrow.on .n, .qrow.on .t { color: var(--signal); }
.qrow .t { font-size: 13px; }
.qrow .a { font-size: 11.5px; color: var(--mute); }
.qrow .d { margin-left: auto; font-family: var(--fn); font-size: 10.5px; color: var(--mute); }

.badge {
  width: 30px; height: 30px; flex: none; border: 1px solid var(--line); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fn); font-size: 10.5px; color: var(--mute);
}
.badge.on { background: var(--signal); border-color: var(--signal); color: var(--onink); }

/* transport bar (desktop) */
#transport { display: none; height: 86px; flex: none; border-top: 1px solid var(--line); background: var(--surface); align-items: center; gap: 22px; padding: 0 24px; }

/* room detail */
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: none; animation: fadeIn .2s; }
#scrim.open { display: block; }
#detail {
  position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--line);
  display: none; flex-direction: column;
  /* phone default: a bottom sheet. The ≥768px rule turns it into a side panel. */
  left: 0; right: 0; bottom: 0; top: auto;
  max-height: 88dvh; border-radius: 2px 2px 0 0;
  animation: sheetUp .3s var(--ease);
}
#detail.open { display: flex; }
#detail .body { padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; }
.bigfader { position: relative; height: 48px; cursor: pointer; touch-action: none; margin-top: 12px; }
.bigfader .track { position: absolute; left: 0; right: 0; top: 23px; height: 3px; background: var(--sunk); }
.bigfader .fill { position: absolute; left: 0; top: 23px; height: 3px; background: var(--signal); }
.bigfader .knob {
  position: absolute; top: 7px; width: 14px; height: 35px; background: var(--knob); border: 1px solid var(--line);
  border-radius: var(--r); transform: translateX(-50%); box-shadow: 0 1px 3px var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.bigfader .knob::after { content: ""; width: 7px; height: 1px; background: var(--line); }

/* expanded player — rises from the transport */
#playerSheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: 0; z-index: 60;
  background: var(--bg); display: none; flex-direction: column;
  transform: translateY(100%);
}
#playerSheet.open { display: flex; animation: sheetUp .3s var(--ease) forwards; }
#playerSheet .head {
  flex: none; padding: calc(16px + env(safe-area-inset-top)) 20px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; gap: 14px;
}
#playerSheet .body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px 28px; }
.handle { width: 34px; height: 3px; background: var(--line); border-radius: var(--r); margin: 0 auto 12px; display: block; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 9px 0; border-bottom: 1px solid var(--line2);
}
.result .thumb {
  width: 40px; height: 40px; flex: none; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--sunk) center/cover; display: flex; align-items: center; justify-content: center;
}
.result .thumb.round { border-radius: 50%; }
.result .nm { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .mt { font-size: 11.5px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .kind { margin-left: auto; font-family: var(--fn); font-size: 9.5px; letter-spacing: .14em; color: var(--mute); }
.result:hover .nm { color: var(--signal); }
.clickable { cursor: pointer; }

@media (min-width: 768px) {
  #playerSheet { left: auto; width: 520px; border-left: 1px solid var(--line); }
}
@media (min-width: 1280px) {
  #playerSheet { top: 38px; bottom: 86px; width: 560px; }
}

/* speaker button next to the volume fader */
.spk-btn {
  display: flex; align-items: center; justify-content: center; flex: none; position: relative;
  width: 26px; height: 26px; border: 1px solid var(--line); border-radius: var(--r);
  color: var(--mute); transition: color .2s, border-color .2s;
}
.spk-btn::after { content: ""; position: absolute; inset: -9px 0; }   /* ≥44px tap height */
.spk-btn:hover { color: var(--signal); border-color: var(--signal); }

/* speaker volume list — rises from the volume control, sinks back on close.
   visibility (not display) so both directions animate smoothly. */
#volumePanel {
  position: fixed; right: 20px; bottom: 100px; z-index: 65; width: 330px; max-width: calc(100vw - 32px);
  /* Never taller than the screen — the whole panel scrolls, so every speaker is
     reachable no matter how many speakers + Bluetooth devices there are. */
  max-height: calc(100dvh - 120px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 18px 44px var(--shadow);
  transform: translateY(18px); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform .3s var(--ease), opacity .24s ease, visibility 0s linear .3s;
}
#volumePanel.open {
  transform: translateY(0); opacity: 1; visibility: visible; pointer-events: auto;
  transition: transform .3s var(--ease), opacity .24s ease, visibility 0s;
}
#volumePanel .head {
  padding: 14px 16px 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between;
}
#volumePanel .body { padding: 6px 16px 16px; }
/* Section labels stay put while the panel scrolls. */
#volumePanel .head { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.spk { padding: 11px 0; border-bottom: 1px solid var(--line2); }
.spk:last-child { border-bottom: none; }
.spk .row { display: flex; align-items: baseline; gap: 10px; }
.spk .nm { font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spk .md { font-family: var(--fn); font-size: 9.5px; color: var(--mute); letter-spacing: .1em; }
.spk .pc { font-family: var(--fn); font-size: 11px; }
.spk.playing .nm { color: var(--signal); }
.bt-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.bt-row:last-child { border-bottom: none; }
.bt-row .nm { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-row .md { font-family: var(--fn); font-size: 9.5px; color: var(--mute); letter-spacing: .1em; }
.bt-row .btn { padding: 6px 11px; font-size: 9.5px; }
@media (max-width: 767px) { #volumePanel { bottom: 84px; right: 12px; left: 12px; width: auto; } }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--line); border-left: 2px solid var(--signal);
  border-radius: var(--r); padding: 10px 14px; font-size: 12px; animation: viewIn .2s var(--ease);
  max-width: 320px;
}
.toast.out { opacity: 0; transition: opacity .35s; }

/* setup */
#setup { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.35); display: none; align-items: center; justify-content: center; padding: 20px; }
#setup.open { display: flex; }
#setup .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); width: 100%; max-width: 460px; max-height: 88vh; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- tablet */
@media (min-width: 768px) {
  .view { padding: 0 26px 26px; }
  header { padding: calc(22px + env(safe-area-inset-top)) calc(26px + env(safe-area-inset-right)) 16px calc(26px + env(safe-area-inset-left)); }
  h1 { font-size: 30px; }
  #metrics { display: flex; }
  #tabbar { display: none; }
  #rail { display: flex; }
  .two { display: grid; grid-template-columns: 392px 1fr; gap: 28px; align-items: start; }
  .two-even { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
  .cols2 { column-count: 2; column-gap: 28px; column-rule: 1px solid var(--line2); }
  .cols3 { column-count: 2; column-gap: 28px; column-rule: 1px solid var(--line2); }
  #detail { top: 0; right: 0; bottom: 0; left: auto; width: 392px; max-height: none; border-radius: 0; border-right: none; animation: panelIn .3s var(--ease); }
}

/* ---------------------------------------------------------------- desktop */
@media (min-width: 1280px) {
  .view { padding: 0 32px 28px; }
  header { padding: calc(24px + env(safe-area-inset-top)) calc(32px + env(safe-area-inset-right)) 18px calc(32px + env(safe-area-inset-left)); }
  h1 { font-size: 32px; }
  #titlebar { display: flex; }
  #rail { width: 232px; }
  #railScenes { display: block; }
  #transport { display: flex; }
  .cols3 { column-count: 3; column-gap: 34px; }
  .grid-hem { display: grid; grid-template-columns: 1fr 300px; gap: 32px; align-items: start; }
  #hemAside { display: block !important; }
  #detail { width: 400px; }
}

/* ---------------------------------------------------------------- onboarding tour */
#tour {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
#tour .tour-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
#tour .tour-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px 20px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  animation: tourIn .28s var(--ease);
}
#tour .tour-dots { display: flex; align-items: center; gap: 7px; margin: 18px 0 4px; }
#tour .tour-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .2s; }
#tour .tour-dot.on { background: var(--signal); }
@keyframes tourIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
