/* ==========================================================================
   hue.css – design system for hue.palus.sk (dark only, mobile-first)
   Tokens + app shell + components. Bootstrap 5 stays loaded underneath for
   grid/utilities/offcanvas; every visual component below is ours.
   API reference: REDESIGN.md §11 (Frontend).
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  --bg: #17181c;
  --surface: #2b2d31;
  --surface-2: #36383d;
  --surface-3: #43454b;
  --track: #47484a;
  --tabbar: rgba(13, 15, 18, .92);
  --text: #fff;
  --text-2: rgba(255, 255, 255, .64);
  --label: #9a9ca2;
  --accent: #0a7aff;
  --success: #30d158;
  --danger: #ff453a;
  --warning: #ffb340;
  --r-card: 14px;
  --r-tile: 12px;
  --r-sheet: 20px;
  --r-pill: 999px;
  --gap: 12px;
  --pad: 16px;

  /* derived */
  --text-3: rgba(255, 255, 255, .45);
  --text-dark: rgba(0, 0, 0, .72);
  --inactive: #5a5a5e;
  --line: rgba(255, 255, 255, .08);
  --accent-press: #0065d9;
  --danger-text: #ff6961;
  --appbar-bg: rgba(23, 24, 28, .84);
  --maxw: 560px;
  --appbar-h: 56px;
  --tabbar-h: 56px;
  --savebar-h: 74px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --dur: 200ms;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow-float: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* Bootstrap variables mapped onto our tokens (wins over data-bs-theme=dark) */
html[data-bs-theme=dark] {
  --bs-body-bg: var(--bg);
  --bs-body-bg-rgb: 23, 24, 28;
  --bs-body-color: var(--text);
  --bs-body-font-family: var(--font);
  --bs-body-font-size: 15px;
  --bs-body-line-height: 1.4;
  --bs-emphasis-color: #fff;
  --bs-secondary-color: var(--text-2);
  --bs-secondary-bg: var(--surface-2);
  --bs-tertiary-bg: var(--surface);
  --bs-border-color: var(--line);
  --bs-primary: #0a7aff;
  --bs-primary-rgb: 10, 122, 255;
  --bs-link-color: #4d9dff;
  --bs-link-color-rgb: 77, 157, 255;
  --bs-link-hover-color: #7ab5ff;
  --bs-focus-ring-color: rgba(10, 122, 255, .5);
  --bs-danger: #ff453a;
  --bs-success: #30d158;
  --bs-warning: #ffb340;
}

/* ---------- 2. Base ------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.2; color: inherit; }
p { margin: 0 0 .75em; }
a { color: var(--bs-link-color); }
button { font-family: inherit; }
img, svg { vertical-align: middle; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(10, 122, 255, .45); }
/* scroll lock while a sheet is open: only the root – overflow on <body> would make it a scroll container and the
   sticky top bar would jump off-screen behind the backdrop */
.html-lock { overflow: hidden; overscroll-behavior: none; }

/* Material Symbols Rounded (FILL 1, wght 500) */
.ms {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  width: 1em;
  height: 1em;
  overflow: hidden;
  flex: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  -webkit-user-select: none;
  user-select: none;
  vertical-align: middle;
}
.ms-16 { font-size: 16px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20; }
.ms-18 { font-size: 18px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20; }
.ms-20 { font-size: 20px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20; }
.ms-28 { font-size: 28px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 28; }
.ms-32 { font-size: 32px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 32; }
.ms-40 { font-size: 40px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 40; }
.ms-48 { font-size: 48px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 48; }
.spin { animation: hue-spin 1s linear infinite; }

/* Typography helpers */
.large-title { font-size: 30px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; margin: 4px 0 18px; overflow-wrap: anywhere; }
.t-card { font-size: 17px; font-weight: 600; line-height: 1.25; }
.t-sub { font-size: 13px; font-weight: 400; color: var(--text-2); line-height: 1.35; }
.t-2 { color: var(--text-2) !important; }
.t-label { color: var(--label) !important; }
.t-danger { color: var(--danger-text) !important; }
.t-success { color: var(--success) !important; }
.t-warning { color: var(--warning) !important; }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.section-label {
  display: flex; align-items: center; gap: 8px;
  margin: 28px 4px 10px;
  font-size: 12px; font-weight: 600; line-height: 16px;
  text-transform: uppercase; letter-spacing: .12em; color: var(--label);
}
.section-label:first-child { margin-top: 8px; }
.section-label .count { color: var(--text-3); letter-spacing: .04em; }
.section-label .act {
  margin-left: auto; text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 600;
  color: #4d9dff; text-decoration: none; background: none; border: 0; padding: 4px 0;
}
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }

