@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #07090d;
  --bg-raise: #0c1118;
  --surface: #111821;
  --surface-2: #17202b;
  --line: #212c39;
  --line-strong: #31404f;
  --text: #e7ecf2;
  --muted: #8f9bab;
  --faint: #5e6a7a;
  --steel: #7f9cc0;
  --accent: #3b82f6;
  --accent-hi: #6aa5ff;
  --accent-ink: #f5f9ff;
  --ok: #4ad295;
  --warn: #f0b350;
  --danger: #ff6b6b;
  --font: "Onest", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(90rem 40rem at 50% -18rem, rgba(59, 130, 246, .10), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
main { width: min(1080px, 100%); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) clamp(1.1rem, 4vw, 2rem) 5rem; }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: var(--accent-hi); }
code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .08em .4em;
  overflow-wrap: anywhere;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.lede { color: var(--muted); font-size: 1.08rem; max-width: 60ch; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 3px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.75rem; padding: 0 1.25rem;
  border-radius: 999px; border: 1px solid transparent;
  font: 600 .98rem/1 var(--font); text-decoration: none; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn svg { width: 1em; height: 1em; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #2f74e6; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--steel); }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(255, 107, 107, .45); }
.btn.danger:hover { background: rgba(255, 107, 107, .1); }
.btn.small { min-height: 2.1rem; padding: 0 .85rem; font-size: .88rem; }
.btn.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem clamp(1.1rem, 4vw, 2rem);
  background: rgba(7, 9, 13, .82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--text); text-decoration: none; font-weight: 650; font-size: 1.05rem; }
.brand-mark {
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px;
  background: linear-gradient(145deg, #4c8dff, #1d4ed8); color: #fff;
}
.brand-mark svg { width: 1rem; height: 1rem; margin-left: 2px; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-right form { margin: 0; }
.who { color: var(--muted); font-size: .95rem; }
.toplink { color: var(--muted); text-decoration: none; font-size: .95rem; }
.toplink:hover { color: var(--text); }
@media (max-width: 640px) { .who { display: none; } .topbar-right { gap: .75rem; } }

/* ---------- Login ---------- */
.page-login main { min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden; }
.beam {
  position: fixed; inset: -20vh -10vw auto auto; width: 70vw; height: 140vh;
  background: linear-gradient(200deg, rgba(106, 165, 255, .36), rgba(59, 130, 246, .09) 45%, transparent 70%);
  transform: rotate(28deg); transform-origin: top right;
  filter: blur(40px); pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: rotate(22deg) translateX(-4vw); opacity: .8; } }
.login {
  position: relative; width: min(420px, 100%);
  padding: clamp(1.75rem, 5vw, 2.5rem);
  background: linear-gradient(180deg, rgba(23, 32, 43, .86), rgba(14, 20, 28, .9));
  border: 1px solid var(--line-strong); border-radius: 24px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9), 0 0 0 1px rgba(106, 165, 255, .04) inset;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.login-mark {
  display: grid; place-items: center; width: 3.25rem; height: 3.25rem; border-radius: 15px; margin-bottom: 1.5rem;
  background: linear-gradient(145deg, #5a97ff, #1d4ed8); color: #fff;
  box-shadow: 0 10px 40px -8px rgba(59, 130, 246, .7);
}
.login-mark svg { width: 1.5rem; height: 1.5rem; margin-left: 3px; }
.login h1 { font-size: 2.1rem; font-weight: 700; margin-bottom: .4rem; }
.login .lede { font-size: 1rem; margin-bottom: 1.6rem; }
.login .alert { margin-bottom: 1.2rem; }

/* ---------- Forms ---------- */
.stack { display: grid; gap: 1.1rem; }
.field { display: grid; gap: .4rem; }
.field > span:first-child { font-weight: 600; font-size: .93rem; }
.field small, .hint { color: var(--muted); font-size: .86rem; }
input[type="text"], input:not([type]), input[type="password"] {
  width: 100%; min-height: 2.9rem; padding: .6rem .9rem;
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 12px;
  font: 400 1rem var(--font);
}
input:focus { outline: none; border-color: var(--accent-hi); box-shadow: 0 0 0 3px rgba(59, 130, 246, .25); }
input::placeholder { color: var(--faint); }
.with-btn { display: flex; gap: .5rem; align-items: center; }
.with-btn .btn { flex: none; }
.check { display: flex; align-items: center; gap: .65rem; font-weight: 500; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.panel {
  margin: 0; padding: 1.4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  display: grid; gap: 1rem; min-width: 0;
}
.panel legend { padding: 0 .4rem; margin-left: -.4rem; font-weight: 650; font-size: 1.05rem; }
.form-wide { max-width: 760px; }
.form-narrow { max-width: 460px; }
.alert {
  padding: .85rem 1rem; border-radius: 12px;
  background: rgba(255, 107, 107, .08); border: 1px solid rgba(255, 107, 107, .35); color: #ffc9c9;
}
.alert ul { margin: 0; padding-left: 1.1rem; }
.flash {
  margin: 0 0 1.25rem; padding: .8rem 1rem; border-radius: 12px;
  background: rgba(74, 210, 149, .08); border: 1px solid rgba(74, 210, 149, .3); color: #b6f0d3;
}

/* ---------- Home ---------- */
.hello { margin: clamp(1rem, 4vw, 2.5rem) 0 clamp(2rem, 5vw, 3rem); }
.hello h1 { font-size: clamp(2.4rem, 6.5vw, 4.25rem); font-weight: 700; letter-spacing: -0.035em; margin-bottom: .75rem; }
.svc-list { display: grid; gap: 1.25rem; }
.svc {
  display: grid; grid-template-columns: minmax(220px, 360px) 1fr; gap: clamp(1.25rem, 3vw, 2.25rem); align-items: center;
  padding: clamp(.9rem, 2vw, 1.1rem);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: 26px;
}
.svc-art {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10; border-radius: 18px; overflow: hidden;
  background:
    radial-gradient(60% 80% at 30% 20%, rgba(106, 165, 255, .55), transparent 60%),
    radial-gradient(70% 90% at 90% 100%, rgba(29, 78, 216, .6), transparent 60%),
    linear-gradient(160deg, #0f1b2e, #070b12);
}
.svc-art::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 28px);
}
.svc-glyph {
  position: relative; z-index: 1; display: grid; place-items: center;
  width: 4.5rem; height: 4.5rem; border-radius: 50%;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.svc-glyph svg { width: 1.8rem; height: 1.8rem; margin-left: 4px; }
.svc-body h2 { font-size: clamp(1.7rem, 3.5vw, 2.3rem); font-weight: 700; margin-bottom: .35rem; }
.svc-body p { color: var(--muted); font-size: 1.08rem; margin-bottom: 1.4rem; }
@media (max-width: 700px) { .svc { grid-template-columns: 1fr; } .svc-body { padding: 0 .4rem .5rem; } }
.empty { padding: 2.5rem; border: 1px dashed var(--line-strong); border-radius: 20px; color: var(--muted); }
.empty h1, .empty h2 { color: var(--text); font-size: 1.5rem; margin-bottom: .5rem; }
.empty.center { text-align: center; margin-top: 10vh; display: grid; gap: 1rem; justify-items: center; }

/* ---------- Breadcrumbs & page heads ---------- */
.crumbs { display: flex; gap: .6rem; color: var(--faint); font-size: .93rem; margin-bottom: 1.4rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs [aria-current] { color: var(--text); }
.page-head, .guide-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.25rem;
  margin-bottom: 2rem;
}
.page-head h1 { font-size: clamp(2rem, 4.5vw, 2.75rem); font-weight: 700; margin-bottom: .4rem; }
.guide-head h1 { font-size: clamp(2.4rem, 6vw, 3.75rem); font-weight: 700; letter-spacing: -0.035em; margin-bottom: .6rem; }

/* ---------- Guide ---------- */
.page-guide section + section { margin-top: 2.75rem; }
.page-guide h2 { font-size: 1.4rem; font-weight: 650; margin-bottom: 1rem; }
.creds {
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, .12), transparent 55%), var(--surface);
  border: 1px solid var(--line-strong); border-radius: 22px;
}
.creds-list { margin: 0; display: grid; gap: .1rem; }
.creds-list > div {
  display: grid; grid-template-columns: 9.5rem 1fr; gap: 1rem; align-items: center;
  padding: .75rem 0; border-top: 1px solid var(--line);
}
.creds-list > div:first-child { border-top: 0; padding-top: 0; }
.creds-list dt { color: var(--muted); font-size: .93rem; }
.creds-list dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; min-width: 0; }
.creds-list code { font-size: 1rem; padding: .3em .6em; }
.secret { filter: blur(6px); transition: filter .15s ease; user-select: none; }
.secret.revealed, .secret:focus { filter: none; user-select: text; }
.note { margin-top: 1rem; color: var(--warn); }
@media (max-width: 560px) { .creds-list > div { grid-template-columns: 1fr; gap: .35rem; } }

.device-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.device-tab {
  min-height: 2.6rem; padding: 0 1rem; border-radius: 999px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
  font: 500 .95rem var(--font); cursor: pointer;
}
.device-tab:hover { color: var(--text); border-color: var(--line-strong); }
.device-tab[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 650; }
.device-panel {
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
}
.js .device-panel[data-hidden] { display: none; }
html:not(.js) .device-tabs { display: none; }
html:not(.js) .device-panel + .device-panel { margin-top: 1rem; }
.device-panel h3 { font-size: 1.6rem; font-weight: 700; }
.app-name { color: var(--muted); margin: .3rem 0 1.5rem; }
.app-name strong { color: var(--steel); }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 1.1rem; max-width: 68ch; }
.steps li { counter-increment: step; position: relative; padding-left: 3rem; min-height: 2rem; font-size: 1.04rem; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: -.1rem;
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: rgba(59, 130, 246, .16); color: var(--accent-hi); border: 1px solid rgba(106, 165, 255, .35);
  font-weight: 700; font-size: .92rem;
}
.tip {
  margin-top: 1.5rem; padding: 1rem 1.1rem; max-width: 68ch;
  border-left: 3px solid var(--steel); background: var(--bg-raise); border-radius: 0 12px 12px 0;
  color: var(--muted);
}
.tip strong { color: var(--text); }
.help { color: var(--muted); max-width: 68ch; }
.help ul { padding-left: 1.1rem; margin: 0 0 1rem; display: grid; gap: .5rem; }
.help strong, .help h2 { color: var(--text); }
.addr { display: block; margin-top: .45rem; }

/* ---------- Admin ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th, .table td { text-align: left; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .88rem; background: var(--bg-raise); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.row-link { color: var(--text); font-weight: 600; text-decoration: none; }
.row-link:hover { color: var(--accent-hi); text-decoration: underline; }
.chip { display: inline-block; padding: .15rem .65rem; border-radius: 999px; background: rgba(59, 130, 246, .14); color: var(--accent-hi); font-size: .85rem; font-weight: 500; }
.status { font-size: .9rem; font-weight: 500; }
.status::before { content: ""; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; margin-right: .45rem; vertical-align: .1em; }
.status.on::before { background: var(--ok); }
.status.off { color: var(--muted); }
.status.off::before { background: var(--faint); }
.danger-zone {
  max-width: 760px; margin-top: 3rem; padding: 1.4rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  border: 1px solid rgba(255, 107, 107, .3); border-radius: 18px;
}
.danger-zone h2 { font-size: 1.1rem; margin-bottom: .25rem; }

@media (prefers-reduced-motion: reduce) {
  .beam { animation: none; }
  .btn, .secret { transition: none; }
}
.steps code { font-size: .84em; }
