/* Heselion Liquid Glass (Phase C11).
   Loaded last. It turns the existing surfaces into real, layered glass over the room,
   makes the room a full-bleed wallpaper with the navigation and deck floating above it,
   and adds the Immersive / Control / Advanced modes. Every value that a person can tune
   comes from src/ui/appearance.js as an --hs-* property on <html>; the defaults below
   are the Liquid Glass preset, so the page looks right before that module runs.
   docs/UI-DESIGN-SYSTEM.md explains the material levels and the rules. */

:root {
  /* Brand (packages/shared/src/brand.js; measured from the official logos) */
  --hs-navy: var(--dm-brand-navy, #0a163d);
  --hs-navy-deep: var(--dm-ground, #060a1a);
  --hs-orange: var(--dm-brand-orange, #fd8601);

  --hs-glass-alpha: 0.473;
  --hs-blur: 26px;
  --hs-blur-soft: 13px;
  --hs-tint: 12%;
  --hs-reflect: 0.6;
  --hs-wall-brightness: 1;
  --hs-wall-saturation: 1;
  --hs-wall-blur: 0px;
  --hs-speed: 1;
  --hs-motion: 1;
  --hs-parallax: 0.4;
  --hs-radius: 22px;
  --hs-glow: 0.6;

  /* The deep navy the glass is made of, tinted toward the room's live colour */
  --hs-base: color-mix(in oklab, var(--hs-navy-deep) calc(100% - var(--hs-tint)), var(--live));
  --hs-edge-light: rgb(255 255 255 / calc(0.07 + 0.16 * var(--hs-reflect)));
  --hs-edge-dark: rgb(0 0 0 / 0.28);
  --hs-sheen-top: rgb(255 255 255 / calc(0.05 + 0.22 * var(--hs-reflect)));
  --hs-gloss: linear-gradient(160deg, rgb(255 255 255 / calc(0.09 * var(--hs-reflect))) 0%, rgb(255 255 255 / 0) 38%),
              linear-gradient(340deg, rgb(255 255 255 / calc(0.04 * var(--hs-reflect))) 0%, rgb(255 255 255 / 0) 30%);

  /* Material levels: how much of the room comes through each kind of surface */
  --hs-m-nav: calc(var(--hs-glass-alpha) * 0.92);        /* floating navigation */
  --hs-m-panel: var(--hs-glass-alpha);                  /* the deck, cards on pages */
  --hs-m-raised: min(0.96, calc(var(--hs-glass-alpha) + 0.22)); /* menus, dialogs, tooltips, toasts */
  --hs-m-page: min(0.94, calc(var(--hs-glass-alpha) + 0.3));    /* technical pages over the wallpaper */
  --hs-m-control: calc(0.05 + 0.08 * var(--hs-reflect));       /* buttons, chips and wells on glass */

  --hs-glass-nav: color-mix(in oklab, var(--hs-base) calc(var(--hs-m-nav) * 100%), transparent);
  --hs-glass-panel: color-mix(in oklab, var(--hs-base) calc(var(--hs-m-panel) * 100%), transparent);
  --hs-glass-raised: color-mix(in oklab, var(--hs-base) calc(var(--hs-m-raised) * 100%), transparent);
  --hs-glass-page: color-mix(in oklab, var(--hs-base) calc(var(--hs-m-page) * 100%), transparent);
  --hs-blur-filter: blur(var(--hs-blur)) saturate(165%) brightness(1.03);
  --hs-blur-filter-soft: blur(var(--hs-blur-soft)) saturate(140%);

  --hs-shadow: 0 24px 60px -24px rgb(0 0 0 / 0.65), 0 2px 8px rgb(0 0 0 / 0.22);
  --hs-shadow-raised: 0 30px 80px -28px rgb(0 0 0 / 0.75), 0 4px 14px rgb(0 0 0 / 0.3);
  --hs-inner: inset 0 1px 0 var(--hs-sheen-top), inset 0 0 0 1px rgb(255 255 255 / 0.04), inset 0 -1px 0 var(--hs-edge-dark);

  /* The existing names now mean glass of the right level */
  --glass: var(--hs-glass-panel);
  --glass-strong: var(--hs-glass-raised);
  --glass-raised: var(--hs-glass-raised);
  --blur: var(--hs-blur-filter);
  --blur-light: var(--hs-blur-filter-soft);
  --edge: var(--hs-edge-light);
  --sheen: var(--hs-inner);
  --lift: var(--hs-shadow);
  --radius-glass: var(--hs-radius);
  --r-lg: var(--hs-radius);

  /* Motion follows the person's speed and intensity */
  --fast: calc(140ms * var(--hs-speed));
  --med: calc(240ms * var(--hs-speed));
  --slow: calc(420ms * var(--hs-speed));
  --hs-cine: calc(720ms * var(--hs-speed));
  /* A critically damped spring, sampled (CSS linear()) */
  --hs-spring: linear(0, 0.034 2%, 0.13 4.4%, 0.27 7.2%, 0.43 10.6%, 0.6 15%, 0.75 20.4%, 0.86 27%, 0.93 35%, 0.97 45%, 0.99 60%, 1);
  --hs-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-hs-motion="reduced"] { --fast: 1ms; --med: 1ms; --slow: 1ms; --hs-cine: 1ms; }

/* Quality levels cap the most expensive effects (src/ui/appearance.js caps the blur too) */
html[data-hs-quality="performance"] {
  --hs-blur-filter: blur(var(--hs-blur)) saturate(130%);
  --hs-gloss: none;
  --hs-shadow: 0 12px 28px -14px rgb(0 0 0 / 0.7);
  --hs-shadow-raised: 0 16px 40px -18px rgb(0 0 0 / 0.75);
}

/* Reduced transparency: solid surfaces, readable over anything */
@media (prefers-reduced-transparency: reduce) {
  :root { --hs-m-nav: 0.97; --hs-m-panel: 0.97; --hs-m-raised: 0.98; --hs-m-page: 0.98; --hs-blur-filter: none; --hs-blur-filter-soft: none; }
}

body { background: var(--hs-navy-deep); }

/* ================= The wallpaper ================= */
/* Two layers so a room change can cross-fade; the live room canvas covers them on the
   room routes, and section pages show them, framed and toned as the person chose. */
.hs-wallpaper {
  position: fixed;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  background: var(--hs-navy-deep);
  pointer-events: none;
}
.hs-wall {
  position: absolute;
  inset: calc(-4% * var(--hs-parallax));
  background-color: var(--hs-navy-deep);
  background-position: calc(var(--x, 0.5) * 100%) calc(var(--y, 0.5) * 100%);
  background-repeat: no-repeat;
  background-size: cover;
  filter: brightness(var(--hs-wall-brightness)) saturate(var(--hs-wall-saturation)) blur(var(--hs-wall-blur));
  opacity: 0;
  transform: translate3d(calc(var(--hs-px, 0) * 24px * var(--hs-parallax)), calc(var(--hs-py, 0) * 16px * var(--hs-parallax)), 0) scale(var(--zoom, 1));
  transition: opacity var(--hs-cine) ease, transform calc(var(--hs-cine) * 1.4) var(--hs-ease-out);
  will-change: opacity, transform;
}
.hs-wall.on { opacity: 1; }
.hs-wall.enter { transform: scale(calc(var(--zoom, 1) * (1 + 0.04 * var(--hs-motion)))); }
/* Over the wallpaper a veil keeps page text readable without blacking the room out */
.hs-wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 70% 10%, transparent 30%, rgb(4 8 24 / 0.55)),
    linear-gradient(180deg, rgb(4 8 24 / 0.32), rgb(4 8 24 / 0.6));
}
/* Glow of the room's live light at the page edges */
.hs-wallpaper::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: -10%;
  background: radial-gradient(45% 40% at 85% 0%, color-mix(in srgb, var(--live) calc(28% * var(--hs-glow)), transparent), transparent 70%),
              radial-gradient(40% 40% at 0% 100%, color-mix(in srgb, var(--hs-orange) calc(18% * var(--hs-glow)), transparent), transparent 70%);
  pointer-events: none;
}

