:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0d11;
  color: #f4f6fb;
  --panel: rgba(22, 25, 32, 0.94);
  --border: rgba(255, 255, 255, 0.09);
  --muted: #9ca5b5;
  --accent: #7fd49a;
  --accent-strong: #3fae6a;
  --danger: #ff727f;
  --ok: #67d69d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% -10%, rgba(46, 125, 50, 0.28), transparent 38rem),
    #0b0d11;
}

body {
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

button, input { font: inherit; }

.shell {
  width: min(720px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 4px 16px;
}

.hero h1 { margin: 0; font-size: clamp(28px, 7vw, 42px); }
.hero p { margin: 5px 0 0; color: var(--muted); }

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
}

.card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.18);
}

.card.compact { padding: 16px 18px; }
.card.warning { border-color: rgba(255, 183, 77, 0.35); }
.card h2 { margin: 0 0 14px; font-size: 18px; }
.card p { line-height: 1.5; }

label {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: #dfe4ef;
}

input[type="text"],
input[type="url"],
input:not([type]) {
  width: 100%;
}

input {
  border: 1px solid var(--border);
  background: #0e1117;
  color: #f4f6fb;
  border-radius: 13px;
  padding: 12px 13px;
  outline: none;
}

input:focus {
  border-color: rgba(127, 212, 154, 0.72);
  box-shadow: 0 0 0 3px rgba(127, 212, 154, 0.1);
}

input[type="range"] {
  accent-color: var(--accent);
  padding: 0;
}

.actions, .button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.actions.single {
  grid-template-columns: 1fr;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 13px;
  padding: 0 14px;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background .12s ease;
}

button:active:not(:disabled) { transform: scale(.985); }
button:disabled { opacity: .42; cursor: default; }

button.primary {
  background: var(--accent-strong);
  color: white;
  font-weight: 700;
}

button.secondary {
  background: #272d38;
  color: #edf1f8;
}

.pill {
  justify-self: end;
  white-space: nowrap;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #292e38;
  color: #b5bdcb;
}

.pill.online { color: #072516; background: var(--ok); }
.pill.connecting { color: #191407; background: #f4cd65; }
.pill.error { color: #2c080b; background: var(--danger); }

.muted { color: var(--muted); }
.hidden { display: none !important; }

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.toggle-row small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.toggle-row input {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-row h2, .section-row p { margin-bottom: 0; }

.level-wrap {
  width: 82px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #0d1015;
}

.level {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--ok);
  transition: width 80ms linear;
}

footer {
  text-align: center;
  color: #707989;
  padding: 10px;
  font-size: 12px;
}

@media (max-width: 560px) {
  .hero { grid-template-columns: auto 1fr; }
  .hero .pill { grid-column: 1 / -1; justify-self: start; }
  .actions, .button-grid { grid-template-columns: 1fr; }
}

details summary {
  cursor: pointer;
  color: var(--muted);
  margin-top: 6px;
}

.diag-log {
  max-height: 260px;
  overflow: auto;
  margin: 10px 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
