:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #131821;
  --panel-2: #171d27;
  --line: #273140;
  --line-bright: #3b4a5f;
  --text: #eef4fb;
  --muted: #91a0b2;
  --dim: #5d6b7e;
  --cyan: #5fe7ff;
  --cyan-2: #119fc0;
  --amber: #f2b84b;
  --orange: #ff784f;
  --red: #ff4f61;
  --green: #75e0a7;
  --violet: #7d6cff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: radial-gradient(circle at 50% 32%, #111722 0, var(--bg) 58%);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

button,
input {
  font-family: inherit;
}

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 23, 0.7);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #05070a 36%, var(--cyan) 38%, transparent 60%),
    radial-gradient(circle at 50% 50%, transparent 56%, var(--amber) 58%, transparent 66%);
  box-shadow: 0 0 18px rgba(95, 231, 255, 0.4);
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.brand p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.appbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 0 4px;
}

.back-link:hover {
  color: var(--cyan);
}

.preset-button {
  min-height: 34px;
  padding: 0 16px;
  border: 1px solid rgba(125, 108, 255, 0.5);
  border-radius: 8px;
  background: rgba(125, 108, 255, 0.12);
  color: #cdbcff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.presets {
  margin-top: 4px;
}

.presets-label {
  display: block;
  font-size: 10.5px;
  color: var(--dim);
  margin-bottom: 6px;
}

.preset-row {
  display: flex;
  gap: 8px;
}

.preset-chip {
  flex: 1;
  min-height: 30px;
  border: 1px solid rgba(125, 108, 255, 0.5);
  border-radius: 8px;
  background: rgba(125, 108, 255, 0.12);
  color: #cdbcff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.preset-chip:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(95, 231, 255, 0.1);
}

.equations .eq-group {
  margin: 12px 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--cyan);
}

.equations .eq-group:first-of-type {
  margin-top: 0;
}

.equations .eq {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 0;
}

.equations .eq span {
  font-size: 10.5px;
  color: var(--dim);
}

.equations .eq code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--text);
  word-break: break-word;
}

.equations .eq-math {
  font-size: 12.5px;
  color: var(--text);
  word-break: break-word;
}
/* keep KaTeX raw $...$ readable if the CDN fails to load (offline) */
.equations .eq-math .katex { font-size: 1.05em; }

.equations .eq-note {
  margin: 12px 0 0;
  font-size: 10px;
  line-height: 1.45;
  color: var(--dim);
}

.preset-button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(95, 231, 255, 0.1);
}

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 2px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px;
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.panel label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.panel label:last-child {
  margin-bottom: 0;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.label-row output {
  color: var(--text);
  font-size: 11.5px;
  font-weight: 650;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.readouts dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.readouts div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.readouts dt {
  color: var(--muted);
  font-size: 12px;
}

.readouts dd {
  margin: 0;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.note-panel p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
  min-height: 0;
}

.plot-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.plot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.plot-head h2 {
  margin: 0;
  font-size: 14px;
}

.plot-sub {
  font-size: 11px;
  color: var(--dim);
}

.plot-head-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-button {
  min-height: 30px;
  padding: 0 14px;
  border: 1px solid rgba(95, 231, 255, 0.5);
  border-radius: 8px;
  background: rgba(95, 231, 255, 0.12);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.play-button:hover {
  border-color: var(--cyan);
  background: rgba(95, 231, 255, 0.18);
}

.play-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.play-button.playing {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(242, 184, 75, 0.14);
}

.play-button.active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(117, 224, 167, 0.16);
}

canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: 8px;
  background: #0a0d12;
  border: 1px solid var(--line);
}
