/* The control deck: everything inside the room's .panel (its position, size and glass
   are in shell.css). The interface stays quiet dark glass; the saturated colour in here
   is the light the zones and scenes really put out, plus a few state marks. */

/* ---------- Head: the room, what's playing, power ---------- */
.panel-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; }
.head-text { min-width: 0; }
.head-actions { display: flex; flex: none; align-items: center; justify-content: flex-end; gap: 8px; }
.sync-all-strips { padding: 0 10px; font-size: 0.78rem; white-space: nowrap; }
.sync-all-strips[aria-pressed="true"] { color: var(--text); background: color-mix(in srgb, var(--violet) 20%, transparent); border-color: color-mix(in srgb, var(--violet) 55%, transparent); }

.deck-room {
  margin: 0;
  overflow: hidden;
  font: 640 1.35rem/1.15 var(--display);
  letter-spacing: -0.025em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.now-title { display: flex; min-width: 0; margin: 3px 0 0; color: var(--muted); font-size: 0.88rem; font-weight: 500; letter-spacing: 0; }
.now { overflow: hidden; color: var(--text); white-space: nowrap; text-overflow: ellipsis; }
.now-level { flex: none; white-space: pre; font-variant-numeric: tabular-nums; }
.panel-head .toggle { gap: 8px; color: var(--muted); font-size: 0.84rem; }
.panel > .slider { flex: none; }

/* ---------- Zone chips: each chip face is that zone's live light ----------
   The canvas is the zone's own pixels, stretched over the whole chip; the band printed
   on it names the zone in the ink the app picked for contrast along the strip. Tap one
   to aim the controls at it, tap it again to go back to the whole room. */
.chip-deck { flex: none; margin-top: 16px; }
.deck-head { display: flex; align-items: center; gap: 10px; }
.deck-head .field { display: flex; flex: 1; align-items: center; gap: 10px; margin: 0; white-space: nowrap; }
.deck-head .field > select { min-height: 34px; margin: 0; font-size: 0.84rem; }

.zone-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.zone-chip {
  --chip-ink: #f5f7ff;
  --chip-muted: rgba(245, 247, 255, 0.86);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  min-height: 78px;
  padding: 0;
  overflow: hidden;
  color: var(--chip-ink);
  text-align: left;
  background: var(--raised);
  border: 0;
  border-radius: var(--r-xs);
  box-shadow: 0 10px 20px -12px rgba(0, 0, 0, 0.8), 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform var(--fast) var(--ease), box-shadow var(--med) var(--ease);
}

/* A hairline and a lit top edge so the chip reads as a piece of glass over the light */
.zone-chip::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(130% 100% at 22% 0%, rgba(255, 255, 255, 0.2), transparent 58%),
    linear-gradient(180deg, transparent 45%, rgba(9, 11, 18, 0.2));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  pointer-events: none;
}

/* A lit diffuser: brighter where the light enters, falling off toward the printed band.
   Dark ink sits on the bright part, so it skips the falloff */
.zone-chip.ink-dark::after { background: radial-gradient(130% 100% at 22% 0%, rgba(255, 255, 255, 0.22), transparent 58%); }

.zone-chip:hover { transform: translateY(-2px); box-shadow: 0 14px 24px -12px rgba(0, 0, 0, 0.85), 0 2px 4px rgba(0, 0, 0, 0.3); }
.zone-chip:active { transform: scale(0.98); }
.zone-chip[aria-pressed="true"] { box-shadow: var(--ring), 0 14px 24px -12px rgba(0, 0, 0, 0.85); }
.zone-chip:focus-visible { outline: 2px solid var(--violet-ink); outline-offset: 4px; }

