:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d5dbe7;
  --grid: #e8edf5;
  --axis: #97a3b6;
  --teal: #007a78;
  --orange: #c35f2e;
  --rose: #c43a5f;
  --violet: #5d55a6;
  --button: #172033;
  --button-hover: #2a3448;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
canvas {
  font: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  font-size: 0.98rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.formula,
.readout {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  min-height: 1.45em;
  font-variant-numeric: tabular-nums;
}

#reset-button {
  min-width: 78px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: #fff;
  cursor: pointer;
  padding: 0 16px;
  font-weight: 720;
}

#reset-button:hover {
  background: var(--button-hover);
}

#reset-button:focus-visible {
  outline: 3px solid rgba(0, 122, 120, 0.28);
  outline-offset: 3px;
}

.period-update-toggle {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  min-height: 32px;
  border: 1px solid rgba(23, 32, 51, 0.18);
  border-radius: 8px;
  background: #eef2f7;
  color: var(--ink);
  cursor: pointer;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 760;
}

.period-update-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.period-update-toggle:focus-within {
  outline: 3px solid rgba(0, 122, 120, 0.24);
  outline-offset: 2px;
}

.planes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 660px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(22, 31, 51, 0.08);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 70px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

canvas {
  flex: 1 1 0;
  display: block;
  width: 100%;
  height: auto;
  min-height: 590px;
  background: #fbfcff;
  touch-action: none;
}

#parameter-plane {
  cursor: grab;
}

#parameter-plane.dragging {
  cursor: grabbing;
}

@media (max-width: 940px) {
  .app {
    padding: 14px;
  }

  .planes {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: 640px;
  }

  canvas {
    min-height: 560px;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  #reset-button {
    width: 100%;
  }

  .panel-header {
    min-height: 82px;
  }
}
