:root {
  --fond: #f4f5f7;
  --panneau: #ffffff;
  --texte: #1b1f24;
  --discret: #5b636e;
  --bord: #d3d8de;
  --accent: #1f5fbf;
  --rouge: #d62828;
  --police: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #15181c;
    --panneau: #1e2227;
    --texte: #e7e9ec;
    --discret: #9aa3ae;
    --bord: #353b43;
    --accent: #7eaaf2;
    --rouge: #ff6b6b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  line-height: 1.5;
}

header {
  max-width: 1300px;
  margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
}

h1 { margin: 0 0 0.25rem; font-size: 1.75rem; font-weight: 600; }
header p { margin: 0; color: var(--discret); max-width: 75ch; }

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1rem;
  max-width: 1300px;
  margin: 0 auto;
  padding: 1rem;
}

#controles {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-self: start;
}

fieldset {
  margin: 0;
  padding: 0.75rem 0.9rem 0.9rem;
  background: var(--panneau);
  border: 1px solid var(--bord);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

legend { padding: 0 0.35rem; font-weight: 600; }

label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.95rem; }
label.case { flex-direction: row; align-items: center; gap: 0.5rem; }

.ligne { display: flex; align-items: center; gap: 0.6rem; }
.ligne input { flex: 1; min-width: 0; }
output { min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--discret); }

select, button {
  font: inherit;
  color: var(--texte);
  background: var(--panneau);
  border: 1px solid var(--bord);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); }

input[type="range"] { accent-color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#liste {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  max-height: 11rem;
  overflow-y: auto;
}

#liste li { margin-bottom: 0.3rem; }
#liste li.rouge { color: var(--rouge); }
#liste li.vide { list-style: none; margin-left: -1.2rem; color: var(--discret); }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 1rem;
  align-items: start;
}

.vue {
  background: var(--panneau);
  border: 1px solid var(--bord);
  border-radius: 6px;
  padding: 0.75rem;
}

.vue h2 { margin: 0 0 0.5rem; font-size: 1.05rem; font-weight: 600; }

#cv2d {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  cursor: pointer;
}

#cv3d {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #eef0f3;
  cursor: grab;
  touch-action: none;
}

#cv3d:active { cursor: grabbing; }

.aide { margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--discret); }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  main { grid-template-columns: 1fr; }
}
