/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #333;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #6ea8fe;
  --accent2: #a87ffe;
  --sidebar-w: 260px;
  --radius: 6px;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html, body { height: 100%; width: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

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

#canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

/* ===== Loading overlay ===== */
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 14px 12px;
  gap: 14px;
}

#sidebar header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

#sidebar h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Control groups ===== */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group > label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

select, input[type="number"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

select:focus, input[type="number"]:focus {
  border-color: var(--accent);
}

select option { background: var(--surface2); }

/* Range slider */
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: background 0.15s;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

input[type="range"]:hover::-webkit-slider-thumb { background: var(--accent2); }

/* Value badge */
.value-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent);
}

/* Input row (Julia C) */
.input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-row input { flex: 1; min-width: 0; }

label.small {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Coordinates */
.coord-group { gap: 6px; }

.coord-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
}

.mono {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text);
  text-align: right;
}

/* ===== Presets ===== */
.presets-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-btn {
  width: 100%;
  padding: 6px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}

.preset-btn:hover {
  background: var(--border);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Action buttons ===== */
.action-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
}

.btn-primary, .btn-secondary, .btn-icon {
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  padding: 7px 12px;
  transition: background 0.12s, border-color 0.12s;
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Footer ===== */
#sidebar footer {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.help {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ===== Scrollbar ===== */
#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Responsive: mobile stack ===== */
@media (max-width: 600px) {
  #app { flex-direction: column; }
  #canvas-wrap { flex: 1; min-height: 0; }
  #sidebar {
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: auto;
    padding: 10px;
    max-height: 45vh;
  }
  .control-group, .action-group { min-width: 140px; flex: 1; }
}