/* ================= Glass surfaces ================= */
.top, .panel, .cinema-bar, .bottom-nav, .tour, .hs-quick {
  background-color: var(--hs-glass-panel);
  background-image: var(--hs-gloss);
  border: 1px solid var(--hs-edge-light);
  box-shadow: var(--hs-inner), var(--hs-shadow);
  -webkit-backdrop-filter: var(--hs-blur-filter);
  backdrop-filter: var(--hs-blur-filter);
}

/* Dialogs, menus, toasts and popovers: the raised level */
dialog.sheet:not(.as-page):not(.as-panel), .toast, [role="tooltip"], .menu, .popover {
  background-color: var(--hs-glass-raised);
  background-image: var(--hs-gloss);
  border-color: var(--hs-edge-light);
  box-shadow: var(--hs-inner), var(--hs-shadow-raised);
  -webkit-backdrop-filter: var(--hs-blur-filter);
  backdrop-filter: var(--hs-blur-filter);
}
dialog.sheet::backdrop { background: rgb(4 8 24 / 0.42); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* Controls sitting on glass are lit from above, not flat boxes */
.ghost, .tool, .mini, .chip {
  background-color: rgb(255 255 255 / var(--hs-m-control));
  border-color: rgb(255 255 255 / calc(0.06 + 0.08 * var(--hs-reflect)));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / calc(0.1 * var(--hs-reflect)));
}