/* ---------- 3. App shell ------------------------------------------------- */
.appbar {
  position: sticky; top: 0; z-index: 1020;
  padding-top: var(--sat);
  background: transparent;
  transition: background-color var(--dur) ease-out, box-shadow var(--dur) ease-out;
}
.appbar.is-scrolled, .appbar.is-collapsed {
  background: var(--appbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 var(--line);
}
.appbar-in {
  max-width: var(--maxw); height: var(--appbar-h); margin: 0 auto;
  padding: 0 calc(6px + var(--sar)) 0 calc(6px + var(--sal));
  display: grid; grid-template-columns: minmax(44px, 1fr) auto minmax(44px, 1fr); align-items: center; gap: 4px;
}
.appbar-start { display: flex; align-items: center; justify-self: start; }
.appbar-end { display: flex; align-items: center; gap: 2px; justify-self: end; }
.appbar-title {
  min-width: 0; max-width: 100%; text-align: center;
  font-size: 17px; font-weight: 600; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--dur) ease-out, transform var(--dur) ease-out;
}
.appbar.is-collapsed .appbar-title, .appbar.is-compact .appbar-title { opacity: 1; transform: none; }
.appbar-btn {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  background: transparent; border: 0; color: #fff; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur);
}
.appbar-btn:hover { color: #fff; }
.appbar-btn:active { background: rgba(255, 255, 255, .12); }
.appbar-btn .appbar-dot { position: absolute; top: 9px; right: 9px; box-shadow: 0 0 0 2px var(--bg); }
.appbar-link { color: #4d9dff; font-weight: 600; font-size: 16px; text-decoration: none; padding: 10px 10px; background: none; border: 0; }

.page {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 max(var(--pad), var(--sar)) calc(var(--tabbar-h) + var(--sab) + 32px) max(var(--pad), var(--sal));
}
body.no-tabbar .page { padding-bottom: calc(var(--sab) + 32px); }
body.has-savebar .page { padding-bottom: calc(var(--tabbar-h) + var(--sab) + var(--savebar-h) + 24px); }
body.no-tabbar.has-savebar .page { padding-bottom: calc(var(--sab) + var(--savebar-h) + 24px); }

/* Bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  background: var(--tabbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, .06);
  padding: 0 var(--sar) var(--sab) var(--sal);
}
.tabbar-in { max-width: var(--maxw); height: var(--tabbar-h); margin: 0 auto; display: flex; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--inactive); text-decoration: none;
  font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; line-height: 12px;
  transition: color var(--dur) ease-out;
}
.tab .ms { font-size: 24px; transition: transform 150ms var(--ease); }
.tab:hover { color: #8a8a8f; }
.tab.is-active, .tab.is-active:hover { color: #fff; }
.tab:active .ms { transform: scale(.9); }
/* 5 tabs (+ Asistent, §13): tighter labels so "Zariadenia" fits on 320–390 px phones */
.tabbar-in.is-5 .tab { min-width: 0; letter-spacing: .03em; }
.tabbar-in.is-5 .tab > span:last-child { max-width: 100%; overflow: hidden; white-space: nowrap; }
@media (max-width: 359px) { .tabbar-in.is-5 .tab { font-size: 9px; letter-spacing: 0; } }

/* Reconnect / info banner */
.banner-h {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  margin: 0 0 12px; padding: 8px 10px 8px 14px; border-radius: var(--r-tile);
  background: color-mix(in srgb, var(--danger) 18%, var(--surface));
  color: #fff; font-size: 14px; font-weight: 600; text-decoration: none;
}
.banner-h:hover { color: #fff; }
.banner-h > .ms:first-child { color: var(--danger-text); font-size: 20px; }
.banner-h .banner-end { margin-left: auto; display: flex; align-items: center; gap: 2px; color: var(--text-2); font-weight: 500; }
.banner-h.is-warning { background: color-mix(in srgb, var(--warning) 16%, var(--surface)); }
.banner-h.is-warning > .ms:first-child { color: var(--warning); }
.banner-h.is-info { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.banner-h.is-info > .ms:first-child { color: #4d9dff; }

/* Hamburger menu (Bootstrap offcanvas-start #menu) */
.offcanvas.menu-h {
  --bs-offcanvas-width: min(320px, 86vw);
  --bs-offcanvas-bg: #1c1d22;
  --bs-offcanvas-color: #fff;
  --bs-offcanvas-border-width: 0;
  padding-top: var(--sat); padding-bottom: var(--sab); padding-left: var(--sal);
  box-shadow: 12px 0 40px rgba(0, 0, 0, .5);
}
.offcanvas-backdrop.show { opacity: .55; }
.menu-head { display: flex; align-items: center; gap: 14px; padding: 18px 12px 14px 20px; }
.menu-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 20px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #ff9f43 0%, #ee5a9b 50%, #6c5ce7 100%);
}
.menu-who { flex: 1; min-width: 0; }
.menu-name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-mail { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-home { display: flex; align-items: center; gap: 6px; margin: 0 20px 10px; font-size: 13px; color: var(--label); }
.menu-home .ms { font-size: 16px; }
.menu-list { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.menu-sep { height: 1px; background: var(--line); margin: 8px 20px; }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 12px;
  border: 0; border-radius: 12px; background: transparent; color: #fff; text-align: left;
  font-size: 16px; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur);
}
.menu-item:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.menu-item:active, .menu-item.is-active { background: var(--surface); }
.menu-item > .ms:first-child { color: var(--label); }
.menu-item .menu-end { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.menu-item.is-danger, .menu-item.is-danger > .ms:first-child { color: var(--danger-text); }
.menu-foot { margin-top: auto; padding: 8px 10px 14px; }

/* ---------- 4. Buttons ---------------------------------------------------- */
.btn-h {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill);
  background: var(--surface-2); color: #fff;
  font: 600 15px/1 var(--font); letter-spacing: .005em; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur), opacity var(--dur), transform 120ms var(--ease), box-shadow var(--dur);
}
.btn-h:hover { color: #fff; background: var(--surface-3); }
.btn-h:active { transform: scale(.97); }
.btn-h .ms { font-size: 20px; margin-left: -4px; }
.btn-h.primary { background: var(--accent); }
.btn-h.primary:hover { background: #2388ff; }
.btn-h.primary:active { background: var(--accent-press); }
.btn-h.danger { background: color-mix(in srgb, var(--danger) 18%, var(--surface-2)); color: var(--danger-text); }
.btn-h.danger:hover { background: color-mix(in srgb, var(--danger) 26%, var(--surface-2)); }
.btn-h.danger-solid { background: var(--danger); color: #fff; }
.btn-h.ghost { background: transparent; color: #4d9dff; padding: 0 12px; }
.btn-h.ghost:hover { background: rgba(10, 122, 255, .1); }
.btn-h.light { background: #fff; color: #111; }
.btn-h.block { display: flex; width: 100%; height: 50px; font-size: 16px; }
.btn-h.sm { height: 34px; padding: 0 14px; font-size: 14px; }
.btn-h.sm .ms { font-size: 18px; }
.btn-h:disabled, .btn-h.is-disabled, .btn-h[aria-disabled=true] { opacity: .38; pointer-events: none; box-shadow: none; }
.btn-h.is-busy { pointer-events: none; }
.btn-h.is-busy > :not(.btn-spin) { visibility: hidden; }
.btn-h.is-busy { -webkit-text-fill-color: transparent; }              /* bare text labels too (save bar, JS labels) */
.btn-h.is-busy .btn-spin { -webkit-text-fill-color: currentColor; }
.btn-h .btn-spin { position: absolute; inset: 0; margin: auto; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn-h { flex: 1; }

.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; padding: 0; border: 0;
  background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur), transform 120ms var(--ease);
}
.icon-btn::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; }
.icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .18); }
.icon-btn:active { transform: scale(.92); }
.icon-btn .ms { font-size: 22px; }
.icon-btn.lg { width: 44px; height: 44px; }
.icon-btn.plain { background: transparent; }
.icon-btn.plain:hover { background: rgba(255, 255, 255, .08); }
.icon-btn.accent { background: var(--accent); }
.icon-btn.dark { background: rgba(0, 0, 0, .28); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }

/* ---------- 5. Switch ----------------------------------------------------- */
.hswitch {
  -webkit-appearance: none; appearance: none;
  position: relative; flex: none; display: inline-block; vertical-align: middle;
  width: 51px; height: 31px; margin: 0; padding: 0; border: 0; border-radius: var(--r-pill);
  background: var(--track); cursor: pointer;
  transition: background-color var(--dur) ease-out, box-shadow var(--dur) ease-out;
}
.hswitch::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .18), 0 1px 1px rgba(0, 0, 0, .1);
  transition: transform var(--dur) var(--ease);
}
.hswitch::after { content: ""; position: absolute; inset: -7px -4px; border-radius: var(--r-pill); }
.hswitch:checked { background: var(--accent); }
.hswitch:checked::before { transform: translateX(20px); }
.hswitch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hswitch:disabled { opacity: .4; cursor: default; }
.hswitch.tint:checked, .is-tinted .hswitch:checked { background: rgba(0, 0, 0, .22); }
.is-tinted .hswitch:focus-visible { outline-color: #fff; }

/* ---------- 6. Slider (.hslider – driven by Hue.slider) ------------------ */
.hslider {
  --p: .5;
  --fill: rgba(255, 255, 255, .62);
  --track-bg: var(--track);
  --h: 6px;
  --thumb: 20px;
  --radius: 999px;
  position: relative; display: flex; align-items: center;
  height: 32px; min-width: 60px;
  touch-action: pan-y; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.hslider:focus-visible { outline: none; }
.hslider-track {
  position: relative; width: 100%; height: var(--h); border-radius: var(--radius);
  background: var(--track-bg); overflow: hidden;
}
.hslider-fill {
  position: absolute; inset: 0; border-radius: inherit;
  background: var(--fill);
  clip-path: inset(0 calc(100% - var(--thumb) / 2 - var(--p) * (100% - var(--thumb))) 0 0 round var(--radius));
}
.hslider-thumb {
  position: absolute; top: 50%; left: calc(var(--p) * (100% - var(--thumb)));
  width: var(--thumb); height: var(--thumb); margin-top: calc(var(--thumb) / -2);
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 0 0 .5px rgba(0, 0, 0, .06);
  pointer-events: none; transition: transform 120ms var(--ease);
}
.hslider.is-dragging .hslider-thumb { transform: scale(1.14); }
.hslider:focus-visible .hslider-thumb { box-shadow: 0 0 0 2px var(--accent), 0 1px 3px rgba(0, 0, 0, .4); }
.hslider.is-disabled, .hslider[aria-disabled=true] { opacity: .4; pointer-events: none; }
.hslider-value {
  position: absolute; top: 50%; left: 16px; transform: translateY(-50%);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: #fff; pointer-events: none;
}
.hslider-value .ms { font-size: 20px; }

/* card bar: 6 px track, 20 px thumb, fill with 1 px white 30 % border */
.hslider--bar { --h: 6px; --thumb: 20px; height: 32px; }
.hslider--bar .hslider-fill { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
.is-tinted .hslider--bar, .hslider--bar.on-tint { --track-bg: rgba(0, 0, 0, .25); }

/* large header slider: 8 px track, 24 px thumb */
.hslider--lg { --h: 8px; --thumb: 24px; height: 44px; }
.hslider--lg .hslider-fill { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
.is-tinted .hslider--lg { --track-bg: rgba(0, 0, 0, .25); }

/* big pill: 44 px, fill = any CSS background, value text inside */
.hslider--pill { --h: 44px; --thumb: 0px; --radius: 22px; height: 44px; --track-bg: var(--surface-2); }
.hslider--pill .hslider-fill { clip-path: inset(0 calc((1 - var(--p)) * 100%) 0 0 round var(--radius)); }
/* pill has no thumb (iOS style): the fill edge is the indicator */
.hslider--pill .hslider-thumb { display: none; }
.hslider--pill .hslider-fill .hslider-value { color: #fff; }
.hslider--pill.is-light .hslider-fill .hslider-value { color: var(--text-dark); }
.hslider--pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }

/* ---------- 7. Segmented control, chips, mode pills ---------------------- */
.seg {
  position: relative; display: flex; gap: 2px; padding: 3px;
  border-radius: var(--r-pill); background: var(--surface);
}
.card-h .seg, .sheet .seg, .list-h .seg { background: rgba(0, 0, 0, .28); }
.seg > button, .seg > a, .seg > label {
  position: relative; flex: 1; min-width: 0; height: 34px; margin: 0; padding: 0 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: var(--r-pill); background: transparent;
  color: var(--text-2); font: 600 14px/1 var(--font); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur) ease-out, color var(--dur) ease-out, box-shadow var(--dur);
}
.seg > button::after, .seg > label::after { content: ""; position: absolute; inset: -5px 0; }
.seg > :hover { color: #fff; }
.seg > .is-active, .seg > [aria-selected=true], .seg > [aria-pressed=true], .seg > input:checked + label {
  background: var(--surface-3); color: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.seg > input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg > input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg .ms { font-size: 18px; }
.seg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #fff); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll, .mode-strip {
  flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--pad)); padding: 4px var(--pad);
  scroll-padding: 0 var(--pad);
}
.chips.scroll::-webkit-scrollbar, .mode-strip::-webkit-scrollbar, .scene-grid::-webkit-scrollbar { display: none; }
.chip {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-pill);
  background: var(--surface-2); color: #fff;
  font: 500 14px/1 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur) ease-out, color var(--dur) ease-out, opacity var(--dur), transform 120ms var(--ease);
}
.chip::after { content: ""; position: absolute; inset: -4px 0; }
.chip:hover { color: #fff; background: var(--surface-3); }
.chip:active { transform: scale(.96); }
.chip .ms { font-size: 18px; margin-left: -2px; }
.chip-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--c, #fff); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.chip.is-active, .chip[aria-pressed=true], input:checked + .chip { background: #fff; color: #111; }
.chip.is-active .chip-dot, .chip[aria-pressed=true] .chip-dot { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.chip.is-dim, .chip:disabled { opacity: .4; }
.chip.is-dim:disabled { pointer-events: none; }
.chip.accent { background: rgba(10, 122, 255, .18); color: #6aaeff; }
.chip.danger { background: color-mix(in srgb, var(--danger) 18%, var(--surface-2)); color: var(--danger-text); }
.chip.warning { background: color-mix(in srgb, var(--warning) 18%, var(--surface-2)); color: var(--warning); }
.chip.success { background: color-mix(in srgb, var(--success) 20%, var(--surface-2)); color: #5fe07f; }
.chip.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.chip.sm .ms { font-size: 16px; }
input.chip-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
input.chip-input:focus-visible + .chip { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Mode pills: home strip + mode tabs on detail pages */
.mode-strip { display: flex; gap: 8px; }
.mode-pill {
  --c: var(--accent);
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px 0 13px; border: 0; border-radius: var(--r-pill);
  background: var(--surface); color: #fff;
  font: 600 15px/1 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur) ease-out, color var(--dur) ease-out, transform 120ms var(--ease), box-shadow var(--dur);
}
.mode-pill::after { content: ""; position: absolute; inset: -2px 0; }
.mode-pill:hover { color: #fff; background: var(--surface-2); }
.mode-pill:active { transform: scale(.96); }
.mode-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--c); transition: background-color var(--dur), box-shadow var(--dur); }
.mode-pill.is-active, .mode-pill.is-active:hover, .mode-pill[aria-selected=true] { background: var(--c); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--c) 35%, transparent); }
.mode-pill.is-active .mode-dot, .mode-pill[aria-selected=true] .mode-dot { background: rgba(255, 255, 255, .92); }
.mode-pill.is-active.is-light, .mode-pill[aria-selected=true].is-light { color: var(--text-dark); }
.mode-pill.is-active.is-light .mode-dot, .mode-pill[aria-selected=true].is-light .mode-dot { background: rgba(0, 0, 0, .55); }
.mode-pill.is-current .mode-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c); }
.mode-pill.is-current.is-active .mode-dot, .mode-pill.is-current[aria-selected=true] .mode-dot { box-shadow: 0 0 0 2px var(--c), 0 0 0 3.5px rgba(255, 255, 255, .92); }
.mode-pill.is-busy .mode-dot { animation: hue-pulse 1s ease-in-out infinite; }
.mode-pill:disabled { opacity: .4; pointer-events: none; }
/* Záložky režimov v editore (senzor, vypínač): podčiarknutá záložka, nie plná pilulka – ťuknutie nevyzerá ako prepnutie
   režimu domácnosti (to je plná pilulka na Domov). Režim zapnutý doma = krúžok okolo bodky (.is-current). */
.mode-tabs { gap: 2px; box-shadow: inset 0 -1px 0 var(--line); }
.mode-tabs .mode-pill { height: 44px; padding: 0 12px; border-radius: 10px 10px 0 0; background: transparent; color: var(--text-2); box-shadow: none; }
.mode-tabs .mode-pill:hover { background: rgba(255, 255, 255, .04); color: #fff; }
.mode-tabs .mode-pill:active { transform: none; }
.mode-tabs .mode-pill.is-active, .mode-tabs .mode-pill.is-active:hover, .mode-tabs .mode-pill[aria-selected=true] { background: transparent; color: #fff; box-shadow: inset 0 -3px 0 var(--c); }
.mode-tabs .mode-pill[aria-selected=true] .mode-dot, .mode-tabs .mode-pill.is-active .mode-dot,
.mode-tabs .mode-pill[aria-selected=true].is-light .mode-dot { background: var(--c); }
.mode-tabs .mode-pill[aria-selected=true].is-light { color: #fff; }
.mode-tabs .mode-pill.is-current .mode-dot, .mode-tabs .mode-pill.is-current[aria-selected=true] .mode-dot { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--c); }

/* ---------- 8. Lists, cards, tiles --------------------------------------- */
.list-h { position: relative; background: var(--surface); border-radius: var(--r-card); overflow: hidden; }
.list-h + .list-h { margin-top: var(--gap); }
.row-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 64px; padding: 10px 14px 10px 12px; margin: 0; border: 0;
  background: transparent; color: #fff; text-align: left; text-decoration: none; font: inherit;
  transition: background-color var(--dur);
}
.list-h > .row-item + .row-item::before, .list-h > .row-item + .row-sep::before, .list-h > * + .row-item::before {
  content: ""; position: absolute; top: 0; left: 64px; right: 0; height: 1px; background: var(--line); pointer-events: none;
}
a.row-item, button.row-item, label.row-item { cursor: pointer; }
a.row-item:hover, button.row-item:hover, label.row-item:hover { color: #fff; }
a.row-item:active, button.row-item:active, label.row-item:active { background: var(--surface-2); }
@media (hover: hover) { a.row-item:hover, button.row-item:hover { background: rgba(255, 255, 255, .03); } }
.row-item.compact { min-height: 52px; }
.row-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-item:has(> .row-link) .row-end > * { position: relative; z-index: 2; }
.row-item:has(> .row-link:active) { background: var(--surface-2); }
.row-ic {
  position: relative; width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--surface-2); color: #fff;
  transition: background-color var(--dur), color var(--dur);
}
.row-ic .ms { font-size: 22px; }
.row-ic.is-on { background: var(--c, var(--accent)); color: #fff; }
.row-ic.is-on.is-light { color: var(--text-dark); }
.row-ic > [class^="dot-"], .row-ic > [class*=" dot-"] { position: absolute; top: 0; right: 0; box-shadow: 0 0 0 2px var(--surface); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 16px; font-weight: 500; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--text-2); line-height: 1.3; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { display: flex; align-items: center; gap: 8px; flex: none; color: var(--text-2); font-size: 14px; }
.row-end .ms { font-size: 20px; }
.row-chev { color: var(--label); font-size: 22px; margin-right: -6px; }
.row-item.is-unreachable .row-ic { opacity: .55; }
.row-item.is-danger { color: var(--danger-text); }
.row-item.is-danger .row-ic { color: var(--danger-text); background: color-mix(in srgb, var(--danger) 16%, var(--surface-2)); }

.card-h { position: relative; background: var(--surface); border-radius: var(--r-card); padding: var(--pad); }
.card-h + .card-h { margin-top: var(--gap); }
.card-h-head { display: flex; align-items: center; gap: 12px; }
.card-h-head + * { margin-top: 12px; }
.card-h-title { font-size: 17px; font-weight: 600; line-height: 1.25; }
.card-h-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.card-h.flush { padding: 0; overflow: hidden; }
.card-h.tint { background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface)); }

.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.tile-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; min-height: 88px; padding: 12px;
  border: 0; border-radius: var(--r-tile); background: var(--surface-2); color: #fff; text-align: left; text-decoration: none; font: inherit;
  transition: transform 150ms var(--ease), background-color var(--dur);
}
a.tile, button.tile { cursor: pointer; }
a.tile:hover, button.tile:hover { color: #fff; background: var(--surface-3); }
a.tile:active, button.tile:active { transform: scale(.97); }
.tile .ms { font-size: 26px; }
.tile-title { font-size: 15px; font-weight: 600; line-height: 1.2; }
.tile-sub { font-size: 12px; color: var(--text-2); }
.tile.is-active { background: #fff; color: #111; }
.tile.is-active .tile-sub { color: rgba(0, 0, 0, .6); }

/* Status dots / badges */
.dot-danger, .dot-warning, .dot-success, .dot-muted, .dot-accent {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; vertical-align: middle;
}
.dot-danger { background: var(--danger); }
.dot-warning { background: var(--warning); }
.dot-success { background: var(--success); }
.dot-muted { background: var(--inactive); }
.dot-accent { background: var(--accent); }
.dot-lg { width: 10px; height: 10px; }
.dot-pulse { animation: hue-pulse 1.4s ease-in-out infinite; }
.alert-badge {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.count-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
}
.count-badge.muted { background: var(--surface-3); }

/* ---------- 9. Room card -------------------------------------------------- */
.room-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
@media (min-width: 600px) { .room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.room-card {
  --room-bg: var(--surface);
  --room-fill: rgba(255, 255, 255, .62);
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-rows: 44px 32px; column-gap: 10px;
  min-height: 88px; padding: 12px 14px 0 12px; border-radius: var(--r-card);
  background: var(--surface); color: rgba(255, 255, 255, .6);
  box-shadow: var(--shadow-card);
  transition: background .3s ease-out, color var(--dur) ease-out, transform 150ms var(--ease);
}
.room-card.is-on { background: var(--room-bg); color: #fff; }
.room-card.is-on.is-light { color: var(--text-dark); }
.room-card-ic { align-self: center; justify-self: center; font-size: 28px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 28; }
.room-card-text { align-self: center; min-width: 0; }
.room-card-name { font-size: 17px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-card-sub { font-size: 13px; line-height: 1.3; margin-top: 1px; opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 13 px podtitul bielym na bledej farbe (pravidlo Hue necháva biely text do jasu ~192): plná sýtosť + jemný tieň */
.room-card.is-on:not(.is-light) .room-card-sub { opacity: 1; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.room-card > .hswitch { align-self: center; position: relative; z-index: 2; }
.room-card.is-on > .hswitch:checked { background: rgba(0, 0, 0, .22); }
.room-card.is-on.is-light > .hswitch:checked { background: rgba(0, 0, 0, .28); }
.room-card > .hslider { grid-column: 1 / -1; grid-row: 2; position: relative; z-index: 2; margin: 0 -2px; }
.room-card.is-on > .hslider { --track-bg: rgba(0, 0, 0, .25); --fill: var(--room-fill); }
.room-card:not(.is-on) > .hslider .hslider-fill { opacity: 0; }
.room-card-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.room-card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.room-card:has(.room-card-link:active) { transform: scale(.985); }
.room-card.is-unreachable { background: var(--surface); color: rgba(255, 255, 255, .6); opacity: .6; }
.room-card.is-unreachable > .hslider, .room-card.is-unreachable > .hswitch { pointer-events: none; }
.room-card .alert-badge { top: 10px; right: auto; left: 34px; }

/* Brightness shading (Hue app): the lower the brightness, the darker the card/header – a visible brightness cue that also
   keeps white text readable on pale colors. --dim = 1 − bri/100 (Hue.paint.room / server first paint);
   1 % ≈ .40 top / .72 bottom, 35 % ≈ .26 / .47, 100 % = none. Text color is decided on the shaded color. */
.room-card.is-on::before, .room-hero.is-on::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
  background: linear-gradient(180deg, rgba(0, 0, 0, calc(var(--dim, 0) * .4)) 0%, rgba(0, 0, 0, calc(var(--dim, 0) * .72)) 100%);
  transition: background .3s ease-out;
}

/* Full-bleed room header (room detail) uses the same painting */
.room-hero {
  --room-bg: var(--surface);
  position: relative; isolation: isolate;
  background: var(--surface); color: rgba(255, 255, 255, .7);
  transition: background .3s ease-out, color var(--dur);
}
.room-hero.is-on { background: var(--room-bg); color: #fff; }
.room-hero.is-on.is-light { color: var(--text-dark); }

/* ---------- 10. Scene tile ------------------------------------------------ */
.scene-grid {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 96px); grid-auto-columns: 96px; gap: 10px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; scroll-snap-type: x proximity;
  margin: 0 calc(-1 * var(--pad)); padding: 2px var(--pad) 6px; scroll-padding: 0 var(--pad);
}
.scene-grid.one-row { grid-template-rows: 96px; }
.scene-tile {
  --scene-bg: conic-gradient(from 195deg, #ffd8a1, #ffb46b, #ffd8a1);
  --scene-fill: var(--scene-bg);
  position: relative; isolation: isolate; overflow: hidden;
  width: 96px; height: 96px; padding: 10px 6px 6px; border: 0; border-radius: var(--r-tile);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface-2); color: #fff; text-align: center; font: inherit; cursor: pointer;
  scroll-snap-align: start;
  transition: transform 150ms var(--ease), box-shadow var(--dur) ease-out, color .5s ease-out;
}
.scene-tile::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--scene-fill);
  clip-path: circle(0 at 50% 32px);
  transition: clip-path .6s var(--ease);
}
/* active ring above the fill (an inset box-shadow would be painted under the ::before fill) */
.scene-tile::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85); opacity: 0; transition: opacity var(--dur) ease-out;
}
.scene-tile.is-active::after { opacity: 1; }
.scene-tile.is-active::before { clip-path: circle(110% at 50% 32px); }
.scene-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scene-tile.is-active.is-light { color: var(--text-dark); }
.scene-tile:active { transform: scale(.95); }
.scene-thumb {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--scene-bg); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  transition: transform .5s var(--ease), box-shadow var(--dur);
}
.scene-tile.is-active .scene-thumb { box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 2px 8px rgba(0, 0, 0, .25); animation: hue-pop .5s var(--ease); }
.scene-tile.is-pending .scene-thumb { animation: hue-pulse 1s ease-in-out infinite; }
.scene-name {
  font-size: 12px; font-weight: 600; line-height: 1.15; max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}

/* ---------- 11. Light tile ------------------------------------------------ */
.light-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.light-tile {
  --c: #ffd8a1;
  --ring: var(--c);
  --p: 1;
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-rows: minmax(0, 1fr) 40px;
  height: 112px; border-radius: var(--r-tile);
  background: var(--surface-2); color: rgba(255, 255, 255, .6);
  touch-action: pan-y; -webkit-user-select: none; user-select: none; cursor: pointer;
  transition: transform 150ms var(--ease), box-shadow var(--dur) ease-out, background .3s ease-out, color var(--dur);
}
.light-tile.is-on { background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, .22) 100%), var(--c); color: #fff; }
.light-tile.is-on.is-light { color: var(--text-dark); }
.light-tile-top { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; padding: 8px 12px 0; }
.light-tile-top .ms { font-size: 24px; }
.light-tile-name { font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.light-tile-band {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 8px 0 12px; background: rgba(0, 0, 0, .28);
}
.light-tile:not(.is-on) .light-tile-band { background: rgba(0, 0, 0, .14); }
.light-tile-val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.light-tile-band .hswitch { position: relative; z-index: 2; }
.light-tile.is-on .light-tile-band .hswitch:checked { background: rgba(0, 0, 0, .22); }
.light-tile::after {
  content: ""; position: absolute; left: 0; bottom: 40px; height: 3px; width: calc(var(--p) * 100%);
  background: rgba(255, 255, 255, .85); opacity: 0; transition: opacity var(--dur);
}
.light-tile.is-light::after { background: rgba(0, 0, 0, .5); }
.light-tile.is-dragging { transform: scale(1.02); }
.light-tile.is-dragging::after { opacity: 1; }
.light-tile:active:not(.is-dragging) { transform: scale(.97); }
.light-tile.is-selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ring); }
.light-tile:not(.is-on).is-selected { --ring: #fff; }
.light-tile.is-unreachable { background: var(--surface-2); color: rgba(255, 255, 255, .6); opacity: .6; }
.light-tile.is-unreachable .hswitch { pointer-events: none; }
.light-tile.is-dim { opacity: .45; }
/* brightness shading on lit tiles (--p = brightness 0..1 from Hue.paint.light / the drag) */
.light-tile.is-on::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: rgba(0, 0, 0, calc((1 - var(--p, 1)) * .46));
}
.light-tile { outline: none; }
.light-tile:focus-visible { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.light-tile.is-unreachable .light-tile-val { color: var(--danger-text); }

/* ---------- 12. Bottom sheet --------------------------------------------- */
.sheet-layer {
  position: fixed; inset: 0; z-index: 1055;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .52);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 260ms ease-out;
}
.sheet-layer.is-open .sheet-backdrop { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-width: var(--maxw);
  max-height: calc(100vh - var(--sat) - 24px); max-height: calc(100dvh - var(--sat) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 8px max(var(--pad), var(--sar)) calc(var(--pad) + var(--sab)) max(var(--pad), var(--sal));
  background: var(--surface); color: #fff; border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
  transform: translateY(105%);
  transition: transform 300ms var(--ease);
}
.sheet-layer.is-open .sheet { transform: translateY(var(--drag, 0px)); }
.sheet-layer.is-dragging .sheet { transition: none; }
.sheet:focus { outline: none; }
@media (min-width: 600px) {
  .sheet-layer { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-sheet); padding-bottom: var(--pad); max-width: 460px; }
}
.sheet-grab { display: block; width: 36px; height: 5px; margin: 0 auto 10px; border-radius: 3px; background: rgba(255, 255, 255, .24); touch-action: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; min-height: 40px; margin-bottom: 12px; touch-action: none; }
.sheet-title { flex: 1; min-width: 0; font-size: 19px; font-weight: 700; letter-spacing: -.005em; line-height: 1.25; }
.sheet-text { color: var(--text-2); font-size: 15px; line-height: 1.45; margin: -4px 0 16px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.sheet-icon { width: 56px; height: 56px; margin: 4px auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); }
.sheet-icon .ms { font-size: 30px; }
.sheet-icon.danger { background: color-mix(in srgb, var(--danger) 18%, var(--surface-2)); color: var(--danger-text); }
.sheet.is-center .sheet-title, .sheet.is-center .sheet-text { text-align: center; }
.action-list { display: flex; flex-direction: column; margin: 0 calc(-1 * var(--pad) + 6px); }
.action-item {
  display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 12px; width: 100%;
  border: 0; border-radius: 12px; background: transparent; color: #fff; text-align: left; text-decoration: none;
  font: 500 16px/1.2 var(--font); cursor: pointer; transition: background-color var(--dur);
}
.action-item:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.action-item:active { background: var(--surface-2); }
.action-item > .ms { color: var(--label); }
.action-item.is-danger, .action-item.is-danger > .ms { color: var(--danger-text); }
.action-item:disabled { opacity: .4; pointer-events: none; }

