/* ha-shell.css — shared design system for ha.knwl.me */

/* Foundations are available to every app. Historical aliases keep legacy pages stable. */
:root {
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  /* Type scale: 11 px is the floor for any text. */
  --text-xs: 0.6875rem;
  --text-caption: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-body: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.5rem;
  --text-display: 2.5rem;
  /* Two content widths: reading streams and dashboards. */
  --content-read: 860px;
  --content-wide: 1240px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.18);
  --control-height: 36px;
  --control-height-touch: 44px;
  --duration-fast: 120ms;
  --duration-normal: 180ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --focus-ring: #2563eb;

  --bg: #ffffff;
  --bg-card: #f8f9fa;
  --bg-card-hover: #f0f2f5;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1a202c;
  --text-muted: #718096;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: #eff6ff;
  --accent-contrast: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.92);
  --toggle-bg: #e2e8f0;
  --shadow: var(--shadow-sm);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #222534;
  --border: #2d3148;
  --border-strong: #3d435f;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: #172554;
  --accent-contrast: #07111f;
  --header-bg: rgba(15, 17, 23, 0.92);
  --toggle-bg: #3b82f6;
  --focus-ring: #93c5fd;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Utility v2 is opt-in so editorial, tutorial and playful apps keep their identity. */
:root[data-ha-design="v2"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f9fc;
  --border: #dbe3ee;
  --border-strong: #b9c6d8;
  --text: #182235;
  --text-muted: #5f6f84;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #dbeafe;
  --accent-contrast: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.88);
  --toggle-bg: #dbe3ee;
  --focus-ring: #2563eb;
  --shadow: var(--shadow-sm);
  /* Shared status tokens (default v2 values = the historical app colors). */
  --status-ok: #16a34a;
  --status-ok-text: #166534;
  --status-ok-soft: #dcfce7;
  --status-warn: #f59e0b;
  --status-warn-text: #92400e;
  --status-warn-soft: #fef3c7;
  --status-bad: #dc2626;
  --status-bad-text: #b91c1c;
  --status-bad-soft: #fee2e2;
  --status-info: #0284c7;
  --status-info-text: #075985;
  --status-info-soft: #e0f2fe;
}

:root[data-ha-design="v2"][data-theme="dark"] {
  color-scheme: dark;
  --bg: #090d14;
  --bg-card: #121923;
  --bg-card-hover: #182230;
  --border: #283548;
  --border-strong: #41516a;
  --text: #e7edf5;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: #172b4d;
  --accent-contrast: #07111f;
  --header-bg: rgba(9, 13, 20, 0.88);
  --toggle-bg: #243247;
  --focus-ring: #93c5fd;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 26px 72px rgba(0, 0, 0, 0.48);
  --shadow: var(--shadow-sm);
  --status-ok-text: #86efac;
  --status-ok-soft: #14532d;
  --status-warn-text: #fcd34d;
  --status-warn-soft: #431407;
  --status-bad-text: #fca5a5;
  --status-bad-soft: #450a0a;
  --status-info-text: #7dd3fc;
  --status-info-soft: #0c4a6e;
}

/* Opt-in edebost.com palette (Tech Watch, Forecast). edebost.com is the reference:
   warm paper / neutral near-black, teal accent, indigo secondary, muted statuses,
   and a 12-step categorical scale at equal lightness. */
:root[data-ha-design="v2"][data-ha-palette="edebost"] {
  color-scheme: light;
  --bg: #eceef1;
  --bg-card: #f8f9fb;
  --bg-card-hover: #f2f4f7;
  --border: #d8dce2;
  --border-strong: #bcc3cc;
  --text: #121418;
  --text-muted: #5a616b;
  --accent: #0d6b66;
  --accent-hover: #0a5652;
  --accent-soft: #dfe9e6;
  --accent-contrast: #ffffff;
  --accent-2: #4d5ca3;
  --accent-2-soft: #e3e4ee;
  --header-bg: rgba(236, 238, 241, 0.88);
  --toggle-bg: #d8dce2;
  --focus-ring: #0d6b66;
  --shadow-sm: 0 1px 2px rgba(18, 20, 24, 0.06);
  --shadow-md: 0 8px 24px rgba(18, 20, 24, 0.08);
  --shadow-lg: 0 24px 64px rgba(18, 20, 24, 0.16);
  --status-ok: #558a49;
  --status-ok-text: #38612f;
  --status-ok-soft: #e1f1de;
  --status-warn: #a07020;
  --status-warn-text: #724d0b;
  --status-warn-soft: #f7e9d6;
  --status-bad: #b25e59;
  --status-bad-text: #803f3b;
  --status-bad-soft: #ffe4e1;
  --status-info: #4b7cba;
  --status-info-text: #305686;
  --status-info-soft: #dfedfe;
  --cat-ink: #ffffff;
  --cat-1: #9b4251;
  --cat-2: #9a4729;
  --cat-3: #8e5300;
  --cat-4: #7a6001;
  --cat-5: #2f7434;
  --cat-6: #016f82;
  --cat-7: #026a9d;
  --cat-8: #3c61a7;
  --cat-9: #5d57a4;
  --cat-10: #7a4d94;
  --cat-11: #914373;
  --cat-12: #5d646f;
}

