:root {
  --bg: #0a0b0f;
  --bg-2: #0f1117;
  --panel: #14161d;
  --panel-2: #1a1d26;
  --panel-3: #212531;
  --line: #262a37;
  --line-2: #343a4c;
  --text: #e9ebf1;
  --muted: #959cb0;
  --faint: #5f667a;
  --accent: #4f86f7;
  --accent-2: #38bdf8;
  --accent-soft: rgba(79, 134, 247, 0.14);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --grad: linear-gradient(135deg, #4f86f7 0%, #38bdf8 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
::selection { background: rgba(124, 108, 255, 0.4); }
button, input, select, textarea { font: inherit; color: inherit; }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.ico { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ico svg { display: block; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { background: var(--panel-3); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .tab:focus-visible, .tree-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--grad); filter: brightness(1.12); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
.btn-icon { width: 32px; padding: 0; justify-content: center; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn-danger:hover { color: var(--bad); }
.btn-active { background: var(--accent-soft); border-color: rgba(124, 108, 255, 0.5); color: #cfc9ff; }

.input, .select, .textarea {
  width: 100%; height: 30px; padding: 0 9px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--bad); }
.textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.mono { font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; }
input[type='color'] { padding: 2px; height: 30px; width: 44px; cursor: pointer; }
input[type='checkbox'] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.panel-head .grow { flex: 1; }
.section { padding: 12px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section-title { font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); margin: 0 0 9px; }

.field { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.field.has-reset { grid-template-columns: 92px 1fr auto; }
.field > label { color: var(--muted); font-size: 12.5px; }
.field-row { display: flex; gap: 6px; }
.field-reset { width: 20px; height: 20px; border: 0; background: transparent; color: var(--faint); cursor: pointer; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: 15px; line-height: 1; }
.field-reset:hover { color: var(--text); background: var(--panel-2); }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tab {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--panel-3); color: var(--muted); font-size: 11px; font-weight: 600; }
.badge.warn { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
.badge.bad { background: rgba(248, 113, 113, 0.16); color: var(--bad); }
.badge.good { background: rgba(52, 211, 153, 0.16); color: var(--good); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.kbd { font: 11px ui-monospace, Consolas, monospace; padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); }

.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.01em; font-size: 15px; }
.logo-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 4px 14px rgba(79, 134, 247, 0.4); }

.menu { position: absolute; z-index: 60; min-width: 220px; padding: 5px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 9px; background: none; border: 0; border-radius: 6px; color: var(--text); cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--panel-3); }
.menu-item:disabled { opacity: 0.4; cursor: not-allowed; }
.menu-item .kbd { margin-left: auto; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }

dialog { padding: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); max-width: min(760px, 94vw); width: 100%; }
dialog::backdrop { background: rgba(4, 5, 8, 0.7); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-body { padding: 20px; }
.dialog-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; background: var(--panel-3); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; animation: toast-in 0.18s ease-out; }
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.status { font-size: 13px; min-height: 1.4em; margin: 8px 0 0; color: var(--muted); }
.status.good { color: var(--good); }
.status.bad { color: var(--bad); }
.code { font: 700 22px ui-monospace, Consolas, monospace; letter-spacing: 0.16em; }
ul.players { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
ul.players li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.22); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); } }

/* Fingers: bigger targets, and 16 px text in fields so iPhones do not zoom the page when one is focused. */
@media (pointer: coarse) {
  .input, .select, .textarea { font-size: 16px; }
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; }
}
@media (pointer: coarse) { .menu-item .kbd { display: none; } }
