/* Apparence de Strascloud. TOUT le design est ici : les scripts ne posent que des noms de classes. */

/* Jetons du thème (clair par défaut, sombre au choix ou selon l'appareil). */
:root { --bg: #f4f2ee; --sf: #fbfaf8; --tx: #1c1c1e; --mu: #55555a; --bd: #cfcbc2; --ac: #b8301f; --on: #ffffff; --ink: #1c1c1e;
  --okbg: #d9efe2; --ok: #11522f; --wrbg: #fdf0c9; --wr: #5c4300; --erbg: #fbe0dc; --er: #8c1c10; --veil: rgba(0,0,0,.55); --r: 8px; --ts: 1;
  --c-photos: #8fd3ff; --c-files: #b4bdff; --c-team: #ffb0c8; --c-transfer: #d6b8ff; --c-scan: #c9e8a0; --c-agenda: #9fe3b4; --c-notes: #ffe58a;
  --c-vault: #8fe0dc; --c-space: #f5c6c0; --c-look: #e8d9a8; --c-settings: #d9d6cf; --c-admin: #ffc67d;
  /* Toujours blancs, quel que soit le thème : fond du QR code (sinon illisible par l'appareil photo) et papier. */
  --paper: #ffffff; color-scheme: light; }
:root[data-theme="dark"] { --bg: #1b1b1d; --sf: #26262a; --tx: #f2f2f2; --mu: #bcbcc0; --bd: #45454b; --ac: #ff7a6e; --on: #1d0603;
  --okbg: #16402f; --ok: #a5f3cc; --wrbg: #4a3a0c; --wr: #ffe9a8; --erbg: #54201a; --er: #ffd0ca; color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] { --bg: #1b1b1d; --sf: #26262a; --tx: #f2f2f2; --mu: #bcbcc0; --bd: #45454b; --ac: #ff7a6e; --on: #1d0603;
    --okbg: #16402f; --ok: #a5f3cc; --wrbg: #4a3a0c; --wr: #ffe9a8; --erbg: #54201a; --er: #ffd0ca; color-scheme: dark; }
}
:root[data-text="big"] { --ts: 1.15; }
:root[data-text="bigger"] { --ts: 1.3; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--tx); font: calc(16px * var(--ts)) / 1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; font-size: calc(16px * var(--ts)); }
/* Boutons : cibles d'au moins 44 px au doigt. */
button, .btn { display: inline-block; min-height: 44px; padding: 9px 16px; border: 1px solid var(--bd); border-radius: var(--r); background: var(--sf); color: var(--tx); font-weight: 600; line-height: 1.3; cursor: pointer; text-decoration: none; text-align: center; }
button.p, .btn.p { background: var(--ac); color: var(--on); border-color: var(--ac); }
button.danger { color: var(--er); border-color: var(--er); }
button:disabled { opacity: .55; cursor: default; }
button:focus, input:focus, select:focus, textarea:focus, a:focus { outline: 3px solid var(--ac); outline-offset: 2px; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
input, select, textarea { width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid var(--bd); border-radius: var(--r); background: var(--bg); color: var(--tx); }
textarea { min-height: 120px; resize: vertical; }
input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; flex: none; }
label { display: block; margin: 12px 0 4px; font-weight: 600; }
label.chk { display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 400; }
h1 { font-size: 1.3rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 18px 0 8px; }
a { color: var(--ac); }
.mu { color: var(--mu); font-size: .92em; }
.boot { padding: 24px; text-align: center; }

