.sys-scene {
  container-type: inline-size;
  min-inline-size: 0;
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.sys-scene *, .sys-scene *::before, .sys-scene *::after { box-sizing: border-box; }
.sys-body { display: grid; align-items: start; gap: .75rem; min-inline-size: 0; }
.sys-body > * { min-inline-size: 0; }
.sys-body > button { justify-self: start; }
.sys-scene fieldset { min-inline-size: 0; margin: 0; }
.sys-scene .sys-sr {
  position: absolute; inline-size: 1px; block-size: 1px;
  margin: -1px; border: 0; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.sys-scene button, .sys-scene input, .sys-scene select, .sys-scene summary { font: inherit; }
.sys-scene button, .sys-scene label, .sys-scene select, .sys-scene summary { -webkit-tap-highlight-color: transparent; }
.sys-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sys-scene .sys-status { margin: .9rem 0 0; line-height: 1.5; overflow-wrap: anywhere; }
.sys-scene .sys-reading, .sys-scene .sys-toggle, .sys-range-heading {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .25rem .65rem; margin: 0; min-inline-size: 0;
}
.sys-scene .sys-reading > *, .sys-scene .sys-toggle > span, .sys-controls > * { min-inline-size: 0; }
.sys-scene .sys-reading .demo-value { margin-inline-start: auto; text-align: end; overflow-wrap: anywhere; }
.sys-scene .sys-controls { display: flex; flex-wrap: wrap; align-items: stretch; gap: .45rem; margin: 0; }
.sys-controls > button, .sys-cable > button { min-block-size: 2.4rem; max-inline-size: 100%; white-space: normal; }
.sys-scene .sys-caption { margin: .15rem 0 -.45rem; }
.sys-scene .sys-choices {
  position: relative; display: flex; align-items: stretch; flex-wrap: wrap;
  margin: 0; padding: 3px; gap: 3px; border: 1px solid var(--rule);
  border-radius: .4rem; background: var(--soft);
}
.sys-scene .sys-choice {
  display: flex; position: relative; flex: 1 1 0; min-width: 0; margin: 0; padding: 0;
  border: 0; background: transparent; text-align: center; cursor: pointer; font: inherit;
}
.sys-choice > .sys-radio {
  position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit;
}
.sys-choice > span {
  display: grid; place-content: center; inline-size: 100%; min-block-size: 2.25rem; padding: .3rem .35rem;
  color: var(--muted); border: 1px solid transparent; border-radius: .25rem; line-height: 1.2; font-size: .875em; font-weight: 550;
}
.sys-choice input:checked + span { background: var(--accent-wash); color: var(--accent-ink); border-color: var(--accent-line); font-weight: 650; }
.sys-choices:disabled .sys-choice { cursor: default; }
.sys-choices:disabled .sys-choice span { color: var(--muted); }
.sys-choices:disabled input:checked + span { background: var(--raised); border: 1px dashed var(--muted); }
.sys-scene .sys-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.sys-list > * + * { border-block-start: 1px solid var(--rule); }
.sys-source, .sys-output { position: relative; display: flex; align-items: center; min-inline-size: 0; }
.sys-source { user-select: none; -webkit-user-select: none; }
.sys-source[data-dragging] { background: var(--soft); }
.sys-source[data-drop]::after {
  position: absolute; inset-inline: 0; border-block-start: 2px solid var(--accent); content: '';
}
.sys-source[data-drop="before"]::after { inset-block-start: 0; }
.sys-source[data-drop="after"]::after { inset-block-end: 0; }
.sys-grip, .sys-rank {
  flex: none; display: grid; align-content: center; justify-items: center; gap: .15rem;
  width: 2rem; align-self: stretch; color: var(--muted); font-size: .83em;
}
.sys-grip { touch-action: none; cursor: grab; }
.sys-grip::after { content: ''; width: .7rem; height: 4px; border-block: 1px solid currentColor; }
.sys-source[data-dragging] .sys-grip { cursor: grabbing; }
.sys-scene .sys-pick {
  flex: 1; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: .15rem .5rem; min-inline-size: 0; min-block-size: 2.8rem; padding: .4rem .45rem;
  border: 0; border-radius: .35rem; color: var(--ink); background: transparent; box-shadow: none;
  font-size: inherit; font-weight: 550; text-align: start;
}
.sys-scene .sys-pick[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-wash); }
.sys-pick[aria-pressed="true"] .sys-device-name { text-decoration: underline; text-underline-offset: .22em; }
.sys-scene .sys-pick:disabled { color: var(--muted); opacity: 1; }
.sys-device-name { min-inline-size: 0; overflow-wrap: anywhere; }
.sys-device-flag { color: var(--muted); font-weight: 450; font-size: .82em; }
.sys-nudges { display: flex; align-items: center; gap: 2px; }
.sys-scene .sys-nudge {
  display: grid; place-content: center; min-width: 2rem; min-height: 2.5rem; padding: 0;
  border: 0; border-radius: .35rem; color: var(--ink); background: transparent; box-shadow: none;
  font-size: 1.05rem; line-height: 1;
}
.sys-scene .sys-nudge:disabled { color: var(--muted); }
@media (hover: hover) {
  .sys-scene .sys-nudge:hover:enabled, .sys-scene .sys-pick[aria-pressed="false"]:hover:enabled { background: var(--soft); color: var(--ink); }
  .sys-choices:enabled .sys-choice:hover input:not(:checked) + span { background: var(--raised); border-color: var(--line-strong); color: var(--ink); }
  .sys-options > summary:hover { text-decoration: underline; text-underline-offset: .2em; }
}
.sys-scene .sys-cable, .sys-scene .sys-route {
  display: flex; align-items: center; flex-wrap: wrap; gap: .6rem .8rem; margin: 0;
  padding: .65rem .8rem; background: var(--soft); border-radius: .35rem;
}
.sys-cable > button { margin-inline-start: auto; }
.sys-wire { position: relative; width: 2.6rem; height: .55rem; flex: none; color: var(--accent); }
.sys-wire::before, .sys-wire::after { position: absolute; top: 0; height: 100%; content: ''; }
.sys-wire::before {
  inset-inline-start: 0; width: 55%; border-inline-end: .4rem solid currentColor;
  background: linear-gradient(currentColor, currentColor) left center / 100% 2px no-repeat;
}
.sys-wire::after { inset-inline-end: 0; width: 45%; border: 1.5px solid currentColor; border-inline-end-width: .35rem; }
.sys-cable[data-online="false"] .sys-wire { color: var(--muted); }
.sys-cable[data-online="false"] .sys-wire::before { width: 35%; }
.sys-scene .sys-route { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.3fr); }
.sys-route-arrow { text-align: center; color: var(--accent); font-weight: 600; }
.sys-route strong { text-align: end; }
.sys-scene .sys-apps, .sys-scene .sys-connections { display: grid; border: 0; padding: 0; }
.sys-apps > legend, .sys-connections > legend { margin: 0 0 .3rem; padding: 0; }
.sys-scene .sys-toggle { min-block-size: 2.65rem; flex-wrap: nowrap; padding: .2rem .1rem; cursor: pointer; }
.sys-toggle > span { flex: 1; overflow-wrap: anywhere; }
.sys-toggle + .sys-toggle { border-block-start: 1px solid var(--rule); }
.sys-scene .sys-switch {
  appearance: none; -webkit-appearance: none; display: block; position: relative; flex: none;
  width: 2.4rem; height: 1.45rem; min-width: 0; min-height: 0; margin: 0; padding: 0;
  border: 1px solid var(--muted); border-radius: 2rem; background: var(--raised); cursor: pointer;
}
.sys-switch::before { content: ''; display: block; position: absolute; inset: 2px auto 2px 2px; aspect-ratio: 1; border-radius: 50%; background: var(--muted); }
.sys-scene .sys-switch:checked { border-color: var(--accent-fill); background: var(--accent-fill); }
.sys-switch:checked::before { inset-inline-start: auto; inset-inline-end: 2px; background: var(--on-accent); }
.sys-check { flex: none; width: 1.1rem; height: 1.1rem; margin-inline-end: .2rem; accent-color: var(--accent); }
.sys-scene .sys-instrument, .sys-scene .sys-countdown, .sys-scene .sys-session {
  display: grid; gap: .6rem; min-inline-size: 0; margin: 0; padding: .85rem;
  border: 1px solid var(--rule); border-radius: .35rem; background: var(--raised);
}
.sys-instrument > .sys-reading .demo-value { font-size: 1.2em; }
.sys-tach { display: block; width: 100%; height: .65rem; appearance: none; border: 0; border-radius: 1rem; background: var(--rule); accent-color: var(--accent); }
.sys-tach::-webkit-meter-bar { border: 0; border-radius: 1rem; background: var(--rule); }
.sys-tach::-webkit-meter-optimum-value { border-radius: 1rem; background: var(--accent); }
.sys-tach::-moz-meter-bar { border-radius: 1rem; background: var(--accent); }
.sys-temps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem 1.1rem; }
.sys-temps .sys-reading { gap: .1rem .4rem; font-size: .9em; }
.sys-field, .sys-editor, .sys-request { display: grid; gap: .5rem; min-inline-size: 0; }
.sys-field { margin: 0; }
.sys-inline-field { grid-template-columns: 1fr auto; align-items: center; }
.sys-range { display: block; width: 100%; min-height: 2rem; margin: 0; accent-color: var(--accent); cursor: pointer; }
.sys-date, .sys-select, .sys-number {
  display: block; min-width: 0; max-width: 100%; min-height: 2.3rem; padding: .35rem .5rem;
  line-height: 1.4;
}
.sys-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .85em; }
.sys-number { width: 5.5rem; }
.sys-date { width: 100%; }
.sys-issue { margin: 0; color: var(--error); font-weight: 600; line-height: 1.5; }
.sys-editor [aria-invalid="true"] { border: 1px dashed var(--error); }
.sys-ticks { display: grid; gap: 4px; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.sys-ticks i { height: 4px; border-radius: 2px; background: var(--rule); }
.sys-ticks i.sys-lit { background: var(--accent); }
.sys-countdown .sys-reading .icon { width: 42px; height: 23px; color: var(--muted); }
.sys-countdown[data-completed=true] { --sun-offset: 14px; }
.sys-scene .demo-button.destructive { color: #fff; border-color: #b83137; background: #b83137; }
.sys-options { border-block: 1px solid var(--rule); }
.sys-options > summary { padding: .6rem .1rem; cursor: pointer; font-weight: 600; }
.sys-options[open] { padding-block-end: .25rem; }
.sys-request > button { justify-self: start; }
.sys-scene .sys-monitor { display: grid; justify-items: center; margin: 0; padding: .65rem; }
.sys-monitor::after {
  content: ''; width: 3.4rem; height: .5rem; background: var(--muted);
  clip-path: polygon(35% 0,65% 0,65% 65%,100% 75%,100% 100%,0 100%,0 75%,35% 65%);
}
.sys-screen {
  display: grid; min-height: 6.3rem; width: min(100%, 15rem); place-content: center; justify-items: center;
  gap: .48rem; padding: .65rem; border: 3px solid var(--muted); border-radius: .55rem;
  color: var(--ink); background: var(--soft); text-align: center;
}
.sys-screen-icon { width: .95rem; height: .95rem; border: 2px solid currentColor; border-radius: 50%; }
.sys-monitor[data-display="held"] .sys-screen-icon { background: var(--accent); border-color: var(--accent); }
.sys-monitor[data-display="asleep"] .sys-screen { background: #191919; color: #fff; }
.sys-monitor[data-display="asleep"] .sys-screen-icon { height: 2px; border: 0; border-radius: 0; background: currentColor; }

@container (max-width: 350px) {
  .sys-choices:has(> label:nth-of-type(4)) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sys-temps { grid-template-columns: 1fr; }
  .sys-body > .sys-reading { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sys-source .sys-pick { flex-direction: column; align-items: start; justify-content: center; }
  .sys-grip, .sys-rank { width: 1.7rem; }
  .sys-cable > button { margin-inline-start: 0; }
}
@media (pointer: coarse) {
  .sys-choice > span, .sys-scene .sys-nudge, .sys-scene .sys-toggle, .sys-scene button, .sys-options > summary { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .sys-scene *, .sys-scene *::before, .sys-scene *::after { animation: none; transition: none; }
}
@media (forced-colors: active) {
  .sys-scene .sys-switch { appearance: auto; }
  .sys-switch::before { display: none; }
  .sys-choice input:checked + span { outline: 2px solid Highlight; outline-offset: -2px; }
  .sys-ticks i.sys-lit { background: Highlight; forced-color-adjust: none; }
}
