@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap");

:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #181c26;
  --line: #262b38;
  --text: #e8ebf2;
  --muted: #8b93a7;
  --live: #ff2d55;
  --live-glow: rgba(255, 45, 85, .35);
  --ok: #22c55e;
  --warn: #f59e0b;
  --accent: #3b82f6;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Inter", "Segoe UI", system-ui, sans-serif; }
a { color: #8fb6ff; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .92em; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: #3a4152; background: #1e2330; }
.btn:focus-visible, .tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: #2a1117; border-color: #5b1a28; color: #ff8aa0; }
.btn.danger:hover { background: #3a1520; }
.btn.live { background: var(--live); border-color: var(--live); color: #fff; box-shadow: 0 0 0 4px var(--live-glow); }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 28px; min-height: 28px; padding: 0; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel > header h2 { margin: 0; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; flex: 1; }
.panel .body { padding: 14px; }

.pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4b5263; }
.pill.ok { color: var(--text); } .pill.ok::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.warn { color: var(--text); } .pill.warn::before { background: var(--warn); }
.pill.bad { color: var(--text); } .pill.bad::before { background: var(--live); }

label.field { display: grid; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0d1017; color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: #0d1017; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13px; user-select: none; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 99px; background: #2b3140; position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

.meter { height: 10px; border-radius: 99px; background: #0d1017; border: 1px solid var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22c55e 0%, #22c55e 65%, #f59e0b 85%, #ff2d55 100%); background-size: 100vw 100%; transition: width .08s linear; }

.toast { position: fixed; left: 50%; bottom: 20px; translate: -50% 0; background: #1f2430; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 9999; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.err { border-color: #5b1a28; color: #ff9db0; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
dialog form { display: grid; gap: 14px; padding: 18px; }
dialog h3 { margin: 0; font-size: 18px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
