:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4d;
  --text: #e8eef7;
  --muted: #8fa3bf;
  --accent: #3d8bfd;
  --accent-dim: #2563b8;
  --danger: #f87171;
  --ok: #4ade80;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1b2838 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--sans);
}

.hidden { display: none !important; }

#app { min-height: 100vh; }

.panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--border);
  border-radius: 12px;
}

h1, h2 { margin: 0; font-weight: 600; }

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1218;
  color: var(--text);
  font: inherit;
}

input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  border-color: var(--accent);
}

.btn {
  border: 1px solid var(--border);
  background: #121a24;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: inherit;
  cursor: pointer;
}

.btn:hover:not(:disabled) { border-color: var(--muted); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent-dim);
  color: white;
}

.btn.ghost {
  background: transparent;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.status-line {
  margin: 0.75rem 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.status-line.ok { color: var(--ok); }

#auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  width: min(100%, 380px);
  padding: 1.5rem;
}

.auth-form .btn { width: 100%; margin-top: 1rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  padding: 1rem;
}

.connect-panel,
.player-panel {
  padding: 1rem 1.25rem 1.25rem;
}

.meta-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.meta-row span { color: var(--muted); }

.meta-row strong {
  font-family: var(--mono);
  font-weight: 500;
}

.service-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.label {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.dls {
  min-height: 2.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #0d1218;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.player-controls {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.meta-small {
  margin: 0.35rem 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.services-block {
  margin: 1rem 0;
}

.services-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.services-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.badge {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #243044;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  text-align: center;
}

.hint {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.services-table-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.services-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.services-table th,
.services-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.services-table th {
  position: sticky;
  top: 0;
  background: #121a24;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.services-table tbody tr:hover {
  background: rgba(61, 139, 253, 0.08);
}

.services-table tbody tr.active {
  background: rgba(61, 139, 253, 0.18);
}

.services-table .sid {
  font-family: var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

.services-table .pty {
  font-family: var(--mono);
  color: var(--muted);
}

.tech-log {
  margin-top: 1rem;
  color: var(--muted);
}

.tech-log pre {
  max-height: 220px;
  overflow: auto;
  background: #0d1218;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.diag-panel {
  margin: 0 1rem 1rem;
  padding: 1rem 1.25rem 1.25rem;
}

.diag-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.diag-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.diag-ts {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.diag-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.diag-tab {
  border: 1px solid var(--border);
  background: #121a24;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.diag-tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(61, 139, 253, 0.12);
}

.diag-pane {
  display: none;
}

.diag-pane.active {
  display: block;
}

.diag-kv {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
  font-size: 0.88rem;
}

.diag-kv dt {
  margin: 0;
  color: var(--muted);
}

.diag-kv dd {
  margin: 0;
  font-family: var(--mono);
  word-break: break-word;
}

.diag-sub {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.diag-table-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.diag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.diag-table th,
.diag-table td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.diag-table th {
  position: sticky;
  top: 0;
  background: #121a24;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.diag-events {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.diag-events li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.diag-events li.warn { color: #fbbf24; }
.diag-events li.info { color: var(--muted); }

.diag-events time {
  color: var(--muted);
  margin-right: 0.5rem;
}

.diag-json {
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 0.75rem;
  background: #0d1218;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .service-head { grid-template-columns: 1fr; }
}