/* Hlavička detailu zariadenia (senzor, vypínač): meno je v hornej lište; tu karta s ikonou, miestnosťou a stavovými čipmi */
.dev-head { display: flex; align-items: center; gap: 14px; margin-top: 8px; padding: 12px 14px; border-radius: var(--r-card); background: var(--surface); }
.dev-head-ic { position: relative; flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: #fff; }
.dev-head-ic .ms { font-size: 28px; }
.dev-head-main { flex: 1; min-width: 0; }
.dev-head-room { font-size: 16px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.dev-head .dev-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.dev-head .dev-chips:empty { display: none; }
.dev-head .chip { cursor: default; }
.dev-head .chip:not(button):active { transform: none; }
.dev-head button.chip { cursor: pointer; padding-right: 6px; gap: 6px; }
.dev-head button.chip::after { inset: -8px -3px; }            /* 28 px čip, 44 px plocha na ťuknutie */
.dev-head .chip .ms { font-size: 16px; }
.dev-head .chip .chip-chev { font-size: 18px; margin: 0 0 0 -4px; opacity: .7; }

/* ---------- 13. Toasts + progress (Hue.toast / Hue.save) ----------------- */
/* Snackbar dole nad tab barom / lištou Uložiť (ako Hue appka): nezakrýva nadpis, režimy ani hlavičky zariadení.
   Najnovší je najnižšie. Keď je otvorený hárok (dole), toasty idú hore nad stmavené pozadie; pri otvorenom menu sú
   pod jeho pozadím. Bez tlačidiel (info, úspech, priebeh) prepúšťajú ťuknutia na ovládanie pod sebou. */
.toasts {
  position: fixed; bottom: calc(var(--sab) + var(--tabbar-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 1090;
  width: min(420px, calc(100% - 24px));
  display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none;
}
body.has-savebar .toasts { bottom: calc(var(--sab) + var(--tabbar-h) + var(--savebar-h) + 4px); }
body.no-tabbar .toasts { bottom: calc(var(--sab) + 16px); }
body.no-tabbar.has-savebar .toasts { bottom: calc(var(--sab) + var(--savebar-h) + 4px); }
html.html-lock .toasts { top: calc(var(--sat) + 12px); bottom: auto; flex-direction: column; }
body:has(.offcanvas.show) .toasts, body:has(.offcanvas.showing) .toasts { z-index: 1035; }
.toast-h {
  position: relative; overflow: hidden; pointer-events: none;
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 8px 8px 14px;
  border-radius: 14px; color: #fff;
  background: rgba(43, 45, 49, .97);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-float), inset 0 0 0 1px rgba(255, 255, 255, .06);
  animation: hue-toast-in 280ms var(--ease) both;
}
.toast-h.has-actions, .toast-h.is-error { pointer-events: auto; }
.toast-h:nth-child(n+4) { display: none; }
.toast-h.is-out { animation: hue-toast-out 220ms ease-in both; }
.toast-ic { font-size: 24px; color: var(--label); }
.toast-h.is-progress .toast-ic { color: #4d9dff; }
.toast-h.is-success .toast-ic { color: var(--success); }
.toast-h.is-error .toast-ic { color: var(--danger); }
.toast-h.is-warning .toast-ic { color: var(--warning); }
.toast-main { flex: 1; min-width: 0; padding: 2px 0; }
.toast-title { font-size: 15px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-sub { font-size: 13px; line-height: 1.3; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-sub:empty { display: none; }
.toast-count { flex: none; font-size: 13px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; padding-right: 6px; }
.toast-count:empty { display: none; }
.toast-xslot:empty { display: none; }
.toast-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.toast-actions:empty { display: none; }
/* with actions (error): buttons go to their own row so the title and the reason stay readable */
.toast-h.has-actions { flex-wrap: wrap; row-gap: 8px; padding-bottom: 12px; }
.toast-h.has-actions .toast-actions { order: 5; flex: 1 0 100%; justify-content: flex-end; padding-left: 36px; }
.toast-btn {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .14); color: #fff; font: 600 13px/1 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur);
}
.toast-btn:hover { color: #fff; background: rgba(255, 255, 255, .2); }
.toast-btn.primary { background: var(--accent); }
.toast-btn.primary:hover { background: #2388ff; }
.toast-x { position: relative; width: 32px; height: 32px; margin-left: -4px; border: 0; border-radius: 50%; display: grid; place-items: center; flex: none; background: transparent; color: var(--label); cursor: pointer; }
.toast-x::after { content: ""; position: absolute; inset: -6px; }
.toast-x:hover { color: #fff; }
.toast-x .ms { font-size: 20px; }
.toast-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .08); opacity: 0; transition: opacity var(--dur); }
.toast-bar > i { display: block; height: 100%; width: 100%; background: var(--accent); transform: scaleX(var(--p, 0)); transform-origin: left center; transition: transform 320ms ease-out, background-color var(--dur); }
.toast-h.has-bar .toast-bar { opacity: 1; }
.toast-bar.is-indeterminate > i { width: 38%; border-radius: 2px; transform: none; animation: hue-indeterminate 1.15s ease-in-out infinite; }
.toast-h.is-error .toast-bar > i { background: var(--danger); transform: none; }
.toast-demo { display: flex; flex-direction: column; gap: 8px; }
.toast-demo .toast-h { animation: none; }

/* ---------- 14. Empty state, skeleton ------------------------------------ */
.empty-h { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px 24px; text-align: center; }
.empty-h-ic { width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--label); }
.empty-h-ic .ms { font-size: 40px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 40; }
.empty-h-text { font-size: 16px; font-weight: 500; color: var(--text-2); max-width: 28ch; }
.empty-h .btn-h { margin-top: 6px; }
.empty-h.compact { padding: 24px 16px; }

.skel { position: relative; overflow: hidden; display: block; background: var(--surface); border-radius: 8px; }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .055), transparent);
  animation: hue-shimmer 1.4s ease-in-out infinite;
}
.skel.on-surface { background: var(--surface-2); }
.skel-card { height: 88px; border-radius: var(--r-card); }
.skel-row { height: 64px; border-radius: var(--r-card); }
.skel-tile { width: 96px; height: 96px; border-radius: var(--r-tile); }
.skel-light { height: 112px; border-radius: var(--r-tile); }
.skel-line { height: 12px; border-radius: 6px; margin: 6px 0; width: 100%; }
.skel-line.w40 { width: 40%; } .skel-line.w60 { width: 60%; } .skel-line.w80 { width: 80%; }
.skel-title { height: 28px; width: 55%; border-radius: 8px; margin: 4px 0 18px; }
.skel-circle { width: 40px; height: 40px; border-radius: 50%; }
.skel-pill { height: 40px; width: 110px; border-radius: var(--r-pill); }

/* ---------- 15. Forms ------------------------------------------------------ */
.form-label { display: block; margin: 0 0 6px 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-control, .form-select {
  min-height: 48px; padding: 11px 14px; border: 1px solid transparent; border-radius: var(--r-tile);
  background-color: var(--surface-2); color: #fff; font: 400 16px/1.35 var(--font);
  transition: border-color var(--dur), box-shadow var(--dur), background-color var(--dur);
}
.form-control::placeholder { color: rgba(255, 255, 255, .55); }
.form-control:focus, .form-select:focus { background-color: var(--surface-2); color: #fff; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: var(--surface); color: var(--text-2); opacity: 1; }
.form-select {
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%239a9ca2' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-size: 16px 16px; background-position: right 14px center;
}
.form-select option { background: var(--surface-2); color: #fff; }
.form-control.is-invalid, .form-select.is-invalid, .was-validated .form-control:invalid { border-color: var(--danger); background-image: none; padding-right: 14px; }
.form-control.is-invalid:focus, .form-select.is-invalid:focus { box-shadow: 0 0 0 1px var(--danger); }
.invalid-feedback { font-size: 13px; color: var(--danger-text); margin: 6px 0 0 4px; }
.form-text { font-size: 13px; color: var(--text-2); margin: 6px 0 0 4px; }
.field + .field { margin-top: 16px; }
.card-h .form-control, .card-h .form-select, .sheet .form-control, .sheet .form-select { background-color: var(--surface-2); }
.form-check-input { background-color: var(--surface-2); border-color: var(--surface-3); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 2px rgba(10, 122, 255, .45); border-color: var(--accent); }
.select-sm { min-height: 40px; padding: 7px 34px 7px 12px; border-radius: 10px; background-position: right 10px center; }
.time-pick { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.time-pick .form-select { width: auto; min-width: 68px; }
.time-pick .sep { color: var(--text-2); font-weight: 600; }

.search-h { position: relative; }
.search-h > .ms { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--label); font-size: 20px; pointer-events: none; }
.search-h .form-control { min-height: 40px; padding: 8px 12px 8px 40px; border-radius: 12px; background-color: var(--surface); }
.search-h .form-control::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-right: -2px; cursor: pointer;
  background: rgba(255, 255, 255, .55);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 1a9 9 0 1 0 0 18 9 9 0 0 0 0-18zm3.9 11.5-1.4 1.4L10 11.4l-2.5 2.5-1.4-1.4L8.6 10 6.1 7.5l1.4-1.4L10 8.6l2.5-2.5 1.4 1.4-2.5 2.5 2.5 2.5z'/%3E%3C/svg%3E") center / 20px 20px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 1a9 9 0 1 0 0 18 9 9 0 0 0 0-18zm3.9 11.5-1.4 1.4L10 11.4l-2.5 2.5-1.4-1.4L8.6 10 6.1 7.5l1.4-1.4L10 8.6l2.5-2.5 1.4 1.4-2.5 2.5 2.5 2.5z'/%3E%3C/svg%3E") center / 20px 20px no-repeat;
}
.search-h .form-control::-webkit-search-cancel-button:hover { background: #fff; }

/* Stepper */
.stepper { display: inline-flex; align-items: center; height: 44px; padding: 0 4px; border-radius: var(--r-pill); background: var(--surface-2); }
.card-h .stepper { background: rgba(0, 0, 0, .28); }
.stepper-btn {
  position: relative; width: 36px; height: 36px; border: 0; border-radius: 50%; padding: 0; flex: none;
  display: grid; place-items: center; background: transparent; color: #fff; cursor: pointer;
  transition: background-color var(--dur), opacity var(--dur);
}
.stepper-btn::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; }
.stepper-btn:hover { background: rgba(255, 255, 255, .08); }
.stepper-btn:active { background: rgba(255, 255, 255, .16); }
.stepper-btn:disabled { opacity: .28; pointer-events: none; }
.stepper-btn .ms { font-size: 20px; }
.stepper-val { min-width: 72px; padding: 0 4px; text-align: center; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stepper.is-null .stepper-val { color: var(--text-2); }
.stepper.is-disabled { opacity: .4; pointer-events: none; }

/* ---------- 16. Sticky save bar (Hue.guard) ------------------------------- */
.savebar {
  position: fixed; left: 0; right: 0; z-index: 1025;
  bottom: calc(var(--tabbar-h) + var(--sab));
  padding: 14px max(var(--pad), var(--sar)) 10px max(var(--pad), var(--sal));
  background: linear-gradient(180deg, rgba(23, 24, 28, 0) 0%, rgba(23, 24, 28, .94) 38%);
  pointer-events: none;
}
body.no-tabbar .savebar { bottom: 0; padding-bottom: calc(12px + var(--sab)); }
.savebar-in { max-width: calc(var(--maxw) - 2 * var(--pad)); margin: 0 auto; display: flex; gap: 10px; pointer-events: auto; }
.savebar .btn-h { flex: 1; height: 50px; font-size: 16px; }
.savebar .btn-h.primary:not(:disabled) { box-shadow: 0 6px 20px rgba(10, 122, 255, .35); }
.savebar .btn-h:disabled { opacity: 1; background: var(--surface-2); color: var(--text-3); }
.savebar.is-static { position: static; padding: 0; background: none; }

/* ---------- 17. Bare layout (guest / onboarding) -------------------------- */
body.bare .page {
  max-width: 420px; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding-top: calc(var(--sat) + 24px); padding-bottom: calc(var(--sab) + 32px);
}
body.bare .page.top { justify-content: flex-start; }
body.bare .appbar + .page { min-height: calc(100dvh - var(--appbar-h) - var(--sat)); padding-top: 8px; }
.brand-mark { display: block; width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 20px; box-shadow: 0 12px 32px rgba(238, 90, 155, .25); }
.progress-dots { display: flex; justify-content: center; gap: 8px; }
.progress-dots > i { width: 8px; height: 8px; border-radius: 4px; background: var(--surface-3); transition: width var(--dur) var(--ease), background-color var(--dur); }
.progress-dots > i.is-active { width: 22px; background: #fff; }
.progress-dots > i.is-done { background: var(--text-2); }

/* ---------- 18. Style guide page helpers (partials.styleguide) ----------- */
.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.sg-swatch { border-radius: 12px; overflow: hidden; background: var(--surface); font-size: 12px; }
.sg-swatch > i { display: block; height: 44px; box-shadow: inset 0 -1px 0 var(--line); }
.sg-swatch > span { display: block; padding: 6px 8px; color: var(--text-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.3; word-break: break-all; }
.sg-swatch > b { display: block; padding: 6px 8px 0; font-weight: 600; color: #fff; font-size: 12px; }
.sg-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sg-note { font-size: 12px; color: var(--label); margin: 8px 4px 0; }
.sg-frame { position: relative; border-radius: var(--r-card); overflow: hidden; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.sg-frame .appbar, .sg-frame .tabbar { position: relative; }
.sg-frame .sheet-layer { position: relative; inset: auto; z-index: 0; padding: 40px 0 0; }
.sg-frame .sheet-layer .sheet-backdrop { opacity: 1; }
.sg-frame .sheet { transform: none; max-height: none; }

/* ---------- 19. Motion ------------------------------------------------------ */
@keyframes hue-spin { to { transform: rotate(360deg); } }
@keyframes hue-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes hue-pop { 0% { transform: scale(1); } 45% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes hue-shimmer { 100% { transform: translateX(100%); } }
@keyframes hue-indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(270%); } }
@keyframes hue-toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes hue-toast-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes hue-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.shake { animation: hue-shake .36s ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  .spin, .btn-spin { animation-duration: 1.2s !important; animation-iteration-count: infinite !important; }
  .toast-bar.is-indeterminate > i { width: 100%; opacity: .45; transform: none; }
}

/* ---------- 20. PWA: installed app (html.is-standalone, set by Hue.pwa) ---- */
/* No pull-to-refresh / rubber-band glitches, no text-selection or callouts on app chrome (like a native app).
   Safe areas: the top bar, bare pages, headers, tab bar, menu, sheets and toasts already pad with --sat/--sab/--sal/--sar. */
html.is-standalone, html.is-standalone body { overscroll-behavior-y: none; }
html.is-standalone body { -webkit-touch-callout: none; }
html.is-standalone :is(.appbar, .tabbar, .menu-h, .btn-h, .icon-btn, .chip, .seg, .mode-pill, .row-item, .room-card, .tile,
  .light-tile, .scene-tile, .hslider, .hswitch, .stepper, .toast-h, .sheet-head, .action-item, .large-title) {
  -webkit-user-select: none; user-select: none;
}

/* "Pridať na plochu" sheet (iOS) */
.pwa-steps { list-style: none; margin: 0; padding: 4px 0 0; display: flex; flex-direction: column; gap: 10px; }
.pwa-steps > li {
  display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 8px 14px 8px 12px;
  border-radius: var(--r-card); background: var(--surface-2);
}
.pwa-step-n {
  width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); color: var(--text-2); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pwa-step-ic { width: 40px; height: 40px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: #4d9dff; }
.pwa-step-ic .ms { font-size: 24px; }
.pwa-step-t { font-size: 16px; font-weight: 600; }
