:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  background: #0b111d;
  color: #f2f6fc;
  --surface: #121d2f;
  --surface-raised: #17253b;
  --border: #283952;
  --text: #f2f6fc;
  --muted: #aab9cf;
  --mint: #7aefbc;
  --brand-orange: #ff9258;
  --brand-ink: #231109;
  --red: #ff9b9e;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  min-width: 17rem;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse 46rem 24rem at 37% 0%, #15253e, transparent 95%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 4px;
}

.wrap {
  width: min(100% - 3rem, 74rem);
  margin-inline: auto;
}

.topbar {
  border-bottom: 1px solid #26344a;
  background: #0c1422;
}

.topbar-inner {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
}

.brand-mark {
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  object-fit: contain;
}

.brand-name {
  display: grid;
  gap: .18rem;
  line-height: 1.08;
}

.brand-name strong {
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: .1em;
}

.brand-name span {
  color: var(--muted);
  font-size: .875rem;
}

.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .58rem .95rem;
  border: 1px solid transparent;
  border-radius: .65rem;
  font-size: .875rem;
  font-weight: 690;
  line-height: 1.2;
  text-align: center;
  transition: background-color .17s, color .17s, border-color .17s;
}

.button-quiet, .button-secondary {
  background: #152033;
  color: #dce7f7;
  border-color: #30435f;
}

.button-quiet:not(:disabled):hover, .button-secondary:not(:disabled):hover {
  background: #20314c;
  border-color: #526b8e;
}

.button-primary {
  background: var(--brand-orange);
  color: var(--brand-ink);
  border-color: var(--brand-orange);
}

.button-primary:not(:disabled):hover {
  background: #ffb589;
  border-color: #ffb589;
}

.button-danger {
  background: #331d29;
  color: #ffd0d2;
  border-color: #673a46;
}

.button-danger:not(:disabled):hover {
  background: #4a2634;
  border-color: #a65d69;
}

.button:disabled { opacity: .55; }

.power-icon, .plus-icon {
  position: relative;
  flex: none;
  width: .95rem;
  height: .95rem;
  display: inline-block;
}

.plus-icon::before, .plus-icon::after, .power-icon::before, .power-icon::after {
  content: "";
  position: absolute;
}

.button-quiet::before {
  content: "";
  flex: none;
  width: .68rem;
  height: .68rem;
  border: 2px solid #a9bad4;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #30435f;
}

.plus-icon::before, .plus-icon::after {
  background: currentColor;
  border-radius: 5px;
}

.plus-icon::before { inset: calc(50% - 1px) .04rem; }
.plus-icon::after { inset: .04rem calc(50% - 1px); }

.power-icon::before {
  inset: .13rem .035rem .025rem;
  border: .105rem solid;
  border-top-color: transparent;
  border-radius: 50%;
}

.power-icon::after {
  width: .104rem;
  height: .44rem;
  top: .025rem;
  left: calc(50% - .052rem);
  border-radius: 4px;
  background: currentColor;
}

.dashboard { padding-block: 2rem 3rem; }

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 19rem);
  align-items: center;
  gap: 1.75rem;
  min-height: 12rem;
  padding: clamp(1.5rem, 3.5vw, 2.5rem);
  overflow: hidden;
  border: 1px solid #304760;
  border-radius: 1.25rem;
  background: linear-gradient(105deg, #192a44 0%, #142238 60%, #153132 145%);
  box-shadow: 0 1.2rem 3rem #0509143f;
}