.chip-swatch { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.zone-chip.ink-dark { --chip-ink: #10131c; --chip-muted: rgba(16, 19, 28, 0.82); }
.zone-chip.ink-light .chip-band { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

.chip-band {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 1px 6px;
  padding: 8px 10px 9px;
  line-height: 1.2;
}

/* Only where neither ink holds along the whole strip does the band get a dark scrim */
.zone-chip.ink-scrim .chip-band { background: rgba(9, 11, 18, 0.62); -webkit-backdrop-filter: var(--blur-light); backdrop-filter: var(--blur-light); }
.chip-band b { grid-column: 1 / -1; overflow: hidden; font-size: 0.86rem; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; text-overflow: ellipsis; }
.chip-band small { overflow: hidden; color: var(--chip-muted); font-size: 0.72rem; font-weight: 520; white-space: nowrap; text-overflow: ellipsis; }
.chip-band output { align-self: end; font-size: 0.74rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Off is one look wherever it comes from: dark glass, quiet but readable ink */
.zone-chip.off { --chip-ink: var(--muted); --chip-muted: var(--faint); background: var(--well); box-shadow: none; }
.zone-chip.off::after { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.zone-chip.off .chip-band { background: none; text-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.zone-chip.off[aria-pressed="true"] { box-shadow: var(--ring); }

/* ---------- What's really happening on the room's hardware ---------- */
.hw-bar {
  --state: var(--faint);
  display: grid;
  flex: none;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 8px 10px 8px 12px;
  font-size: 0.82rem;
  line-height: 1.3;
  background: color-mix(in srgb, var(--state) 7%, var(--well));
  border: 1px solid color-mix(in srgb, var(--state) 26%, transparent);
  border-radius: var(--r-sm);
}

.hw-bar[data-state="ok"] { --state: var(--ok); }
.hw-bar[data-state="pending"], .hw-bar[data-state="warn"] { --state: var(--warn); }
.hw-bar[data-state="bad"] { --state: var(--bad); }
.hw-bar > i { width: 8px; height: 8px; background: var(--state); border: 1.5px solid var(--state); border-radius: 50%; }
.hw-bar[data-state="pending"] > i { background: transparent; animation: deck-pulse 0.8s ease-in-out infinite alternate; }
.hw-text { display: block; font-weight: 560; }
.hw-detail { display: block; color: var(--muted); font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.hw-bar .mini { min-height: 30px; }

@keyframes deck-pulse { from { opacity: 0.35; } }

/* ---------- Tabs: a segmented control; icon over label when narrow ---------- */
.tabs {
  container-type: inline-size;
  display: grid;
  flex: none;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  margin: 16px 0 0;
  padding: 4px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 48px;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 540;
  line-height: 1.1;
  background: none;
  border: 0;
  border-radius: var(--r-xs);
  transition: color var(--fast), background var(--fast), box-shadow var(--fast);
}

.tabs .ed-icon { width: 18px; height: 18px; }
.tabs button:hover { color: var(--text); background: var(--surface); }
.tabs button:active { background: var(--surface-press); }
.tabs [aria-selected="true"], .tabs [aria-selected="true"]:hover { color: var(--text); font-weight: 620; background: var(--raised); box-shadow: var(--sheen), 0 4px 10px -4px rgba(0, 0, 0, 0.6); }
.tabs [aria-selected="true"] .ed-icon { color: var(--violet-ink); }

/* The wider studio deck has room for icon and label side by side */
@container (min-width: 420px) {
  .tabs button { flex-direction: row; gap: 8px; min-height: 40px; padding: 0 8px; font-size: 0.84rem; }
  .tabs .ed-icon { width: 17px; height: 17px; }
}

/* ---------- The scrolling middle and the foot ---------- */
.panel-scroll { flex: none; min-height: 0; margin-top: 6px; padding: 6px 0 12px; }

@media (min-width: 1101px) {
  .panel-scroll {
    flex: 1 1 auto;
    margin-right: -14px;
    padding-right: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    /* Rows fade at the edges rather than being cut */
    -webkit-mask-image: linear-gradient(transparent, #000 10px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(transparent, #000 10px, #000 calc(100% - 28px), transparent);
  }
}

.panel-scroll h3 { margin: 22px 0 8px; }

.panel-foot { flex: none; padding-top: 14px; border-top: 1px solid var(--line); }
.panel-foot .primary { width: 100%; min-height: 44px; margin-top: 14px; }

/* ---------- Colour presets ---------- */
.swatches, .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }

.swatch {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  padding: 0;
  overflow: hidden;
  background: var(--swatch);
  border: 0;
  border-radius: var(--r-xs);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 8px -4px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  transition: transform var(--fast) var(--ease), box-shadow var(--med);
}

.swatch.tiny { width: 26px; height: 26px; color: var(--ink); font-size: 0.66rem; font-weight: 700; }
.swatch:hover { transform: translateY(-2px); }
.swatch:active { transform: scale(0.94); }
.swatch[aria-pressed="true"] { box-shadow: var(--ring); }
.swatch:focus-within { outline: 2px solid var(--violet-ink); outline-offset: 2px; }
.swatch.custom, .swatch.random { background: conic-gradient(#ff1e2d, #ffb000, #18e06a, #18d6ff, #1e50ff, #c23dff, #ff1e2d); }

/* The real colour input fills the chip but stays invisible */
.swatch input { position: absolute; inset: -6px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }

/* ---------- Scenes ---------- */
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.scene { position: relative; min-width: 0; }

.scene-card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  min-height: 76px;
  padding: 0;
  color: var(--text);
  text-align: left;
  background: var(--raised);
  border: 0;
  border-radius: var(--r-xs);
  box-shadow: inset 0 0 0 1px var(--line), 0 10px 20px -12px rgba(0, 0, 0, 0.8);
  transition: transform var(--fast) var(--ease), box-shadow var(--med) var(--ease);
}

.scene-card:hover { transform: translateY(-2px); }
.scene-card:active { transform: scale(0.98); }
.scene-card[aria-pressed="true"] { box-shadow: var(--ring), 0 14px 24px -12px rgba(0, 0, 0, 0.85); }
.scene-card:focus-visible { outline-offset: 4px; }

/* The art is the scene's own light; a scrim at the foot keeps the name readable */
.scene-art {
  position: absolute;
  inset: 0;
  display: block;
  background: linear-gradient(180deg, transparent 38%, rgba(9, 11, 18, 0.78)), var(--art);
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Light bleed: the playing scene's own colours spill softly under its card */
.scene-art::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 30% 10% -14%;
  background: var(--art);
  border-radius: inherit;
  filter: blur(18px) saturate(1.2);
  opacity: 0;
  transition: opacity var(--slow) var(--ease);
}

.scene-card[aria-pressed="true"] .scene-art::after { opacity: 0.55; }
.scene-name, .scene-note { position: relative; }
.scene-name { display: block; padding: 7px 10px 8px; overflow: hidden; font-size: 0.82rem; font-weight: 620; line-height: 1.2; text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.scene-note { display: block; margin-top: -4px; padding: 0 10px 8px; color: var(--warn); font-size: 0.7rem; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }

/* Effects as cards: a thin strip of the effect's light over a name */
.scene-card:has(.scene-art.thin) { justify-content: flex-start; min-height: 0; padding: 6px; background: var(--surface); }
.scene-card:has(.scene-art.thin):hover { background: var(--surface-hover); }
.scene-card:has(.scene-art.thin)[aria-pressed="true"] { background: color-mix(in srgb, var(--violet) 14%, transparent); }
.scene-art.thin { position: relative; inset: auto; height: 30px; background: var(--art); border-radius: 5px; }
.scene-art.thin + .scene-name { padding: 7px 4px 2px; text-shadow: none; }

.scene-tools {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--fast);
}

.scene:hover .scene-tools, .scene:focus-within .scene-tools, .scene-grid.editing .scene-tools { opacity: 1; }
.scene-edit { margin-left: auto; }
.scene-tools .mini { min-height: 26px; padding: 0 8px; font-size: 0.7rem; background: var(--glass-strong); border-color: var(--edge-strong); -webkit-backdrop-filter: var(--blur-light); backdrop-filter: var(--blur-light); }
.scene-tools .mini:hover:not(:disabled) { background: var(--elevated); }

/* The one-time invitation to the welcome tour */
.tour-invite {
  margin: 12px 0 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  box-shadow: var(--sheen);
}

.tour-invite p { margin: 0 0 12px; font-size: 0.88rem; line-height: 1.45; }
.tour-invite b { font-weight: 640; }

/* ---------- Effect and palette lists ---------- */
.browser-tools { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.browser-tools .chip { min-height: 40px; white-space: nowrap; }
.browser-tools > select { grid-column: 1 / -1; width: 100%; min-width: 0; }

.browser-list {
  display: grid;
  gap: 2px;
  max-height: 240px;
  margin: 8px 0 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  scrollbar-width: thin;
}

.browser-list li { position: relative; }

.browser-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 4px 38px 4px 10px;
  font-size: 0.86rem;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  transition: background var(--fast), border-color var(--fast);
}

.browser-row > span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.browser-row:hover { background: var(--surface-hover); }
.browser-row:active { background: var(--surface-press); }
.browser-row[aria-pressed="true"] { font-weight: 620; background: color-mix(in srgb, var(--violet) 16%, transparent); border-color: color-mix(in srgb, var(--violet) 55%, transparent); }
.browser-row:focus-visible { outline-offset: -2px; }
.palette-bar { flex: 1; min-width: 50px; max-width: 160px; height: 10px; margin-left: auto; background: var(--bar); border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.tag { flex: none; margin-left: auto; padding: 1px 8px; color: var(--muted); font-size: 0.7rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }

.star {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--faint);
  background: none;
  border: 0;
  border-radius: var(--r-xs);
  transform: translateY(-50%);
  transition: color var(--fast), background var(--fast);
}

.star:hover { color: var(--text); background: var(--surface-hover); }
.star.on { color: var(--violet-ink); }
.star .ed-icon { width: 16px; height: 16px; }
.star.on .ed-icon { fill: currentColor; }

/* ---------- Effects tab ---------- */
.led-preview-panel { margin: 0 0 14px; padding: 12px; background: var(--well); border: 1px solid var(--line); border-radius: var(--r-md); }
.led-preview-panel > .row { gap: 8px 10px; }
.led-preview-panel strong { flex: 1 0 100%; font-size: 0.86rem; font-weight: 620; }
.led-preview-panel .field { flex: 1 1 140px; width: auto; margin: 0; }
.led-preview-panel .field > select { min-height: 34px; font-size: 0.84rem; }
.led-preview { display: block; width: 100%; height: 120px; margin: 10px 0 6px; background: #05070c; border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--line); }
.led-preview-panel > small { display: block; font-size: 0.76rem; font-variant-numeric: tabular-nums; }

/* ---------- Music: magenta is the beat ---------- */
.meter { margin-top: 10px; padding: 12px; background: var(--well); border: 1px solid var(--line); border-radius: var(--r-md); }
.spectrum { display: block; width: 100%; height: 64px; border-radius: var(--r-xs); }
.levels { display: grid; gap: 5px; margin: 10px 0; }
.level { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 8px; }
.level b { color: var(--muted); font-size: 0.74rem; font-weight: 520; text-transform: capitalize; }
.level span { height: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.08); border-radius: 3px; }
.level i { display: block; height: 100%; background: color-mix(in srgb, var(--magenta) 70%, var(--faint)); border-radius: inherit; transform: scaleX(0); transform-origin: left; }
/* The band the music reaction follows; the others dim so it's clear which one moves the lights */
.levels:has(.level.chosen) .level:not(.chosen) { opacity: 0.45; }
.level.chosen b { color: var(--text); font-weight: 640; }
.level.chosen i { background: var(--magenta); }
.react-to { display: grid; gap: 8px; margin: 6px 0 12px; }
.react-to .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.react-to .hint { margin: 0; }
.beat { display: inline-block; width: 10px; height: 10px; background: var(--magenta); border-radius: 50%; }
.bpm { color: var(--text); font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.route { padding: 8px 12px; background: var(--well); border: 1px solid var(--line); border-radius: var(--r-sm); }

/* ---------- Screen: cyan marks what is live ---------- */
.screen-tab h3 { margin: 22px 0 8px; }
.screen-tab > .ghost { margin-top: 12px; }
.screen-layout { margin-top: 8px; }
.screen-map-head { margin-bottom: 8px; font-size: 0.8rem; }
.screen-map {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  touch-action: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 10% 10%,
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 10% 10%,
    #05070c;
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--med);
}
.screen-map.live { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cyan) 50%, transparent); }
.screen-map.drop-target { box-shadow: inset 0 0 0 2px var(--violet); }
.screen-map-picture { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; }
.screen-map.live .screen-map-picture { opacity: 0.85; }
.screen-map-sharp { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.screen-map.sharp .screen-map-sharp { opacity: 0.9; }
.screen-map.sharp .screen-map-picture { opacity: 0; }
.screen-map-bars { position: absolute; border: 1px dashed rgba(255, 255, 255, 0.5); pointer-events: none; }
.screen-map-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 0 16px; color: var(--muted); font-size: 0.84rem; text-align: center; }
.screen-map-actions { gap: 6px; }
.screen-map-shown, .screen-map-add { margin-top: 10px; }
.screen-map-add .chip { touch-action: none; cursor: grab; }
.screen-map-bars[hidden], .screen-map-empty[hidden], .screen-area[hidden], .screen-map-add[hidden], .screen-map-actions > [hidden], .screen-map-shown[hidden] { display: none; }

/* Each zone's area keeps its own identifying hue */
.screen-eye { display: inline-flex; align-items: center; gap: 6px; box-shadow: inset 0 0 0 1px hsl(var(--area-hue) 85% 62% / 0.55); }
.screen-eye svg { width: 14px; height: 14px; color: hsl(var(--area-hue) 85% 62%); }
.screen-eye.off { opacity: 0.6; box-shadow: none; }
.screen-eye.off svg { color: var(--muted); }

.screen-area {
  --area: hsl(var(--area-hue) 85% 62%);
  position: absolute;
  min-width: 14px;
  min-height: 14px;
  cursor: move;
  background: hsl(var(--area-hue) 85% 62% / 0.14);
  border: 2px solid var(--area);
  border-radius: 6px;
  outline: none;
}
.screen-area.selected, .screen-area:focus-visible { z-index: 2; background: hsl(var(--area-hue) 85% 62% / 0.26); box-shadow: 0 0 0 2px rgba(9, 11, 18, 0.6), 0 8px 20px -6px rgba(0, 0, 0, 0.7); }
.screen-area:focus-visible { outline: 2px solid var(--violet-ink); outline-offset: 3px; }
.screen-area-name { position: absolute; top: 2px; left: 5px; max-width: calc(100% - 10px); overflow: hidden; color: #fff; font-size: 0.72rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9); pointer-events: none; }
.screen-grip { position: absolute; width: 12px; height: 12px; background: var(--area); border: 2px solid rgba(9, 11, 18, 0.7); border-radius: 50%; }
.screen-grip.nw { top: -7px; left: -7px; cursor: nwse-resize; }
.screen-grip.ne { top: -7px; right: -7px; cursor: nesw-resize; }
.screen-grip.sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.screen-grip.se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.screen-area:not(.selected):not(:focus-visible) .screen-grip { opacity: 0; }
@media (pointer: coarse) {
  .screen-grip { width: 20px; height: 20px; }
  .screen-grip.nw, .screen-grip.ne { top: -11px; }
  .screen-grip.sw, .screen-grip.se { bottom: -11px; }
  .screen-grip.nw, .screen-grip.sw { left: -11px; }
  .screen-grip.ne, .screen-grip.se { right: -11px; }
}
.screen-ghost { position: fixed; z-index: 80; pointer-events: none; opacity: 0.9; background: hsl(var(--area-hue) 85% 62% / 0.3); box-shadow: 0 10px 26px -6px rgba(0, 0, 0, 0.7); }

.screen-layout.expanded {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(9, 11, 18, 0.94);
  -webkit-backdrop-filter: var(--blur-light);
  backdrop-filter: var(--blur-light);
}
.screen-layout.expanded > * { width: min(100%, calc((100vh - 150px) * 16 / 9)); }
.screen-layout.expanded .screen-area-name { font-size: 0.9rem; }

.screen-zones { display: grid; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.screen-zone { padding: 10px 14px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); transition: border-color var(--fast), background var(--fast); }
.screen-zone.selected { background: color-mix(in srgb, var(--violet) 8%, var(--surface)); border-color: color-mix(in srgb, var(--violet) 55%, transparent); }
.screen-zone-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0 12px; }
.screen-zone-grid > [hidden], .screen-zone .toggle[hidden] { display: none; }
.screen-zone .hint { margin: 8px 0 0; }

/* Saver Mode: the strips read, drawn on a small picture of the screen */
.saver { margin-top: 4px; }
.saver-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 220px;
  margin: 10px auto 0;
  overflow: hidden;
  background: #05070c;
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--line);
}
.saver-preview.live { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cyan) 50%, transparent); }
.saver-preview[hidden], .saver-details[hidden], .saver-readout[hidden], .saver-edge > [hidden], .saver-grid > [hidden] { display: none; }
.saver-picture { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; }
.saver-preview.live .saver-picture { opacity: 1; }
.saver-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.saver-outline { fill: none; stroke: rgba(255, 255, 255, 0.4); stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.saver-skipped { fill: rgba(9, 11, 18, 0.6); }
.saver-preview:not(.live) .saver-skipped { fill: rgba(255, 255, 255, 0.03); }
.saver-strip { fill: color-mix(in srgb, var(--cyan) 18%, transparent); stroke: var(--cyan); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.saver-preview.live .saver-strip { fill: none; }
.saver-label { fill: var(--muted); font-family: var(--font); }
.saver-readout { margin: 8px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; font-variant-numeric: tabular-nums; }
.saver-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; margin-top: 6px; }
.saver-each { margin-top: 6px; }
.saver-edges { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 2px 0 8px; padding: 0; list-style: none; }
.saver-edge { padding: 6px 12px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.saver-edge.off { opacity: 0.7; }
.saver-perf { margin-top: 8px; }
.saver-stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 4px 0 8px; font-size: 0.8rem; }
.saver-stats dt { color: var(--muted); }
.saver-stats dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- Zones ---------- */
.zone-list { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }

.zone-card {
  padding: 10px 14px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: opacity var(--med), background var(--fast);
}

.zone-card.off { background: transparent; }
.zone-card.off .slider { opacity: 0.5; }
.zone-card .fold { margin-top: 8px; }
.zone-head { display: flex; align-items: center; gap: 10px; }
.zone-head .toggle { flex: 1; font-weight: 620; }
.zone-head input[type="color"] { width: 30px; height: 30px; }

/* One state mark everywhere: a filled dot is confirmed, cyan is streaming live, a ring
   is waiting, a red dot is a failure, a hollow grey ring is not connected */
.zone-status { display: flex; align-items: baseline; gap: 7px; color: var(--muted); font-size: 0.76rem; line-height: 1.35; }
.zone-status i { flex: none; width: 8px; height: 8px; background: transparent; border: 1.5px solid var(--faint); border-radius: 50%; transform: translateY(-1px); }
.zone-status[data-status="synced"] i { background: var(--ok); border-color: var(--ok); }
.zone-status[data-status="streaming"] i { background: var(--cyan); border-color: var(--cyan); }
.zone-status[data-status="pending"] i { border-color: var(--warn); }
.zone-status[data-status="offline"] i, .zone-status[data-status="failed"] i { background: var(--bad); border-color: var(--bad); }
.zone-status[data-status="failed"], .zone-status[data-status="offline"] { color: var(--bad-ink); }
.zone-status[data-status="blocked"] { color: var(--warn); }
.zone-status[data-status="blocked"] i { background: var(--warn); border-color: var(--warn); }
.zone-actual { display: block; color: var(--muted); font-size: 0.74rem; font-variant-numeric: tabular-nums; }

/* ---------- Tablets and phones: the deck is the page, natural height ---------- */
@media (max-width: 1100px) {
  .deck-room { display: none; }
  .now-title { margin: 0; color: var(--text); font-size: 1.14rem; font-weight: 640; }
  .browser-list { max-height: 40vh; }
  .browser-row { min-height: 42px; }
  .star { width: 40px; height: 40px; }
  .browser-row { padding-right: 46px; }
  .swatch { width: 36px; height: 36px; }
  .swatch.tiny { width: 32px; height: 32px; }
  .scene-card:has(.scene-art.thin) { min-height: 44px; }

  /* One swipeable row of chips keeps scenes on the first screen */
  .zone-chips {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 128px;
    margin-inline: -18px;
    padding: 4px 18px 10px;
    overflow-x: auto;
    scroll-padding-inline: 18px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .zone-chip { min-height: 80px; scroll-snap-align: start; }

  /* On a phone, scene tools only appear in edit mode, as a list with full-size buttons */
  .scene-tools { display: none; }
  .scene-grid.editing { grid-template-columns: 1fr; }
  .scene-grid.editing .scene { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; }
  .scene-grid.editing .scene-tools { position: static; display: flex; flex-wrap: wrap; gap: 6px; }
  .scene-grid.editing .scene-tools .mini { min-height: 44px; padding: 0 12px; font-size: 0.84rem; }
  .hw-bar .mini, .deck-head .field > select, .led-preview-panel .field > select { min-height: 40px; }
}

@media (max-width: 480px) {
  .zone-chips { margin-inline: -16px; padding-inline: 16px; scroll-padding-inline: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .zone-chip:hover, .zone-chip:active, .scene-card:hover, .scene-card:active, .swatch:hover, .swatch:active { transform: none; }
  .hw-bar[data-state="pending"] > i { animation: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .zone-chip.ink-scrim .chip-band, .scene-tools .mini, .screen-layout.expanded { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .zone-chip.ink-scrim .chip-band { background: rgba(9, 11, 18, 0.8); }
}
