/* Three-Body Problem Simulation — Styles */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a14;
  --panel-bg: #0f0f1e;
  --panel-border: rgba(255,255,255,0.08);
  --text: #e0e0f0;
  --text-dim: rgba(224,224,240,0.5);
  --accent1: #ff6b6b;
  --accent2: #4ecdc4;
  --accent3: #ffe66d;
  --btn-bg: rgba(255,255,255,0.08);
  --btn-hover: rgba(255,255,255,0.15);
  --section-header: rgba(255,255,255,0.06);
  --slider-track: rgba(255,255,255,0.15);
  --slider-thumb: #4ecdc4;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

/* ===== Layout ===== */
#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

#canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#sim-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#sim-canvas:active { cursor: grabbing; }

/* ===== Sidebar ===== */
#sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
  z-index: 10;
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
}

#sidebar-inner {
  width: 300px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Header ===== */
#sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

#sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: linear-gradient(90deg, var(--accent1), var(--accent2), var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 2px;
}

#sidebar-header p {
  color: var(--text-dim);
  font-size: 11px;
}

/* ===== Stats ===== */
#stats-panel {
  padding: 10px 16px;
  border-bottom: 1px solid var(--panel-border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  flex-shrink: 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
}

.stat-label {
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-val {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  color: var(--accent2);
}

.stat-row.full { grid-column: 1 / -1; }

/* ===== Playback buttons ===== */
#playback-bar {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.ctrl-btn {
  flex: 1;
  padding: 6px 0;
  background: var(--btn-bg);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.ctrl-btn:hover { background: var(--btn-hover); }
.ctrl-btn.primary { border-color: var(--accent2); color: var(--accent2); }

/* ===== Controls scroll area ===== */
#controls-panel {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
}

#controls-panel::-webkit-scrollbar { width: 4px; }
#controls-panel::-webkit-scrollbar-track { background: transparent; }
#controls-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ===== Section ===== */
.ctrl-section {
  border-bottom: 1px solid var(--panel-border);
}

.ctrl-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 16px;
  background: var(--section-header);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  user-select: none;
}
.ctrl-section-header:hover { background: rgba(255,255,255,0.08); }
.chevron { font-size: 10px; }

.ctrl-section-body {
  padding: 8px 16px 12px;
}

/* ===== Control rows ===== */
.ctrl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 6px;
}

.ctrl-row label {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 80px;
  flex-shrink: 0;
}

.slider-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.ctrl-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  background: var(--slider-track);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.ctrl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--slider-thumb);
  cursor: pointer;
  transition: transform 0.1s;
}
.ctrl-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider-val {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 10px;
  color: var(--accent3);
  min-width: 50px;
  text-align: right;
}

.ctrl-select {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text);
  padding: 3px 6px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.ctrl-select option { background: #1a1a2e; }

.ctrl-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--accent2);
  cursor: pointer;
}

/* ===== Body headers ===== */
.body-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin: 8px 0 6px;
}
.body-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== Vector inputs ===== */
.vec-row {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
}
.vec-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vec-input-wrap label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ctrl-input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text);
  padding: 4px 6px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  outline: none;
}
.ctrl-input:focus { border-color: rgba(78,205,196,0.4); }

/* ===== Presets ===== */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.preset-btn {
  background: var(--btn-bg);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  transition: all 0.15s;
}
.preset-btn:hover { background: var(--btn-hover); border-color: rgba(255,255,255,0.2); }
.preset-btn.active { border-color: var(--accent2); color: var(--accent2); background: rgba(78,205,196,0.1); }

/* ===== Toggle button (floating) ===== */
#btn-toggle-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: rgba(15,15,30,0.85);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  #sidebar {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    z-index: 50;
  }
  #btn-toggle-panel { display: block; }
  #sidebar.collapsed { width: 0; min-width: 0; }
}

/* ===== Scrollbar for body ===== */
body::-webkit-scrollbar { display: none; }
