:root,
html[data-theme="neon"] {
  --ink: #eef1ff;
  --muted: #9aa3c7;
  --paper: rgba(10, 12, 32, 0.72);
  --card: rgba(22, 26, 58, 0.78);
  --line: rgba(148, 168, 255, 0.16);
  --accent: #6d7cff;
  --accent-2: #ff3d9a;
  --accent-3: #3ecbff;
  --accent-dark: #4f5dff;
  --ok: #3ee0a0;
  --bad: #ff5d7a;
  --warn: #ffb020;
  --shadow: 0 18px 48px rgba(4, 6, 20, 0.45);
  --glow: 0 10px 28px rgba(88, 96, 255, 0.32);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius: var(--radius-lg);
  --font: "Ubuntu", "Segoe UI", sans-serif;
  --display: "Ubuntu", "Segoe UI", sans-serif;
  --body-bg: #07091a;
  --body-image:
    radial-gradient(900px 520px at 8% -12%, rgba(92, 74, 255, 0.38), transparent 58%),
    radial-gradient(720px 460px at 96% 4%, rgba(255, 48, 148, 0.22), transparent 52%),
    radial-gradient(820px 520px at 78% 108%, rgba(40, 196, 255, 0.14), transparent 48%),
    linear-gradient(180deg, #0b0e22 0%, #07091a 100%);
  --surface: linear-gradient(180deg, rgba(36, 40, 82, 0.72), rgba(16, 18, 44, 0.86));
  --blur: blur(18px);
  --tablist-bg: rgba(12, 14, 36, 0.55);
  --tab-active: linear-gradient(135deg, #6f7bff 0%, #9b4dff 52%, #ff4aa6 120%);
  --btn-bg: linear-gradient(135deg, #6675ff 0%, #8b5cff 58%, #ff4aa8 140%);
  --btn-hover: linear-gradient(135deg, #7a86ff 0%, #9d68ff 58%, #ff63b4 140%);
  --btn-text: #fff;
  --ghost-bg: rgba(255, 255, 255, 0.03);
  --ghost-hover: rgba(110, 130, 255, 0.12);
  --danger-bg: linear-gradient(135deg, #ff5d7a, #ff3d9a);
  --danger-shadow: 0 10px 24px rgba(255, 70, 120, 0.28);
  --inset-bg: rgba(8, 10, 28, 0.35);
  --chip-bg: rgba(255, 61, 154, 0.1);
  --chip-line: rgba(255, 61, 154, 0.22);
  --needle-bg: rgba(62, 203, 255, 0.1);
  --needle-line: rgba(62, 203, 255, 0.22);
  --hover-row: rgba(109, 124, 255, 0.12);
  --banner-ok-bg: rgba(62, 224, 160, 0.12);
  --banner-ok-line: rgba(62, 224, 160, 0.22);
  --banner-bad-bg: rgba(255, 93, 122, 0.12);
  --banner-bad-line: rgba(255, 93, 122, 0.28);
  --banner-bad-text: #ff8aa0;
  --bar-track: rgba(255, 255, 255, 0.06);
  --bar-fill: linear-gradient(90deg, #3ecbff, #7a6bff, #ff4aa8);
  --bar-glow: 0 0 12px rgba(110, 130, 255, 0.55);
  --timer-fill: linear-gradient(90deg, #8ecbff, #d57bff);
  --timer-clip: text;
  --timer-color: transparent;
  --placeholder: #6f789d;
  --focus-border: rgba(110, 168, 255, 0.8);
  --focus-ring: 0 0 0 3px rgba(80, 140, 255, 0.22);
  --check: #7a86ff;
  --scroll: rgba(140, 160, 255, 0.28);
  --btn-hover-filter: brightness(1.08);
  --ok-glow: 0 0 10px rgba(62, 224, 160, 0.7);
  --selected-inset: inset 3px 0 0 #7a86ff;
  --nav-current: linear-gradient(135deg, #6675ff, #8b5cff);
  --link-bg: linear-gradient(135deg, #6675ff, #ff4aa8);
  --ha-tab-active: linear-gradient(135deg, #6675ff, #ff4aa8);
  --cmd-result-bg: rgba(8, 10, 28, 0.45);
  --card-shadow: var(--shadow);
  --shell-bg: transparent;
  color-scheme: dark;
  font-family: var(--font);
}

html[data-theme="light"],
html[data-theme="paper"] {
  --ink: #111827;
  --muted: #4b5563;
  --paper: #ffffff;
  --card: #ffffff;
  --line: rgba(140, 150, 176, 0.16);
  --accent: #ff4d78;
  --accent-2: #ff8a62;
  --accent-3: #6b7cff;
  --accent-dark: #e13d6a;
  --ok: #22b07d;
  --bad: #ff4d78;
  --warn: #ff9f43;
  --shadow: 0 10px 28px rgba(28, 40, 72, 0.07);
  --glow: 0 8px 18px rgba(255, 77, 120, 0.22);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius: var(--radius-md);
  --font: "Ubuntu", "Segoe UI", sans-serif;
  --display: "Ubuntu", "Segoe UI", sans-serif;
  --body-bg: #f5f7fb;
  --body-image: none;
  --surface: #ffffff;
  --blur: none;
  --tablist-bg: #ffffff;
  --tab-active: linear-gradient(135deg, #ff4d78 0%, #ff8a62 100%);
  --btn-bg: linear-gradient(135deg, #ff4d78 0%, #ff8a62 100%);
  --btn-hover: linear-gradient(135deg, #ff5d86 0%, #ff9a74 100%);
  --btn-text: #fff;
  --ghost-bg: #f5f7fb;
  --ghost-hover: #eef1f7;
  --danger-bg: linear-gradient(135deg, #ff5d7a, #ff3d9a);
  --danger-shadow: 0 10px 22px rgba(255, 77, 120, 0.18);
  --inset-bg: #ffffff;
  --chip-bg: rgba(255, 77, 120, 0.08);
  --chip-line: rgba(255, 77, 120, 0.18);
  --needle-bg: rgba(107, 124, 255, 0.08);
  --needle-line: rgba(107, 124, 255, 0.18);
  --hover-row: rgba(255, 77, 120, 0.06);
  --banner-ok-bg: rgba(34, 176, 125, 0.1);
  --banner-ok-line: rgba(34, 176, 125, 0.2);
  --banner-bad-bg: rgba(255, 77, 120, 0.1);
  --banner-bad-line: rgba(255, 77, 120, 0.22);
  --banner-bad-text: #d63d66;
  --bar-track: #eef1f7;
  --bar-fill: linear-gradient(90deg, #6b7cff, #ff4d78, #ff8a62);
  --bar-glow: none;
  --timer-fill: linear-gradient(90deg, #ff4d78, #ff8a62);
  --timer-clip: text;
  --timer-color: transparent;
  --placeholder: #6b7280;
  --focus-border: rgba(255, 77, 120, 0.7);
  --focus-ring: 0 0 0 3px rgba(255, 77, 120, 0.14);
  --check: #ff4d78;
  --scroll: rgba(140, 150, 176, 0.35);
  --btn-hover-filter: brightness(1.04);
  --ok-glow: none;
  --selected-inset: inset 3px 0 0 #ff4d78;
  --nav-current: transparent;
  --link-bg: linear-gradient(135deg, #ff4d78, #ff8a62);
  --ha-tab-active: linear-gradient(135deg, #ff4d78, #ff8a62);
  --cmd-result-bg: #f5f7fb;
  --card-shadow: 0 8px 22px rgba(28, 40, 72, 0.06);
  --shell-bg: #f7f8fc;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
}

html:has(body.app-shell) {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--body-bg);
  background-image: var(--body-image);
  font-family: var(--font);
  font-weight: 400;
}

/* Ubuntu ships 400/500/700 — intermediate weights (550/600/650) often resolve to 700. */
strong {
  font-weight: 500;
}

body.app-shell {
  display: flex;
  align-items: stretch;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.gate {
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.gate-card,
.top {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
}

.gate-card {
  width: min(420px, 100%);
  padding: 36px 32px 32px;
  border-radius: var(--radius-lg);
}

/* Page sections stay flat — chrome lives on cards / gate only */
section.page-panel,
.layout > section.page-panel,
.layout > section:not(.dash-card):not(.panel-card) {
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--accent-3);
}

h1 {
  margin: 6px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 32px;
  letter-spacing: -0.03em;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

h3 {
  font-weight: 500;
}

.lede, .hint {
  color: var(--muted);
  font-weight: 400;
  line-height: 1.45;
}

.hint-cascade {
  margin: 8px 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
}

.hint-cascade > summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}

.hint-cascade > summary::-webkit-details-marker {
  display: none;
}

.hint-cascade > summary::before {
  content: "▸ ";
  color: var(--accent-3);
}

.hint-cascade[open] > summary::before {
  content: "▾ ";
}

.hint-cascade[open] > summary {
  margin-bottom: 6px;
}

.hint-cascade .hint {
  margin: 6px 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 0 0 16px;
  width: 100%;
  padding: 22px 24px;
  border-radius: var(--radius);
}

.layout {
  width: 100%;
  margin: 0 0 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
}

.layout > section {
  width: 100%;
  min-width: 0;
}

section {
  padding: 20px;
  border-radius: var(--radius-md);
}

section.page-panel {
  padding: 4px 0 20px;
}

.layout > section > label:not(.check) {
  max-width: none;
}

.panel-card > label:not(.check) {
  max-width: min(100%, 28rem);
}

.panel-card > label:has(textarea) {
  max-width: min(100%, 46rem);
}

.oww-grid > div > label:not(.check),
.oww-grid > .panel-card > label:not(.check),
.oww-split > div > label:not(.check),
.oww-split > .panel-card > label:not(.check),
.profiles-layout label:not(.check) {
  max-width: none;
}

.tablist,
.section-wide,
.actions {
  grid-column: 1 / -1;
}

.tablist {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 0 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.tablist button {
  flex: 0 0 auto;
  margin: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.tablist button[aria-selected="true"] {
  color: var(--btn-text);
  background: var(--tab-active);
  box-shadow: none;
}

section[hidden],
.app-main .layout > section[hidden],
.panel-card[hidden] {
  display: none !important;
}

label {
  display: block;
  margin: 10px 0;
  font-size: 13px;
  color: var(--muted);
}

input, select, textarea, button {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring);
}

::placeholder {
  color: var(--placeholder);
}

textarea { resize: vertical; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check input {
  width: auto;
  margin: 0;
  accent-color: var(--check);
}

button {
  width: auto;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 0;
  cursor: pointer;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

button:hover {
  filter: var(--btn-hover-filter);
  background: var(--btn-hover);
}

button:hover:not(:disabled):not(.ghost):not(.danger) {
  box-shadow: var(--glow);
}

button:focus-visible:not(.ghost):not(.danger) {
  box-shadow: var(--glow);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: none;
  box-shadow: none;
}

button.ghost {
  background: var(--ghost-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--ghost-hover);
  filter: none;
}

button.ghost[aria-pressed="true"] {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: transparent;
  box-shadow: var(--glow);
}

button.danger {
  background: var(--danger-bg);
  color: var(--btn-text);
  box-shadow: var(--danger-shadow);
}

pre#bt-log {
  white-space: pre-wrap;
  max-height: 140px;
  overflow: auto;
  font-size: 12px;
  background: var(--paper);
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

#bt-list {
  min-height: 72px;
  max-height: 360px;
}

#bt-list button,
#bt-list .row button,
.entity-list .bt-row button {
  width: auto;
  min-width: max-content;
  flex: 0 0 auto;
}

.entity-list .bt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.entity-list .bt-row span {
  flex: 1 1 180px;
}

.entity-list .bt-row .row {
  margin: 0;
  flex: 0 0 auto;
}

.entity-list > div,
.entity-list div.bt-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.banner {
  width: 100%;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--banner-ok-bg);
  color: var(--ok);
  border: 1px solid var(--banner-ok-line);
}

.banner.error {
  background: var(--banner-bad-bg);
  color: var(--banner-bad-text);
  border-color: var(--banner-bad-line);
}

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 10px 12px 14px;
  border-radius: 14px;
  background: var(--banner-ok-bg);
  color: var(--ok);
  border: 1px solid var(--banner-ok-line);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}

.toast-error {
  background: var(--banner-bad-bg);
  color: var(--banner-bad-text);
  border-color: var(--banner-bad-line);
}

.toast-progress {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.toast-text {
  flex: 1 1 auto;
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
}

.toast-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.toast-action,
.toast-close {
  width: auto;
  min-width: 32px;
  margin: 0;
  padding: 4px 8px;
  box-shadow: none;
}

.toast-close {
  font-size: 18px;
  line-height: 1;
  padding: 2px 8px;
}

.toast.is-leaving {
  animation: toast-out 0.18s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.is-leaving { animation: none; }
}

.wake-needles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}

.wake-needles span {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--needle-bg);
  border: 0;
  font-size: 13px;
}

.entity-list {
  max-height: 220px;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  background: var(--inset-bg);
}

.entity-list code { color: var(--muted); }

.ha-area-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
}

.ha-area-tabs[hidden] {
  display: none;
}

.ha-area-tabs button,
.ha-area-tab {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  min-height: 32px;
  color: var(--muted);
  background: var(--chip-bg);
  border: 0;
  border-radius: 999px;
  box-shadow: none;
}

.ha-area-tabs button[aria-selected="true"],
.ha-area-tab[aria-selected="true"] {
  color: var(--btn-text);
  background: var(--ha-tab-active);
  box-shadow: none;
}

.ha-device-list {
  width: 100%;
  max-height: 520px;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 4px 8px 10px;
  background: var(--inset-bg);
}

.ha-settings-page .ha-device-list {
  overflow-x: visible;
  overflow-y: auto;
  padding-bottom: 28px;
}

.ha-floor {
  margin: 16px 0 4px;
  font-size: 15px;
}

.ha-area {
  margin: 12px 0 2px;
  color: var(--accent-3);
  font-size: 13px;
  font-weight: 500;
}

.ha-device {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) minmax(148px, 200px);
  gap: 8px 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  align-items: start;
  overflow: visible;
}

button.ha-area-select {
  width: 100%;
  margin: 0;
  min-width: 0;
  justify-self: stretch;
  text-align: left;
  font-weight: 500;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
  padding: 8px 12px;
}

button.ha-area-select:hover {
  filter: none;
  background: var(--ghost-hover);
}

.ha-area-picker {
  position: fixed;
  z-index: 80;
  min-width: 180px;
  max-width: min(280px, calc(100vw - 24px));
  max-height: min(280px, 50vh);
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.ha-area-option {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  text-align: left;
  font-weight: 500;
  background: transparent;
  color: var(--ink);
  border: 0;
  box-shadow: none;
  border-radius: 8px;
}

.ha-area-option[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.ha-area-option:hover {
  filter: none;
  background: var(--ghost-hover);
}

.ha-device-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ha-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.ha-link::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.ha-link.online { color: var(--ok); }
.ha-link.online::before {
  background: var(--ok);
  box-shadow: var(--ok-glow);
}
.ha-link.unavailable { color: var(--warn); }
.ha-link.unavailable::before { background: var(--warn); }
.ha-link.missing { color: var(--bad); }
.ha-link.missing::before { background: var(--bad); }

.ha-device-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ha-device-name strong {
  font-size: 14px;
  font-weight: 500;
}

.ha-device-name code,
.ha-device-meta {
  color: var(--muted);
  font-size: 12px;
}

.ha-aliases {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 6px;
}

.ha-aliases span {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-line);
  font-size: 12px;
}

.ha-device label.ha-extra {
  margin: 0;
}

.ha-device label.ha-extra input {
  margin-top: 4px;
}

.ha-device .check {
  margin-top: 0;
}

.home-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.home-head-actions input[type="search"] {
  width: min(280px, 100%);
  margin: 0;
}

.home-gear {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  margin: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.home-gear .nav-ico {
  width: 20px;
  height: 20px;
  display: block;
}

.ha-card-grid {
  --ha-gap: 12px;
  --ha-cell: 176px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(176px, 100%), 1fr));
  grid-auto-rows: var(--ha-cell);
  grid-auto-flow: dense;
  gap: var(--ha-gap);
  width: 100%;
  min-width: 0;
}

.ha-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  aspect-ratio: 1 / 1;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 14px 14px 12px;
  overflow: hidden;
  box-sizing: border-box;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
  cursor: pointer;
}

.ha-card-wide {
  /* Kept for legacy CSS hooks; board cards never span — equal grid cells. */
  grid-column: span 1;
  grid-row: span 1;
  aspect-ratio: 1 / 1;
  height: 100%;
  max-height: 100%;
}

.ha-card:hover {
  filter: none;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.ha-card-icon {
  width: 32px;
  height: 32px;
  color: var(--muted);
}

.ha-card-face-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
}

.ha-card[data-on="1"] .ha-card-icon {
  color: var(--accent);
}

.ha-card-face {
  width: 36px;
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ha-icon-stack {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ha-icon-stack .ha-card-avatar {
  position: absolute;
  width: 16px;
  height: 16px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  opacity: 1;
  filter: none;
}

.ha-icon-stack .ha-card-icon {
  position: relative;
  z-index: 1;
}

.ha-card-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: contain;
  object-position: center center;
  background: transparent;
  image-rendering: auto;
  display: block;
}

.ha-card-top.ha-card-hero,
.ha-card-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 72px;
  margin: 0 auto 2px;
  flex: 0 0 auto;
}

.ha-card-hero-avatar,
.ha-card-hero .ha-card-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 0;
  object-fit: contain;
  object-position: center center;
  background: transparent;
  flex: 0 0 auto;
  box-shadow: none;
  /* Soft depth only — no brightness/saturate filters that muddy color */
  filter: drop-shadow(0 6px 10px rgba(20, 24, 40, 0.18));
  image-rendering: auto;
  pointer-events: none;
}

.ha-card-hero .ha-card-icon {
  width: 64px;
  height: 64px;
  color: var(--accent);
}

.ha-card-hero .ha-card-top-actions {
  position: absolute;
  top: 0;
  right: 0;
}

.ha-card-identity {
  display: grid;
  gap: 2px;
  justify-items: center;
  margin: 0 0 10px;
  min-width: 0;
}

.ha-card-identity strong {
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  -webkit-line-clamp: 2;
}

.ha-card-identity .ha-card-sub {
  margin-top: 0;
  text-align: center;
}

.ha-sensor-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin-top: auto;
  max-height: 34px;
  min-width: 0;
  overflow: hidden;
}

.ha-sensor-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 28px;
  max-height: 32px;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  border: 0;
  color: var(--muted);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.ha-sensor-chip:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.ha-sensor-chip-solo {
  grid-column: 1 / -1;
}

.ha-sensor-chip-ico {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: inherit;
}

.ha-sensor-chip-text {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.ha-sensor-chip-value {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.1;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ha-sensor-chip-unit {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.1;
  color: inherit;
  opacity: 0.9;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ha-card[data-status="unavailable"] .ha-card-icon { color: var(--warn); }
.ha-card[data-status="missing"] .ha-card-icon { color: var(--bad); }

.ha-card-top,
.ha-card-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.ha-card-top-actions {
  flex: 0 0 auto;
}

.ha-card-top-actions .ha-controls {
  width: auto;
  justify-content: flex-end;
}

.ha-icon-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: inherit;
}

.ha-icon-picker {
  position: absolute;
  top: 40px;
  left: 0;
  z-index: 8;
  width: min(248px, 80vw);
  max-height: 200px;
  overflow: auto;
  padding: 8px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.ha-icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 28px);
  gap: 4px;
}

.ha-icon-pick {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 3px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  color: var(--ink);
}

.ha-icon-pick .ha-icon-stack {
  width: 20px;
  height: 20px;
}

.ha-icon-pick .ha-card-icon {
  width: 18px;
  height: 18px;
}

.ha-icon-pick .ha-card-avatar {
  display: none;
}

.ha-icon-pick[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.ha-detail-icons {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}

.ha-detail-icon-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
}

.ha-detail-icon-btn .ha-card-icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.ha-card-head .ha-card-icon {
  flex: 0 0 30px;
}

.ha-card-foot {
  margin-top: 0;
  min-width: 0;
}

.ha-card strong,
.ha-card-head strong,
.ha-card-foot strong {
  display: block;
  min-width: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ha-card-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.ha-card-body {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 36px;
  min-width: 0;
  overflow: hidden;
  padding: 0;
}

.ha-card-footer-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: auto;
  min-height: 36px;
}

.ha-card-footer-actions .ha-controls {
  width: 100%;
  justify-content: center;
}

.ha-card-footer-actions .ha-controls-icons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.ha-card-multi .ha-card-body {
  justify-content: flex-end;
  min-height: 36px;
  overflow: hidden;
  text-align: center;
}

.ha-card-multi .ha-face-row {
  text-align: left;
}

.ha-face-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 32px;
}

.ha-face-name {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ha-face-row .ha-reading {
  flex: 0 1 auto;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.15;
  text-align: right;
}

.ha-face-row .ha-controls {
  width: auto;
  flex: 0 0 auto;
  justify-content: flex-end;
}

.ha-card-actions,
.ha-card-extras {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ha-reading {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.15;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ha-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: auto;
}

.ha-controls-icons {
  flex-wrap: nowrap;
  gap: 4px;
}

.ha-controls-thermo {
  flex-wrap: nowrap;
}

.ha-thermo-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ha-thermo-mini [data-thermo-mini] {
  min-width: 3.2rem;
  text-align: center;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ha-thermo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 16px 16px;
  border-radius: var(--radius-lg);
  background: var(--paper);
  border: 1px solid var(--line);
}

.ha-detail-sheet .ha-thermo {
  border: 0;
  background: transparent;
  padding: 8px 0 4px;
  box-shadow: none;
}

.ha-thermo-kicker {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.ha-thermo-current {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.ha-thermo-dial {
  position: relative;
  width: min(100%, 280px);
  aspect-ratio: 1;
}

.ha-thermo-dial svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ha-thermo-track {
  fill: none;
  stroke: color-mix(in srgb, var(--ink) 14%, transparent);
  stroke-width: 18;
  stroke-linecap: round;
}

.ha-thermo-fill {
  fill: none;
  stroke: var(--ok);
  stroke-width: 18;
  stroke-linecap: round;
}

.ha-thermo-thumb {
  fill: #fff;
  stroke: color-mix(in srgb, var(--ink) 18%, transparent);
  stroke-width: 1.5;
}

html[data-theme="light"] .ha-thermo-thumb,
html[data-theme="paper"] .ha-thermo-thumb {
  fill: #fff;
  stroke: rgba(17, 24, 39, 0.16);
}

.ha-thermo-face {
  position: absolute;
  inset: 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.ha-thermo-status {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.ha-thermo-target {
  margin: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-family: var(--display);
  line-height: 0.9;
}

.ha-thermo-target strong {
  font-size: clamp(48px, 14vw, 72px);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.ha-thermo-target sup {
  margin-top: 10px;
  font-size: 0.42em;
  font-weight: 700;
}

.ha-thermo-unit {
  margin: 12px 0 0 4px;
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
}

.ha-thermo-steps {
  display: flex;
  gap: 28px;
  margin: 4px 0 8px;
}

button.ha-thermo-step {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}

button.ha-thermo-step:hover {
  filter: none;
  background: var(--ghost-hover);
}

.ha-thermo-mini button.ha-thermo-step {
  width: 32px;
  min-width: 32px;
  height: 32px;
  font-size: 18px;
}

.ha-thermo-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.ha-thermo-modes:has(> :only-child) {
  grid-template-columns: 1fr;
}

button.ha-thermo-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 14px;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
}

.ha-thermo-mode-ico,
.ha-thermo-preset-ico {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.ha-thermo-preset-ico {
  width: 10px;
  height: 10px;
  flex-basis: 10px;
  border-radius: 50%;
  background: var(--ink);
}

.ha-thermo-mode-ico .ha-card-icon {
  width: 20px;
  height: 20px;
}

.ha-thermo .ha-detail-voice {
  width: 100%;
}

.ha-thermo-menu {
  position: fixed;
  z-index: 40;
  min-width: 200px;
  max-width: min(90vw, 320px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--card-shadow);
}

.ha-thermo-menu button {
  justify-content: flex-start;
  text-align: left;
}

.ha-controls button.ha-action-icon,
button.ha-action-icon {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  box-shadow: none;
  color: var(--ink);
}

.ha-controls button.ha-action-icon:hover,
button.ha-action-icon:hover {
  filter: none;
  background: var(--ghost-hover);
}

.ha-controls button.ha-action-icon[aria-pressed="true"],
button.ha-action-icon[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

.ha-action-icon .ha-card-icon {
  width: 20px;
  height: 20px;
}

.ha-controls button:not(.ha-ios-switch):not(.ha-power-btn):not(.ha-action-icon),
button.ha-mini,
button.ha-switch:not(.ha-ios-switch):not(.ha-power-btn) {
  width: auto;
  min-width: 64px;
  height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.ha-ios-switch {
  position: relative;
  width: 52px;
  min-width: 52px;
  height: 32px;
  padding: 4px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  background: color-mix(in srgb, var(--muted) 28%, var(--card));
  color: inherit;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  font-size: 0;
  line-height: 0;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  z-index: 2;
}

button.ha-ios-switch::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 999px;
}

button.ha-ios-switch:hover {
  filter: none;
  background: color-mix(in srgb, var(--muted) 38%, var(--card));
}

button.ha-ios-switch[aria-pressed="true"],
button.ha-ios-switch[aria-checked="true"] {
  background: color-mix(in srgb, var(--accent) 28%, var(--card));
}

button.ha-ios-switch[aria-pressed="true"]:hover,
button.ha-ios-switch[aria-checked="true"]:hover {
  background: color-mix(in srgb, var(--accent) 38%, var(--card));
}

.ha-ios-knob {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #cfd3dc;
  display: block;
  pointer-events: none;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease, background 0.18s ease;
}

button.ha-ios-switch[aria-pressed="true"] .ha-ios-knob,
button.ha-ios-switch[aria-checked="true"] .ha-ios-knob {
  background: var(--accent);
  transform: translateX(20px);
}

button.ha-ios-switch.is-busy {
  cursor: pointer;
}

button.ha-power-btn {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 40px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 22%, var(--card));
  color: color-mix(in srgb, var(--ink) 55%, var(--muted));
  box-shadow: none;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  transition: background 0.18s ease, color 0.18s ease;
}

button.ha-power-btn::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 999px;
}

button.ha-power-btn:hover {
  filter: none;
  background: color-mix(in srgb, var(--muted) 32%, var(--card));
}

button.ha-power-btn[aria-pressed="true"],
button.ha-power-btn[aria-checked="true"] {
  background: color-mix(in srgb, var(--accent) 22%, var(--card));
  color: var(--accent);
}

button.ha-power-btn[aria-pressed="true"]:hover,
button.ha-power-btn[aria-checked="true"]:hover {
  background: color-mix(in srgb, var(--accent) 32%, var(--card));
}

button.ha-power-btn .ha-power-ico {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;
}

button.ha-power-btn.is-busy {
  cursor: pointer;
  opacity: 0.85;
}

.ha-card-footer-actions .ha-controls:has(.ha-power-btn) {
  width: 100%;
}

.ha-type-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.ha-type-icon-row {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--muted) 8%, var(--card));
  min-width: 0;
  overflow: visible;
}

.ha-type-icon-row .ha-icon-picker {
  top: auto;
  left: 8px;
  right: 8px;
  width: auto;
  margin-top: 4px;
  position: relative;
  max-height: 220px;
}

.ha-type-icon-preview {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.18));
}

.ha-type-icon-row strong {
  display: block;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
}

.ha-type-icon-row .row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.ha-type-icon-row input[type="url"],
.ha-type-icon-row input[type="text"] {
  width: 100%;
  min-width: 0;
  font-size: 12px;
}

.ha-settings-page {
  width: 100%;
}

.ha-settings-page .panel-card {
  width: 100%;
  overflow: visible;
}

.ha-settings-head,
.ha-detail-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 12px;
}

.ha-detail-head h3 {
  margin: 0;
  font-family: var(--font);
}

.ha-detail-a11y {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ha-detail {
  position: relative;
  padding: 0;
  overflow: hidden;
  border: none;
  background: transparent;
  box-shadow: none;
}

.ha-detail-entity {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.ha-detail #ha-detail-body,
.ha-detail-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.ha-detail-screen {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ha-detail-overview {
  gap: 0;
}

.ha-detail-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 28px;
  background: color-mix(in srgb, var(--muted) 8%, var(--shell-bg, var(--body-bg)));
  border-radius: 22px 22px 0 0;
}

.ha-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 36px;
}

.ha-detail-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ha-detail-close,
.ha-history-nav-btn {
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ha-detail-close:hover,
.ha-history-nav-btn:hover {
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  color: var(--ink);
}

.ha-detail-avatar,
.ha-detail-hero .ha-card-avatar {
  width: 120px;
  height: 120px;
  border-radius: 0;
  object-fit: contain;
  object-position: center center;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 10px 18px rgba(20, 24, 40, 0.18));
  image-rendering: auto;
}

.ha-detail-hero .ha-card-icon {
  width: 120px;
  height: 120px;
  color: var(--accent-3);
}

.ha-detail-name {
  margin: 4px 0 0;
  text-align: center;
  font-family: var(--font);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}

.ha-detail-sub,
.ha-history-sub {
  margin: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

.ha-detail-sheet {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: -14px;
  padding: 22px 16px 18px;
  border-radius: 28px 28px var(--radius-md) var(--radius-md);
  background: var(--paper);
  border: 0;
  box-shadow: none;
}

.ha-detail-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ha-detail-group-title {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink);
}

.ha-detail-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ha-detail-tile {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--muted) 6%, var(--paper));
  border: 0;
  min-width: 0;
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: default;
}

button.ha-detail-sensor {
  cursor: pointer;
}

button.ha-detail-sensor:hover {
  background: color-mix(in srgb, var(--muted) 10%, var(--paper));
}

.ha-detail-actuator {
  grid-template-areas: "icon copy action";
}

.ha-detail-sensor {
  grid-template-areas: "icon copy chevron";
}

.ha-detail-actuator .ha-detail-tile-icon,
.ha-detail-sensor .ha-detail-tile-icon { grid-area: icon; }
.ha-detail-actuator .ha-detail-tile-copy,
.ha-detail-sensor .ha-detail-tile-copy { grid-area: copy; }
.ha-detail-actuator .ha-detail-tile-action { grid-area: action; }
.ha-detail-sensor .ha-detail-chevron { grid-area: chevron; }

.ha-detail-tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex: 0 0 auto;
}

.ha-detail-tone-violet {
  background: color-mix(in srgb, var(--accent-3) 82%, #7b61ff);
  color: #fff;
}

.ha-detail-tone-mint {
  background: color-mix(in srgb, var(--ok) 78%, #5fd0a5);
  color: #fff;
}

.ha-detail-tone-lime {
  background: color-mix(in srgb, #8fd46a 70%, var(--ok));
  color: #fff;
}

.ha-detail-tone-indigo {
  background: color-mix(in srgb, #6a74d8 70%, var(--accent-3));
  color: #fff;
}

.ha-detail-tile-icon .ha-card-icon {
  width: 22px;
  height: 22px;
  color: inherit;
}

.ha-detail-tile-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ha-detail-tile-copy strong {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ha-detail-sensor-value {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ha-detail-tile-meta {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.ha-detail-tile-action {
  flex: 0 0 auto;
}

.ha-detail-chevron {
  font-size: 22px;
  font-weight: 400;
  color: color-mix(in srgb, var(--muted) 70%, transparent);
  line-height: 1;
}

.ha-detail-sensor[data-status="unavailable"] .ha-detail-sensor-value,
.ha-detail-sensor[data-status="missing"] .ha-detail-sensor-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
}

.ha-detail-chart {
  min-width: 0;
  width: 100%;
}

.ha-detail-chart-lg {
  min-height: 220px;
  padding: 4px 0 8px;
}

.ha-detail-chart canvas {
  display: block;
  width: 100%;
  height: 104px;
  cursor: crosshair;
  touch-action: none;
}

.ha-detail-chart-lg canvas {
  height: 220px;
}

.ha-detail-chart-empty {
  margin: 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
}

.ha-detail-chart-lg .ha-detail-chart-empty {
  min-height: 180px;
  justify-content: center;
}

.ha-history-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 4px 0 8px;
}

.ha-history-chip {
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.ha-history-chip[aria-pressed="true"] {
  color: #fff;
  background: var(--accent-3);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent-3) 35%, transparent);
}

.ha-history-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 8px;
}

.ha-history-nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.ha-history-title {
  margin: 0;
  font-family: var(--font);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}

.ha-history-sub {
  text-align: left;
}

.ha-history-siblings {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 2px 4px;
  scrollbar-width: thin;
}

.ha-history-sibling {
  flex: 0 0 auto;
  min-width: 118px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: none;
  border-radius: 18px;
  background: color-mix(in srgb, var(--muted) 10%, var(--paper));
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ha-history-sibling-room {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.ha-history-sibling-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.ha-history-sibling-ico {
  width: 16px;
  height: 16px;
  color: var(--accent-3);
}

.ha-detail-history-screen {
  gap: 8px;
  padding: 8px 4px 12px;
  background: var(--paper);
  border-radius: 22px;
  border: 1px solid var(--line);
}

.ha-detail-voice {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--muted) 6%, var(--paper));
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.ha-detail-voice input {
  width: auto;
  min-width: 18px;
  height: 18px;
  margin: 3px 0 0;
  flex: 0 0 auto;
  accent-color: var(--check);
}

.ha-detail-voice-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ha-detail-voice-copy strong {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ha-detail-empty {
  margin: 0;
  padding: 16px;
  border-radius: 16px;
  background: var(--paper);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 14px;
}

html[data-theme="neon"] .ha-detail-hero {
  background: color-mix(in srgb, var(--paper) 70%, transparent);
}

html[data-theme="neon"] .ha-detail-tile,
html[data-theme="neon"] .ha-detail-voice,
html[data-theme="neon"] .ha-history-sibling {
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  border: 0;
}

html[data-theme="neon"] .ha-history-chip {
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  color: var(--ink);
}

html[data-theme="neon"] .ha-history-chip[aria-pressed="true"] {
  background: var(--accent-3);
  color: #041018;
}

.ha-device-actions {
  min-width: 180px;
}

.profiles-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(320px, 1.2fr);
  gap: 18px;
}

.profiles-layout:has(#profile-editor[hidden]) {
  grid-template-columns: minmax(250px, 28rem);
}

.profiles-list .profile-row {
  cursor: pointer;
  align-items: center;
}

.profiles-list .profile-row:hover,
.profiles-list .profile-row.selected {
  background: var(--hover-row);
  border-radius: 10px;
}

.profile-meta {
  color: var(--muted);
  font-size: 12px;
}

.profile-messages {
  max-height: 280px;
}

.profile-messages div {
  display: block;
}

.profile-messages strong {
  color: var(--accent-3);
}

#profile-active {
  width: 100%;
  margin: 0 0 12px;
}

.profile-delete-zone {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.subheading {
  margin-top: 20px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.top-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 500;
  font-size: 13px;
}

.top-nav a[aria-current="page"] {
  background: var(--nav-current);
  color: var(--btn-text);
  box-shadow: var(--glow);
}

a.btn-link {
  display: inline-block;
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--link-bg);
  color: var(--btn-text);
  text-decoration: none;
  font-weight: 500;
  box-shadow: var(--glow);
}

a.btn-link:hover {
  filter: var(--btn-hover-filter);
}

.tab-count:not(:empty)::before {
  content: "· ";
}

.gate-card .theme-toggle {
  margin-top: 18px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
}

.theme-toggle .nav-ico {
  width: 22px;
  height: 22px;
}

html[data-theme="neon"] .theme-ico-moon,
html[data-theme="light"] .theme-ico-sun,
html[data-theme="paper"] .theme-ico-sun {
  display: none;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 280px));
  gap: 16px;
  max-width: 720px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 16px;
  text-align: left;
  background: var(--ghost-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.theme-card:hover {
  filter: none;
  background: var(--ghost-hover);
}

.theme-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--ghost-hover);
  box-shadow: var(--glow);
  color: var(--ink);
}

.theme-card strong {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 500;
}

.theme-card > span:last-of-type {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  line-height: 1.4;
}

.theme-preview {
  display: block;
  width: 100%;
  height: 72px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.theme-preview-neon {
  background:
    radial-gradient(80px 40px at 20% 20%, rgba(92, 74, 255, 0.6), transparent 60%),
    radial-gradient(80px 40px at 80% 80%, rgba(255, 48, 148, 0.45), transparent 55%),
    linear-gradient(180deg, #1a1e44, #07091a);
}

.theme-preview-light,
.theme-preview-paper {
  background:
    linear-gradient(180deg, #ff4d78, #ff8a62) 0 0 / 22% 100% no-repeat,
    linear-gradient(#111827, #111827) 32% 22% / 52% 7% no-repeat,
    linear-gradient(#4b5563, #4b5563) 32% 34% / 38% 5% no-repeat,
    linear-gradient(#ffffff, #ffffff) 28% 16% / 64% 30% no-repeat,
    linear-gradient(#ffffff, #ffffff) 28% 56% / 30% 30% no-repeat,
    linear-gradient(#ffffff, #ffffff) 62% 56% / 30% 30% no-repeat,
    #f5f7fb;
}

.oww-page {
  width: 100%;
}

.oww-grid,
.oww-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  width: 100%;
}

.oww-grid + .oww-split {
  margin-top: 16px;
}

.oww-timer {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0 8px;
  letter-spacing: -0.04em;
  background: var(--timer-fill);
  -webkit-background-clip: var(--timer-clip);
  background-clip: var(--timer-clip);
  color: var(--timer-color);
}

.oww-counter {
  margin: 12px 0;
}

.oww-counter > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.oww-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bar-track);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-top: 6px;
}

.oww-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--bar-fill);
  box-shadow: var(--bar-glow);
}

.oww-retrain {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 0 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--inset-bg);
}

.oww-retrain-ring {
  position: relative;
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
}

.oww-retrain-ring svg {
  display: block;
  width: 100%;
  height: 100%;
}

.oww-retrain-arc {
  stroke: var(--accent);
}

.oww-retrain[data-status="disabled"] .oww-retrain-arc,
.oww-retrain[data-status="empty"] .oww-retrain-arc {
  stroke: var(--muted);
}

.oww-retrain[data-status="waiting_clips"] .oww-retrain-arc {
  stroke: var(--warn);
}

.oww-retrain[data-status="due"] .oww-retrain-arc {
  stroke: var(--ok);
}

.oww-retrain[data-status="running"] .oww-retrain-arc {
  stroke: var(--accent);
}

.oww-retrain-value {
  position: absolute;
  inset: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 4px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-align: center;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.oww-retrain-value.is-status {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.2;
}

.oww-retrain-copy {
  min-width: 0;
  flex: 1;
}

.oww-retrain-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

.oww-retrain-copy .hint {
  margin: 0;
}

.oww-clip-list {
  width: 100%;
  max-width: none;
  max-height: 420px;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--inset-bg);
}

#oww-auto.oww-clip-list {
  max-height: min(70vh, 760px);
}

.oww-clip {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.oww-clip:last-child {
  border-bottom: 0;
}

.oww-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.oww-bulk[hidden] {
  display: none;
}

.oww-bulk-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.oww-select-all {
  margin: 0 0 8px;
}

.oww-clip-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  justify-content: stretch;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.oww-clip-pick-wrap {
  margin: 0;
}

.oww-clip.is-selected {
  background: var(--hover-row);
  border-radius: 10px;
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
}

.oww-clip-head span {
  color: var(--muted);
  font-size: 12px;
}

.oww-clip audio {
  width: 100%;
  margin: 0 0 8px;
}

.oww-marks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.oww-marks .check {
  margin: 0;
}

button.danger-ghost {
  color: var(--bad);
  border-color: rgba(255, 93, 122, 0.35);
}

html[data-theme="light"] button.danger-ghost,
html[data-theme="paper"] button.danger-ghost {
  border-color: rgba(226, 59, 92, 0.35);
}

.cmd-result {
  width: 100%;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--cmd-result-bg);
  margin: 0 0 14px;
}

.cmd-result h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.cmd-kv {
  margin: 0 0 8px;
  font-size: 14px;
}

.cmd-kv span {
  color: var(--muted);
}

.cmd-call {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--hover-row);
  border: 1px solid var(--line);
  margin: 8px 0;
}

.cmd-candidates {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 0;
}

.cmd-candidates button {
  width: 100%;
  text-align: left;
}

.cmd-device-list {
  max-height: 320px;
}

.cmd-device {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-weight: 500;
  box-shadow: none;
}

.cmd-device:hover,
.cmd-device[aria-selected="true"] {
  background: var(--hover-row);
  filter: none;
}

.cmd-device[aria-selected="true"] {
  box-shadow: var(--selected-inset);
}

.cmd-device small {
  color: var(--muted);
  font-weight: 400;
}

#cmd-aliases {
  min-height: 36px;
}

#cmd-aliases button {
  width: auto;
  margin: 0;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar {
  flex: 0 0 248px;
  flex-shrink: 0;
  width: 248px;
  align-self: stretch;
  height: auto;
  max-height: 100%;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 14px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: none;
  backdrop-filter: var(--blur);
  z-index: 30;
  overflow: hidden;
}

.sidebar-brand strong {
  display: block;
  margin-top: 4px;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  border: 0;
  box-shadow: none;
  text-decoration: none;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  text-align: left;
  border-radius: 12px;
}

.sidebar-item:hover {
  background: var(--ghost-hover);
  filter: none;
  color: var(--ink);
}

.sidebar-item[aria-selected="true"],
.sidebar-item.is-current,
.sidebar-item[aria-current="page"] {
  color: var(--btn-text);
  background: var(--tab-active);
  box-shadow: var(--glow);
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-group-toggle .nav-chevron {
  width: 16px;
  height: 16px;
  margin-left: auto;
  flex: 0 0 16px;
  color: currentColor;
  transition: transform 0.18s ease;
}

.sidebar-group.is-open .nav-chevron {
  transform: rotate(90deg);
}

.sidebar-subnav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 0 4px 10px;
}

.sidebar-subnav[hidden] {
  display: none;
}

.sidebar-subnav .sidebar-item {
  font-size: 13px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.nav-ico {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: block;
}

.nav-badge {
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--accent);
  color: var(--btn-text);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  flex: 0 0 auto;
}

.nav-badge:not(:empty):not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gate-card .nav-ico {
  flex: 0 0 22px;
}

.sidebar-footer {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.sidebar-footer .nav-edit,
.sidebar-footer .theme-toggle {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  margin: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer .nav-ico {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: block;
}

.sidebar-footer form {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  display: flex;
}

.sidebar-footer form button {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-edit {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-edit[aria-pressed="true"] {
  background: var(--ghost-hover);
  color: var(--ink);
}

.nav-handle {
  display: none;
  flex: 0 0 14px;
  width: 14px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: -0.12em;
  cursor: grab;
  user-select: none;
}

.sidebar-nav.is-editing .nav-handle {
  display: inline-block;
}

.sidebar-nav.is-editing .sidebar-item {
  cursor: grab;
}

.sidebar-nav.is-editing .sidebar-item.is-dragging {
  opacity: 0.55;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-burger {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
}

.sidebar-burger-icon,
.sidebar-burger-icon::before,
.sidebar-burger-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.sidebar-burger-icon {
  position: relative;
  transition: background 0.18s ease;
}

.sidebar-burger-icon::before,
.sidebar-burger-icon::after {
  content: "";
  position: absolute;
  left: 0;
  transition: transform 0.18s ease, top 0.18s ease;
}

.sidebar-burger-icon::before {
  top: -6px;
}

.sidebar-burger-icon::after {
  top: 6px;
}

body.sidebar-open .sidebar-burger-icon {
  background: transparent;
}

body.sidebar-open .sidebar-burger-icon::before {
  top: 0;
  transform: rotate(45deg);
}

body.sidebar-open .sidebar-burger-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.main-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 12px;
  width: 100%;
  padding: 4px 0 8px;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

body.showing-dashboard .settings-actions,
body.showing-log .settings-actions,
body.showing-home .settings-actions,
body.showing-scenarios .settings-actions {
  display: none;
}

.settings-actions {
  position: sticky;
  bottom: 0;
  z-index: 24;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 8px 0 0;
  padding: 14px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--body-bg) 0%, transparent) 0%,
    color-mix(in srgb, var(--body-bg) 92%, transparent) 28%,
    var(--body-bg) 100%
  );
  border-top: 0;
}

.dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.dashboard-head h2 {
  margin: 0;
}

.dashboard-panel {
  width: 100%;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.dashboard-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-edit {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.dash-edit[aria-pressed="true"] {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: transparent;
}

.dash-edit-hint {
  margin: 0;
}

.dashboard-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.dashboard-board [data-dash-block="host"] {
  grid-column: 1 / -1;
}

.dashboard-board [data-dash-block="openai"],
.dashboard-board [data-dash-block="wake"],
.dashboard-board [data-dash-block="local"] {
  grid-column: span 2;
}

.dashboard-board [data-dash-block="recent"],
.dashboard-board [data-dash-block="commands"] {
  grid-column: span 3;
}

.dash-block {
  position: relative;
}

.dash-block-handle {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--ghost-bg);
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  font-size: 14px;
  line-height: 1;
  letter-spacing: -2px;
  box-shadow: none;
}

.dashboard-board.is-editing .dash-block-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dashboard-board.is-editing .dash-block {
  outline: 1px dashed var(--line);
}

.dashboard-board.is-editing .dash-block.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.dash-gauges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px 12px;
  align-items: start;
}

.dash-block-host {
  padding: 14px 16px 12px;
}

.dash-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  text-align: center;
}

.dash-gauge-ring {
  position: relative;
  width: 124px;
  height: 124px;
  flex: 0 0 124px;
}

.dash-gauge-ring svg {
  display: block;
  width: 100%;
  height: 100%;
}

.dash-gauge-track,
.dash-gauge-arc {
  fill: none;
  stroke-width: 8;
}

.dash-gauge-track {
  stroke: var(--line);
}

.dash-gauge-arc {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 238.76;
  stroke-dashoffset: 238.76;
  transition: stroke-dashoffset 0.35s ease, stroke 0.2s ease;
}

.dash-gauge-cpu { stroke: var(--accent-3); }
.dash-gauge-ram { stroke: var(--accent); }
.dash-gauge-disk-io { stroke: var(--accent-2); }
.dash-gauge-disk { stroke: var(--ok); }
.dash-gauge-bt { stroke: var(--muted); }
.dash-gauge-mic { stroke: var(--muted); }
.dash-mic-card.is-live .dash-gauge-mic { stroke: var(--accent); }
.dash-mic-card.is-hot .dash-gauge-mic { stroke: var(--warn); }
.dash-mic-card.is-off .dash-gauge-mic { stroke: var(--bad); }

.dash-bt-card.is-on .dash-gauge-bt { stroke: var(--muted); }
.dash-bt-card.is-off .dash-gauge-bt { stroke: var(--bad); }
.dash-bt-card[data-quality="excellent"] .dash-gauge-bt { stroke: var(--ok); }
.dash-bt-card[data-quality="good"] .dash-gauge-bt { stroke: var(--accent-3); }
.dash-bt-card[data-quality="fair"] .dash-gauge-bt { stroke: var(--warn); }
.dash-bt-card[data-quality="weak"] .dash-gauge-bt { stroke: var(--bad); }

.dash-gauge-value {
  position: absolute;
  inset: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

.dash-gauge-value.is-rssi {
  font-size: 22px;
}

.dash-gauge-value.is-status {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0;
}

.dash-gauge-unit {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  color: var(--muted);
}

.dash-gauge-label {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
}

.dash-gauge-meta {
  margin: 0;
  min-height: 2.7em;
  max-width: 168px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  text-align: center;
}

.dash-host-value {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.dashboard-host {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}

.dashboard-feeds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 28px;
  padding-top: 8px;
  align-items: start;
}

.range-toggle {
  display: flex;
  gap: 6px;
}

.range-toggle button {
  margin: 0;
}

.page-panel {
  width: 100%;
}

.log-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.log-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.log-live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.log-live.is-on {
  color: var(--ok);
}

.log-live.is-on i {
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent);
}

.log-card {
  display: flex;
  flex-direction: column;
  min-height: min(68vh, 760px);
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.log-view {
  flex: 1 1 auto;
  min-height: 360px;
  max-height: min(68vh, 760px);
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #0b1020;
  color: #d7deea;
  font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.45;
}

.log-line {
  display: grid;
  grid-template-columns: 7.2em minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.log-line time {
  color: #8b95ad;
  font-variant-numeric: tabular-nums;
}

.log-line span {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-line.is-err {
  color: #ff9aa8;
}

.log-line.is-err time {
  color: #ff7a8e;
}

body.showing-log .layout {
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0;
}

#panel-log:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#panel-log:not([hidden]) .log-card {
  flex: 1 1 auto;
  min-height: 0;
}

#panel-log:not([hidden]) .log-view {
  max-height: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.panel-grid + .panel-grid,
.panel-grid + .panel-card,
.panel-card + .panel-grid {
  margin-top: 16px;
}

.panel-card-wide {
  grid-column: 1 / -1;
}

.panel-card,
.dash-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 16px 14px;
  border-radius: var(--radius-md);
  background: var(--inset-bg);
  border: 1px solid var(--line);
}

.dash-card {
  overflow: hidden;
}

.panel-card .entity-list,
.panel-card .ha-device-list,
.panel-card .oww-clip-list,
.panel-card .ha-aliases {
  width: 100%;
  max-width: none;
  border: 0;
}

.panel-card > h2,
.panel-card > h3:not(.subheading),
.dash-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.panel-card > .hint:first-of-type {
  margin-top: 0;
}

.dash-card > .hint {
  min-height: 1.35em;
  margin: 0 0 10px;
}

.dash-chart {
  position: relative;
  width: 100%;
  height: 220px;
  min-width: 0;
  overflow: hidden;
}

.dash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.dash-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dash-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.dash-swatch-count {
  background: var(--accent-3);
}

.dash-swatch-tokens {
  background: var(--accent-2);
}

.dash-swatch-ram-used {
  background: var(--accent);
}

.dash-swatch-ram-free {
  background: var(--muted);
  opacity: 0.55;
}

.dash-swatch-disk-read {
  background: var(--accent-3);
}

.dash-swatch-disk-write {
  background: var(--accent-2);
}

.dash-bt-card.is-on .dash-gauge-value {
  color: var(--ok);
}

.dash-bt-card.is-off .dash-gauge-value {
  color: var(--bad);
}

.dash-bt-quality {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
}

.dash-bt-quality-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.dash-bt-quality-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--ok);
}

.dash-bt-quality[data-quality="good"] .dash-bt-quality-bar i {
  background: var(--accent-3);
}

.dash-bt-quality[data-quality="fair"] .dash-bt-quality-bar i {
  background: var(--warn);
}

.dash-bt-quality[data-quality="weak"] .dash-bt-quality-bar i {
  background: var(--bad);
}

.dash-bt-quality #dash-bt-quality-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.dash-card canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.dash-recent {
  min-height: 120px;
  max-height: 360px;
  overflow: auto;
}

.dash-recent-row {
  display: grid;
  grid-template-columns: 92px 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.dash-recent-row time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dash-kind {
  font-weight: 500;
}

.dash-kind-openai { color: var(--accent-3); }
.dash-kind-wake { color: var(--accent-2); }
.dash-kind-local { color: var(--ok); }

.dash-recent-row.is-bad .dash-kind {
  color: var(--bad);
}

html[data-theme="light"] .gate-card,
html[data-theme="light"] .top,
html[data-theme="light"] .sidebar,
html[data-theme="paper"] .gate-card,
html[data-theme="paper"] .top,
html[data-theme="paper"] .sidebar {
  background: #fff;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

html[data-theme="light"] .gate-card,
html[data-theme="paper"] .gate-card {
  box-shadow: var(--shadow);
  border: 0;
}

html[data-theme="light"] .sidebar,
html[data-theme="paper"] .sidebar {
  border-right: 1px solid #eef0f5;
  box-shadow: none;
}

html[data-theme="light"] .main-top,
html[data-theme="paper"] .main-top {
  background: transparent;
  border: 0;
  box-shadow: none;
}

html[data-theme="light"] section.page-panel,
html[data-theme="paper"] section.page-panel,
html[data-theme="light"] .layout > section:not(.dash-card):not(.panel-card),
html[data-theme="paper"] .layout > section:not(.dash-card):not(.panel-card) {
  border: 0;
  box-shadow: none;
}

html[data-theme="light"] .sidebar-brand,
html[data-theme="paper"] .sidebar-brand {
  margin: -6px 0 8px;
  padding: 16px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff4d78 0%, #ff8a62 100%);
  color: #fff;
}

html[data-theme="light"] .sidebar-brand .eyebrow,
html[data-theme="light"] .sidebar-brand strong,
html[data-theme="paper"] .sidebar-brand .eyebrow,
html[data-theme="paper"] .sidebar-brand strong {
  color: #fff;
}

html[data-theme="light"] .sidebar-item,
html[data-theme="paper"] .sidebar-item {
  border-radius: 10px;
  font-weight: 500;
  color: #5b6475;
}

html[data-theme="light"] .sidebar-item[aria-selected="true"],
html[data-theme="light"] .sidebar-item.is-current,
html[data-theme="light"] .sidebar-item[aria-current="page"],
html[data-theme="paper"] .sidebar-item[aria-selected="true"],
html[data-theme="paper"] .sidebar-item.is-current,
html[data-theme="paper"] .sidebar-item[aria-current="page"] {
  color: #ff4d78;
  background: rgba(255, 77, 120, 0.08);
  box-shadow: inset 3px 0 0 #ff4d78;
}

html[data-theme="light"] .page-panel,
html[data-theme="paper"] .page-panel {
  background: var(--shell-bg);
}

html[data-theme="light"] .panel-card,
html[data-theme="light"] .dash-card,
html[data-theme="light"] .ha-card,
html[data-theme="paper"] .panel-card,
html[data-theme="paper"] .dash-card,
html[data-theme="paper"] .ha-card {
  background: #fff;
  border: 1px solid #eef0f5;
  box-shadow: var(--card-shadow);
  color: var(--ink);
}

html[data-theme="light"] .ha-sensor-chip,
html[data-theme="paper"] .ha-sensor-chip {
  background: #e8edf5;
  border: 0;
  color: #6b758a;
}

html[data-theme="neon"] .ha-sensor-chip {
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  border: 0;
  color: var(--muted);
}

html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="paper"] h1,
html[data-theme="paper"] h2,
html[data-theme="paper"] h3 {
  color: var(--ink);
}

html[data-theme="light"] label,
html[data-theme="light"] .lede,
html[data-theme="light"] .hint,
html[data-theme="light"] .dash-legend,
html[data-theme="light"] .dash-recent-row time,
html[data-theme="light"] .theme-card > span:last-of-type,
html[data-theme="light"] .profile-meta,
html[data-theme="light"] .ha-device-meta,
html[data-theme="paper"] label,
html[data-theme="paper"] .lede,
html[data-theme="paper"] .hint,
html[data-theme="paper"] .dash-legend,
html[data-theme="paper"] .dash-recent-row time,
html[data-theme="paper"] .theme-card > span:last-of-type,
html[data-theme="paper"] .profile-meta,
html[data-theme="paper"] .ha-device-meta {
  color: #374151;
}

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="paper"] input,
html[data-theme="paper"] select,
html[data-theme="paper"] textarea {
  background: #f5f7fb;
  border-color: #e6e9f2;
}

html[data-theme="light"] .tablist,
html[data-theme="paper"] .tablist {
  background: transparent;
  border: 0;
  border-bottom: 1px solid #eef0f5;
  box-shadow: none;
}

html[data-theme="light"] .oww-clip-list,
html[data-theme="light"] .ha-device-list,
html[data-theme="light"] .entity-list,
html[data-theme="paper"] .oww-clip-list,
html[data-theme="paper"] .ha-device-list,
html[data-theme="paper"] .entity-list {
  background: color-mix(in srgb, #f5f7fb 88%, #fff);
  border: 0;
}

html[data-theme="light"] .settings-actions,
html[data-theme="paper"] .settings-actions {
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in srgb, var(--shell-bg) 88%, transparent) 28%,
    var(--shell-bg) 100%
  );
}

html[data-theme="light"] .theme-card,
html[data-theme="paper"] .theme-card {
  background: #fff;
  border-color: #eef0f5;
  box-shadow: var(--card-shadow);
}

html[data-theme="light"] .theme-card[aria-pressed="true"],
html[data-theme="paper"] .theme-card[aria-pressed="true"] {
  border-color: #ff4d78;
  box-shadow: 0 8px 18px rgba(255, 77, 120, 0.16);
}

html[data-theme="light"] .toast,
html[data-theme="paper"] .toast {
  background: #fff;
  color: var(--ink);
  border: 1px solid #eef0f5;
  border-left-width: 3px;
  box-shadow: var(--card-shadow);
}

html[data-theme="light"] .toast-ok,
html[data-theme="paper"] .toast-ok {
  border-left-color: var(--ok);
}

html[data-theme="light"] .toast-error,
html[data-theme="paper"] .toast-error {
  border-left-color: #ff4d78;
}

html[data-theme="light"] .toast-progress,
html[data-theme="paper"] .toast-progress {
  border-left-color: #6b7cff;
}

@media (max-width: 1100px) and (min-width: 721px) {
  .sidebar {
    flex-basis: 84px;
    width: 84px;
    padding: 16px 10px;
  }
  .sidebar-brand strong,
  .sidebar .nav-label {
    display: none;
  }
  .sidebar-item {
    justify-content: center;
    padding: 10px 6px;
  }
  .sidebar-group-toggle .nav-chevron {
    display: none;
  }
  .sidebar-subnav {
    padding-left: 0;
  }
  .nav-ico {
    margin: 0 auto;
  }
  .nav-badge:not(:empty):not([hidden]) {
    position: absolute;
    top: 2px;
    right: 2px;
    margin: 0;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 10px;
    z-index: 1;
  }
  .sidebar-footer {
    align-items: center;
  }
  .sidebar-footer form button {
    padding: 8px 6px;
    font-size: 12px;
  }
}

@media (max-width: 720px) {
  .app-main {
    padding: 8px max(8px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .main-top {
    margin: 0 0 8px;
    padding: 4px 0 6px;
    gap: 10px;
    border-radius: 0;
  }
  .layout {
    margin: 0 0 12px;
    gap: 10px;
  }
  section.page-panel,
  .layout > section.page-panel {
    padding: 2px 0 12px;
    border-radius: 0;
  }
  .gate-card,
  .top {
    padding: 12px;
    border-radius: var(--radius-md);
  }
  .sidebar-item {
    min-height: 44px;
  }
  button.ghost,
  .range-toggle button,
  .log-head-actions button,
  .dashboard-head-actions .ghost,
  .ha-area-tabs button,
  .ha-area-tab {
    min-height: 44px;
  }
  .ha-sensor-chips {
    max-height: none;
    gap: 4px;
  }
  .ha-sensor-chip {
    max-height: none;
    min-height: 28px;
    white-space: normal;
  }
  .ha-sensor-chip-value,
  .ha-sensor-chip-unit {
    white-space: nowrap;
  }
  .ha-card {
    padding: 12px;
    border-radius: var(--radius-lg);
  }
  .tablist {
    padding: 0 0 6px;
    border-radius: 0;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    flex-basis: 248px;
    width: min(248px, 86vw);
    padding: 16px 10px 12px;
  }
  body.sidebar-open .sidebar {
    transform: none;
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 20, 0.46);
    z-index: 25;
  }
  .sidebar-burger {
    display: inline-flex;
    margin: 0;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-board {
    grid-template-columns: 1fr;
  }
  .dashboard-board [data-dash-block="host"],
  .dashboard-board [data-dash-block="openai"],
  .dashboard-board [data-dash-block="wake"],
  .dashboard-board [data-dash-block="local"],
  .dashboard-board [data-dash-block="recent"],
  .dashboard-board [data-dash-block="commands"] {
    grid-column: 1 / -1;
  }
  .dash-gauges {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 4px;
  }
  .dash-gauge {
    flex: 0 0 156px;
  }
  .dash-gauge-meta {
    max-width: 156px;
  }
  .dashboard-host,
  .dashboard-feeds {
    grid-template-columns: 1fr;
  }
  .dash-recent-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .ha-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    --ha-gap: 8px;
    --ha-cell: calc((100% - var(--ha-gap)) / 2);
    grid-auto-rows: var(--ha-cell);
  }
  .ha-card-wide {
    grid-column: span 1;
    grid-row: span 1;
  }
  .ha-thermo-modes {
    grid-template-columns: 1fr;
  }
  .ha-detail-voice-copy strong {
    white-space: normal;
  }
  .ha-detail-tile {
    padding: 12px;
  }
  .ha-detail-name,
  .ha-history-title {
    font-size: 24px;
  }
  .ha-detail-avatar,
  .ha-detail-hero .ha-card-avatar,
  .ha-detail-hero .ha-card-icon {
    width: 96px;
    height: 96px;
  }
}

@media (max-width: 820px) {
  .tablist, .section-wide, .actions { grid-column: auto; }
  .profiles-layout { grid-template-columns: 1fr; }
  .ha-device { grid-template-columns: 1fr; }
  .oww-grid, .oww-split { grid-template-columns: 1fr; }
  .oww-retrain {
    flex-direction: column;
    text-align: center;
  }
  .oww-retrain-copy .hint {
    text-align: center;
  }
  .theme-grid { grid-template-columns: 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
  .top-actions { width: 100%; }
  h1 { font-size: 26px; }
  .dashboard-grid, .dashboard-host, .dashboard-feeds, .dashboard-board { grid-template-columns: 1fr; }
}

.scn-head-actions,
.scn-toolbar,
.scn-detail-actions,
.scn-row-actions,
.scn-block-head,
.scn-card-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scn-toolbar {
  margin: 0 0 12px;
}

.scn-search {
  flex: 1 1 180px;
  min-width: 0;
  margin: 0;
}

.scn-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.scn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.scn-row:last-child {
  border-bottom: 0;
}

.scn-row:hover {
  background: var(--hover-row);
}

.scn-row-main {
  min-width: 0;
}

.scn-row-main strong {
  display: block;
  font-weight: 500;
}

.scn-row-main .hint {
  margin: 4px 0 0;
}

.scn-row-actions {
  flex: 0 0 auto;
}

.scn-run,
.scn-detail-actions button,
.scn-head-actions button {
  min-height: 44px;
  min-width: 44px;
}

.scn-detail {
  margin-top: 8px;
}

.scn-detail-head {
  margin-bottom: 10px;
}

.scn-detail-head h3 {
  margin: 0 0 4px;
}

.scn-detail-actions {
  margin: 0 0 12px;
}

.scn-tabs {
  margin: 0 0 12px;
}

.scn-editor,
.scn-yaml-wrap,
.scn-history,
.scn-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scn-editor[hidden],
.scn-yaml-wrap[hidden],
.scn-history[hidden],
.scn-history-page[hidden],
#scn-list-view[hidden] {
  display: none !important;
}

.scn-form,
.scn-form-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scn-field-hint {
  margin: 4px 0 0;
}

.scn-duration {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.scn-duration input {
  margin-top: 6px;
  text-align: center;
}

.scn-kv {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scn-kv-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 44px;
  gap: 8px;
  align-items: center;
}

.scn-kv-row input,
.scn-kv-actions button {
  margin-top: 0;
}

.scn-kv-actions {
  display: flex;
  justify-content: flex-start;
}

.scn-weekdays {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 6px;
}

.scn-weekday {
  margin: 0;
}

.scn-nested,
.scn-branch {
  padding: 10px 10px 10px 14px;
  border-radius: var(--radius-sm);
  border: 0;
  border-left: 2px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--inset-bg) 70%, transparent);
}

.scn-nested.is-active,
.scn-branch.is-active,
.scn-block.is-active .scn-nested,
.scn-block:focus-within > .scn-nested,
.scn-block:focus-within > .scn-branch {
  border-left-color: var(--accent);
}

.scn-nested h4,
.scn-branch-head {
  margin: 0 0 8px;
}

.scn-branch {
  margin: 0 0 10px;
}

.scn-branch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.scn-block-nested {
  margin: 0;
  padding: 8px;
  border-style: solid;
}

.scn-advanced {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed var(--line);
}

.scn-advanced summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--muted);
}

.scn-advanced[open] summary {
  margin-bottom: 8px;
}

.scn-top,
.scn-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.scn-top label,
.scn-fields label {
  margin: 0;
}

.scn-block {
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: var(--paper);
}

.scn-block-head {
  justify-content: space-between;
  margin-bottom: 8px;
}

.scn-block-head h3 {
  margin: 0;
  font-size: 15px;
}

.scn-card {
  padding: 10px;
  margin: 8px 0 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--inset-bg);
}

.scn-card-bar select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
}

.scn-icon-btn {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

#scn-yaml {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-height: 280px;
}

.scn-hist {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.scn-hist p {
  grid-column: 1 / -1;
  margin: 0;
}

.scn-hist.is-ok .scn-hist-state {
  color: var(--accent-3, #7dffb3);
}

.scn-hist.is-err .scn-hist-state {
  color: var(--danger, #ff6b8a);
}

.scn-history-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto auto;
  gap: 10px 12px;
  align-items: end;
  margin: 0 0 14px;
}

.scn-history-filters label {
  margin: 0;
}

.scn-history-filters button {
  margin: 0;
  min-height: 44px;
}

.scn-history-more {
  margin: 4px 0 0;
}

.scn-picker {
  display: grid;
  gap: 10px;
}

.scn-picker-search {
  width: 100%;
}

.scn-picker-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scn-picker-tab.is-active,
.scn-easy-tools .ghost.is-active {
  border-color: var(--accent, #7aa2ff);
  color: var(--text);
  background: color-mix(in srgb, var(--accent, #7aa2ff) 18%, transparent);
}

.scn-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}

.scn-pick-tile {
  display: grid;
  gap: 6px;
  justify-items: start;
  text-align: left;
  min-height: 96px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--line, #334) 80%, transparent);
  background: color-mix(in srgb, var(--panel, #151821) 88%, transparent);
  color: inherit;
  cursor: pointer;
}

.scn-pick-tile:hover,
.scn-pick-tile.is-selected {
  border-color: var(--accent, #7aa2ff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent, #7aa2ff) 35%, transparent);
}

.scn-pick-tile strong {
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.25;
}

.scn-pick-tile .hint {
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.scn-pick-ico {
  width: 22px;
  height: 22px;
  color: var(--accent, #7aa2ff);
}

.scn-selected-device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--line, #334) 80%, transparent);
  margin-bottom: 10px;
}

.scn-selected-face {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.scn-selected-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.scn-selected-text .hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scn-easy-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

@media (max-width: 720px) {
  .scn-top,
  .scn-fields,
  .scn-kv-row {
    grid-template-columns: 1fr;
  }
  .scn-duration {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  }
  .scn-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .scn-row-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .scn-history-filters {
    grid-template-columns: 1fr;
  }
  .scn-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .scn-selected-device {
    align-items: flex-start;
    flex-direction: column;
  }
}
