:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #121a2d;
  --line: #2a3857;
  --text: #edf3ff;
  --muted: #91a0bd;
  --cyan: #55d7ff;
  --green: #58e39d;
  --red: #ff6b7f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #172846 0, var(--bg) 45%);
}

header, .controls, main, footer {
  width: min(1240px, calc(100% - 32px));
  margin-inline: auto;
}

header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 34px 0 20px;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(25px, 4vw, 42px); letter-spacing: -.04em; }
h2 { font-size: 18px; }

.eyebrow {
  margin-bottom: 4px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .16em;
}

.status {
  max-width: 460px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(8, 13, 25, .65);
}

.status.ok { color: var(--green); border-color: rgba(88, 227, 157, .45); }
.status.error { color: #ff9aaa; border-color: rgba(255, 107, 127, .5); }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(18, 26, 45, .88);
}

label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.token-field { flex: 1 1 260px; }

input, select, button {
  min-height: 40px;
  border: 1px solid #344564;
  border-radius: 9px;
  color: var(--text);
  background: #0c1426;
  font: inherit;
}

input, select { padding: 8px 11px; }
button { padding: 8px 16px; border-color: #258eae; background: #176d88; cursor: pointer; }
button.secondary { border-color: #405170; background: #202c43; }
button:disabled { opacity: .42; cursor: not-allowed; }

.check-field { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.check-field input { min-height: auto; }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  padding: 16px 0;
}

.trace-panel, .summary {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(18, 26, 45, .9);
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; }
.start-dot { background: var(--green); }
.point-dot { background: var(--cyan); }
.end-dot { background: var(--red); }

.canvas-wrap { position: relative; min-height: 480px; }
#trace { display: block; width: 100%; min-height: 480px; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }

.grid-line { stroke: #1e2b44; stroke-width: 1; }
.track-line { fill: none; stroke: var(--cyan); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.track-point { fill: #0d192b; stroke: var(--cyan); stroke-width: 3; cursor: pointer; }
.track-point:hover, .track-point:focus { fill: var(--cyan); outline: none; }
.endpoint-start { fill: var(--green); stroke: #071d16; stroke-width: 4; }
.endpoint-end { fill: var(--red); stroke: #260c13; stroke-width: 4; }
.endpoint-label { fill: var(--text); font-size: 15px; font-weight: 800; text-anchor: middle; pointer-events: none; }

.summary { padding: 20px; }
.summary dl { display: grid; gap: 0; margin: 14px 0; }
.summary dl div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.summary dt { color: var(--muted); font-size: 12px; }
.summary dd { margin: 3px 0 0; word-break: break-word; }
.point-detail { padding: 12px; border-radius: 9px; color: var(--muted); background: #0b1426; white-space: pre-line; }

footer { padding: 4px 0 28px; color: var(--muted); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  header { align-items: start; flex-direction: column; }
  main { grid-template-columns: 1fr; }
  .panel-heading { align-items: start; flex-direction: column; }
  .canvas-wrap, #trace { min-height: 360px; }
}
