:root {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1f2840;
  --border: #2a3550;
  --text: #e8ecf5;
  --muted: #9aa5bf;
  --accent: #6c8cff;
  --accent-text: #0b1020;
  --ok: #3ccf8e;
  --bad: #ff6b6b;
  --warn: #f4c152;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef1f8;
    --border: #d9deea;
    --text: #141a29;
    --muted: #5b6680;
    --accent: #3b5bdb;
    --accent-text: #ffffff;
    --ok: #12a26a;
    --bad: #d6363c;
    --warn: #b9850f;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9em; }

.top {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 20px 16px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 1.5rem; margin: 0; letter-spacing: .02em; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }

main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 24px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: .85rem; }

.hosts {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin: 12px 0 28px;
}
.host {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.host-head { display: flex; gap: 12px; align-items: center; }
.host-title h3 { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.host-addr { margin: 0; color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.host-status { margin: 0; color: var(--muted); font-size: .9rem; min-height: 2.7em; }
.host-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--warn); flex: none; }
.host[data-status="online"] .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); }
.host[data-status="offline"] .dot { background: var(--bad); }
.host[data-status="checking"] .dot { animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }

.empty {
  text-align: center; background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 32px 16px; margin: 12px 0 28px;
}
.empty h2 { margin-top: 0; }
.empty p { color: var(--muted); max-width: 520px; margin: 0 auto 16px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.panel h2 { margin-top: 0; }
.steps { padding-left: 1.2em; margin: 0; }
.steps li { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }
details { margin-top: 6px; }
summary { cursor: pointer; color: var(--accent); }

.code {
  display: flex; gap: 8px; align-items: flex-start; margin-top: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.code code { flex: 1; overflow-wrap: anywhere; white-space: pre-wrap; min-width: 0; }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  width: min(460px, calc(100vw - 32px)); padding: 20px;
}
dialog::backdrop { background: rgb(0 0 0 / .55); }
dialog h2 { margin-top: 0; }
dialog label { display: block; margin-bottom: 12px; font-weight: 600; font-size: .95rem; }
dialog input {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
dialog input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.error { color: var(--bad); margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-weight: 600; max-width: calc(100vw - 32px); z-index: 10;
}
.foot { max-width: 1100px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: .85rem; }
