:root {
  --canvas: #f7f6f3;
  --surface: #fff;
  --text: #2f3437;
  --muted: #787774;
  --line: #eaeaea;
  --ink: #111;
  --danger: #9f2f2d;
  --ok: #346538;
  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans: "Manrope", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--canvas);
  color: var(--text);
  min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
.wrap { max-width: 960px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }
.wrap-wide { max-width: 1120px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem 0; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--ink);
}
.brand-logo { width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.nav { display: flex; flex-wrap: wrap; gap: 0.85rem; color: var(--muted); font-size: 0.92rem; }
.nav a.active, .nav a:hover { color: var(--ink); }
.support-link {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}
.support-link:hover { color: var(--ink); }
.cabinet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff; border: 0; border-radius: 6px;
  padding: 0.7rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.1rem 1.2rem; margin-bottom: 1rem;
}
h1, h2 { font-family: var(--serif); font-weight: 400; color: var(--ink); letter-spacing: -0.02em; }
h1 { font-size: 2rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.35rem; margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.35rem; }
label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 0.65rem 0.75rem; border: 1px solid var(--line);
  border-radius: 6px; font: inherit; background: #fff; margin-bottom: 0.85rem;
}
.row { display: grid; gap: 0.75rem; }
@media (min-width: 720px) { .row.two { grid-template-columns: 1fr 1fr; } }
.flash { padding: 0.75rem 0.9rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.92rem; }
.flash.err { background: #fdebec; color: var(--danger); }
.flash.ok { background: #edf3ec; color: var(--ok); }
.device {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.75rem 0; border-bottom: 1px solid var(--line);
}
.device:last-child { border-bottom: 0; }
.device-name { font-weight: 600; color: var(--ink); }
.chip {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
  background: #edf3ec; color: var(--ok); font-size: 0.75rem; font-weight: 600;
}
.chip.warn { background: #fbf3db; color: #956400; }
.list-check { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.5rem 0 1rem; }
.list-check label { display: flex; gap: 0.5rem; align-items: center; color: var(--text); margin: 0; }
.auth-box { max-width: 420px; margin: 3rem auto; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.55rem 0.35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.empty { color: var(--muted); padding: 1rem 0; }

.top-actions { display: flex; gap: 0.35rem; align-items: center; margin-left: auto; }
.last-updated {
  font-size: 0.62rem;
  line-height: 1.2;
  color: var(--muted);
  text-align: right;
  max-width: 4.8rem;
  white-space: pre-line;
  margin-right: 0.15rem;
}
.btn-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.btn-icon:hover { color: var(--ink); background: #fafafa; }
.btn-icon.active {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}
.pult-list.edit-order .drag-grip { display: inline-block; }
.pult-list:not(.edit-order) .drag-grip { display: none; }
.drag-grip {
  display: none;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.15rem 0.2rem;
  cursor: grab;
  user-select: none;
}
.drag-grip:active { cursor: grabbing; }
.device-item.dragging { opacity: 0.55; }
.pult-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.pult-head-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}
.pult-head-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  margin-left: auto;
  justify-content: flex-end;
  text-align: right;
}
.pult-head h1 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.15;
}
.pult-head #edit-order {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  font-size: 0.88rem;
}
.pult-head #edit-order.active {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}
.pult-head-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}
.pult-head .status-line {
  margin: 0;
  font-size: 0.9rem;
}
.pult-head .chip {
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
}
.pult-shell-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.15rem 0.45rem;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  margin: 0 -0.15rem 0.35rem;
}
.pult-head-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  margin-left: auto;
}
.subtitle { color: var(--muted); margin: 0; font-size: 0.92rem; }
.status-line { margin: 0 0 1rem; font-size: 0.92rem; color: var(--muted); }
.pult-shell {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.4rem 0.85rem 0.85rem; margin-bottom: 1rem; flex: 1; min-width: 0;
  max-width: 420px;
}
.pult-workspace {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  flex-wrap: nowrap;
  margin-bottom: 1rem;
  max-height: min(82vh, 920px);
  min-height: 360px;
}
.pult-workspace .pult-shell {
  margin-bottom: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.delegate-panel {
  flex: 1;
  min-width: 280px;
  max-width: 420px;
  margin-bottom: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: sticky;
  top: 0.5rem;
  align-self: flex-start;
  max-height: min(82vh, 920px);
}
.delegate-label-top { margin-top: 0.5rem; }
.delegate-select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  margin-bottom: 0.35rem;
}
.delegate-target-status {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
}
.delegate-target-status.is-pending { color: #9a6b00; }
.delegate-target-status.is-connected { color: #1a5c32; }
.delegate-target-status.is-expired { color: #9a6b00; }
.delegate-user-tools {
  margin: 0 0 0.65rem;
}
.delegate-user-tools label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.delegate-name-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.delegate-name-row .delegate-input {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.delegate-name-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.btn.danger {
  color: #8b1c1c;
  border-color: #f0c4c4;
  background: #fff5f5;
}
.btn.danger:hover {
  background: #fdeeee;
}
.delegate-body { margin-top: 0.25rem; }
.delegate-drag-hint {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}
.delegate-drop-target {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 74px;
  margin: 0 0 0.9rem;
  padding: 0.8rem 0.9rem;
  border: 2px dashed #93c5fd;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.delegate-drop-target-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: #dbeafe;
  font-size: 1.25rem;
  font-weight: 700;
}
.delegate-drop-target strong,
.delegate-drop-target small {
  display: block;
}
.delegate-drop-target strong {
  font-size: 0.9rem;
}
.delegate-drop-target small {
  margin-top: 0.15rem;
  color: #5b6f91;
  font-size: 0.73rem;
  line-height: 1.35;
}
.delegate-drop-hover { display: none !important; }
.delegate-drop-target.drag-over {
  border-color: #16a34a;
  background: #ecfdf3;
  color: #166534;
  transform: scale(1.01);
}
.delegate-drop-target.drag-over .delegate-drop-idle { display: none; }
.delegate-drop-target.drag-over .delegate-drop-hover { display: block !important; }
.delegate-panel.delegate-drop-active {
  outline: 3px dashed #60a5fa;
  outline-offset: -5px;
}
.delegate-panel.delegate-drop-ready {
  outline-color: #16a34a;
  background: #f7fff9;
}
.pult-shell.delegate-source-active {
  outline: 2px dashed var(--accent, #2563eb);
  outline-offset: 2px;
}
.device-item.delegate-source .device-main {
  gap: 0.35rem;
}
.device-item.delegate-source .device-panel {
  margin-left: 4.4rem;
}
.delegate-drag-grip {
  flex-shrink: 0;
  color: var(--accent, #2563eb);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.15rem 0.2rem;
  cursor: copy;
  user-select: none;
  touch-action: none;
}
.delegate-drag-grip:active {
  cursor: grabbing;
}
.device-item.delegate-source.dragging {
  opacity: 0.55;
}
.delegate-col-title {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.45rem;
}
.delegate-assigned-zone {
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.4rem 0.85rem 0.85rem;
  background: #fafaf9;
  transition: border-color 0.15s, background 0.15s;
}
.delegate-assigned-zone.drag-over {
  border-color: var(--accent, #2563eb);
  background: #f0f7ff;
}
.delegate-assigned-zone.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 1.5rem 0.85rem;
  min-height: 140px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.device-item.delegate-source {
  cursor: grab;
}
.device-item.delegate-source .drag-grip {
  cursor: grab;
}
body.delegate-pointer-active {
  cursor: grabbing;
  user-select: none;
}
body.delegate-pointer-active * {
  cursor: grabbing !important;
}
.delegate-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(320px, calc(100vw - 32px));
  padding: 0.65rem 0.8rem;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
  pointer-events: none;
  will-change: transform;
}
.delegate-drag-ghost-icon {
  flex-shrink: 0;
  font-size: 1.05rem;
}
.device-item.device-draggable { cursor: grab; }
.device-item.device-draggable.dragging {
  opacity: 0.55;
  cursor: grabbing;
}
.device-actions .delegate-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.25rem;
  margin-right: 0.15rem;
  cursor: pointer;
}
.device-actions .delegate-remove:hover { color: var(--danger); }
.delegate-list {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafaf9;
  padding: 0.35rem;
}
.delegate-list-assigned {
  border-style: solid;
  background: var(--surface);
}
.delegate-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.5rem;
  margin-bottom: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: grab;
  font-size: 0.88rem;
}
.delegate-item.dragging { opacity: 0.55; cursor: grabbing; }
.delegate-grip {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
  user-select: none;
}
.delegate-label { flex: 1; min-width: 0; line-height: 1.3; }
.delegate-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
}
.delegate-remove:hover { color: var(--danger); }
.delegate-empty {
  padding: 0.75rem 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
}
.delegate-add-user {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.delegate-invite-result {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}
.delegate-invite-result:not(.hidden) {
  display: block;
}
.delegate-invite-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
}
.delegate-invite-heading .hint {
  margin-bottom: 0.45rem;
}
.delegate-invite-state {
  flex-shrink: 0;
  color: #1a5c32;
  font-size: 0.76rem;
  font-weight: 600;
}
.delegate-invite-state.is-expired {
  color: #9a6b00;
}
.delegate-invite-link-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}
.delegate-steps {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.45;
}
.delegate-steps li { margin-bottom: 0.35rem; }
.delegate-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  margin-bottom: 0.65rem;
}
.delegate-invite-link {
  display: block;
  min-width: 0;
  flex: 1;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin: 0;
  word-break: break-all;
}
.delegate-icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 2.35rem;
  padding: 0;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1d4ed8;
  background: #fff;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, transform 0.15s;
}
.delegate-icon-button:hover {
  background: #dbeafe;
}
.delegate-icon-button:active {
  transform: scale(0.96);
}
.delegate-icon-button:focus-visible,
.delegate-regenerate-button:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}
.delegate-icon-button svg,
.delegate-regenerate-button svg {
  width: 1.1rem;
  height: 1.1rem;
}
.delegate-invite-expiry {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.delegate-regenerate-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.15rem;
}
.guest-card { max-width: 420px; }
.loading {
  display: flex; align-items: center; gap: 0.6rem; color: var(--muted);
  padding: 1rem 0.25rem; font-size: 0.92rem;
}
.loading.hidden { display: none; }
.hidden { display: none !important; }
.spinner {
  width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--ink);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pult-list.empty { color: var(--muted); padding: 1.2rem 0.4rem; }