/* Écrans sans compte : une colonne centrée. */
.auth { max-width: 420px; margin: 0 auto; padding: 24px 16px; padding-top: calc(24px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.auth form button { width: 100%; margin-top: 14px; }
.auth .links { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.logo { display: inline-block; width: 27px; height: 27px; margin-right: 8px; vertical-align: -6px; }
.logo b { float: left; width: 12px; height: 12px; margin: 0 3px 3px 0; border-radius: 2px; background: var(--c-photos); }
.logo b:nth-child(2) { background: var(--c-files); }
.logo b:nth-child(3) { background: var(--c-admin); }
.logo b:nth-child(4) { background: var(--ac); }

/* Structure : barre à gauche sur grand écran, barre du bas à 3 entrées sinon. */
.side { display: none; }
.top { position: -webkit-sticky; position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--bd); }
.top form { flex: 1 1 auto; min-width: 0; }
.top .btn { flex: none; }
.page { padding: 12px; padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); padding-bottom: calc(90px + env(safe-area-inset-bottom)); max-width: 1100px; overflow-wrap: break-word; word-wrap: break-word; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--sf); border-top: 1px solid var(--bd); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1 1 0; min-height: 58px; padding: 6px 2px; text-align: center; text-decoration: none; color: var(--mu); font-weight: 600; font-size: .85em; }
.tabbar a[aria-current="page"] { color: var(--tx); box-shadow: inset 0 -3px 0 var(--ac); }
.tabbar span { display: block; font-size: 1.4em; }
@media (min-width: 900px) {
  .shell { display: flex; align-items: flex-start; }
  .side { display: block; flex: none; width: 220px; position: -webkit-sticky; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 12px; background: var(--sf); border-right: 1px solid var(--bd); }
  .side a { display: block; padding: 9px 10px; border-radius: var(--r); color: var(--tx); text-decoration: none; font-weight: 600; }
  .side a[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--ac); }
  .main { flex: 1 1 auto; min-width: 0; }
  .tabbar { display: none; }
  .page { padding-bottom: 40px; }
}

/* Tuiles pleine couleur : texte foncé, lisible dans les deux thèmes. */
.tiles { display: flex; flex-wrap: wrap; margin: 0 -4px; }
.tile { display: flex; flex-direction: column; justify-content: space-between; width: calc(33.333% - 8px); min-height: 90px; margin: 4px; padding: 10px; border-radius: var(--r); color: var(--ink); font-weight: 800; font-size: .9em; text-decoration: none; }
.tile span { font-size: 1.7em; }
@media (min-width: 900px) { .tile { width: calc(16.666% - 8px); } }
.t-photos { background: var(--c-photos); } .t-files { background: var(--c-files); } .t-team { background: var(--c-team); } .t-transfer { background: var(--c-transfer); }
.t-scan { background: var(--c-scan); } .t-agenda { background: var(--c-agenda); } .t-notes { background: var(--c-notes); } .t-vault { background: var(--c-vault); }
.t-space { background: var(--c-space); } .t-look { background: var(--c-look); } .t-settings { background: var(--c-settings); } .t-admin { background: var(--c-admin); }

.card { background: var(--sf); border: 1px solid var(--bd); border-radius: var(--r); padding: 12px; margin: 10px 0; }
progress { width: 100%; height: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: center; margin: 6px -4px; }
.row > * { margin: 4px; }
.item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--bd); }
.item:last-child { border-bottom: 0; }
.item > .grow { flex: 1 1 190px; min-width: 0; margin-right: 8px; overflow-wrap: break-word; word-wrap: break-word; }
.item > .grow b { display: block; }
.item > .acts { display: flex; flex-wrap: wrap; }
.item > .acts > * { margin: 3px; }
.item select { width: auto; max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; margin: 0 -4px; }
.chips a, .chips button { margin: 4px; }
.chips a { min-height: 44px; padding: 9px 14px; border: 1px solid var(--bd); border-radius: 22px; background: var(--sf); color: var(--tx); text-decoration: none; font-weight: 600; }
.chips a[aria-current="page"], button[aria-pressed="true"] { background: var(--tx); color: var(--bg); border-color: var(--tx); }
.badge { display: inline-block; padding: 1px 10px; border-radius: 20px; background: var(--okbg); color: var(--ok); font-size: .82em; font-weight: 700; }
.badge.w { background: var(--wrbg); color: var(--wr); }
.note { margin: 10px 0; padding: 10px 12px; border-radius: var(--r); background: var(--wrbg); color: var(--wr); }
.note.ok { background: var(--okbg); color: var(--ok); }
.note.err { background: var(--erbg); color: var(--er); }
.empty { padding: 28px 12px; text-align: center; color: var(--mu); }
.pre { white-space: pre-wrap; }

