:root {
  color-scheme: light;
  --bg: #d7e1ec;
  --ink: #1a2432;
  --muted: #5b6b7c;
  --faint: #8a97a6;
  --line: rgba(255, 255, 255, 0.58);
  --line-soft: rgba(36, 56, 78, 0.1);
  --online: #2f8a62;
  --offline: #c43b32;
  --partial: #c47a1a;
  --unknown: #7b8896;
  --fill: #3d73a8;
  --fill-ink: #f7fbff;
  --fill-soft: rgba(61, 115, 168, 0.14);
  --fill-deep: #2b557c;
  --danger: #c43b32;
  --glass: rgba(255, 255, 255, 0.42);
  --glass-strong: rgba(255, 255, 255, 0.64);
  --glass-tint: rgba(236, 244, 252, 0.5);
  --shine: inset 0 1px 0 rgba(255, 255, 255, 0.78);
  --sans: -apple-system, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --serif: var(--sans);
  --mono: ui-monospace, "SF Mono", Consolas, "Cascadia Mono", monospace;
  --radius: 22px;
  --radius-sm: 16px;
  --blur: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.011em;
}

html {
  background: #d7e1ec;
}

body {
  isolation: isolate;
  background:
    radial-gradient(1100px 720px at 8% -12%, rgba(255, 255, 255, 0.88), transparent 58%),
    radial-gradient(820px 560px at 96% 4%, rgba(122, 168, 214, 0.38), transparent 52%),
    radial-gradient(760px 520px at 78% 108%, rgba(176, 198, 222, 0.5), transparent 58%),
    linear-gradient(180deg, #eaf0f6 0%, #d4dee9 100%);
  min-height: 100vh;
}

.sky {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.sky::before,
.sky::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.7;
}

.sky::before {
  width: 42vw;
  height: 42vw;
  min-width: 280px;
  min-height: 280px;
  left: -8vw;
  top: 18vh;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.7), rgba(186, 210, 232, 0.18) 62%, transparent 72%);
}

.sky::after {
  width: 36vw;
  height: 36vw;
  min-width: 240px;
  min-height: 240px;
  right: -6vw;
  bottom: 8vh;
  background: radial-gradient(circle, rgba(154, 186, 220, 0.45), transparent 70%);
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid rgba(61, 115, 168, 0.55);
  outline-offset: 3px;
}

.shell,
.workspace,
aside {
  position: relative;
  z-index: 1;
}

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

aside {
  position: sticky;
  top: 14px;
  height: calc(100vh - 28px);
  margin: 14px 0 14px 14px;
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(1.7);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.7);
  border: 1px solid var(--line);
  box-shadow: var(--shine), 0 18px 50px rgba(40, 70, 100, 0.08);
  border-radius: 28px;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 8px 8px;
}

.brand svg {
  width: 34px;
  height: 34px;
  color: var(--fill);
  padding: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--line);
  box-shadow: var(--shine);
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.brand small, .aside-foot, .eyebrow, .quiet, .meta { color: var(--muted); }

.brand small { display: block; margin-top: 3px; font-size: 12px; font-weight: 500; }

.navs { display: flex; flex-direction: column; gap: 6px; }

.nav {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  color: var(--ink);
  font-weight: 560;
  transition: background 160ms ease, color 160ms ease;
}

.nav:hover { background: rgba(255, 255, 255, 0.28); }

.nav.is-active {
  background: var(--glass-strong);
  color: var(--fill-deep);
  box-shadow: var(--shine), 0 8px 22px rgba(45, 80, 120, 0.08);
}

.aside-foot {
  margin-top: auto;
  font-size: 13px;
  padding: 0 8px;
  line-height: 1.4;
}

.workspace {
  padding: 28px 36px 80px;
  max-width: 1160px;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 24px;
}

.eyebrow { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 680;
  letter-spacing: -0.045em;
}

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

.top-meta { margin: 0; color: var(--muted); font-size: 13px; }

.toast {
  background: rgba(26, 36, 50, 0.72);
  color: #f4f8fc;
  padding: 13px 16px;
  margin-bottom: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: var(--shine);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(1.6);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.6);
  border: 1px solid var(--line);
  box-shadow: var(--shine), 0 16px 40px rgba(40, 70, 100, 0.07);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

.stat { padding: 18px 20px; background: transparent; border: 0; border-right: 1px solid var(--line-soft); }

