@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;

  --bg:            #EEF1F6;
  --surface:       #FFFFFF;
  --surface-sunk:  #E4E9F2;
  --ink:           #0E1520;
  --ink-2:         #55627A;
  --ink-3:         #8492AB;
  --line:          #D5DCE8;

  --accent:        #2B4CE0;
  --accent-ink:    #FFFFFF;
  --accent-soft:   #E3E8FD;

  --ok:            #0E8F63;
  --ok-soft:       #DCF3EA;
  --warn:          #B4720C;
  --warn-soft:     #FBEEDA;
  --stop:          #C0392B;
  --stop-soft:     #FBE4E1;

  --radius:        14px;
  --radius-sm:     10px;
  --gap:           14px;
  --pad:           18px;

  --knob:          #FFFFFF;

  --shadow: 0 1px 2px rgba(14, 21, 32, .05), 0 6px 20px rgba(14, 21, 32, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #0B1017;
    --surface:      #141B26;
    --surface-sunk: #1D2634;
    --ink:          #E7ECF4;
    --ink-2:        #9FADC4;
    --ink-3:        #6C7B93;
    --line:         #263141;

    --accent:       #6E8BFF;
    --accent-ink:   #0B1017;
    --accent-soft:  #1B2647;

    --ok:           #3FBF90;
    --ok-soft:      #102A22;
    --warn:         #D9A052;
    --warn-soft:    #2C2214;
    --stop:         #E4796C;
    --stop-soft:    #2E1A18;
    --knob:         #C9D3E2;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --bg: #0B1017; --surface: #141B26; --surface-sunk: #1D2634;
  --ink: #E7ECF4; --ink-2: #9FADC4; --ink-3: #6C7B93; --line: #263141;
  --accent: #6E8BFF; --accent-ink: #0B1017; --accent-soft: #1B2647;
  --ok: #3FBF90; --ok-soft: #102A22; --warn: #D9A052; --warn-soft: #2C2214;
  --stop: #E4796C; --stop-soft: #2E1A18; --knob: #C9D3E2;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
}

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

html { overflow-y: scroll; scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 88px;

  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 480px; margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top, 0px))
           max(16px, env(safe-area-inset-right))
           0
           max(16px, env(safe-area-inset-left));
}

:where(a, button, input, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}

h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; line-height: 1.15; }

.page-title {
  position: sticky; top: 0; z-index: 15;

  margin: calc(-22px - env(safe-area-inset-top, 0px)) -16px 18px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.page-title h1 { margin: 0; font-size: 21px; }

.page-reload { flex: none; margin: -4px -6px -4px 0; }
.page-reload button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  color: var(--ink-2);
  background: none; border: 0; border-radius: 50%;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.page-reload button:active { background: var(--surface-sunk); color: var(--accent); }

.page-reload.htmx-request button { color: var(--accent); }
.page-reload.htmx-request svg { animation: page-spin .7s linear infinite; }
@keyframes page-spin { to { transform: rotate(360deg); } }
@media (min-width: 900px) { .page-reload { display: none; } }
.page-title + .sub { margin-top: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 26px 0 10px; color: var(--ink-2); }
.sub { color: var(--ink-2); font-size: 14px; margin: 0 0 18px; }
.sub code { font-size: 13px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }

/* ── cards ───────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--gap); }

.hero {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px var(--pad);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.hero-row { display: flex; align-items: center; gap: 14px; }
.hero .dot {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
  display: grid; place-items: center; flex: none;
}
.hero .dot svg { width: 22px; height: 22px; }
.hero .dot.warn { background: var(--warn-soft); color: var(--warn); }
.hero .dot.stop { background: var(--stop-soft); color: var(--stop); }
.hero .state { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.hero .detail { color: var(--ink-2); font-size: 14px; }
.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; background: var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
}
.hero-stats div { background: var(--surface); padding: 11px 12px; }
.hero-stats dt { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.hero-stats dd {
  margin: 3px 0 0; font-size: 16px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── device list ─────────────────────────────────────────── */

.list { display: flex; flex-direction: column; gap: 1px; background: var(--line);
        border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.item {
  background: var(--surface); padding: 14px var(--pad);
  display: flex; align-items: center; gap: 13px;
  text-decoration: none; color: inherit;
}
a.item:active { background: var(--surface-sunk); }
.item.quiet { opacity: .55; }
.item .icon {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--surface-sunk); color: var(--ink-2);
  display: grid; place-items: center;
}
.item .icon svg { width: 20px; height: 20px; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 500; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--ink-3); font-size: 13px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .chev { color: var(--ink-3); flex: none; display: grid; place-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; padding: 4px 9px;
  border-radius: 20px; white-space: nowrap; flex: none;
  background: var(--surface-sunk); color: var(--ink-2);
}
.badge.on   { background: var(--accent-soft); color: var(--accent); }
.badge.full { background: var(--ok-soft);     color: var(--ok); }
.badge.off  { background: var(--surface-sunk); color: var(--ink-3); }

/* ── device rows ────────────────────────────────────────── */

.devs { display: flex; flex-direction: column; gap: 8px; }
.dev {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  padding: 11px 13px;
  box-shadow: var(--shadow);
}

.dev.safe {
  background: color-mix(in srgb, var(--ok-soft) 65%, var(--surface));
  border-left-color: var(--ok);
}
.dev.quiet { opacity: .62; }

.dev-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex: none;
  background: var(--surface-sunk); color: var(--ink-2);
  display: grid; place-items: center;
}
.dev-icon svg { width: 19px; height: 19px; }
.dev.safe .dev-icon { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }

.dev-body { min-width: 0; }

.dev-name { display: flex; align-items: center; min-height: 23px; }
.dev-title {
  font: inherit; font-weight: 500; letter-spacing: -.01em;
  line-height: 23px; color: inherit; text-align: left;
  background: none; border: 0; padding: 0; margin: 0;
  cursor: text; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.dev-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 5px; }
.dev-name.editing .dev-title { display: none; }
.dev-rename { display: flex; align-items: center; gap: 3px; width: 100%; }

.dev-rename[hidden] { display: none; }
.dev-rename input {
  flex: 1 1 auto; min-width: 0;
  height: 23px; padding: 0 7px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500;
}
.dev-rename input:focus { border-color: var(--accent); outline: none; }

.dev-rename .rename-act { inline-size: 23px; block-size: 23px; border-radius: 6px; }
.dev-meta { color: var(--ink-3); font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dev-addr {
  display: flex; flex-wrap: wrap; gap: 2px 9px; margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dev-addr .dev-mac { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.vpn-toggle {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 4px 5px 4px 9px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.vpn-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em;
  color: var(--ink-3);
  transition: color 150ms ease;
}
.vpn-tag svg { width: 13px; height: 13px; }
.switch {
  width: 42px; height: 25px; flex: none;
  padding: 3px; border-radius: 999px;
  background: var(--surface-sunk);
  display: block;
  transition: background 150ms ease;
}
.switch .knob {
  display: block; width: 19px; height: 19px; border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 3px rgba(9, 20, 40, .3);
  transition: translate 150ms ease;
}

.vpn-toggle[aria-checked="true"] {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}
.vpn-toggle[aria-checked="true"] .vpn-tag { color: var(--ok); }
.vpn-toggle[aria-checked="true"] .switch { background: var(--ok); }
.vpn-toggle[aria-checked="true"] .knob { translate: 17px 0; }
.vpn-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dev.safe .vpn-toggle { background: transparent; }

.dev-open {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex: none;
  background: var(--surface-sunk); color: var(--ink-3);
  display: grid; place-items: center; text-decoration: none;
}
.dev-open:active { color: var(--accent); }
.dev-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sorter { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 0 0 11px; }
.sorter-label { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.sort-group { display: flex; align-items: center; gap: 7px; }

.hide-off { margin-left: auto; }
.hide-off .vpn-tag { text-transform: none; letter-spacing: 0; font-size: 11px; font-weight: 500; }
.sort {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  text-decoration: none;
}
.sort.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.sort .dir { transition: rotate 150ms ease; }
.sort .dir.down { rotate: 180deg; }

.vh {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ── connection mode ─────────────────────────────────────── */

.modes { display: flex; flex-direction: column; gap: 10px; }
.mode {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 15px var(--pad);
}

.mode.selected,
.mode:has(input[type="radio"]:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode .radio {
  width: 20px; height: 20px; border-radius: 50%; flex: none; margin-top: 2px;
  border: 2px solid var(--ink-3); display: grid; place-items: center;
}
.mode input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.mode.selected .radio,
.mode:has(input[type="radio"]:checked) .radio { border-color: var(--accent); }
.mode.selected .radio::after,
.mode:has(input[type="radio"]:checked) .radio::after {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
}
.mode > span:last-child { display: block; }
.mode .name { display: block; font-weight: 600; letter-spacing: -.01em; }
.mode .desc { display: block; color: var(--ink-2); font-size: 13.5px; margin-top: 3px; line-height: 1.45; }

.mode.off { opacity: .62; }
.mode .why {
  display: block; margin-top: 6px; font-size: 13px; line-height: 1.45;
  color: var(--warn);
}

/* ── buttons ─────────────────────────────────────────────── */

.btn {
  display: block; width: 100%; text-align: center; text-decoration: none;
  padding: 14px 20px; border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
}
.btn.secondary { background: var(--surface-sunk); color: var(--ink); }
.btn.danger    { background: var(--stop-soft);   color: var(--stop); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn + .btn { margin-top: 10px; }
.linklike {
  background: none; border: 0; padding: 4px; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--ink-3);
}
.linklike:hover { color: var(--ink); }

/* ── key-value rows ──────────────────────────────────────── */

.rows { display: flex; flex-direction: column; margin: 0; }
.row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row:first-child { padding-top: 0; }
.row:last-child { border-bottom: none; padding-bottom: 0; }
.row dt { color: var(--ink-2); font-size: 14px; }
.row dd { margin: 0; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.row dd.ok { color: var(--ok); }
.row dd.warn { color: var(--warn); }
.row dd.stop { color: var(--stop); }

/* ── pagination ──────────────────────────────────────────── */

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px;
}
.pager .btn { width: auto; min-width: 0; padding: 11px 18px; font-size: 15px; }
.pager .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.pager-at { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ── notes ───────────────────────────────────────────────── */

.note {
  border-radius: var(--radius-sm); padding: 13px 15px;
  font-size: 14px; line-height: 1.5;
}
.note.info { background: var(--accent-soft); color: var(--accent); }
.note.warn { background: var(--warn-soft);   color: var(--warn); }
.note.ok   { background: var(--ok-soft);     color: var(--ok); }
.note.stop { background: var(--stop-soft);   color: var(--stop); }
.note + .note { margin-top: 10px; }

/* ── log ─────────────────────────────────────────────────── */

.log { display: flex; flex-direction: column; }
.log-item { display: flex; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.log-item:first-child { padding-top: 0; }
.log-item:last-child { border-bottom: none; padding-bottom: 0; }
.log-item .when {
  color: var(--ink-3); font-size: 12.5px; flex: none; width: 76px;
  font-variant-numeric: tabular-nums; padding-top: 1px;
}
.log-item .what { font-size: 14.5px; }
.log-item .who { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.log-item.bad .what { color: var(--stop); }

.log-item.auto { padding-left: 11px; margin-left: -11px; border-left: 2px solid var(--accent); }
.ai-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px 2px 5px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
}
.ai-tag svg { flex: none; }

/* ── connectivity bar ───────────────────────────────── */

.uptime { display: flex; align-items: end; gap: 2px; height: 26px; }
.uptime i { flex: 1 1 auto; min-width: 2px; border-radius: 2px; background: var(--ok); transition: filter 90ms ease; }
.uptime i.part { background: var(--warn); }
.uptime i.gap  { background: color-mix(in srgb, var(--stop) 70%, transparent); }

.uptime i.void { background: color-mix(in srgb, var(--ink-3) 22%, transparent); }
.uptime i.hot  { filter: brightness(1.25) saturate(1.2); }
.uptime-legend { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-3); margin-top: 6px; }

.spark-tip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 7px 10px;
  box-shadow: var(--shadow);
  font-size: 12px; line-height: 1.45; white-space: nowrap; color: var(--ink);
  opacity: 0; translate: 0 4px; transition: opacity 110ms ease, translate 110ms ease;
}
.spark-tip[data-show="1"] { opacity: 1; translate: 0 0; }
.spark-tip .tip-range { font-variant-numeric: tabular-nums; color: var(--ink-3); }
.spark-tip .tip-state { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.spark-tip .tip-state::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
}
.spark-tip[data-kind="part"] .tip-state::before { background: var(--warn); }
.spark-tip[data-kind="gap"]  .tip-state::before { background: var(--stop); }
.spark-tip .tip-pct { color: var(--ink-3); }

/* ── vpn switch ─────────────────────────────────────── */

.vpn { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.vpn-left { min-width: 0; flex: 1 1 220px; }
.vpn-state { font-size: 19px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.vpn-state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.vpn-state.on { color: var(--ok); }
.vpn-state.on::before { background: var(--ok); }
.vpn-state.off { color: var(--ink-2); }
.vpn-state.off::before { background: var(--ink-3); }
.vpn-note { margin: 6px 0 0; color: var(--ink-2); font-size: 13.5px; max-width: 46ch; }
.vpn form { flex: none; }
.vpn .btn { width: auto; min-width: 150px; padding: 12px 18px; font-size: 15px; }

/* ── site lists ──────────────────────────────────────────── */
.sites { list-style: none; margin: 0 0 12px; padding: 0;
         display: flex; flex-direction: column; gap: 1px;
         background: var(--line); border-radius: var(--radius); overflow: hidden; }
.sites li { display: flex; align-items: center; justify-content: space-between;
            gap: 10px; padding: 12px 14px; background: var(--surface); }
.sites li.empty { color: var(--ink-2); }
.sites .name { font-weight: 500; word-break: break-all; }
.sites form { margin: 0; }
.sites .btn { width: auto; min-width: 0; padding: 8px 12px; font-size: 14px; }
.siteadd { display: flex; gap: 8px; margin: 0 0 22px; }
.siteadd input { flex: 1; min-width: 0; padding: 11px 12px; font-size: 16px;
                 color: var(--ink); background: var(--surface);
                 border: 1px solid var(--line); border-radius: var(--radius-sm); }
.siteadd input:focus { border-color: var(--accent); outline: none; }
.siteadd .btn { width: auto; min-width: 0; padding: 10px 14px; font-size: 15px; }

/* ── login forms ─────────────────────────────────────────── */

.form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.form input {
  font: inherit; font-size: 16px;
  padding: 13px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
  width: 100%;
}
.form input:focus { border-color: var(--accent); outline: none; }
.alert {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px;
  background: var(--stop-soft); color: var(--stop);
}

/* ── empty state ─────────────────────────────────────────── */

.empty { color: var(--ink-3); font-size: 14px; padding: 6px 0 2px; }
.foot { color: var(--ink-3); font-size: 12.5px; margin-top: 20px; }

/* ── traffic bar ─────────────────────────────────────────── */

.gauge {
  margin-top: 14px; height: 8px; border-radius: 4px;
  background: var(--surface-sunk); overflow: hidden;
}

.sub { display: flex; flex-direction: column; gap: 16px; }
.sub-row { display: flex; align-items: center; gap: 12px; min-height: 24px; }
.sub-key { color: var(--ink-2); font-size: 14px; flex: none; }
.sub-val {
  margin-left: auto; text-align: right; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.sub-val.stop { color: var(--stop); }
.sub .gauge { flex: 1 1 50px; min-width: 36px; margin: 0; height: 10px; border-radius: 5px; }
.sub .gauge i { border-radius: 5px; }

.inf { font-size: 19px; line-height: 1; vertical-align: -2px; }
.gauge i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.gauge i.full { background: var(--stop); }

/* ── theme toggle ────────────────────────────────────────── */

.theme {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--line); border-radius: var(--radius-sm); overflow: hidden;
}
.theme button {
  font: inherit; font-size: 14px; padding: 12px 8px; cursor: pointer;
  border: none; background: var(--surface); color: var(--ink-2);
}
.theme button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ── navigation feedback ─────────────────────────────── */

#progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%; opacity: 0;
  z-index: 100; pointer-events: none;
}

body.loading #progress { opacity: 1; animation: crawl 1.2s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes crawl { 0% { transform: scaleX(0); } 55% { transform: scaleX(.65); } 100% { transform: scaleX(.9); } }

@media (prefers-reduced-motion: no-preference) {
  .view-enter { animation: enter 150ms ease both; }
}
@keyframes enter { from { opacity: 0; } }

/* ── bottom nav ──────────────────────────────────────────── */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}

.tabbar .inner { max-width: 520px; margin: 0 auto; display: grid;
                 grid-auto-flow: column; grid-auto-columns: 1fr; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; text-decoration: none; color: var(--ink-3); font-size: 11px;

  min-width: 0; overflow: hidden;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--accent); }

.tab span { display: none; }

body.bare { padding-bottom: 24px; }
body.bare .app { padding-top: 6vh; }

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

/* ======================== desktop ======================== */

@media (min-width: 900px) {
  body { padding-bottom: 40px; padding-left: 248px; }
  body.bare { padding-left: 0; }

  .app { max-width: 760px; padding: 34px 32px 0; margin: 0; }
  body.bare .app { margin: 0 auto; max-width: 480px; }

  h1 { font-size: 32px; }

  .page-title {
    position: absolute; width: 1px; height: 1px;
    margin: 0; padding: 0; min-height: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
    background: none; box-shadow: none; border: none;
  }
  .page-title h1 { font-size: 24px; }
  .sub { font-size: 15px; margin-bottom: 24px; }
  h2 { font-size: 16px; margin: 34px 0 12px; }

  .tabbar {
    top: 0; bottom: 0; right: auto; width: 248px;
    border-top: none; border-right: 1px solid var(--line);
    padding: 34px 16px; backdrop-filter: none;
    background: var(--surface);
    display: flex; flex-direction: column;
  }
  .tabbar .inner { grid-auto-flow: row; grid-auto-columns: auto;
                   grid-template-columns: 1fr; gap: 3px; max-width: none; align-content: start; }
  .tab {
    flex-direction: row; justify-content: flex-start; align-items: center;
    gap: 12px; padding: 11px 14px; border-radius: 10px; font-size: 15px;
  }
  .tab span { display: inline; }
  .tab.active { background: var(--accent-soft); }
  .tab svg { width: 20px; height: 20px; }

  .card, .hero { padding: 22px 24px; }
  .item { padding: 16px 24px; }
  .mode { padding: 17px 22px; }

  .btn { display: inline-block; width: auto; min-width: 220px; }
  .btn + .btn { margin-top: 0; margin-left: 10px; }
  .form .btn { min-width: 0; }
}

@media (min-width: 1500px) {
  .app { max-width: 860px; }
}

.debug {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-3);
  opacity: .65;
  word-break: break-word;
}

.nodes-card { display: flex; flex-direction: column; gap: 16px; }

.nodes-card .label {
  display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 7px;
}

.pick-row { display: flex; gap: 8px; align-items: stretch; max-width: 560px; }
.pick-row form:first-child { flex: 1; min-width: 0; }
.pick-row form { margin: 0; }
.nodes-card .refresh {
  padding: 11px 15px;
  font: inherit; font-size: 14px;
  color: var(--ink);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.nodes-card .refresh:hover { border-color: var(--accent); color: var(--accent); }
.nodes-card .refresh:disabled { opacity: .55; cursor: default; }

.nodes-card select {
  width: 100%; max-width: 440px;
  padding: 11px 38px 11px 12px;
  font: inherit; font-size: 15px;
  color: var(--ink);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  appearance: none;

  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
                    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.nodes-card select:disabled { opacity: .65; background-image: none; }

.nodes-card .check {
  display: flex; align-items: flex-start; gap: 10px;
  cursor: pointer; line-height: 1.45;
}
.nodes-card .check input { margin-top: 3px; flex: none; accent-color: var(--accent); }
.nodes-card .hint { font-size: 13px; color: var(--ink-3); line-height: 1.5; margin: 0; }
.nodes-card .node-pick .hint { margin-top: 7px; }

.nodes-card .rotation summary {
  cursor: pointer; font-size: 14.5px; font-weight: 600;
  padding: 2px 0; user-select: none;
}
.nodes-card .rotation .hint { margin: 8px 0 12px; }

.rot-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) {
  .rot-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
}

.node-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1.3;
}
.node-row input { flex: none; accent-color: var(--accent); }
.node-row.now { border-color: var(--accent); background: var(--accent-soft); }

.node-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-badge {
  font-size: 11.5px; font-weight: 600; color: var(--accent);
  white-space: nowrap;
}

.node-right { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.node-delay {
  font-size: 13px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.node-delay.dim { color: var(--ink-3); }

/* ── pending overlay ─────────────────────────────────────── */

.busy[hidden] { display: none; }

.busy {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  padding: 24px; text-align: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(3px);
}

.busy-text { margin: 0; font-size: 15px; color: var(--ink); max-inline-size: 22em; }
.busy-spin {
  inline-size: 28px; block-size: 28px; border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: busy-turn 700ms linear infinite;
}
@keyframes busy-turn { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .busy-spin { animation-duration: 2.4s; }
}

.mono-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  font-size: 12.5px; letter-spacing: .02em; color: var(--ink-3);
  margin-block-start: -6px;
}

/* ── device rename ──────────────────────────────────────── */

.rename-field { position: relative; display: flex; align-items: center; }
.rename-field input {
  font: inherit; font-size: 16px;
  padding: 13px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
  width: 100%;
}
.rename-field input:focus { border-color: var(--accent); outline: none; }
.rename-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.rename-acts {
  position: absolute; inset-inline-end: 5px;
  display: none; gap: 2px;
}

.rename.dirty .rename-acts { display: flex; }
.rename.dirty .rename-field input { padding-inline-end: 86px; }

@media (scripting: none) {
  .rename-acts { display: flex; }
  .rename-field input { padding-inline-end: 86px; }
}

.noscript-only { display: none; }
@media (scripting: none) { .noscript-only { display: block; } }

.rename-act {
  display: grid; place-items: center;
  inline-size: 38px; block-size: 38px;
  padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--ink-3); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rename-act.save { color: var(--accent); }
.rename-act:active { background: var(--surface-sunk); }
.rename-act:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (prefers-reduced-motion: no-preference) {
  .rename.dirty .rename-act { animation: rename-in 120ms ease-out both; }
}
@keyframes rename-in { from { opacity: 0; transform: scale(.86); } }

.rename-hint { margin-block: 10px 0; }

.card.tight { padding-block: 14px; }

/* ── web app ────────────────────────────────────────────── */

html { touch-action: pan-x pan-y; }

html, body { overscroll-behavior: none; }

* { -webkit-tap-highlight-color: transparent; }

button, .btn, .tabbar, .page-reload, .switch, .vpn-tag, .dev-open, .fab, label {
  -webkit-user-select: none; user-select: none;
}
a, button { -webkit-touch-callout: none; }

@media (hover: none) {
  .btn:active { filter: brightness(0.88); scale: 0.98; }
  .tab:active { color: var(--ink); }
}

.fab { display: none; }
@media (hover: none) {
  .standalone .fab {
    position: fixed; z-index: 25;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 66px);
    left: max(16px, calc(env(safe-area-inset-left) + 8px));
    display: grid; place-items: center; width: 52px; height: 52px; padding: 0;
    border-radius: 50%; border: 1px solid var(--line); color: var(--ink);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px -8px rgb(0 0 0 / .45);
    cursor: pointer;
  }
  .standalone .fab svg { width: 22px; height: 22px; }
  .standalone .fab:active { background: var(--surface-sunk); scale: .94; }

  .standalone #view:has(.fab) { padding-bottom: 72px; }
}

/* ── notifications ────────────────────────────────────────── */

.push-offer {
  margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--ink); font-size: 14px; line-height: 1.45;
}
.push-offer[hidden] { display: none; }
.push-offer[data-state="denied"],
.push-offer[data-state="broken"],
.push-offer[data-state="offline"] { background: var(--warn-soft); }
.push-offer-text { margin: 0; }
.push-offer ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 3px; }
.push-offer .push-offer-btn { margin-top: 10px; padding: 11px 16px; font-size: 15px; }
.push-offer .push-offer-btn[disabled] { opacity: .6; }

/* ── guest wi-fi ──────────────────────────────────────────── */

.wifi-btn { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0 4px; }
.wifi-btn svg { width: 20px; height: 20px; flex: none; }
.wifi-radio { position: absolute; opacity: 0; pointer-events: none; }
.wifi-share.toggle .wifi-card { display: none; }
#wifi-5:checked ~ .wifi-card[data-band="5"],
#wifi-24:checked ~ .wifi-card[data-band="24"] { display: block; }
.wifi-card { display: grid; gap: 10px; }
.wifi-qr-box { background: #fff; border-radius: var(--radius-sm); padding: 6px; width: min(100%, 280px); margin: 0 auto; }
.wifi-qr { display: block; width: 100%; height: auto; }
.wifi-hint { text-align: center; color: var(--ink-2); font-size: 14px; margin: 0 0 4px; }
.wifi-pass { font-family: ui-monospace, "SF Mono", Menlo, monospace; user-select: all; -webkit-user-select: all; word-break: break-all; }
.wifi-seg { display: flex; gap: 4px; padding: 4px; margin: 0 0 var(--gap); border-radius: var(--radius-sm); background: var(--surface-sunk); }
.wifi-seg label { flex: 1; text-align: center; padding: 10px 8px; border-radius: 8px; font-weight: 600; font-size: 15px; color: var(--ink-2); cursor: pointer; }
#wifi-5:checked ~ .wifi-seg label[for="wifi-5"],
#wifi-24:checked ~ .wifi-seg label[for="wifi-24"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.wifi-radio:focus-visible ~ .wifi-seg { outline: 2px solid var(--accent); outline-offset: 2px; }