:root[data-ha-design="v2"][data-ha-palette="edebost"][data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0b0d;
  --bg-card: #121417;
  --bg-card-hover: #181b1f;
  --border: #24282e;
  --border-strong: #373c44;
  --text: #f3f4f6;
  --text-muted: #9aa1ab;
  --accent: #73dbcc;
  --accent-hover: #9ae6da;
  --accent-soft: #0e2a2a;
  --accent-contrast: #0a0b0d;
  --accent-2: #858fbd;
  --accent-2-soft: #12163a;
  --header-bg: rgba(10, 11, 13, 0.88);
  --toggle-bg: #24282e;
  --focus-ring: #73dbcc;
  --status-ok: #89bb7e;
  --status-ok-text: #a9d1a0;
  --status-ok-soft: #192916;
  --status-warn: #d0a260;
  --status-warn-text: #e3bd8a;
  --status-warn-soft: #2f210c;
  --status-bad: #e3928b;
  --status-bad-text: #f4b0aa;
  --status-bad-soft: #351c1a;
  --status-info: #7faee9;
  --status-info-text: #a1c7f8;
  --status-info-soft: #162537;
  --cat-ink: #0a0b0d;
  --cat-1: #f7a3ad;
  --cat-2: #f6a88d;
  --cat-3: #ebb077;
  --cat-4: #d7bb70;
  --cat-5: #95cf96;
  --cat-6: #69cee6;
  --cat-7: #80c7f8;
  --cat-8: #9bbeff;
  --cat-9: #b7b5fc;
  --cat-10: #d3abed;
  --cat-11: #eda4cc;
  --cat-12: #b6becb;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { accent-color: var(--accent); }
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  transition: background var(--duration-normal) var(--ease-standard), color var(--duration-normal) var(--ease-standard);
}
button, input, select, textarea { font: inherit; }
::selection { background: var(--accent-soft); color: var(--text); }
:where(a, button, input, select, textarea, summary, [role="button"]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

[data-ha-design="v2"] body {
  line-height: 1.45;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Shared header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background var(--duration-normal) var(--ease-standard), border-color var(--duration-normal) var(--ease-standard);
}
.header-top { display: flex; align-items: center; justify-content: space-between; min-width: 0; }
.header-left { display: flex; min-width: 0; align-items: center; gap: 12px; }
.header-controls { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; }

[data-ha-design="v2"] header {
  min-height: 52px;
  justify-content: center;
  gap: var(--space-2);
  padding: 7px 20px;
  border-color: color-mix(in srgb, var(--border) 86%, transparent);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  backdrop-filter: blur(16px) saturate(1.35);
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
}
[data-ha-design="v2"] .header-left { gap: var(--space-2); }
[data-ha-design="v2"] .header-controls { gap: 6px; }

/* Identity and icon buttons */
.ha-logo {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: default;
}
a.ha-logo { cursor: pointer; }
.ha-logo span { color: var(--accent); }
[data-ha-design="v2"] .ha-logo { font-size: 17px; font-weight: 760; letter-spacing: -0.025em; }

.ha-back-link,
.ha-icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
}
.ha-back-link svg,
.ha-icon-button svg { width: 17px; height: 17px; stroke: currentColor; }
.ha-back-link:hover,
.ha-icon-button:hover { border-color: var(--border); background: var(--bg-card-hover); color: var(--accent); }
.ha-back-link:active,
.ha-icon-button:active { transform: translateY(1px); }
/* Touch screens keep :hover after a tap; do not leave one header icon boxed. */
@media (hover: none) {
  .ha-back-link:hover,
  .ha-icon-button:hover { border-color: transparent; background: transparent; color: var(--text-muted); }
}