.stat:last-child { border-right: 0; }

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.stat b {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.045em;
  line-height: 1;
}

.stat.online b { color: var(--online); }
.stat.offline b { color: var(--offline); }
.stat.partial b { color: var(--partial); }

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head .chips { margin-left: auto; }

.layout { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 18px; }

.card, .row, .panel, .scan-card, .device-card {
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(1.65);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.65);
  border: 1px solid var(--line);
  box-shadow: var(--shine), 0 14px 36px rgba(40, 70, 100, 0.07);
  border-radius: var(--radius);
}

.card { padding: 20px; }

.bars { display: flex; flex-direction: column; gap: 12px; }

.bar-line {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.track {
  height: 8px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.track span { display: block; height: 100%; background: var(--online); }

.toolbar, .actions, .inline, .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline input { width: auto; flex: 1 1 160px; min-width: 0; }

.toolbar { margin-bottom: 14px; }

.toolbar input, .toolbar select { width: auto; }

.grow { flex: 1 1 220px; }

.btn, .chip {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(45, 70, 100, 0.14);
  background: rgba(255, 255, 255, 0.72);
  color: var(--fill-deep);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  padding: 8px 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: var(--shine);
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.btn:hover, .chip:hover { background: rgba(255, 255, 255, 0.82); }

.btn:active, .chip:active { transform: scale(0.98); }

.btn.primary, .chip.is-on {
  background: linear-gradient(180deg, #5b8fc2 0%, var(--fill) 100%);
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--fill-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 24px rgba(61, 115, 168, 0.28);
}

.btn.danger {
  border-color: rgba(196, 59, 50, 0.22);
  color: var(--danger);
  background: rgba(255, 244, 242, 0.72);
}

.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 16px 1.4fr 0.8fr 1fr 0.9fr;
  gap: 12px;
  align-items: center;
}

.row.static { cursor: default; }

.row.row-lite { grid-template-columns: 16px 1.6fr 1fr auto; }

.device-main { min-width: 0; }

.device-main strong, .name-line { display: block; font-weight: 650; }

.sub {
  display: block;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono { font-family: var(--mono); font-size: 14px; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--unknown);
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45);
}

.dot.online { background: var(--online); }
.dot.offline { background: var(--offline); }
.dot.degraded { background: var(--partial); }

.state-online { color: var(--online); font-weight: 650; }
.state-offline { color: var(--offline); font-weight: 650; }
.state-degraded { color: var(--partial); font-weight: 650; }
.state-unknown { color: var(--unknown); }

.badge {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 9px;
  font-size: 12px;
  color: var(--muted);
  margin-left: 6px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.4);
}

.badge.warn {
  color: var(--partial);
  border-color: rgba(196, 122, 26, 0.28);
  background: rgba(255, 246, 232, 0.7);
}

.empty { padding: 28px 4px; color: var(--muted); max-width: 62ch; }

.stack { display: flex; flex-direction: column; gap: 14px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }

label.line { flex-direction: row; align-items: center; gap: 8px; font-weight: 560; }

input, select, textarea {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  width: 100%;
  font-weight: 450;
  box-shadow: var(--shine);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(61, 115, 168, 0.45);
  background: rgba(255, 255, 255, 0.78);
}

textarea { resize: vertical; }

.grid-2, .grid-3 { display: grid; gap: 12px; }

.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1.2fr 0.8fr 0.8fr; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

.ip-box {
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shine);
}

.help { margin: 0; color: var(--muted); font-size: 13px; font-weight: 450; }

.form-error { color: var(--danger); margin: 0; font-weight: 600; }

.house-note {
  margin: 0 0 16px;
  padding: 13px 16px;
  background: rgba(255, 246, 244, 0.7);
  border: 1px solid rgba(196, 59, 50, 0.18);
  border-radius: 18px;
  color: #7a271a;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shine);
}