.room-group { margin: 0.35rem 0 0.65rem; }
.room-name {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); margin: 0.3rem 0 0.25rem; padding: 0 0.15rem;
}
.device-item {
  border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.65rem;
  margin-bottom: 0.35rem; background: #fff;
}
.device-item.device-offline { opacity: 0.62; }
.device-main {
  display: flex; align-items: center; gap: 0.5rem;
}
.device-icon {
  width: 2rem; height: 2rem; display: grid; place-items: center;
  color: #59636d; flex-shrink: 0;
}
.device-icon svg {
  width: 1.55rem; height: 1.55rem; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.device-symbol--snow { color: #0284c7; }
.device-symbol--light-lamp { color: #b45309; }
.device-symbol--light-ceiling { color: #c2410c; }
.device-symbol--light-strip { color: #0f766e; }
.device-symbol--plug { color: #6d28d9; }
.device-symbol--switch { color: #be123c; }
.device-symbol--sensor,
.device-symbol--climate { color: #0e7490; }
.device-symbol--button { color: #be123c; }
.device-symbol--tv { color: #6d28d9; }
.device-symbol--speaker { color: #be123c; }
.device-symbol--water { color: #0369a1; }
.device-symbol--home { color: #59636d; }
.device-info { flex: 1; min-width: 0; }
.device-name {
  font-weight: 500; color: var(--ink); font-size: 0.88rem; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.device-type { font-size: 0.7rem; color: var(--muted); margin-top: 1px; line-height: 1.25; }
.device-actions { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.no-control { color: var(--muted); font-size: 0.75rem; }

.toggle { position: relative; width: 40px; height: 24px; display: inline-block; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0; background: #d8d8d4; border-radius: 999px; cursor: pointer;
  transition: background 0.15s ease;
}
.toggle-slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: #3f6f45; }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }

.device-panel {
  margin: 0.4rem 0 0 2.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}
.device-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 0.4rem;
  align-items: center;
  min-height: 1.7rem;
}
.summary-side {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.summary-left { justify-content: flex-start; }
.summary-right { justify-content: flex-end; }
.summary-right {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0.4rem;
}
.device-summary.has-details {
  grid-template-columns: minmax(0, 1fr) max-content auto;
}
.details-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.details-toggle:hover { background: #f0efeb; color: var(--ink); }
.details-toggle:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }
.details-toggle svg { width: 1.15rem; height: 1.15rem; transition: transform 0.16s ease; }
.details-toggle.open svg { transform: rotate(180deg); }
.device-details { margin-top: 0.55rem; display: grid; gap: 0.55rem; }
.device-controls { display: grid; gap: 0.4rem; }
.device-control {
  display: flex;
  min-height: 1.9rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.device-control select,
.device-control .compact-number {
  min-width: 7rem;
  max-width: 10rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.device-control .compact-number { width: 5rem; min-width: 5rem; text-align: right; }
.mini-toggle { position: relative; width: 2.3rem; height: 1.35rem; flex-shrink: 0; }
.mini-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.mini-toggle > span { position: absolute; inset: 0; border-radius: 999px; background: #d8d8d4; transition: background 0.15s ease; }
.mini-toggle > span::before { content: ''; position: absolute; width: 1rem; height: 1rem; left: 0.18rem; top: 0.18rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15); transition: transform .15s ease; }
.mini-toggle input:checked + span { background: #3f6f45; }
.mini-toggle input:checked + span::before { transform: translateX(0.95rem); }
.device-readings { display: grid; gap: 0.35rem; }
.device-reading { display: flex; justify-content: space-between; gap: 0.75rem; color: var(--muted); font-size: 0.75rem; }
.device-reading strong { color: var(--ink); font-weight: 600; text-align: right; }
.summary-label {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
  margin: 0;
}
.summary-value {
  font-size: 0.82rem;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}
.temperature-control {
  display: grid;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  min-width: 0;
}
.temperature-stepper {
  display: inline-grid;
  grid-template-columns: 2rem 4rem 2rem;
  justify-items: stretch;
  align-items: center;
  width: 8rem;
  min-width: 0;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}
.temperature-stepper.loading { opacity: 0.55; }
.temperature-stepper > button {
  display: grid; place-items: center; width: 100%; height: 100%; min-width: 0;
  border: 0; background: transparent; cursor: pointer;
  font-size: 1rem; color: var(--ink); line-height: 1; padding: 0;
}
.temperature-stepper > button:hover:not(:disabled) { background: #f0efeb; }
.temperature-stepper > button:disabled { opacity: 0.4; cursor: not-allowed; }
.temperature-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: 28px;
  margin: 0;
  padding: 0 0.3rem;
  border-inline: 1px solid var(--line);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
  gap: 0.1rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
.temperature-value input {
  width: 2.5ch; min-width: 2ch; max-width: 4ch;
  field-sizing: content;
  border: 0; margin: 0; padding: 0; text-align: center;
  font: inherit; font-weight: 600; background: transparent; outline: 0;
  appearance: textfield; line-height: 1;
}
.temperature-value input::-webkit-outer-spin-button,
.temperature-value input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.temperature-value input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* Правая панель: имена всегда переносятся */
.delegate-assigned-zone .device-name,
.delegate-assigned-zone .device-type {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.delegate-assigned-zone .device-panel {
  margin-left: 0;
}
.delegate-assigned-zone .device-summary {
  grid-template-columns: 1fr;
  gap: 0.3rem;
}
.delegate-assigned-zone .summary-right {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.yandex-connect { max-width: 420px; }
.yandex-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.35rem;
}
.yandex-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: #fc3f1d;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  margin-left: 0.35rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.yandex-page .card { margin-bottom: 0.85rem; }

.auth-links {
  display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.75rem;
}
.auth-links a { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 640px) {
  .wrap.wrap-wide {
    padding-inline: 0.65rem;
  }

  .top { flex-wrap: wrap; }
  .pult-shell, .guest-card, .delegate-panel { max-width: none; }
  .pult-shell {
    width: 100%;
    padding-inline: 0.55rem;
  }

  .device-item {
    padding-inline: 0.45rem;
  }

  .device-panel,
  .device-item.delegate-source .device-panel {
    margin-left: 0;
  }

  .device-summary {
    gap: 0.5rem;
  }

  .summary-left {
    gap: 0.35rem;
    white-space: nowrap;
  }

  .temperature-stepper {
    width: min(8rem, 32vw);
    grid-template-columns: 1.7rem minmax(0, 1fr) 1.7rem;
  }

  .pult-workspace {
    flex-direction: column;
    flex-wrap: wrap;
    max-height: none;
    min-height: 0;
  }
  .pult-workspace .pult-shell,
  .delegate-panel {
    max-height: none;
    overflow-y: visible;
    position: static;
  }
}