/* Language switch */
.lang-toggle {
  display: flex;
  gap: 2px;
  padding: 4px 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
}
.lang-btn {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.lang-btn.active { background: var(--accent); color: #ffffff; }
[data-ha-design="v2"] .lang-toggle {
  height: var(--control-height);
  align-items: center;
  padding: 3px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
[data-ha-design="v2"] .lang-btn {
  min-width: 32px;
  height: 28px;
  padding: 0 7px;
  border-radius: 7px;
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
}
[data-ha-design="v2"] .lang-btn.active { background: var(--accent-soft); color: var(--accent-hover); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent); }

/* Opt-in segmented language switch for apps listed in the public catalog. */
.lang-toggle.lang-toggle--segmented {
  gap: 0;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-sm);
}
.lang-toggle--segmented .lang-btn {
  border-radius: 5px;
}
.lang-toggle--segmented .lang-btn:not(.active) {
  color: color-mix(in srgb, var(--text) 68%, var(--bg-card));
}
.lang-toggle--segmented .lang-btn + .lang-btn {
  box-shadow: inset 1px 0 0 color-mix(in srgb, var(--border) 80%, transparent);
}
.lang-toggle.lang-toggle--segmented .lang-btn.active {
  z-index: 1;
  background: var(--accent-hover);
  color: var(--accent-contrast);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 28%, transparent);
}
.lang-toggle.lang-toggle--segmented .lang-btn.active > span {
  background: transparent;
  color: inherit;
}

/* Theme switch */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--toggle-bg);
  transition: background var(--duration-normal) var(--ease-standard);
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform var(--duration-normal) var(--ease-standard);
}
[data-theme="dark"] .toggle-thumb { transform: translateX(18px); }
.toggle-icon { display: inline-grid; place-items: center; color: var(--text-muted); line-height: 1; }
.toggle-icon svg { width: 14px; height: 14px; stroke: currentColor; }
[data-ha-design="v2"] .theme-toggle {
  min-width: 76px;
  height: var(--control-height);
  justify-content: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard);
}
[data-ha-design="v2"] .theme-toggle:hover { border-color: var(--border-strong); background: var(--bg-card-hover); }
[data-ha-design="v2"] .toggle-track { width: 36px; height: 20px; border-radius: var(--radius-full); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border-strong) 45%, transparent); }
[data-ha-design="v2"] .toggle-thumb { width: 14px; height: 14px; box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28); }
[data-ha-design="v2"][data-theme="dark"] .toggle-thumb { transform: translateX(16px); }

/* Search subheader */
.subheader {
  position: sticky;
  top: 52px;
  z-index: 99;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background var(--duration-normal) var(--ease-standard), border-color var(--duration-normal) var(--ease-standard);
}
[data-ha-design="v2"] .subheader {
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
}

/* Opt-in primitives. App classes may extend geometry without redefining states. */
.ha-button,
.ha-pill,
.ha-control,
.ha-card { font-family: var(--font-sans); }
.ha-button {
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
}
.ha-button:hover { border-color: var(--border-strong); background: var(--bg-card-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.ha-button:active { box-shadow: var(--shadow-sm); transform: translateY(0); }
.ha-button[disabled] { opacity: 0.56; cursor: not-allowed; box-shadow: none; transform: none; }
.ha-button--primary { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); }
.ha-button--primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); color: var(--accent-contrast); }

.ha-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
}
.ha-pill:hover { border-color: var(--border-strong); background: var(--bg-card-hover); color: var(--text); }
.ha-pill.active,
.ha-pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); }

.ha-control {
  width: 100%;
  min-width: 0;
  min-height: var(--control-height);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard);
}
.ha-control:hover { border-color: var(--border-strong); }
.ha-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.ha-control::placeholder { color: var(--text-muted); opacity: 0.82; }

.ha-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-normal) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
}
.ha-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

/* Themed select (data-ha-select): the native control keeps its box, ha-shell.js
   swaps its option list for a searchable popover drawn with theme tokens. */
