/* ==========================================================================
   Ramses web UI – single stylesheet, no framework.
   Theme via [data-theme] on <html>; all colours are CSS variables.
   ========================================================================== */

:root {
  --radius: 16px;
  --radius-sm: 10px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .06);
  --topbar-h: 60px;
  --bottomnav-h: 64px;
}

:root, [data-theme="light"] {
  --bg: #f1f4f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #dde3ec;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --primary-soft: #dbe7ff;
  --on: #16a34a;
  --on-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --accent: #c026d3;
  --watermark: url("../gfx/RamsesLogo.svg");
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #151d2e;
  --surface-2: #1e293b;
  --border: #283548;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-text: #ffffff;
  --primary-soft: #1e3a8a;
  --on: #22c55e;
  --on-soft: #14532d;
  --danger: #f87171;
  --danger-soft: #7f1d1d;
  --accent: #e879f9;
  --watermark: url("../gfx/RamsesLogoInverted.svg");
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
/* Ramses logo as a subtle background watermark */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--watermark) center / min(70vw, 560px) no-repeat;
  opacity: .05;
  pointer-events: none;
  z-index: -1;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); }

svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .9rem; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { color: var(--accent); }
.icon-btn.danger:hover { color: var(--danger); }

/* --- Forms -------------------------------------------------------------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field input, .field select, select.input, input.input {
  width: 100%; min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
}
.field input:focus, .field select:focus, select.input:focus, input.input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field .readonly { padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
  font-family: ui-monospace, Consolas, monospace; font-size: .9rem; overflow-wrap: anywhere; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px;
  border-radius: var(--radius-sm); margin: 0 0 14px; font-size: .9rem; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details.advanced { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 14px; }
details.advanced summary { cursor: pointer; color: var(--muted); font-size: .9rem; font-weight: 600; }
details.advanced[open] summary { margin-bottom: 12px; }

/* --- Login -------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 24px;
  padding: 32px 28px 16px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.login-logo { width: 56px; height: 56px; display: block; margin: 0 auto 8px; }
.login-card h1 { text-align: center; margin-bottom: 24px; font-size: 1.6rem; letter-spacing: .02em; }
.login-footer { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }

/* --- Top bar & navigation ----------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; }
.brand img { height: 28px; width: auto; }
.topbar-actions { margin-left: auto; display: flex; gap: 2px; }
.nav { display: flex; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  text-decoration: none; color: var(--muted); font-weight: 600;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .nav a.active { color: #bfdbfe; }

.view { max-width: 1200px; margin: 0 auto; padding: 24px 16px 40px; }

@media (max-width: 720px) {
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
    justify-content: space-around; gap: 0;
  }
  .nav a { flex-direction: column; gap: 2px; font-size: .75rem; border-radius: 12px; padding: 6px 12px; }
  .nav a.active { background: transparent; }
  .view { padding-bottom: calc(var(--bottomnav-h) + 32px); }
}

/* --- Page header / toolbar ---------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head h2 { font-size: 1.5rem; margin-right: auto; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented button { border: 0; background: transparent; padding: 0 14px; min-height: 40px; cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button:hover { background: var(--surface-2); }
.segmented button.active { background: var(--primary); color: var(--primary-text); }

/* --- Cards & grid ------------------------------------------------------- */
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-title { font-weight: 700; font-size: 1.05rem; overflow-wrap: break-word; hyphens: auto; }
.card-sub { color: var(--muted); font-size: .85rem; }
.title-row { display: flex; align-items: center; gap: 8px; }
.wifi { display: inline-flex; flex: none; }
.wifi .icon { width: 18px; height: 18px; }
.wifi.good { color: #16a34a; }
.wifi.fair { color: #ca8a04; }
.wifi.poor { color: var(--danger); }
.card-head .grow { flex: 1; min-width: 0; }
.card-actions { display: flex; gap: 0; margin: -6px -6px 0 0; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.timer { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.badge svg.icon { width: 14px; height: 14px; }

/* Virtual remote ON/OFF */
.onoff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.onoff button {
  min-height: 56px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2);
  font-weight: 700; font-size: 1rem; cursor: pointer; letter-spacing: .04em;
  transition: background .15s, color .15s, border-color .15s, transform .05s;
}
.onoff button:active { transform: scale(.97); }
.onoff button.on.active { background: var(--on); border-color: var(--on); color: #fff; }
.onoff button.off.active { background: var(--muted); border-color: var(--muted); color: var(--surface); }

/* RamsesV4 device card */
.device-visual { display: flex; align-items: center; gap: 14px; }
.device-visual img { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; background: var(--surface-2); padding: 6px; }
.sensors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sensor { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.sensor .val { font-weight: 700; font-size: 1.1rem; }
.sensor .lbl { color: var(--muted); font-size: .75rem; display: flex; justify-content: center; align-items: center; gap: 4px; }
.sensor svg.icon { width: 14px; height: 14px; }
.card-foot { display: flex; gap: 8px; margin-top: auto; }
.card-foot .btn { flex: 1; }

.empty {
  text-align: center; color: var(--muted); padding: 48px 16px;
  border: 2px dashed var(--border); border-radius: var(--radius);
}
.empty svg.icon { width: 40px; height: 40px; margin-bottom: 8px; }
.empty p { margin: 4px 0 16px; }

/* Firmware page */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; max-width: 640px; }
.panel h3 { margin-bottom: 8px; }
.panel ol { padding-left: 20px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); }

/* --- Dialog ------------------------------------------------------------- */
.dialog {
  border: none; padding: 0; border-radius: 20px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
.dialog.wide { width: min(920px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(15 23 42 / .55); backdrop-filter: blur(2px); }
.dialog-inner { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dialog-head { display: flex; align-items: center; gap: 8px; padding: 18px 20px 10px; }
.dialog-head h2 { font-size: 1.2rem; flex: 1; }
.dialog-body { padding: 8px 20px 12px; overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--border); }
@media (max-width: 560px) {
  .dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92vh; }
  .dialog-inner { max-height: 92vh; }
  .dialog-foot .btn { flex: 1; }
}

/* Timer editor */
.tabs { margin-bottom: 18px; display: flex; }
.tabs.segmented { width: 100%; }
.tabs.segmented button { flex: 1; justify-content: center; }
.rule { border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 12px; background: var(--surface-2); }
.rule-head { display: flex; align-items: center; margin-bottom: 8px; font-weight: 700; }
.rule-head .icon-btn { margin-left: auto; width: 32px; height: 32px; }
.rule-line { display: grid; grid-template-columns: 52px repeat(6, minmax(0, 1fr)); gap: 6px; align-items: end; margin-bottom: 6px; }
.rule-line > .lbl { font-weight: 600; color: var(--muted); font-size: .85rem; padding-bottom: 10px; }
.rule-line label { display: grid; gap: 2px; font-size: .7rem; color: var(--muted); }
.rule-line select { min-height: 36px; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); width: 100%; }
@media (max-width: 640px) {
  .rule-line { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rule-line > .lbl { grid-column: 1 / -1; padding: 0; }
}

/* Button mapping */
.keypad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.key { background: var(--surface-2); border-radius: 12px; padding: 10px; display: grid; gap: 6px; }
.key .key-no { font-weight: 700; font-size: .85rem; color: var(--muted); }
.key select { width: 100%; min-height: 38px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 4px; }
.key.set { background: var(--primary-soft); }


/* --- Toasts ------------------------------------------------------------- */
.toasts { position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%);
  bottom: 24px; display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
@media (max-width: 720px) { .toasts { bottom: calc(var(--bottomnav-h) + 16px); } }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-weight: 500;
  animation: toast-in .2s ease-out; pointer-events: auto;
}
.toast.success { background: var(--on); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.grow { flex: 1; min-width: 0; }

/* --- fixes after visual review ------------------------------------------ */
.sensor .val { font-size: 1rem; white-space: nowrap; }
.sensor .val small { font-size: .7rem; font-weight: 600; color: var(--muted); margin-left: 2px; }
.dialog-inner:focus { outline: none; }
.icon-btn:focus:not(:focus-visible) { outline: none; }
@media (max-width: 720px) {
  /* Page titles are hidden on phones: the bottom navigation shows the section.
     They stay available to screen readers. */
  .page-head h2 {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .page-head:not(:has(> :not(h2))) { display: none; }
  .page-head .segmented { flex: 1 1 100%; }
  .page-head .segmented button { flex: 1; justify-content: center; padding: 0 6px; font-size: .85rem; }
  /* Buttons share one row in equal parts (e.g. Sortieren | Hinzufügen). */
  .page-head > .btn { flex: 1 1 0; min-width: 0; justify-content: center; }
}
body { overflow-x: hidden; }
.sensors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sensor .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* themed logos */
.login-logo { width: 200px; height: auto; margin: 0 auto 24px; }
[data-theme="dark"] .only-light, :root:not([data-theme="dark"]) .only-dark { display: none; }
[data-theme="dark"] .brand img { filter: invert(1); }
/* backdrop-filter would make the fixed bottom nav position relative to the top bar */
@media (max-width: 720px) {
  .topbar { backdrop-filter: none; background: var(--surface); }
}

/* Device cards hold two buttons and three sensor tiles side by side, so they
   need more width than remote cards. min() keeps them inside small screens. */
.device-grid { grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); }
.card-foot { flex-wrap: wrap; }
.card-foot .btn { min-width: max-content; }

/* --- Sort mode (remotes) --- */
.grid.sorting .card {
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  outline: 2px dashed var(--border); outline-offset: -2px;
}
.grid.sorting .card:focus-visible { outline: 2px solid var(--primary); }
.grid.sorting .onoff button { pointer-events: none; opacity: .55; }
.card.dragging {
  position: fixed; left: 0; top: 0; z-index: 50; margin: 0;
  pointer-events: none; cursor: grabbing; opacity: .95;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .25); rotate: 1.5deg;
}
.card-placeholder {
  border: 2px dashed var(--primary); border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

/* --- Button mapping: device frame with USB port --- */
.usb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.usb-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.device-frame {
  position: relative; padding: 14px; border: 2px solid var(--border); border-radius: 18px;
  background: var(--surface);
}
.device-frame .keypad { grid-template-rows: repeat(4, auto); }
.usb-port {
  position: absolute; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 22px; border-radius: 6px; background: var(--muted); color: var(--surface);
  left: 50%; translate: -50% 0;
}
.usb-port .icon { width: 16px; height: 16px; }
.device-frame[data-usb=S] .usb-port { bottom: -12px; }
.device-frame[data-usb=N] .usb-port { top: -12px; }
.device-frame[data-usb=E] .usb-port, .device-frame[data-usb=W] .usb-port {
  top: 50%; translate: 0 -50%; width: 22px; height: 44px; left: auto;
}
.device-frame[data-usb=E] .usb-port { right: -12px; }
.device-frame[data-usb=W] .usb-port { left: -12px; }
/* Phones: keep the real 4×4 layout, just more compact. */
@media (max-width: 640px) {
  .device-frame { padding: 10px; }
  .keypad { gap: 6px; }
  .key { padding: 6px; gap: 4px; }
  .key .key-no { font-size: .75rem; }
  .key select { font-size: .75rem; min-height: 34px; padding: 2px; }
  .usb-row .segmented { flex: 1 1 100%; }
  .usb-row .segmented button { flex: 1; justify-content: center; padding: 0 6px; }
}

/* --- Compact remotes view: RamsesV4 keypads --- */
.compact-list { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.compact-device h3 { font-size: 1rem; margin: 0 0 8px; color: var(--muted); }
.ckeypad {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, auto); gap: 8px;
  padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.ckey {
  aspect-ratio: 1; min-width: 0; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: inherit; font: inherit; padding: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  cursor: pointer; transition: transform .08s, background .15s;
}
.ckey:active { transform: scale(.94); }
.ckey.empty { background: transparent; border-style: dashed; opacity: .5; cursor: default; }
.ckey-name {
  font-weight: 700; font-size: .85rem; line-height: 1.2; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ckey-mode { font-size: .65rem; font-weight: 700; letter-spacing: .04em; padding: 2px 6px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.ckey.mode-on .ckey-mode { color: #16a34a; }
.ckey.mode-off .ckey-mode { color: var(--danger); }
.ckey.lit { border-color: #16a34a; box-shadow: inset 0 0 0 1px #16a34a; }
.ckey.unknown .ckey-name { color: var(--muted); font-style: italic; }
@media (max-width: 720px) {
  .ckeypad { gap: 6px; padding: 8px; }
  .ckey { padding: 4px; border-radius: 10px; }
  .ckey-name { font-size: .75rem; }
  .ckey-mode { font-size: .6rem; padding: 1px 4px; }
}

/* --- Configure device (setup QR code) --- */
.setup { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; }
.qr { flex: none; width: 240px; max-width: 100%; padding: 8px; background: #fff; border-radius: 12px; }
.qr svg { display: block; width: 100%; height: auto; }
.setup-text { flex: 1 1 260px; min-width: 0; }
.setup-text .kv { margin-bottom: 0; }
@media (max-width: 720px) {
  .setup { justify-content: center; }
  .qr { width: min(260px, 80vw); }
  /* four tabs in the bottom bar */
  .nav a { flex: 1 1 0; min-width: 0; padding: 6px 2px; font-size: .7rem; text-align: center; }
}

.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
/* Links styled as buttons (e.g. in empty states) */
a.btn { text-decoration: none; color: var(--text); }
a.btn.btn-primary { color: var(--primary-text); }
.empty .btn svg.icon { width: 20px; height: 20px; margin: 0; }
.pre-line { white-space: pre-line; } /* keeps line breaks from translation texts */
.nav a { white-space: nowrap; }
/* Medium widths (tablets, small windows): the top bar is too narrow for four
   labelled tabs, so show icons only. Labels stay for screen readers and as tooltip. */
@media (min-width: 721px) and (max-width: 1000px) {
  .nav a { padding: 8px 12px; }
  .nav a > span {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
}
/* --- Configure device: two QR steps --- */
.setup-steps { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); align-items: start; }
.setup-step { display: flex; flex-direction: column; gap: 12px; }
.setup-step h3 { display: flex; align-items: center; gap: 10px; margin: 0; }
.setup-step .qr { align-self: center; width: min(260px, 80vw); }
.setup-step p { margin: 0; }
.setup-step .kv { margin: 0; }
.setup-step > .btn { align-self: flex-start; }
.step-no {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: var(--primary-text); font-size: .9rem; flex: none;
}
.notice.subtle { font-size: .85rem; }
.field small.hint { margin: 2px 0 0; font-size: .8rem; }
.setup-waiting { display: flex; align-items: center; gap: 10px; margin: 0 0 var(--gap); color: var(--muted); }
.setup-waiting .spinner { flex: none; color: var(--primary); }
/* Desktop: slightly smaller card icons leave room for long names (e.g. Weihnachtsbaum). */
@media (min-width: 721px) { .card-actions .icon-btn { width: 34px; height: 34px; } .card-actions { margin: -3px -4px 0 0; } }
a.brand { color: inherit; text-decoration: none; }
/* Wi-Fi symbol among the card icons (WallSwitch-C3): same box as an icon button */
.card-actions .wifi { width: 40px; height: 40px; align-items: center; justify-content: center; }
@media (min-width: 721px) { .card-actions .wifi { width: 34px; height: 34px; } }
