:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --ink: #1e2420;
  --muted: #69726d;
  --line: #d8ded7;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0a514d;
  --measure: #c2410c;
  --x: #2563eb;
  --y: #a21caf;
  --shadow: 0 18px 45px rgba(30, 36, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.brand h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.05;
}

.brand p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
  letter-spacing: 0;
}

.file-picker {
  display: block;
  margin-bottom: 8px;
}

.file-picker input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.file-picker span,
button.secondary,
.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fdfefd;
  color: var(--ink);
}

.file-picker span {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.file-picker span:hover {
  background: var(--accent-dark);
}

button.secondary:hover,
.segmented button:hover {
  border-color: #aeb8b1;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.segmented button.active {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.stack {
  display: grid;
  gap: 10px;
}

.axis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.scale-controls {
  margin-bottom: 12px;
}

.hidden {
  display: none;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.readout {
  min-height: 48px;
  padding: 10px;
  border: 1px solid #cddbd8;
  border-radius: 7px;
  background: #edf8f6;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.fit-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.list-panel {
  min-height: 110px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.icon-button {
  inline-size: 30px;
  block-size: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.count {
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef1ed;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.point-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.point-list li {
  padding-right: 4px;
}

.workspace {
  min-width: 0;
  padding: 22px;
  overflow: auto;
}

.chart-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 44px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #eef1ed 25%, transparent 25%),
    linear-gradient(-45deg, #eef1ed 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef1ed 75%),
    linear-gradient(-45deg, transparent 75%, #eef1ed 75%);
  background-color: white;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  box-shadow: var(--shadow);
}

.chart-frame.drag-over {
  border-color: var(--accent);
  background-color: #edf8f6;
  outline: 3px solid rgba(15, 118, 110, 0.2);
  outline-offset: -8px;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 80px);
  cursor: crosshair;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    padding: 14px;
  }

  .chart-frame {
    min-height: 60vh;
  }
}