/* Fichiers : vue en icônes (comme un Drive) ou en liste. */
.files { display: flex; flex-wrap: wrap; margin: 0 -5px; }
.fi { position: relative; width: calc(50% - 10px); margin: 5px; background: var(--sf); border: 1px solid var(--bd); border-radius: var(--r); }
@media (min-width: 600px) { .fi { width: calc(25% - 10px); } }
@media (min-width: 1100px) { .fi { width: calc(20% - 10px); } }
.fi .open { display: flex; flex-direction: column; align-items: center; width: 100%; height: 100%; padding: 12px 8px 50px; border: 0; background: transparent; color: var(--tx); text-decoration: none; text-align: center; }
.fi .open b { max-width: 100%; margin-top: 6px; font-size: .92em; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; }
.fi .open small { color: var(--mu); font-weight: 400; }
.fi .more { position: absolute; right: 4px; bottom: 4px; min-width: 48px; border: 0; background: transparent; font-size: 1.3em; }
.thumb { display: flex; align-items: center; justify-content: center; width: 80px; height: 64px; font-size: 2.6em; line-height: 1; }
.thumb img { width: 80px; height: 64px; object-fit: cover; border-radius: 4px; }
.folder { position: relative; display: block; width: 74px; height: 52px; margin: 10px 3px 2px; border-radius: 0 6px 6px 6px; background: var(--c-files); }
.folder::before { content: ""; position: absolute; left: 0; top: -8px; width: 32px; height: 8px; border-radius: 6px 6px 0 0; background: inherit; }
.folder.team { background: var(--c-team); }
.crumb a, .crumb span { display: inline-block; padding: 8px 4px; }

/* Galerie : vignettes réduites par le serveur, chargées à la demande. */
.gallery { display: flex; flex-wrap: wrap; margin: 0 -2px; }
.gallery button { position: relative; width: calc(33.333% - 4px); margin: 2px; padding: 0 0 calc(33.333% - 4px); border: 0; overflow: hidden; background: var(--sf); }
@media (min-width: 900px) { .gallery button { width: calc(16.666% - 4px); padding-bottom: calc(16.666% - 4px); } }
.gallery img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; }

/* Fenêtres : toujours plus petites que l'écran, et elles défilent. */
.veil { position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 12px; padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom)); background: var(--veil); }
.box { width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; border-radius: var(--r); background: var(--sf); color: var(--tx); }
.box.wide { max-width: 900px; }
/* Sur téléphone, la fenêtre part du haut : le clavier ne cache pas les champs. */
@media (max-width: 600px) { .veil { align-items: flex-start; } }
/* La page derrière une fenêtre ne défile pas. */
body.locked { overflow: hidden; }
.box .list button, .box .list a { display: block; width: 100%; margin: 6px 0; text-align: left; }
.box img, .box video { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto; }
.box audio { width: 100%; }
.qr { display: block; margin: 8px auto; width: 220px; height: 220px; background: var(--paper); padding: 10px; image-rendering: pixelated; }
.value { display: block; padding: 10px; border: 1px dashed var(--bd); border-radius: var(--r); background: var(--bg); color: var(--tx); word-break: break-all; -webkit-user-select: all; user-select: all; }
.big-code { font-size: 1.6em; font-weight: 700; text-align: center; }

#toast:not(:empty) { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30; max-width: 520px; margin: 0 auto; padding: 12px 14px; border-radius: var(--r); background: var(--tx); color: var(--bg); }
#uploads:not(:empty) { position: fixed; right: 12px; left: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 15; max-width: 420px; max-height: 40vh; margin-left: auto; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--bd); border-radius: var(--r); background: var(--sf); color: var(--tx); }

/* Impression (export PDF) : seulement le contenu. */
@media print { .side, .top, .tabbar, .row, .chips, #toast, #uploads { display: none !important; } body, .card { background: var(--paper); color: var(--ink); } .mu { color: var(--ink); } }
