:root {
  --maxw: 1100px;
  --gap: 12px;
  --border: #d9d9d9;
  --bg: #ffffff;
  --panel-bg: #ffffff;
  --text: #111;
  --muted: #666;
  --danger: #c40000;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans TC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.page { padding: 12px; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  gap: var(--gap);
  align-items: stretch;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
  overflow: hidden;
}

/* Plot panel */
.plot-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.plot-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.plot-title {
  font-size: 16px;
  font-weight: 600;
}

.plot {
  width: 100%;
  height: 520px;
}

/* Controls */
.controls-panel {
  flex: 0 0 340px;
  padding: 12px;
}

.controls-header {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

.control { margin: 14px 0; }

.control-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

label { font-size: 14px; font-weight: 600; }

.value {
  font-size: 13px;
  color: var(--muted);
  min-width: 70px;
  text-align: right;
}

input[type="range"] { width: 100%; }

.hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* X range block */
.xrange {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}

.xrange-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.xrange-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.xfield {
  flex: 1 1 140px;
  min-width: 120px;
}

.xfield label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.xfield input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.xrange-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

button {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f7f7;
  font-size: 14px;
  cursor: pointer;
}

button:hover { background: #f0f0f0; }

.error {
  margin-top: 10px;
  font-size: 12px;
  color: var(--danger);
  min-height: 16px;
}

/* Y scale toggle block */
.yscale {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}

.yscale-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}

.checkbox-row {
  margin-top: 20px;
}

/* Switch (pure CSS) */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input { display: none; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #d0d0d0;
  border-radius: 999px;
  transition: 0.15s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.switch input:checked + .slider {
  background-color: #4a90e2;
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* Responsive */
@media (max-width: 900px) {
  .container { flex-direction: column; }
  .controls-panel { flex: 1 1 auto; }
  .plot { height: 420px; }
}

@media (max-width: 480px) {
  .page { padding: 8px; }
  .plot { height: 360px; }
}