:where(select[data-ha-select]) { background-color: var(--bg-card); color: var(--text); }
/* :root raises specificity above app rules that use the background/padding shorthands. */
:root select[data-ha-select] {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select[data-ha-select][data-ha-open] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.ha-select-panel {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}
.ha-select-search {
  flex: 0 0 auto;
  margin: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
}
.ha-select-search:focus { border-color: var(--accent); }
.ha-select-search::placeholder { color: var(--text-muted); }
.ha-select-list { flex: 1 1 auto; min-height: 0; margin: 0; padding: 4px; overflow-y: auto; list-style: none; outline: none; overscroll-behavior: contain; }
.ha-select-option {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px 6px 28px;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
}
.ha-select-option.is-active { background: var(--bg-card-hover); }
.ha-select-option:hover { background: var(--bg-card-hover); }
.ha-select-option[aria-selected="true"] { color: var(--accent); font-weight: 650; }
.ha-select-option[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 5px;
  height: 9px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-65%) rotate(45deg);
}
.ha-select-option[aria-disabled="true"] { color: var(--text-muted); cursor: not-allowed; opacity: 0.6; }
.ha-select-empty { padding: 10px; color: var(--text-muted); }
/* Options carry display:flex, so the filter needs an explicit rule to hide them. */
.ha-select-option[hidden], .ha-select-empty[hidden] { display: none; }

/* Switch: a checkbox with role="switch" drawn as a track and thumb. */
.ha-switch { display: inline-flex; align-items: center; gap: 10px; min-height: var(--control-height); cursor: pointer; color: var(--text); font-size: var(--text-sm); font-weight: 600; user-select: none; }
.ha-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ha-switch-track { position: relative; flex: 0 0 auto; width: 36px; height: 20px; border-radius: var(--radius-full); background: var(--border-strong); transition: background var(--duration-fast) var(--ease-standard); }
.ha-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg-card); box-shadow: var(--shadow-sm); transition: transform var(--duration-fast) var(--ease-standard); }
.ha-switch input:checked + .ha-switch-track { background: var(--accent); }
.ha-switch input:checked + .ha-switch-track::after { transform: translateX(16px); }
.ha-switch input:focus-visible + .ha-switch-track { outline: 2px solid var(--focus-ring, var(--accent)); outline-offset: 2px; }

/* Disclosure icon: every collapsible block shows a chevron that turns when open. */
.ha-disclosure-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-left: auto;
  border-radius: 6px;
  color: var(--text-muted);
  transition: transform var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard);
}
.ha-disclosure-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
details[open] > summary .ha-disclosure-icon,
[aria-expanded="true"] > .ha-disclosure-icon,
[aria-expanded="true"] .ha-disclosure-icon { transform: rotate(180deg); }
summary:hover .ha-disclosure-icon,
button:hover > .ha-disclosure-icon { color: var(--text); background: var(--bg-card-hover); }

@media (max-width: 600px) {
  header { padding: 10px 14px; }
  .subheader { top: 48px; padding: 8px 14px; }
  [data-ha-design="v2"] header { min-height: 52px; padding: 4px 8px; }
  [data-ha-design="v2"] .header-controls { gap: 4px; }
  [data-ha-design="v2"] .ha-logo { font-size: 16px; }
  [data-ha-design="v2"] .lang-toggle { height: var(--control-height-touch); padding: 0; border-color: transparent; background: transparent; box-shadow: none; }
  [data-ha-design="v2"] .lang-btn { min-width: var(--control-height-touch); height: var(--control-height-touch); }
  [data-ha-design="v2"] .lang-toggle.lang-toggle--segmented { background: var(--bg-card); box-shadow: inset 0 0 0 1px var(--border), var(--shadow-sm); }
  [data-ha-design="v2"] .theme-toggle { min-width: var(--control-height-touch); height: var(--control-height-touch); padding: 0; }
  [data-ha-design="v2"] .ha-back-link,
  [data-ha-design="v2"] .ha-icon-button { width: var(--control-height-touch); height: var(--control-height-touch); }
  .theme-toggle { width: 44px; min-width: 44px; height: 44px; justify-content: center; padding: 0; }
  .theme-toggle .toggle-track { display: none; }
  .theme-toggle .toggle-icon { display: none; }
  .theme-toggle .toggle-icon svg { width: 18px; height: 18px; }
  [data-theme="light"] .theme-toggle .toggle-icon:last-child { display: inline-grid; }
  [data-theme="dark"] .theme-toggle .toggle-icon:first-child { display: inline-grid; }
  [data-ha-design="v2"] .subheader { padding: 8px; }
  .ha-button,
  .ha-control { min-height: var(--control-height-touch); }
  .ha-pill { min-height: var(--control-height-touch); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .ha-button,
  .ha-pill,
  .ha-control,
  .ha-card,
  .lang-toggle,
  .theme-toggle { border-color: CanvasText; }
}
