:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #7c3aed;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 240px;
  --code-bg: #1e293b;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  padding: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.sidebar-logo span {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.sidebar nav { padding: 12px 8px; flex: 1; }

.nav-section {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 8px 8px 4px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.875rem;
  transition: background .15s;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: #eff6ff;
  color: var(--primary);
}

.sidebar-footer {
  padding: 12px 16px;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: 1100px;
}

/* ── Page header ── */
.page-header {
  margin-bottom: 32px;
}

.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.page-header p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}

/* ── Galerie ── */
.categorie-titre {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 32px 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.categorie-titre:first-child { margin-top: 0; }

.galerie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 20px;
}

.exemple-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.exemple-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exemple-header h4 { font-size: 0.9rem; font-weight: 600; }
.exemple-header p { font-size: 0.78rem; color: var(--muted); }

.exemple-body { padding: 0; }

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #334155;
  font-size: 0.72rem;
  color: #94a3b8;
}

.code-block {
  background: var(--code-bg);
  color: #e2e8f0;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.78rem;
  padding: 14px 16px;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre;
  line-height: 1.5;
}

.exemple-actions {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all .15s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: white;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover { background: var(--bg); }

.btn-purple {
  background: var(--accent);
  color: white;
}

.btn-purple:hover { background: #6d28d9; }

/* ── Compilateur ── */
.compiler-layout {
  display: grid;
  gap: 20px;
}

.compiler-pane {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.pane-header {
  padding: 10px 16px;
  background: #334155;
  color: #e2e8f0;
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#editor {
  flex: 1;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.82rem;
  padding: 14px;
  border: none;
  resize: none;
  outline: none;
  background: var(--code-bg);
  color: #e2e8f0;
  line-height: 1.6;
}

.compiler-toolbar {
  padding: 10px 14px;
  background: #1e293b;
  border-top: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 10px;
}

.engine-select {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 0.8rem;
}

.result-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  background: #f1f5f9;
}

.result-pane iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.result-placeholder {
  text-align: center;
  color: var(--muted);
}

.result-placeholder .icon { font-size: 3rem; margin-bottom: 10px; }
.result-placeholder p { font-size: 0.875rem; }

.spinner {
  display: none;
  width: 24px; height: 24px;
  border: 3px solid #475569;
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-bar {
  padding: 6px 14px;
  font-size: 0.75rem;
  background: #1e293b;
  color: #94a3b8;
  border-top: 1px solid #334155;
}

/* ── Accueil ── */
.hero {
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.hero-text h2 { font-size: 1.5rem; margin-bottom: 8px; }
.hero-text p { color: var(--muted); line-height: 1.6; }
.hero-badges { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--text);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.feature-card .icon { font-size: 1.8rem; margin-bottom: 6px; }
.feature-card h4 { font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.feature-card p { font-size: 0.75rem; color: var(--muted); }

/* ── Copy feedback ── */
.copied-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: #1e293b;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.82rem;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}

.copied-toast.show { opacity: 1; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; padding: 20px; }
  .compiler-layout { grid-template-columns: 1fr; }
  .galerie-grid { grid-template-columns: 1fr; }
}