.login-card {
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h2 { margin: 0; font-size: 28px; font-weight: 680; letter-spacing: -0.04em; }

.login-card form { display: flex; flex-direction: column; gap: 12px; }

.login-card a.btn {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  text-decoration: none;
}

.house-code {
  font-family: var(--mono);
  font-size: 28px;
  letter-spacing: 0.08em;
  margin: 0;
}

.secret-key {
  font-family: var(--mono);
  letter-spacing: 0.04em;
  word-break: break-all;
  margin: 0;
}

.qr {
  width: fit-content;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  box-shadow: var(--shine);
}

.qr svg { display: block; width: 220px; height: auto; }

.name-btn {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  font-weight: 650;
}

.name-line { display: flex; align-items: center; gap: 8px; }

.name-line .dot { flex: none; }

.room-block h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.room-block h3 span { color: var(--faint); font-weight: 560; font-size: 13px; }

.device-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.device-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.device-card .quiet { margin: 0; }

.device-card .actions { width: 100%; }

.device-card .btn.primary { flex: 1 1 100%; min-height: 46px; }

.row-actions { grid-column: 1 / -1; }

.command {
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

.btn.tiny { min-height: 32px; padding: 4px 12px; }

.viewer-back { z-index: 6; }

.viewer-panel {
  width: min(920px, 100%);
  background: rgba(16, 22, 30, 0.72);
  color: #f4f6f8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
}

.viewer-panel .help { color: #c5ced6; }
.viewer-panel .btn { background: rgba(255, 255, 255, 0.08); color: white; border-color: rgba(255, 255, 255, 0.16); }
.viewer-panel img { width: 100%; min-height: 240px; background: #000; object-fit: contain; border-radius: 14px; }

.history { margin: 8px 0 0; padding-left: 18px; }
.history li { font-size: 14px; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 30, 44, 0.28);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 5;
}

.panel {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--glass-strong);
  backdrop-filter: blur(34px) saturate(1.7);
  -webkit-backdrop-filter: blur(34px) saturate(1.7);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shine), 0 24px 60px rgba(24, 46, 70, 0.16);
}

.panel h2 { font-size: 24px; font-weight: 680; letter-spacing: -0.03em; }

.scan-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.scan-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.progress {
  height: 8px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--line);
  border-radius: 99px;
  margin: 8px 0;
  overflow: hidden;
}

.progress span { display: block; height: 100%; background: linear-gradient(90deg, #7aa7d4, var(--fill)); }

details summary { cursor: pointer; margin-bottom: 8px; font-weight: 650; }

.checkline { display: flex; gap: 10px; align-items: flex-start; }

.checkline input { width: auto; margin-top: 4px; }

body.modal-open { overflow: hidden; }

body.is-phone .nav-local { display: none; }
body.is-phone .navs { justify-content: space-around; }

.setpoint {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 120px;
}

.setpoint input[type="range"] {
  width: 100%;
  accent-color: var(--fill);
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  min-height: 0;
}

body.is-setup aside { display: none; }
body.is-setup .shell { grid-template-columns: 1fr; }

body.is-setup .workspace {
  min-height: 100vh;
  max-width: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body.is-setup .top { margin-bottom: 8px; }

body.is-setup #view { display: flex; justify-content: center; }

.steps { margin: 0; color: var(--fill); font-size: 13px; font-weight: 700; }

.steps-list {
  margin: 0;
  padding-left: 1.2em;
  display: flex; flex-direction: column;
  gap: 8px;
}

@media (max-width: 980px) {
  .stats, .layout, .split, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .stat:last-child { border-bottom: 0; }
  .section-head { flex-wrap: wrap; }
  .section-head .chips { margin-left: 0; }
}

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  aside {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    height: auto;
    margin: 0;
    z-index: 4;
    flex-direction: row;
    border-radius: 24px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    overflow: hidden;
  }
  .brand, .aside-foot { display: none; }
  .navs { flex-direction: row; width: 100%; gap: 4px; }
  .nav { flex: 1; text-align: center; padding: 10px 4px; border-radius: 16px; font-size: 13px; }
  .workspace { padding: 18px 14px 108px; }
  .top { align-items: flex-start; }
  h1 { font-size: 28px; }
  .row.row-lite { grid-template-columns: 16px 1fr; }
  .row.row-lite .state-online,
  .row.row-lite .state-offline,
  .row.row-lite .state-degraded,
  .row.row-lite .state-unknown { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .chip, .nav { transition: none; }
}

body.lite,
@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass: #eef3f8;
    --glass-strong: #f6f9fc;
    --glass-tint: #e8eef5;
    --blur: 0px;
    --shine: none;
    --line: rgba(36, 56, 78, 0.12);
  }
  html, body { background: #d7e1ec; }
  body { background: #dce4ed; }
  .sky { display: none; }
  .card, .panel, aside, .top, .stat, .toast, .nav, .btn {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
