:root {
  --bg-dark: #1a1a1e;
  --bg-light: #f0eeeb;
  --panel-dark: #242428;
  --panel-light: #ffffff;
  --text-primary: #e8e6e3;
  --text-secondary: #a09d98;
  --text-dark: #2a2a2a;
  --accent: #c4956a;
  --accent-hover: #d4a57a;
  --border: rgba(255,255,255,0.08);
  --border-light: rgba(0,0,0,0.08);
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* ── UI Panel ── */
#ui {
  width: 300px;
  min-width: 300px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-dark);
  border-right: 1px solid var(--border);
  padding: 20px;
  gap: 16px;
  overflow-y: auto;
  z-index: 10;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 6px;
}

.hint {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.4;
}

/* ── Controls ── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.control-row label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 60px;
  flex-shrink: 0;
}

#model-select {
  flex: 1;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}

#model-select:focus {
  border-color: var(--accent);
}

button {
  flex: 1;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover {
  background: var(--accent);
  color: var(--bg-dark);
  border-color: var(--accent);
}

.toggles {
  flex-wrap: wrap;
  gap: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

/* ── Info ── */
.info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.info-row {
  display: flex;
  gap: 8px;
  font-size: 0.78rem;
  line-height: 1.5;
}

.info-row .label {
  color: var(--text-secondary);
  min-width: 70px;
  flex-shrink: 0;
}

.info-row span:last-child {
  color: var(--text-primary);
}

.description {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Footer ── */
footer {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

footer code {
  background: var(--bg-dark);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: 'SF Mono', monospace;
  font-size: 0.65rem;
}

/* ── Canvas ── */
#canvas-container {
  flex: 1;
  position: relative;
  height: 100vh;
}

#canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Loading ── */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  color: var(--text-secondary);
  font-size: 0.9rem;
  z-index: 100;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

#loading-overlay.hidden {
  opacity: 0;
}

/* ── Light mode overrides ── */
body.light-mode {
  background: var(--bg-light);
  color: var(--text-dark);
}

body.light-mode #ui {
  background: var(--panel-light);
  border-right-color: var(--border-light);
}

body.light-mode header h1 {
  color: var(--text-dark);
}

body.light-mode .subtitle {
  color: #8b6914;
}

body.light-mode .hint,
body.light-mode .info-row .label,
body.light-mode .description,
body.light-mode footer,
body.light-mode .toggle {
  color: #6a6864;
}

body.light-mode .info-row span:last-child {
  color: var(--text-dark);
}

body.light-mode #model-select,
body.light-mode button {
  background: var(--bg-light);
  color: var(--text-dark);
  border-color: var(--border-light);
}

body.light-mode button:hover {
  background: var(--accent);
  color: #fff;
}

body.light-mode #loading-overlay {
  background: var(--bg-light);
  color: var(--text-dark);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #ui {
    width: 240px;
    min-width: 240px;
    padding: 12px;
  }
}
