:root {
  --bg: #04060c;
  --panel: #080c17;
  --line: #1a2236;
  --text: #e8edf7;
  --muted: #8a95ad;
  --base: #ff6b4a;
  --hnn: #3ddcff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f43f5e;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px 6px;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 38px);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 0%, var(--hnn) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: clamp(13px, 1.2vw, 18px);
}

.tagline em { color: var(--text); font-style: normal; font-weight: 600; }

#stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 8px 24px;
  min-height: 0;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;
  --accent: var(--base);
}

.panel[data-model="hnn"] { --accent: var(--hnn); }

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
}

.panel-head {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  pointer-events: none;
}

.panel-head .dot {
  flex: none;
  width: 12px; height: 12px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.panel-head h2 {
  margin: 0;
  font-size: clamp(15px, 1.5vw, 22px);
  font-weight: 650;
}

.eq {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: clamp(12px, 1vw, 15px);
}

.eq b { color: var(--text); font-weight: 500; font-family: "Cambria Math", Georgia, serif; }

.badge {
  margin-left: auto;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: clamp(11px, 0.9vw, 14px);
  font-weight: 700;
  letter-spacing: 0.08em;
  border: 1px solid currentColor;
  color: var(--muted);
  transition: color .3s, background .3s;
  white-space: nowrap;
}

.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, transparent); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .55; } }

.panel canvas {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.readout {
  position: absolute;
  left: 16px; bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  pointer-events: none;
}

.readout span { color: var(--muted); font-size: clamp(12px, 1vw, 15px); }

.readout strong {
  font-variant-numeric: tabular-nums;
  font-size: clamp(22px, 2.4vw, 36px);
  color: var(--accent);
  text-shadow: 0 0 16px color-mix(in srgb, var(--accent) 60%, transparent);
}

footer {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 380px);
  gap: 14px;
  padding: 6px 24px 16px;
}

.chart-wrap {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 10px 14px;
  height: clamp(150px, 22vh, 230px);
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.legend { display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; margin-left: 10px; }
.l-base { background: var(--base); }
.l-hnn { background: var(--hnn); }

#cv-chart { flex: 1; width: 100%; min-height: 0; display: block; }

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.clock {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 14px;
}

#orbits { color: var(--text); font-weight: 600; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--hnn);
  background: color-mix(in srgb, var(--hnn) 18%, transparent);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

button:hover { background: color-mix(in srgb, var(--hnn) 30%, transparent); }
button.ghost { border-color: var(--line); background: transparent; }
button.ghost:hover { border-color: var(--muted); background: #ffffff08; }
button:focus-visible { outline: 2px solid var(--hnn); outline-offset: 2px; }

.slider, .check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.slider input { flex: 1; accent-color: var(--hnn); }
#speedVal { width: 3ch; color: var(--text); font-variant-numeric: tabular-nums; }
.check input { accent-color: var(--hnn); }

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

dialog {
  max-width: min(760px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0b1020;
  color: var(--text);
  padding: 24px 28px;
  line-height: 1.5;
}

dialog::backdrop { background: #000a; backdrop-filter: blur(3px); }
dialog h2 { margin-top: 0; }
dialog h3 { margin: 0 0 4px; font-size: 16px; }
.c-base { color: var(--base); }
.c-hnn { color: var(--hnn); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.small { color: var(--muted); font-size: 13px; }
code { font-family: "Cambria Math", Georgia, serif; font-size: 1.05em; color: #fff; }
kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; }
dialog form { text-align: right; }

@media (max-width: 820px) {
  body { height: auto; overflow: auto; }
  header { padding: 14px 16px 6px; }
  #infoBtn { display: none; }
  #stage { grid-template-columns: 1fr; padding: 8px 16px; }
  .panel { height: 78vw; }
  footer { grid-template-columns: 1fr; padding: 6px 16px 16px; }
  .cols { grid-template-columns: 1fr; }
}
