:root {
  --bg: #0d0e12;
  --panel: #16181f;
  --panel-2: #1e212b;
  --line: #2a2e3a;
  --text: #e8e9ee;
  --muted: #9aa0ad;
  --accent: #7aa2ff;
  --accent-2: #b98bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }



.topbar {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: calc(100% - 74px);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sidebar h2 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

button.primary {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #0d0e12;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.primary:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: progress; }

.presets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.presets li button {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.presets li button:hover:not(:disabled) { border-color: var(--accent); background: #232734; }
.presets li button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.presets li button .pname { display: block; font-weight: 600; font-size: 14px; }
.presets li button .pdesc { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.credits { margin-top: auto; font-size: 11.5px; color: var(--muted); line-height: 1.6; }

.stage {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  overflow-y: auto;
}
.viewer {
  width: min(760px, 100%);
  aspect-ratio: 1 / 1;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
#artwork { width: 100%; height: 100%; object-fit: contain; display: block; }
#artwork[hidden] { display: none; }

.placeholder { text-align: center; color: var(--muted); padding: 24px; }
.placeholder .hint { font-size: 12px; margin-top: 6px; }
#status { margin: 12px 0 0; font-size: 14px; }

.spinner {
  width: 34px; height: 34px;
  margin: 0 auto;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.caption { width: min(760px, 100%); text-align: center; }
.caption h3 { margin: 0; font-size: 17px; }
.caption p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.caption .meta { font-size: 12px; color: #6b7280; font-variant-numeric: tabular-nums; }

.error { color: #ff8b8b; }

/* --- Mobile / tablette étroite ------------------------------------------- */
@media (max-width: 720px) {
  /* La page défile naturellement plutôt que deux panneaux à défilement interne. */
  html, body { height: auto; min-height: 100%; }
  .layout { grid-template-columns: 1fr; height: auto; }

  /* L'œuvre d'abord (rendue automatiquement au chargement), les contrôles sous
     le pli : sur mobile on veut voir l'image, pas la liste de presets. */
  .stage { order: 1; padding: 16px; overflow: visible; }
  .sidebar {
    order: 2;
    border-right: none;
    border-top: 1px solid var(--line);
    overflow: visible;
  }

  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 19px; }

  .viewer, .caption { width: 100%; }

  /* Cibles tactiles plus généreuses. */
  button.primary { padding: 14px; }
  .presets li button { padding: 12px; }
}

@media (max-width: 420px) {
  .stage { padding: 12px; }
  .sidebar { padding: 14px; gap: 16px; }
  .topbar { padding: 12px 14px; }
  .tagline { font-size: 12px; }
}

/* Respecte la préférence système de réduction des animations. */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  button.primary { transition: none; }
}
