@import url("https://fonts.googleapis.com/css2?family=Spectral:wght@400;500;600;700&family=STIX+Two+Text:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --ui-font: "Spectral", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --math-font: "STIX Two Text", "Cambria Math", "Times New Roman", serif;
  --paper: #f4efe4;
  --paper-soft: #eee7da;
  --paper-line: rgba(70, 61, 48, 0.18);
  --ink: #20211e;
  --ink-muted: rgba(32, 33, 30, 0.61);
  --rule: rgba(70, 61, 48, 0.16);
  --rule-dark: rgba(70, 61, 48, 0.27);
  --blue: #6551a8;
  --blue-soft: rgba(101, 81, 168, 0.11);
  --red: #bd4b55;
  --red-soft: rgba(189, 75, 85, 0.12);
  --quasi: #0877b8;
  --inside: #2e775d;
  --outside: #aa4d58;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 42%, rgba(65, 45, 118, 0.86), rgba(8, 10, 24, 1) 68%),
    linear-gradient(145deg, #070812, #17102b 58%, #050610);
  color: var(--ink);
  font-family: var(--ui-font);
  line-height: 1.25;
}

#stage {
  position: fixed;
  inset: 0;
}

canvas {
  display: block;
}

#panel {
  position: fixed;
  left: 24px;
  top: 24px;
  width: min(286px, calc(100vw - 48px));
  padding: 15px 16px 14px;
  border: 1px solid rgba(217, 207, 188, 0.94);
  border-radius: 4px;
  background: var(--paper);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.24),
    0 0 0 1px rgba(70, 61, 48, 0.045) inset;
  user-select: none;
}

#panel::before,
#panel::after {
  display: none;
}

header {
  margin-bottom: 11px;
}

.kicker {
  margin-bottom: 5px;
  color: var(--ink-muted);
  font-family: var(--ui-font);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0;
}

.formula {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0 0 13px;
  padding: 8px 0 8px 9px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  border-left: 2px solid rgba(189, 75, 85, 0.58);
  color: rgba(32, 33, 30, 0.79);
  background: transparent;
  font-family: var(--math-font);
  font-size: 17px;
  font-weight: 500;
  font-style: normal;
  white-space: nowrap;
}

#selectedSideFormula {
  color: var(--red);
  font-weight: 700;
  font-style: normal;
}

.control-block {
  margin-top: 11px;
}

.control-block:first-of-type {
  margin-top: 0;
}

.label,
.split-label {
  color: var(--ink-muted);
  font-family: var(--ui-font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.split-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

#deltaValue {
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
}

button {
  appearance: none;
  border: 1px solid rgba(70, 61, 48, 0.22);
  border-radius: 4px;
  color: var(--ink);
  background: #f1ecdf;
  box-shadow: none;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease;
}

button:hover {
  border-color: rgba(70, 61, 48, 0.38);
  background: #f8f4eb;
}

.side-button {
  height: 31px;
  font-family: var(--math-font);
  font-size: 20px;
  font-weight: 700;
}

.side-button.active {
  border-color: rgba(189, 75, 85, 0.56);
  background: var(--red-soft);
  color: var(--red);
}

.wide-button {
  width: 100%;
  height: 31px;
  margin-top: 7px;
  font-family: var(--ui-font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

input[type="range"] {
  width: 100%;
  height: 21px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), rgba(70, 61, 48, 0.24));
}

input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -5px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

input[type="range"]::-moz-range-track {
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), rgba(70, 61, 48, 0.24));
}

input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.compact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  color: rgba(23, 29, 37, 0.73);
  font-family: var(--ui-font);
  font-size: 15px;
}

.compact-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 25px;
  padding: 3px 0;
  border: 0;
  border-top: 1px solid var(--paper-line);
  border-radius: 0;
  background: transparent;
}

.compact-grid input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--blue);
}

.quasi-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.quasi-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #1fb6ff;
  box-shadow: 0 0 0 1px rgba(23, 29, 37, 0.18), 0 0 9px rgba(31, 182, 255, 0.72);
}

.readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 10px;
  border-top: 1px solid var(--rule);
}

.readout div {
  min-height: 44px;
  padding: 8px 8px 3px 0;
  border-left: 0;
  background: transparent;
}

.readout div + div {
  padding-left: 10px;
  border-left: 1px solid var(--rule);
}

.readout span {
  display: block;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.16;
}

.readout strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

sub {
  font-size: 0.68em;
  line-height: 0;
}

@media (max-width: 700px) {
  #panel {
    left: 12px;
    top: 12px;
    width: min(284px, calc(100vw - 24px));
    padding: 14px 15px 13px;
  }

  h1 {
    font-size: 23px;
  }

  .formula {
    font-size: 15px;
  }
}

.readout .inside strong {
  color: var(--inside);
}

.readout .outside strong {
  color: var(--outside);
}

.readout .outside {
  background: transparent;
}

#quasiStatus strong {
  color: var(--quasi);
}
