/* Home — dark, glowing, tile based. Tokens first, so a theme is one block. */
:root {
  --bg0: #0b0d1a;
  --bg1: #121531;
  --card: rgba(22, 26, 56, 0.78);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-border-hi: rgba(140, 170, 255, 0.28);
  --text: #e9ecff;
  --muted: #8d93bb;
  --faint: #5c6290;
  --accent: #5ad1ff;
  --accent-2: #9d7bff;
  --ok: #4de3a0;
  --warn: #ffb03a;
  --bad: #ff5d73;
  --track: rgba(255, 255, 255, 0.10);
  --radius: 18px;
  --gap: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 700px at 15% -10%, #1a1f4d 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 20%, #23184a 0%, transparent 55%),
              linear-gradient(180deg, var(--bg1), var(--bg0) 60%);
  background-attachment: fixed;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ---- header --------------------------------------------------------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 20px; font-weight: 650; letter-spacing: 0.2px; margin: 0; }
.hubdot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 0 transparent; transition: all .3s; }
.hubdot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.hubdot.bad { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.pill { font-size: 11px; font-family: var(--mono); letter-spacing: .6px; text-transform: uppercase; color: var(--muted);
        border: 1px solid var(--card-border); padding: 3px 8px; border-radius: 999px; }
.meta { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* ---- layout --------------------------------------------------------- */
#app { display: flex; flex-direction: column; gap: 22px; }
.section-title { font-size: 11px; font-family: var(--mono); letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); margin: 0 0 10px 4px; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 16px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
  transition: border-color .25s;
}
.card.busy { border-color: var(--card-border-hi); }
.card.offline { opacity: .55; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head .title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-head .name { font-weight: 620; font-size: 15px; }
.card-head .sub { font-size: 12px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- switch --------------------------------------------------------- */
.switch { position: relative; width: 50px; height: 30px; flex: none; border-radius: 999px; background: var(--track); border: none; cursor: pointer; transition: background .25s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .25s; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; }

/* ---- light hero ----------------------------------------------------- */
.hero { display: flex; align-items: center; gap: 16px; }
.swatch { width: 72px; height: 72px; border-radius: 50%; flex: none; background: #333; transition: background .3s, box-shadow .3s; border: 2px solid rgba(255,255,255,.12); }
.hero .big { font-size: 28px; font-weight: 650; line-height: 1.05; }
.hero .small { font-size: 13px; color: var(--muted); font-family: var(--mono); margin-top: 4px; }

/* ---- sliders -------------------------------------------------------- */
.row { display: flex; flex-direction: column; gap: 6px; }
.row .label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-family: var(--mono); letter-spacing: .4px; }
.row .label b { color: var(--text); font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: var(--slider-bg, var(--track)); }
input[type=range]::-moz-range-track { height: 8px; border-radius: 999px; background: var(--slider-bg, var(--track)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px; border-radius: 50%; background: #fff; border: 3px solid var(--bg0); box-shadow: 0 2px 8px rgba(0,0,0,.5); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--bg0); }
input[type=range]:disabled { opacity: .45; }

/* ---- presets -------------------------------------------------------- */
.presets { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chip { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.14); cursor: pointer; padding: 0; transition: transform .15s, border-color .15s; }
.chip:active { transform: scale(.92); }
.chip.active { border-color: #fff; box-shadow: 0 0 0 2px var(--bg0), 0 0 14px currentColor; }
.chip.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); position: relative; overflow: hidden; }
.chip.custom input { position: absolute; inset: -10px; width: 200%; height: 200%; opacity: 0; cursor: pointer; }

/* ---- buttons / misc ------------------------------------------------- */
.btn { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--card-border); border-radius: 12px; padding: 9px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.btn:active { background: rgba(255,255,255,.14); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b0d1a; border: none; font-weight: 650; }
.btn:disabled { opacity: .5; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.kv .v { text-align: right; font-weight: 560; }
.status-line { font-size: 13px; color: var(--muted); }
.status-line.on { color: var(--ok); }
.status-line.off { color: var(--faint); }
.status-line.warn { color: var(--warn); }
.caps { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--card-border); border-radius: 8px; padding: 3px 7px; }

/* ---- circadian timeline -------------------------------------------- */
.timeline { position: relative; height: 14px; border-radius: 999px;
  background: linear-gradient(90deg, #fff4e0 0%, #ffa03c 2%, #ff5a00 25%, #ff0000 75%, #b30000 100%); opacity: .95; }
.timeline .now { position: absolute; top: -5px; width: 4px; height: 24px; border-radius: 2px; background: #fff; box-shadow: 0 0 8px #fff; transform: translateX(-2px); }
.timeline-labels { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 6px; }

.loading { color: var(--muted); font-family: var(--mono); text-align: center; padding: 40px 0; }
.foot { text-align: center; font-family: var(--mono); font-size: 11px; color: var(--faint); padding: 26px 0 8px; }
.error-banner { background: rgba(255,93,115,.12); border: 1px solid rgba(255,93,115,.35); color: #ffb6c1; border-radius: 12px; padding: 10px 14px; font-size: 13px; }

@media (max-width: 420px) {
  body { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .card { padding: 14px; }
  .hero .big { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- login ---------------------------------------------------------- */
.login-overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(180deg, var(--bg1), var(--bg0)); z-index: 10; }
.login-card { width: min(100%, 360px); display: flex; flex-direction: column; gap: 14px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 24px;
  backdrop-filter: blur(14px); }
.login-title .name { font-size: 22px; font-weight: 650; }
.login-title .sub { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.login-card input { font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px; color: var(--text);
  background: rgba(0,0,0,.25); border: 1px solid var(--card-border); outline: none; }
.login-card input:focus { border-color: var(--accent); }
.login-msg { min-height: 18px; font-size: 13px; color: var(--bad); }
.iconbtn { background: none; border: 1px solid var(--card-border); color: var(--muted); border-radius: 10px;
  width: 32px; height: 28px; margin-left: 10px; cursor: pointer; font-size: 15px; line-height: 1; }
