:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #06b6d4;
  --accent-dim: rgba(6, 182, 212, 0.15);
  --border-color: #334155;
  --color-regular: #3b82f6;
  --color-shortcut: #f59e0b;
  --color-curve-c: #06b6d4;
  --color-curve-l: #f43f5e;
  --color-regime: rgba(16, 185, 129, 0.12);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}
.sw-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}
header {
  text-align: center;
  margin-bottom: 24px;
}
header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6, #06b6d4, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}
header .subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.main-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Plots */
.viz-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.plot-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 16px;
}
.plot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.plot-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.plot-info {
  font-size: 0.78rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.plot-wrapper {
  position: relative;
  width: 100%;
  background: #0a0f1e;
  border-radius: 8px;
  overflow: hidden;
}
.plot-wrapper canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.network-wrapper {
  aspect-ratio: 1 / 1;
  max-height: 520px;
}
.chart-wrapper {
  height: 260px;
}

/* Controls */
.controls-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.control-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 16px;
}
.control-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Presets */
.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.preset-btn {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
  padding: 8px 6px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}
.preset-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.preset-btn.preset-wide {
  flex: 1 1 100%;
}

/* Sliders */
.slider-group {
  margin-bottom: 12px;
}
.slider-group:last-child {
  margin-bottom: 0;
}
.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.slider-label > span:first-child {
  flex: 1;
}
.slider-value {
  font-weight: 600;
  color: var(--text-primary);
  min-width: 40px;
  text-align: right;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  width: 100%;
  height: 5px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-primary);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* Slider ticks */
.slider-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 0.58rem;
  color: var(--text-muted);
  padding: 0 2px;
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 8px;
}
.action-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
}
.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.action-btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.action-btn.primary:hover {
  background: rgba(6, 182, 212, 0.25);
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-item {
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.stat-value {
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

/* Legend */
.legend-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}
.legend-line.regular-line {
  background: var(--color-regular);
}
.legend-line.shortcut-line {
  background: var(--color-shortcut);
}
.legend-line.curve-c {
  background: var(--color-curve-c);
  height: 4px;
}
.legend-line.curve-l {
  background: var(--color-curve-l);
  height: 4px;
}
.legend-box {
  width: 24px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
  background: var(--color-regime);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Explanation */
.explanation {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 24px;
  margin-top: 20px;
}
.explanation h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text-primary);
}
.explanation p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 12px;
  line-height: 1.7;
}
.explanation p:last-child {
  margin-bottom: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .sw-container {
    padding: 12px;
  }
  header h1 {
    font-size: 1.3rem;
  }
  .network-wrapper {
    max-height: 360px;
  }
  .chart-wrapper {
    height: 200px;
  }
  .preset-btn {
    flex: 1 1 calc(33% - 4px);
  }
}