/* The brand action: orange with navy ink (7.2:1) */
.primary {
  color: var(--hs-navy);
  background: linear-gradient(180deg, color-mix(in srgb, var(--hs-orange) 88%, #fff), var(--hs-orange));
  border-color: color-mix(in srgb, var(--hs-orange) 70%, #fff);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.45), 0 8px 20px -10px rgb(0 0 0 / 0.6);
}
.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--hs-orange) 80%, #fff), color-mix(in srgb, var(--hs-orange) 94%, #fff));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.55), 0 10px 24px -10px rgb(0 0 0 / 0.65);
}
.ed-tool[aria-pressed="true"] { color: var(--hs-navy); }

/* Specular refraction on the floating glass, only where it is cheap enough (Ultra) */
html[data-hs-quality="ultra"] :is(.top, .panel) {
  -webkit-backdrop-filter: url(#hs-refract) var(--hs-blur-filter);
  backdrop-filter: url(#hs-refract) var(--hs-blur-filter);
}

/* ================= Full-bleed room with floating chrome (desktop) ================= */
@media (min-width: 1101px) {
  :root { --hs-gap: 14px; --hs-rail-w: calc(var(--sidebar-width) + var(--hs-gap)); }

  /* The sidebar is an island of glass over the room */
  .top {
    inset: var(--hs-gap) auto var(--hs-gap) var(--hs-gap);
    background-color: var(--hs-glass-nav);
    background-image: radial-gradient(120% 40% at 0% 0%, color-mix(in srgb, var(--live) calc(14% * var(--hs-glow)), transparent), transparent 70%), var(--hs-gloss);
    border: 1px solid var(--hs-edge-light);
    border-radius: var(--hs-radius);
    box-shadow: var(--hs-inner), var(--hs-shadow);
    -webkit-backdrop-filter: var(--hs-blur-filter);
    backdrop-filter: var(--hs-blur-filter);
    transition: width var(--slow) var(--hs-spring), transform var(--slow) var(--hs-ease-out), opacity var(--med);
  }

  /* The room fills the whole window behind the glass */
  body:is([data-route="room"], [data-route="scenes"], [data-route="effects"], [data-route="sync"]):not(.editing) .room-stage { left: 0; right: 0; }
  body:not(.editing) .room { --view-w: 100vw; --view-h: 100svh; }
  .room-stage { background: transparent; }
  /* The soft floor under the chrome: lighter than before, the room should stay visible */
  .room-stage::after {
    background:
      linear-gradient(90deg, rgb(4 8 24 / 0.38), transparent calc(var(--sidebar-width) + 120px)),
      linear-gradient(270deg, rgb(4 8 24 / 0.32), transparent calc(var(--control-width) + 120px)),
      linear-gradient(0deg, rgb(4 8 24 / 0.3), transparent 26%);
  }

  .hero { margin-left: 0; }
  .intro { left: calc(var(--hs-rail-w) + 28px); top: 30px; }
  .panel { top: var(--hs-gap); right: var(--hs-gap); bottom: var(--hs-gap); }
  main, footer, .pages { margin-left: var(--hs-rail-w); }
  .tour { left: calc(var(--hs-rail-w) + 28px); }

  /* Section pages sit over the wallpaper, not on a black ground */
  dialog.sheet.as-page { inset: 0 0 0 var(--hs-rail-w); background: transparent; }
  dialog.sheet.as-page > .sheet-head { background: color-mix(in oklab, var(--hs-base) calc(var(--hs-m-nav) * 100%), transparent); border-bottom-color: var(--hs-edge-light); }
  dialog.sheet.as-page > .sheet-body {
    margin: 18px auto 40px;
    padding: 24px 32px 48px;
    background-color: var(--hs-glass-page);
    background-image: var(--hs-gloss);
    border: 1px solid var(--hs-edge-light);
    border-radius: var(--hs-radius);
    box-shadow: var(--hs-inner), var(--hs-shadow);
    -webkit-backdrop-filter: var(--hs-blur-filter);
    backdrop-filter: var(--hs-blur-filter);
  }
}

/* Section pages and their cards are glass too (all sizes) */
.page { background: transparent; }
/* C11-D1: `.dash-card { margin: 0 }` (same specificity, later) cancelled the centring of
   `.page > *`, so cards on Integrations sat at the page's left edge under a centred header */
.page > :is(.dash-card, section, .status) { margin-inline: auto; }
main, footer { background: transparent; }
:is(.page-card, .dash-card, .room-tile, .home-card, .integration-card, .af-card, .card) {
  background-color: var(--hs-glass-panel);
  background-image: var(--hs-gloss);
  border-color: var(--hs-edge-light);
  box-shadow: var(--hs-inner), var(--hs-shadow);
  -webkit-backdrop-filter: var(--hs-blur-filter-soft);
  backdrop-filter: var(--hs-blur-filter-soft);
}

/* ================= Brand marks ================= */
.logo img.hs-mark {
  width: 34px;
  height: 34px;
  background: none;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.14), 0 6px 18px -6px color-mix(in srgb, var(--hs-orange) calc(70% * var(--hs-glow)), transparent);
}
.hs-logo {
  position: relative;
  display: inline-grid;
  flex: none;
  width: 34px;
  height: 34px;
}
.hs-logo img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: opacity var(--med) ease, transform var(--slow) var(--hs-spring), filter var(--med);
}
.hs-logo img[aria-hidden="true"] { opacity: 0; transform: rotate(calc(-40deg * var(--hs-motion))) scale(0.8); }
/* A slow orbit of light around the mark, once when the area changes */
.hs-logo::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from var(--hs-orbit, 0deg), transparent 0 70%, color-mix(in srgb, var(--hs-orange) 85%, #fff) 82%, transparent 92%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  opacity: 0;
  pointer-events: none;
}
.hs-logo.orbit::after { animation: hs-orbit calc(1100ms * var(--hs-speed)) var(--hs-ease-out) both; }
@property --hs-orbit { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes hs-orbit { 0% { opacity: 0; --hs-orbit: 0deg; } 20% { opacity: calc(0.9 * var(--hs-glow) + 0.1); } 100% { opacity: 0; --hs-orbit: 360deg; } }
html[data-hs-motion="reduced"] .hs-logo.orbit::after { animation: none; }
.hs-logo-name { display: grid; line-height: 1.05; }
.hs-logo-name small { color: var(--muted); font-size: 0.68rem; font-weight: 560; letter-spacing: 0.02em; }

/* ================= Splash ================= */
.hs-splash {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 50% at 50% 45%, #0f1d4f, var(--hs-navy-deep) 70%);
  /* Never in the way: clicks pass through, and it leaves by itself even if the app's code
     never runs (the website asks a question first; a failed load shows its own note) */
  pointer-events: none;
  animation: hs-splash-out 320ms ease 2.2s forwards;
  transition: opacity 360ms ease, visibility 0s linear 360ms;
}
@keyframes hs-splash-out { to { opacity: 0; visibility: hidden; } }
.hs-splash img { width: 132px; height: 132px; border-radius: 50%; animation: hs-splash-in 700ms var(--hs-ease-out, ease) both; filter: drop-shadow(0 18px 40px rgb(253 134 1 / 0.28)); }
.hs-splash p { margin: 18px 0 0; color: #f5f7ff; font: 640 1.4rem/1 var(--font); letter-spacing: -0.02em; text-align: center; animation: hs-splash-in 700ms 90ms var(--hs-ease-out, ease) both; }
.hs-splash.done { opacity: 0; visibility: hidden; }
@keyframes hs-splash-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
@media (prefers-reduced-motion: reduce) { .hs-splash img, .hs-splash p { animation: none; } }

/* ================= Modes ================= */
/* Immersive: the room first. The sidebar folds to its rail, the deck steps aside, and a
   small floating bar keeps power, brightness and the next steps one tap away. */
html[data-hs-mode="immersive"] body:is([data-route="room"], [data-route="scenes"], [data-route="effects"], [data-route="sync"]):not(.editing):not(.watching) .panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(24px * var(--hs-motion))) scale(0.985);
}
html[data-hs-mode="immersive"] body:is([data-route="room"], [data-route="scenes"], [data-route="effects"], [data-route="sync"]):not(.editing) .room-stage::after {
  background: linear-gradient(0deg, rgb(4 8 24 / 0.32), transparent 24%);
}
.hs-quick {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: 22px;
  display: none;
  align-items: center;
  gap: 14px;
  min-width: min(620px, calc(100vw - 40px));
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  transform: translateX(-50%);
  animation: hs-rise var(--slow) var(--hs-spring) both;
}
html[data-hs-mode="immersive"] body:is([data-route="room"], [data-route="scenes"], [data-route="effects"], [data-route="sync"]):not(.editing):not(.watching) .hs-quick { display: flex; }
.hs-quick .hs-quick-name { display: grid; min-width: 0; line-height: 1.15; }
.hs-quick .hs-quick-name strong { overflow: hidden; font-size: 0.95rem; white-space: nowrap; text-overflow: ellipsis; }
.hs-quick .hs-quick-name span { color: var(--muted); font-size: 0.76rem; white-space: nowrap; }
.hs-quick input[type="range"] { flex: 1; min-width: 120px; }
.hs-quick .hs-quick-value { min-width: 3.2em; color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; text-align: right; }
.hs-sync { display: inline-flex; gap: 6px; }
.hs-sync span { padding: 3px 8px; color: var(--muted); font-size: 0.72rem; border: 1px solid var(--hs-edge-light); border-radius: 999px; }
.hs-sync span.on { color: var(--hs-navy); background: var(--live); border-color: transparent; }
@keyframes hs-rise { from { opacity: 0; transform: translate(-50%, calc(14px * var(--hs-motion))); } }

/* The mode switch in the deck and the quick bar */
.hs-modes { display: inline-flex; padding: 3px; gap: 2px; background: rgb(255 255 255 / 0.05); border: 1px solid var(--hs-edge-light); border-radius: 999px; }
.hs-modes button { min-height: 28px; padding: 0 11px; color: var(--muted); font-size: 0.76rem; font-weight: 560; background: none; border: 0; border-radius: 999px; transition: color var(--fast), background var(--med) var(--hs-spring); }
.hs-modes button[aria-pressed="true"] { color: var(--hs-navy); background: linear-gradient(180deg, color-mix(in srgb, var(--hs-orange) 85%, #fff), var(--hs-orange)); }
.hs-modes button:hover:not([aria-pressed="true"]) { color: var(--text); }

/* Advanced: the deck opens at its studio width (heselion-shell.js) */

/* ================= Room changes ================= */
/* The deck's content steps out and back as the new room arrives; the picture cross-fades
   (shell.css .room.changing) and the wallpaper layers swap. Nothing here sends lighting. */
body.hs-switching .panel > :not(.greeting) { animation: hs-deck-swap calc(var(--hs-cine) * 0.9) var(--hs-ease-out) both; }
body.hs-switching .intro { animation: hs-title-swap calc(var(--hs-cine) * 0.9) var(--hs-ease-out) both; }
@keyframes hs-deck-swap { 35% { opacity: 0.25; transform: translateY(calc(6px * var(--hs-motion))); filter: blur(calc(2px * var(--hs-motion))); } }
@keyframes hs-title-swap { 35% { opacity: 0; transform: translateX(calc(-10px * var(--hs-motion))); } }
html[data-hs-motion="reduced"] body.hs-switching :is(.panel > *, .intro) { animation: none; }

/* Selected and pressed things settle with a spring */
:is(.room-card, .chip, .tab, [role="tab"], .nav-item) { transition-timing-function: var(--hs-spring); }
.nav-item[aria-current="page"] {
  color: var(--text);
  background: linear-gradient(90deg, color-mix(in srgb, var(--hs-orange) 22%, transparent), rgb(255 255 255 / 0.04));
  border-color: color-mix(in srgb, var(--hs-orange) 35%, transparent);
  box-shadow: inset 2px 0 0 var(--hs-orange);
}

/* ================= Appearance settings ================= */
.hs-appearance { display: grid; gap: 22px; }
.hs-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.hs-preset {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 12px;
  text-align: left;
  background: rgb(255 255 255 / 0.04);
  border: 1px solid var(--hs-edge-light);
  border-radius: calc(var(--hs-radius) * 0.7);
  overflow: hidden;
  transition: border-color var(--fast), transform var(--med) var(--hs-spring);
}
.hs-preset:hover { transform: translateY(-2px); }
.hs-preset[aria-pressed="true"] { border-color: var(--hs-orange); box-shadow: 0 0 0 1px var(--hs-orange) inset; }
.hs-preset i { display: block; height: 38px; border-radius: 10px; background-size: cover; background-position: center; }
.hs-preset b { font-size: 0.85rem; font-weight: 600; }
.hs-sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 22px; }
.hs-slider { display: grid; gap: 6px; }
.hs-slider span { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.82rem; }
.hs-slider output { color: var(--text); font-variant-numeric: tabular-nums; }
.hs-preview {
  position: relative;
  height: 160px;
  overflow: hidden;
  border-radius: var(--hs-radius);
  background-size: cover;
  background-position: center;
}
.hs-preview .hs-preview-card {
  position: absolute;
  inset: 22px auto 22px 22px;
  width: 46%;
  padding: 14px;
  color: var(--text);
  background-color: var(--hs-glass-panel);
  background-image: var(--hs-gloss);
  border: 1px solid var(--hs-edge-light);
  border-radius: var(--hs-radius);
  box-shadow: var(--hs-inner), var(--hs-shadow);
  -webkit-backdrop-filter: var(--hs-blur-filter);
  backdrop-filter: var(--hs-blur-filter);
}
.hs-frame { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

/* Density */
html[data-hs-density="compact"] { --space: 16px; }
html[data-hs-density="compact"] :is(.primary, .ghost, .danger, .tool) { min-height: 34px; padding-inline: 12px; }
html[data-hs-density="compact"] .nav-item { min-height: 34px; }

/* ================= Refinements after the first look ================= */
/* Navigation items are bare text until hovered or current: no box per row */
.top .nav-item:not([aria-current="page"]) { background: transparent; border-color: transparent; box-shadow: none; }
.top .nav-item:not([aria-current="page"]):hover { background: rgb(255 255 255 / 0.06); }
/* The sidebar scrolls; a soft fade at its foot says there is more below (C11-D2) */
@media (min-width: 1101px) {
  .top { -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(180deg, #000 calc(100% - 28px), transparent); padding-bottom: 28px; }
}

/* The room stays the wallpaper everywhere: full window behind section pages too */
@media (min-width: 1101px) {
  body:not(.editing) .room-stage { left: 0; right: 0; }
}
/* High and Ultra show the live room (it keeps rendering anyway) behind pages; Balanced and
   Performance show the still wallpaper, which costs nothing per frame */
html:is([data-hs-quality="high"], [data-hs-quality="ultra"]) body:not([data-route="room"]):not([data-route="scenes"]):not([data-route="effects"]):not([data-route="sync"]):not(.editing) .room-stage {
  opacity: 1;
  filter: brightness(calc(0.78 * var(--hs-wall-brightness))) saturate(var(--hs-wall-saturation));
}
body:not([data-route="room"]):not([data-route="scenes"]):not([data-route="effects"]):not([data-route="sync"]) .room-stage::after {
  background: radial-gradient(120% 90% at 70% 10%, transparent 30%, rgb(4 8 24 / 0.5)), linear-gradient(180deg, rgb(4 8 24 / 0.3), rgb(4 8 24 / 0.58));
}
.page > section + section { margin-top: 20px; }
#page-appearance .dash-card h2 { margin: 0 0 14px; font-size: 1rem; font-weight: 620; letter-spacing: -0.01em; }
#page-appearance .hs-preview { margin-top: 14px; }
/* The room's title stays readable over bright art: a soft ground behind the text only */
/* Desktop only: on narrow screens the title is in the page flow, and the ground would reach
   past the window edge (C11: tablet-820 scrolled sideways by 60 px) */
@media (min-width: 1101px) {
  .intro { isolation: isolate; }
  .intro::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -26px -60px -22px -40px;
    background: radial-gradient(closest-side, rgb(4 8 24 / 0.55), transparent);
    pointer-events: none;
  }
}

/* ================= Performance (C11 step 23, measured with tests/bench_ui.py) ================= */
/* The still wallpaper is only painted where it shows: behind section pages at Balanced and
   Performance. Hidden under the live room it still cost a full-window filtered layer every
   frame (SwiftShader, 1600x900: 13 -> 52 fps with it gone). */
body:is([data-route="room"], [data-route="scenes"], [data-route="effects"], [data-route="sync"]) .hs-wallpaper,
body.editing .hs-wallpaper,
html:is([data-hs-quality="high"], [data-hs-quality="ultra"]) .hs-wallpaper { display: none; }
/* No filter pass at all when the wallpaper settings are neutral */
html[data-hs-wall-neutral="true"] .hs-wall { filter: none; }
.hs-wall:not(.enter):not(.on) { will-change: auto; }
/* One gradient pass for the floor under the chrome instead of three */
@media (min-width: 1101px) {
  .room-stage::after {
    background: linear-gradient(90deg, rgb(4 8 24 / 0.36), transparent calc(var(--sidebar-width) + 110px), transparent calc(100% - var(--control-width) - 110px), rgb(4 8 24 / 0.3));
  }
}
/* Performance quality (chosen, or Automatic where the processor draws): no live blur at all.
   Any backdrop blur over the moving room costs a full read-back per frame on the processor,
   whatever its radius (8 px measured the same as 26 px). The glass becomes denser instead, so
   text stays readable over any light. */
html[data-hs-quality="performance"] {
  --hs-m-nav: max(0.9, calc(var(--hs-glass-alpha) * 0.92));
  --hs-m-panel: max(0.9, var(--hs-glass-alpha));
  --hs-m-raised: 0.96;
  --hs-m-page: 0.95;
}
html[data-hs-quality="performance"] *,
html[data-hs-quality="performance"] *::before,
html[data-hs-quality="performance"] *::after,
html[data-hs-quality="performance"] dialog::backdrop {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
/* Performance also leaves out everything layered over the moving room that the processor
   would have to blend again every frame: the sidebar's fade mask, the floor gradient, the
   title ground, the gloss and the large soft shadows (1920x1080 on the processor:
   about 1 -> 21 fps with these gone). */
html[data-hs-quality="performance"] .top { -webkit-mask-image: none; mask-image: none; }
html[data-hs-quality="performance"] .room-stage::after,
html[data-hs-quality="performance"] .room-stage::before,
html[data-hs-quality="performance"] .intro::before { display: none; }
html[data-hs-quality="performance"] { --hs-gloss: none; --hs-shadow: none; --hs-shadow-raised: 0 10px 24px -12px rgb(0 0 0 / 0.6); }
html[data-hs-quality="performance"] .intro { text-shadow: 0 1px 2px rgb(0 0 0 / 0.9), 0 0 12px rgb(0 0 0 / 0.6); }

/* The mark stays on the icon rail; only the name folds away (shell.css hides .logo span) */
body.nav-collapsed .logo .hs-logo { display: inline-grid; }
body.nav-collapsed .logo .hs-logo-name { display: none; }