.hero::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background:
    radial-gradient(ellipse at 78% 72%, #347b692d, transparent 53%),
    repeating-linear-gradient(133deg, transparent 0 1.9rem, #77ccba12 1.9rem calc(1.9rem + 1px), transparent calc(1.9rem + 1px) 2.4rem);
  mask-image: linear-gradient(105deg, transparent 31%, #000 98%);
  pointer-events: none;
}

.hero h1 {
  font-weight: 760;
  font-size: clamp(2.12rem, 4.7vw, 3.4rem);
  letter-spacing: -.062em;
  line-height: 1.06;
  text-wrap: balance;
}

.hero-copy p {
  max-width: 36rem;
  margin-top: .78rem;
  color: #c0cfe4;
  font-size: 1rem;
  line-height: 1.55;
}

.connection {
  --connection-color: #b0c3ff;
  display: grid;
  grid-template-columns: .62rem minmax(0, 1fr);
  align-items: start;
  gap: .7rem;
  padding: .9rem 1rem;
  border: 1px solid #3d5273;
  border-radius: .8rem;
  background: #0d182ad9;
}

.connection[data-tone="online"] {
  --connection-color: var(--mint);
  border-color: #376751;
}

.connection[data-tone="offline"] {
  --connection-color: #ffd187;
  border-color: #68523a;
}

.connection-indicator {
  width: .57rem;
  height: .57rem;
  align-self: start;
  margin-top: .4rem;
  border-radius: 50%;
  background: var(--connection-color);
  box-shadow: 0 0 0 .18rem color-mix(in srgb, var(--connection-color) 14%, transparent);
}

.connection strong {
  color: var(--connection-color);
  font-size: .875rem;
  line-height: 1.35;
}

.connection p {
  margin-top: .19rem;
  color: #b8c6dc;
  font-size: .875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.controls { margin-top: 2rem; }

.controls-heading, .controls-summary, .controls-actions {
  display: flex;
  gap: .7rem;
  align-items: center;
}

.controls-heading {
  justify-content: space-between;
  margin-bottom: 1.05rem;
}

.controls-summary { flex-wrap: wrap; }
.controls-actions { flex: none; }

.controls h2 {
  font-size: 1.45rem;
  line-height: 1.15;
  letter-spacing: -.037em;
}

.active-summary {
  padding: .23rem .61rem;
  border: 1px solid #30425e;
  border-radius: 999px;
  background: #142037;
  color: #bfcee4;
  font-size: .875rem;
  white-space: nowrap;
}

.active-summary span { color: var(--mint); font-variant-numeric: tabular-nums; }

.channel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .85rem;
}

@media (min-width: 65rem) {
  .channel-grid:has(> :nth-child(4)) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.channel {
  display: grid;
  grid-template-rows: auto minmax(3.15rem, 1fr) auto;
  min-width: 0;
  gap: .82rem;
  min-height: 10.8rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: linear-gradient(147deg, #16233a, #101b2c 67%);
  transition: border-color .19s, background-color .19s, box-shadow .19s;
}

.channel[data-state="on"] {
  border-color: #41896c;
  background: linear-gradient(145deg, #173832, #122930 67%, #12242e);
  box-shadow: inset 0 1px 0 #70d9ad23, 0 .45rem 1.15rem #020c1060;
}

.channel-header, .channel-footer, .channel-control {
  display: flex;
  align-items: center;
}

.channel-header, .channel-footer { justify-content: space-between; }
.channel-header { gap: .5rem; }
.channel-footer { gap: .25rem; }

.channel-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  overflow: hidden;
  border: 1px solid #3b5071;
  border-radius: .72rem;
  background: #223551;
  font-size: 1.36rem;
  line-height: 1;
}

.channel-icon svg { width: 1.45rem; height: 1.45rem; }

.channel[data-state="on"] .channel-icon {
  border-color: #4c9f7e;
  background: #244e41;
  color: var(--mint);
}

.channel-tag {
  padding: .23rem .45rem;
  border: 1px solid #3a4d6a;
  border-radius: .35rem;
  color: #b5c5de;
  font-size: .8125rem;
  font-weight: 650;
  white-space: nowrap;
}

.channel-title {
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.26;
  font-weight: 700;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}

.channel-room {
  margin-top: .2rem;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.channel-control { gap: .35rem; min-width: 0; }

.channel-state {
  color: #becce0;
  font-size: .875rem;
  font-weight: 630;
}

.channel[data-state="on"] .channel-state { color: var(--mint); }
.channel[data-state="unknown"] .channel-state { color: #ffd187; }

.switch {
  display: grid;
  flex: none;
  place-items: center start;
  width: 3.1rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: .65rem;
  background: transparent;
}

.switch span {
  position: relative;
  width: 3rem;
  height: 1.65rem;
  border: 1px solid #536887;
  border-radius: 2rem;
  background: #293c59;
  transition: background-color .18s, border-color .18s;
}

.switch span::after {
  content: "";
  position: absolute;
  inset: .1375rem auto .1375rem .1375rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #d9e7fa;
  box-shadow: 0 .07rem .25rem #0005;
  transition: transform .18s, background-color .18s;
}

.switch[aria-checked="true"] span {
  border-color: var(--mint);
  background: var(--mint);
}

.switch[aria-checked="true"] span::after {
  transform: translateX(1.35rem);
  background: #15392a;
}

.switch:not(:disabled):hover span { filter: brightness(1.19); }
.switch:disabled span { opacity: .62; }

.edit-control {
  flex: none;
  min-height: 2.75rem;
  padding: .35rem .37rem;
  border: 0;
  border-radius: .35rem;
  background: transparent;
  color: #bac9df;
  font-size: .875rem;
  font-weight: 630;
}

.edit-control:hover { color: white; text-decoration: underline; }

.empty-state {
  display: grid;
  justify-items: center;
  gap: .55rem;
  padding: 2.2rem 1.25rem;
  border: 1px dashed #3a506f;
  border-radius: 1rem;
  background: #122035;
  text-align: center;
}

.empty-state h3 { font-size: 1.075rem; }
.empty-state p { color: var(--muted); line-height: 1.5; }
.empty-icon { color: var(--mint); margin-bottom: .15rem; }

.feedback {
  min-height: 1.45rem;
  margin-top: .85rem;
  color: #bdcce2;
  font-size: .9rem;
  line-height: 1.53;
}

.feedback[data-tone="error"], .feedback.error { color: var(--red); }

.modal {
  width: min(100% - 2rem, 32rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 1.3rem;
  overflow: auto;
  border: 1px solid #415776;
  border-radius: 1.05rem;
  background: #141f33;
  color: var(--text);
  box-shadow: 0 24px 100px #02050daa;
}

.modal::backdrop {
  background: #030811ba;
  backdrop-filter: blur(5px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.dialog-header h2 {
  font-size: clamp(1.24rem, 4.5vw, 1.62rem);
  letter-spacing: -.035em;
  line-height: 1.2;
}

.close-button {
  position: relative;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid #3a4d69;
  border-radius: .55rem;
  background: #1b2941;
  color: #dee9f8;
}

.close-button:hover { background: #2a3a53; }

.close-button::before, .close-button::after {
  content: "";
  position: absolute;
  left: calc(50% - .48rem);
  top: calc(50% - 1px);
  width: .96rem;
  height: 2px;
  border-radius: 5px;
  background: currentColor;
}

.close-button::before { transform: rotate(45deg); }
.close-button::after { transform: rotate(-45deg); }

.dialog-description {
  margin-top: .5rem;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.55;
}

.dialog-form, .advanced-fields {
  display: grid;
  gap: .9rem;
}

.dialog-form { margin-top: 1rem; }
.advanced-fields { padding: .25rem .75rem .8rem; }

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7rem, .58fr);
  gap: .7rem;
}

.field { display: grid; gap: .36rem; min-width: 0; }

.field label, .icon-picker legend {
  color: #d6e0f2;
  font-size: .875rem;
  font-weight: 670;
}

.field input, .field select {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: .6rem .66rem;
  border: 1px solid #405675;
  border-radius: .55rem;
  background: #0e192c;
  color: var(--text);
  font-size: 1rem;
}

.field input::placeholder { color: #8295b1; opacity: 1; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--red); }

.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 1.85rem; }
.select-wrap::after {
  position: absolute;
  top: calc(50% - .28rem);
  right: .82rem;
  width: .45rem;
  height: .45rem;
  border: solid #c1d1e8;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  content: "";
  pointer-events: none;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .4rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.icon-picker legend { margin-bottom: .42rem; padding: 0; }
.icon-choice { position: relative; cursor: pointer; }

.icon-choice > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
}

.icon-choice > input + span {
  display: grid;
  gap: .25rem;
  align-content: center;
  place-items: center;
  min-height: 3.65rem;
  padding: .37rem .2rem;
  border: 1px solid #3b5071;
  border-radius: .55rem;
  background: #1d2c44;
  color: #cddaf0;
  font-size: .8125rem;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.icon-choice svg { width: 1.28rem; height: 1.28rem; }
.icon-choice:hover > input + span { background: #293c59; }

.icon-choice > input:checked + span {
  border-color: var(--mint);
  background: #214737;
  box-shadow: inset 0 0 0 1px #7aefbc42;
}

.icon-choice > input:focus-visible + span {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

.advanced {
  border: 1px solid #334967;
  border-radius: .62rem;
  background: #111a2c;
}

.advanced summary {
  padding: .7rem .75rem;
  color: #c6d5eb;
  font-size: .875rem;
  line-height: 1.42;
  cursor: pointer;
}

.advanced summary::marker { color: var(--mint); }

.wifi-help {
  margin-top: 1rem;
}

.wifi-help ol {
  display: grid;
  gap: .55rem;
  margin: 0 .85rem .85rem;
  padding-inline-start: 1.25rem;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}

.wifi-help a {
  color: var(--brand-orange);
}

.form-message {
  color: var(--red);
  font-size: .9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.form-message:empty { height: 0; margin-bottom: -.9rem; }

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .55rem;
  margin-top: .15rem;
}

@media (max-width: 49rem) {
  .channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(13rem, .75fr); gap: 1rem; }
}

@media (max-width: 40rem) {
  .wrap { width: calc(100% - 1.75rem); }
  .topbar-inner { min-height: 4rem; }
  .brand { gap: .35rem; }
  .brand-mark { width: 2.8rem; height: 2.8rem; }
  .dashboard { padding-block: 1rem 2.25rem; }
  .hero { grid-template-columns: 1fr; gap: 1.2rem; min-height: auto; padding: 1.25rem; }
  .hero h1 { text-wrap: unset; }
  .connection { padding: .7rem .78rem; }
  .controls { margin-top: 1.5rem; }
  .controls-heading { flex-direction: column; align-items: stretch; gap: .75rem; }
  .controls-summary { justify-content: space-between; }
  .controls-actions .button { flex: 1; }
  .channel-grid { gap: .6rem; }
}

@media (max-width: 26rem) {
  .channel { padding: .76rem; min-height: 10rem; gap: .65rem; }
  .channel-icon { width: 2.45rem; height: 2.45rem; }
  .channel-footer { align-items: center; }
  .channel-control { gap: .26rem; }
  .channel-tag { padding-inline: .3rem; }
  .channel-state { font-size: .8125rem; }
  .switch { width: 2.6rem; }
  .switch span { width: 2.5rem; height: 1.42rem; }
  .switch[aria-checked="true"] span::after { transform: translateX(1.08rem); }
  .edit-control { padding-inline: .14rem; font-size: .8125rem; }
  .modal { padding: 1rem; }
  .icon-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 22rem) {
  .channel-grid { grid-template-columns: 1fr; }
  .controls-actions { flex-wrap: wrap; }
  .controls-actions .button { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
