@charset "utf-8";
:root {
  --bg: #0f0d14;
  --panel: #1a1723;
  --line: #2e2a3b;
  --text: #f2eff7;
  --muted: #9a94ab;
  --accent: #ffd23f;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, p { margin: 0; }
button { font: inherit; }

.top { padding: 10px 24px 0; max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; }
.top .logo { height: 48px; width: auto; flex: none; }
.top h1 { font-size: 20px; letter-spacing: .02em; }
.top p { color: var(--muted); font-size: 14px; }

.layout > * { min-width: 0; }
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 24px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

/* Scène */
.stage { position: sticky; top: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.canvas-wrap { position: relative; line-height: 0; max-width: 100%; }
#poster {
  max-width: 100%;
  max-height: calc(100vh - 106px);
  max-height: calc(100dvh - 106px);
  width: auto;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .55);
  touch-action: none;
  cursor: grab;
  background: #111;
}
#poster:active { cursor: grabbing; }
#poster:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.empty-cta {
  position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; line-height: 1.3;
}
.empty-cta[hidden], .cta-menu[hidden] { display: none; }
.cta-main {
  padding: 14px 22px; border: 0; border-radius: 999px; cursor: pointer; white-space: nowrap;
  background: var(--accent); color: #1a1200; font: 600 16px system-ui, sans-serif;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
.cta-menu {
  display: flex; flex-direction: column; gap: 4px; padding: 6px; min-width: 190px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .6);
}
.cta-menu button {
  padding: 10px 14px; border: 0; border-radius: 10px; background: #262234; color: var(--text); cursor: pointer; text-align: left; white-space: nowrap;
}
.cta-menu button:hover { background: #322d44; }
.hint { color: var(--muted); font-size: 12.5px; text-align: center; }

/* Panneau */
.panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel > section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.panel h2 { font-size: 14px; display: flex; align-items: center; gap: 8px; min-height: 24px; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #1a1200; font-size: 12px; font-weight: 700; flex: none; }
.push { margin-left: auto; font-weight: 400; }

/* Sélecteur « Déplacer » : collé en haut du panneau pour rester visible pendant le défilement */
.seg {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
.seg-label { color: var(--muted); margin: 0 2px; font-size: 14px; }
.seg button {
  flex: 1; padding: 6px 12px; border: 1px solid var(--line); background: #262234; color: var(--text);
  border-radius: 999px; cursor: pointer; min-height: 34px;
}
.seg button[aria-checked="true"] { background: var(--accent); color: #1a1200; border-color: var(--accent); font-weight: 600; }

.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row .btn { flex: 1 1 auto; }
#btn-upload { flex: 1.4 1 0; white-space: nowrap; }
#btn-nextcloud { flex: 1 1 0; }
.btn {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: #262234; color: var(--text);
  cursor: pointer; min-height: 38px;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled, .seg button:disabled, .font-grid button:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1200; font-weight: 600; }
.btn.small { padding: 5px 10px; font-size: 13px; min-height: 32px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }

/* Une ligne « libellé · curseur · action » */
.line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.line > label:first-child { color: var(--muted); font-size: 13px; flex: none; min-width: 2.6rem; }
.line input[type="range"] { flex: 1; min-width: 0; }
.name-line .text-input { flex: 1; min-width: 0; }
input[type="range"] { accent-color: var(--accent); width: 100%; height: 24px; margin: 0; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; white-space: nowrap; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.text-input, #nc-body input:not([type]), #nc-body input[type="password"] {
  width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #110f18; color: var(--text); font: inherit; font-size: 16px; min-height: 40px;
}
.text-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.muted { color: var(--muted); }
.error { color: #ff7a8a; }
.small-note { font-size: 13px; }

/* Réglages de la photo : section repliable (sur ordinateur) */
#sec-adjust { padding: 0; }
#sec-adjust .advanced { border: 0; background: none; }
#sec-adjust .advanced summary { padding: 12px; font-weight: 600; }

/* Réglages avancés (accordéon) */
.advanced { border: 1px solid var(--line); border-radius: 10px; background: #14121b; }
.advanced summary { cursor: pointer; padding: 8px 12px; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 38px; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "▸"; color: var(--accent); transition: transform .15s; }
.advanced[open] summary::before { transform: rotate(90deg); }
.adv-body { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px; }
.adv-body > .btn { align-self: flex-start; }
.sliders { display: flex; flex-direction: column; gap: 4px; }
.slider { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) 3rem; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.slider output { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.rgb-r input { accent-color: #ff5a5a; }
.rgb-g input { accent-color: #46d160; }
.rgb-b input { accent-color: #5a8dff; }
.sliders .row { margin-top: 6px; }
.sliders .row .btn { flex: 0 1 auto; }

/* Soirées : une rangée défilante */
.gala-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 156px; overflow-y: auto; }
.gala {
  display: flex; min-width: 0; align-items: center; gap: 8px; padding: 5px 8px 5px 5px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--line); background: #110f18; color: var(--text); font: inherit; text-align: left; min-height: 46px;
}
.gala[aria-checked="true"] { border-color: var(--accent); }
.gala img { width: 30px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 4px; }
.gala > span:nth-of-type(1) { min-width: 0; flex: 1; }
.gala .gt { font-weight: 600; display: block; font-size: 13.5px; line-height: 1.15; overflow-wrap: anywhere; }
.gala .gd { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.gala .sw { display: none; }

.font-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; max-height: 150px; overflow: auto; padding: 2px; }
.font-grid button {
  padding: 6px 8px; border: 2px solid var(--line); border-radius: 8px; background: #110f18; color: var(--text);
  font-size: 18px; line-height: 1.2; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 40px;
}
.font-grid button[aria-checked="true"] { border-color: var(--accent); }

/* Nextcloud */
dialog { width: min(720px, calc(100vw - 24px)); max-height: 86vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog[open] { display: flex; flex-direction: column; }
.nc-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.nc-head h2 { font-size: 16px; }
.nc-body { padding: 16px 18px 20px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.nc-body details { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.nc-body details > * { margin-top: 8px; }
.nc-bar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crumbs { color: var(--muted); }
.nc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.nc-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px; border-radius: 10px;
  border: 1px solid var(--line); background: #110f18; color: var(--text); cursor: pointer; font: inherit; font-size: 12px;
}
.nc-tile:hover { border-color: var(--accent); }
.nc-tile img, .nc-tile .ico { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: grid; place-items: center; font-size: 34px; }
.nc-tile span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-tile.loading { opacity: .5; pointer-events: none; }
.muted { color: var(--muted); }
.error { color: #ff7a8a; }

.tabbar { display: none; }

/* Mobile : façon éditeur photo — grande image, barre de 4 boutons ronds en bas qui ouvre une section à la fois */
@media (max-width: 900px) {
  body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .top { display: none; }
  .layout { flex: 1; min-height: 0; align-items: stretch; width: 100%; max-width: none; margin: 0; padding: 8px 10px 0; display: flex; flex-direction: column; gap: 6px; }
  .stage { position: static; flex: 1 1 auto; min-height: 0; width: 100%; gap: 0; }
  .canvas-wrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
  #poster { max-width: 100%; max-height: 100%; border-radius: 4px; }
  .hint { display: none; }

  .panel { flex: none; gap: 6px; padding-bottom: env(safe-area-inset-bottom); }
  .seg { position: static; padding: 4px 6px; box-shadow: none; }
  .seg button { min-height: 32px; padding: 4px 10px; }

  /* une seule section visible, sous forme de tiroir défilant */
  .panel > section.sheet { display: none; max-height: 42vh; max-height: 42dvh; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px; }
  .panel > section.sheet.open { display: flex; }
  .panel h2 .step { display: none; }
  /* dans son tiroir, la section Réglages est toujours dépliée */
  #sec-adjust { padding: 10px 12px; }
  #sec-adjust .advanced summary { display: none; }
  #sec-adjust .adv-body { padding: 0; }

  .tabbar { display: flex; justify-content: space-around; gap: 4px; padding: 4px 0 8px; }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; min-width: 0; max-width: 84px;
    background: none; border: 0; color: var(--muted); font-size: 11.5px; cursor: pointer; padding: 0;
  }
  .tab-ico {
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
    background: var(--panel); border: 1px solid var(--line); color: var(--text); transition: background .15s, color .15s;
  }
  .tab-ico svg { width: 22px; height: 22px; }
  .tab[aria-expanded="true"] { color: var(--text); font-weight: 600; }
  .tab[aria-expanded="true"] .tab-ico { background: var(--accent); border-color: var(--accent); color: #1a1200; }

  /* soirées : une seule rangée qu'on fait défiler du doigt */
  .gala-list { display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scrollbar-width: none; max-height: none; }
  .gala-list::-webkit-scrollbar { display: none; }
  .gala { flex: 0 0 auto; scroll-snap-align: start; }
  .gala .gt { white-space: nowrap; }
}
/* Téléphone en paysage : image à gauche, outils à droite */
@media (max-width: 900px) and (orientation: landscape) {
  .layout { flex-direction: row; padding-bottom: 6px; }
  .panel { width: min(360px, 48%); justify-content: flex-end; }
  .panel > section.sheet { max-height: calc(100dvh - 140px); }
}
@media (max-width: 380px) {
  .slider { grid-template-columns: 4.4rem minmax(0, 1fr) 2.8rem; }
}
