:root {
  color-scheme: dark;
  --bg: #071017;
  --panel: rgba(12, 27, 37, 0.88);
  --panel-line: rgba(133, 181, 205, 0.15);
  --text: #e8f5fb;
  --muted: #7f9baa;
  --cyan: #45d7f1;
  --cyan-soft: rgba(69, 215, 241, 0.12);
  --orange: #ff9c57;
  --red: #ff6c6c;
  --green: #68e0aa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(39, 131, 162, 0.16), transparent 34rem),
    linear-gradient(135deg, #061017 0%, #071119 46%, #050b10 100%);
}
button, select, input { font: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.app-shell { width: min(1520px, 100%); min-height: 100vh; margin: 0 auto; padding: 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.title-group { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 13px; }
.title-group h1 { grid-column: 1 / -1; }
.back-link { color: #6e8996; font: 700 9px/1 ui-monospace, monospace; letter-spacing: .12em; text-decoration: none; transition: color .15s; }
.back-link:hover { color: var(--cyan); }
.eyebrow, .panel-kicker { margin: 0 0 4px; color: var(--cyan); font: 700 10px/1.2 ui-monospace, monospace; letter-spacing: .2em; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 38px); font-weight: 650; letter-spacing: -.035em; }
.connection-cluster { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--panel-line); border-radius: 999px; color: var(--muted); background: rgba(4, 11, 16, .62); font-size: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.status-pill[data-state="connected"] { color: var(--green); }
.status-pill[data-state="connecting"] { color: var(--orange); }
.status-pill[data-state="error"] { color: var(--red); }

.button { min-height: 38px; border: 1px solid var(--panel-line); border-radius: 9px; padding: 0 15px; color: var(--text); background: rgba(17, 38, 50, .86); cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(69, 215, 241, .42); background: rgba(25, 53, 67, .92); }
.button:disabled { opacity: .38; cursor: not-allowed; }
.button.primary { border-color: rgba(69, 215, 241, .38); background: var(--cyan); color: #041116; font-weight: 700; }
.button.primary:hover:not(:disabled) { background: #73e4f6; }
.button.subtle { color: var(--muted); }
.button.danger:not(:disabled) { color: #ffb1b1; }
.icon-button { min-height: 34px; font-size: 12px; }
.icon-button[aria-pressed="true"] { color: var(--orange); border-color: rgba(255, 156, 87, .44); }

.notice { margin-bottom: 16px; padding: 13px 16px; border: 1px solid rgba(255, 156, 87, .38); border-radius: 10px; color: #ffd1ae; background: rgba(74, 38, 17, .45); font-size: 14px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; min-height: calc(100vh - 116px); }
.panel { border: 1px solid var(--panel-line); border-radius: 14px; background: var(--panel); box-shadow: 0 20px 50px rgba(0, 0, 0, .16); backdrop-filter: blur(16px); }
.radar-panel { min-width: 0; display: flex; flex-direction: column; padding: 14px; overflow: hidden; }
.panel-heading, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading { min-height: 50px; padding: 0 4px 12px; }
.panel-heading strong { font-size: 14px; font-weight: 550; color: #b8cbd4; }
.canvas-wrap { position: relative; flex: 1; min-height: 520px; overflow: hidden; border-radius: 10px; border: 1px solid rgba(104, 194, 222, .12); background: #050c11; }
#radarCanvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; pointer-events: none; }
.empty-state[hidden] { display: none; }
.empty-state strong { font-size: 16px; font-weight: 560; }
.empty-state small { max-width: 420px; color: var(--muted); line-height: 1.6; }
.radar-icon { width: 74px; height: 74px; margin-bottom: 8px; border: 1px solid rgba(69, 215, 241, .32); border-radius: 50%; background: radial-gradient(circle, var(--cyan) 0 2px, transparent 3px), repeating-radial-gradient(circle, transparent 0 13px, rgba(69, 215, 241, .13) 14px 15px); box-shadow: 0 0 40px rgba(69, 215, 241, .09); }
.paused-badge { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 6px 10px; border-radius: 6px; color: #ffd1ae; background: rgba(50, 26, 11, .86); border: 1px solid rgba(255, 156, 87, .38); font: 700 10px/1 ui-monospace, monospace; letter-spacing: .12em; }

.sidebar { display: flex; flex-direction: column; gap: 16px; }
.controls-panel, .stats-panel, .error-panel { padding: 17px; }
.section-title { margin-bottom: 17px; padding-bottom: 12px; border-bottom: 1px solid var(--panel-line); font-size: 13px; font-weight: 650; }
.section-number { color: #496575; font: 700 10px/1 ui-monospace, monospace; }
.field { display: grid; gap: 8px; margin: 14px 0; color: #a7bdc8; font-size: 12px; }
.field > span { display: flex; justify-content: space-between; }
output { color: var(--cyan); font-family: ui-monospace, monospace; }
select { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--panel-line); border-radius: 8px; color: var(--text); background: #0a1821; }
input[type="range"] { width: 100%; accent-color: var(--cyan); }
.check-field { display: flex; align-items: center; gap: 9px; margin-top: 13px; color: #a7bdc8; font-size: 12px; cursor: pointer; }
.check-field input { accent-color: var(--cyan); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 0 0 14px; }
.stats-grid div { min-width: 0; padding: 11px; border-radius: 8px; background: rgba(3, 12, 18, .54); }
.stats-grid dt { margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.stats-grid dd { margin: 0; font: 600 21px/1 ui-monospace, monospace; white-space: nowrap; }
.stats-grid dd small { display: block; margin-top: 6px; color: #57717e; font: 9px/1 ui-monospace, monospace; }
.diagnostic-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px; color: var(--muted); font-size: 10px; border-top: 1px solid rgba(133, 181, 205, .08); }
.diagnostic-row strong, .diagnostic-row code { min-width: 0; color: #a9c0ca; font: 500 10px/1.3 ui-monospace, monospace; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-panel { margin-top: auto; }
.error-panel p { min-height: 38px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.error-panel p.has-error { color: #ffaaaa; }

@media (max-width: 900px) {
  .app-shell { padding: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .connection-cluster { justify-content: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .canvas-wrap { min-height: min(72vw, 620px); }
  .error-panel { margin-top: 0; }
}

@media (max-width: 520px) {
  .connection-cluster { width: 100%; }
  .status-pill { width: 100%; }
  .button { flex: 1; padding-inline: 9px; font-size: 12px; }
  .button.subtle { flex-basis: 100%; }
  .canvas-wrap { min-height: 390px; }
}
