/* LivraPhoto — lisible en plein soleil : fond béton, texte noir, jaune de gilet haute visibilité pour l'action. */
:root {
  --bg: #e7e8e2;
  --surface: #f7f7f3;
  --ink: #101418;
  --ink-2: #4b535b;
  --line: #c6c8c0;
  --hivis: #ffd400;
  --on-hivis: #101418;
  --perso: #2a5bd9;
  --ok: #1b8a4b;
  --warn: #d95f0b;
  --bad: #c62828;
  --bar: #101418;
  --on-bar: #f1f1ec;
  --r: 10px;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --surface: #1d2126;
    --ink: #f1f1ec;
    --ink-2: #a3aab2;
    --line: #373d44;
    --perso: #6f98ff;
    --ok: #48c27a;
    --warn: #ff8a3d;
    --bad: #ff6b6b;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
h1, h2 { margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--hivis); outline-offset: 2px; }
.boot { padding: 40px 20px; text-align: center; color: var(--ink-2); }
.ic { display: inline-flex; flex: none; }
.ic svg { width: 22px; height: 22px; display: block; }
.ic.big svg { width: 40px; height: 40px; }

/* ------------------------------------------------------------ Marque */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; }
.mark { width: 24px; height: 24px; border-radius: 50%; background: var(--hivis); border: 3px solid #fff; display: grid; place-items: center; flex: none; }
.mark span { width: 8px; height: 8px; border-radius: 50%; background: var(--on-hivis); }
.brand.big { flex-direction: column; gap: 14px; font-size: 26px; margin-bottom: 6px; }
.brand.big .mark { width: 84px; height: 84px; border-width: 7px; border-color: var(--ink); }
.brand.big .mark span { width: 26px; height: 26px; }

/* ------------------------------------------------------------ Structure */
.shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 14px 10px; background: var(--bar); color: var(--on-bar); flex: none;
}
.topbar .mark { border-color: var(--on-bar); }
.main { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 16px 28px; -webkit-overflow-scrolling: touch; }
.banners { flex: none; }
.screen { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr); flex: none;
  background: var(--surface); border-top: 2px solid var(--ink);
  padding-bottom: var(--safe-b);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tab-h); text-decoration: none; font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.tab.on { color: var(--ink); }
.tab.on::before { content: ""; position: absolute; top: -2px; left: 18%; right: 18%; height: 5px; background: var(--hivis); }

/* ------------------------------------------------------------ État d'envoi */
.pill {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px;
  padding: 7px 12px 7px 9px; font-size: 13px; font-weight: 700; background: #2a3037; color: var(--on-bar);
}
.pill .ic svg { width: 16px; height: 16px; }
.pill.ok .ic { color: #54d68a; }
.pill.off { background: #3a3f46; color: #c9ced4; }
.pill.warn { background: var(--hivis); color: var(--on-hivis); }
.pill.busy { background: var(--hivis); color: var(--on-hivis); }
.pill.busy .ic { animation: spin 1.2s linear infinite; }
.pill.bad { background: var(--bad); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ Boutons, champs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: var(--r); border: 2px solid var(--ink);
  background: var(--surface); color: var(--ink); font-weight: 800; text-decoration: none;
}
.btn.primary { background: var(--hivis); color: var(--on-hivis); border-color: #101418; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.ghost.light { color: #fff; border-color: #fff; }
.btn.big { min-height: 58px; font-size: 18px; width: 100%; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 2px solid transparent; border-radius: var(--r); background: transparent; text-decoration: none;
}
.icon-btn.on { background: var(--hivis); color: var(--on-hivis); }
.link { background: none; border: 0; padding: 12px 4px; text-decoration: underline; font-weight: 700; color: var(--ink); align-self: center; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .lbl { font-weight: 700; font-size: 15px; }
.lbl { color: var(--ink-2); }
.input {
  width: 100%; min-height: 52px; padding: 0 14px; font-size: 17px; border-radius: var(--r);
  background: var(--surface); border: 2px solid var(--line); color: var(--ink);
}
.input:focus { border-color: var(--ink); outline: 3px solid var(--hivis); outline-offset: 0; }
.input.search { padding-left: 14px; }
.hint { color: var(--ink-2); font-size: 14px; text-align: center; }
.hint.left { text-align: left; }
.hint.tight { margin-top: -2px; }
.err { color: var(--bad); font-weight: 700; font-size: 15px; }
.notice { background: var(--surface); background: color-mix(in srgb, var(--hivis) 28%, transparent); border-left: 5px solid var(--hivis); padding: 10px 12px; border-radius: 6px; font-size: 15px; }

/* Choix Pro / Perso : la couleur sert de repère partout dans l'appli */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.seg-b { min-height: 48px; border: 0; background: var(--surface); font-weight: 800; }
.seg-b + .seg-b { border-left: 2px solid var(--ink); }
.seg-b.on { background: var(--ink); color: var(--bg); }
.seg-b.on.pro { background: var(--hivis); color: var(--on-hivis); }
.seg-b.on.perso { background: var(--perso); color: #fff; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 800; }
.tag.pro { background: var(--hivis); color: var(--on-hivis); }
.tag.perso { background: var(--perso); color: #fff; }

/* Suggestions de lieux */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--ink); border-radius: 999px; background: var(--surface); min-height: 40px; padding: 0 14px; font-weight: 700; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.pro { border-left: 8px solid var(--hivis); }
.chip.perso { border-left: 8px solid var(--perso); }

/* ------------------------------------------------------------ Photos de l'écran « Photo » */
.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shot { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: #000; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-x { position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.7); color: #fff; display: grid; place-items: center; }
.shot-x .ic svg { width: 18px; height: 18px; }
.add-shot {
  aspect-ratio: 1; border-radius: var(--r); border: 2px dashed var(--ink); background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 14px; padding: 6px;
}
.shots > .add-shot:only-child { grid-column: 1 / -1; aspect-ratio: auto; min-height: 150px; font-size: 17px; }
.add-ring { width: 56px; height: 56px; border-radius: 50%; background: var(--hivis); color: var(--on-hivis); border: 4px solid var(--ink); display: grid; place-items: center; }
.shots > .add-shot:only-child .add-ring { width: 72px; height: 72px; }

/* ------------------------------------------------------------ Appareil photo */
.camera { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; overflow: hidden; overscroll-behavior: contain; }
.cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash 0.22s ease-out; }
@keyframes flash { from { opacity: 0.85; } to { opacity: 0; } }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(12px + var(--safe-t)) 14px 24px; background: linear-gradient(#0009, transparent); }
.cam-count { font-weight: 800; font-size: 15px; text-shadow: 0 1px 4px #000; }
.cam-round { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(16, 20, 24, 0.7); color: #fff; display: grid; place-items: center; }
.cam-round.on { background: var(--hivis); color: var(--on-hivis); }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 28px 18px calc(22px + var(--safe-b)); background: linear-gradient(transparent, #000a); }
.cam-side { display: flex; align-items: center; }
.cam-side:last-child { justify-content: flex-end; }
.cam-last { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; border: 2px solid #fff; }
.cam-done { min-height: 48px; padding: 0 18px; border-radius: 999px; border: 2px solid #fff; background: rgba(16, 20, 24, 0.6); color: #fff; font-weight: 800; }
.shutter { width: 86px; height: 86px; border-radius: 50%; border: 6px solid #fff; background: transparent; padding: 0; display: grid; place-items: center; }
.shutter span { width: 62px; height: 62px; border-radius: 50%; background: var(--hivis); display: block; transition: transform 0.08s; }
.shutter:active span { transform: scale(0.88); }
.shutter:disabled { opacity: 0.6; }
.cam-msg { position: absolute; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 12px; text-align: center; background: rgba(16, 20, 24, 0.92); padding: 20px; border-radius: 14px; }
.cam-note { font-size: 13px; color: #c9ced4; }

/* ------------------------------------------------------------ Classeur */
.search-row { display: flex; gap: 8px; align-items: center; }
.dates { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.dates label { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 130px; font-weight: 700; font-size: 14px; }
.count { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.results { display: flex; flex-direction: column; gap: 12px; }
.loading { color: var(--ink-2); text-align: center; padding: 24px 0; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 36px 12px; color: var(--ink-2); }
.empty strong { color: var(--ink); font-size: 18px; }

.folder {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 10px; text-decoration: none;
  background: var(--surface); border-radius: var(--r); border-left: 8px solid var(--hivis);
}
.folder.perso { border-left-color: var(--perso); }
.folder-cover { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex: none; background: #000; }
.folder-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.folder-name { font-weight: 800; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-meta { font-size: 13px; color: var(--ink-2); }
.folder-head { display: flex; align-items: center; gap: 8px; padding-left: 6px; border-left: 8px solid var(--hivis); }
.folder-head.perso { border-left-color: var(--perso); }
.folder-head h1 { font-size: 24px; margin-top: 4px; overflow-wrap: anywhere; }

.delivery { background: var(--surface); border-radius: var(--r); padding: 12px; border-left: 8px solid var(--hivis); display: flex; flex-direction: column; gap: 10px; }
.delivery.perso { border-left-color: var(--perso); }
.dl-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.dl-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dl-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 17px; }
.dl-title strong { overflow-wrap: anywhere; }
.dl-when { font-weight: 700; }
.dl-by { font-size: 13px; color: var(--ink-2); }
.dl-note { font-size: 15px; margin-top: 4px; overflow-wrap: anywhere; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumb { padding: 0; border: 0; border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ------------------------------------------------------------ Visionneuse */
.viewer { position: fixed; inset: 0; z-index: 55; background: #000; color: #fff; display: flex; flex-direction: column; overscroll-behavior: contain; }
.v-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 10px; }
.v-actions { display: flex; gap: 8px; }
.v-count { font-weight: 700; font-size: 14px; }
.v-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.v-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; background: rgba(16, 20, 24, 0.55); color: #fff; display: grid; place-items: center; }
.v-nav.prev { left: 0; border-radius: 0 10px 10px 0; }
.v-nav.next { right: 0; border-radius: 10px 0 0 10px; }
.v-info { padding: 12px 16px calc(16px + var(--safe-b)); font-size: 15px; display: flex; flex-direction: column; gap: 3px; background: #0c0f12; }
.v-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 17px; }
.v-late { color: #ffd400; font-size: 13px; }

/* ------------------------------------------------------------ Fenêtres du bas */
.sheet-back { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow-y: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; animation: rise 0.18s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
.sheet-title { font-size: 20px; }
.sheet-text { color: var(--ink-2); }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.edit { display: flex; flex-direction: column; gap: 16px; }

.q-list { display: flex; flex-direction: column; gap: 10px; }
.q-row { display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: var(--r); padding: 8px; border-left: 6px solid var(--warn); }
.q-row.failed { border-left-color: var(--bad); }
.q-row img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex: none; }
.q-text { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 14px; }
.q-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.q-meta { color: var(--ink-2); }
.q-state { font-weight: 700; }
.q-row.failed .q-state { color: var(--bad); }
.q-btns { display: flex; flex-direction: column; gap: 6px; }

/* ------------------------------------------------------------ Compte, connexion */
.card { background: var(--surface); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.who { font-size: 22px; }
.auth { max-width: 440px; margin: 0 auto; padding: calc(36px + var(--safe-t)) 20px 40px; display: flex; flex-direction: column; gap: 16px; }
.auth h1 { font-size: 26px; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.code-box { font-size: 34px; font-weight: 800; letter-spacing: 0.08em; text-align: center; padding: 22px 8px; border-radius: var(--r); background: var(--hivis); color: var(--on-hivis); border: 3px solid var(--ink); user-select: all; -webkit-user-select: all; }

.banner { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); background: color-mix(in srgb, var(--hivis) 30%, var(--bg)); border-bottom: 2px solid var(--ink); font-size: 14px; }
.banner.warn { background: var(--hivis); color: var(--on-hivis); }
.banner p { flex: 1; }
.banner .btn { flex: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px);
  max-width: min(92vw, 480px); padding: 12px 18px; border-radius: var(--r); background: var(--ink); color: var(--bg);
  font-weight: 700; z-index: 90; opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-bottom: 5px solid var(--ok); }
.toast.warn { border-bottom: 5px solid var(--hivis); }
.toast.bad { border-bottom: 5px solid var(--bad); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (min-width: 700px) {
  .main { padding-top: 24px; }
  .thumbs, .shots { grid-template-columns: repeat(4, 1fr); }
}

/* Administration */
.card.wide { align-self: stretch; align-items: stretch; }
.sline { margin: 0; color: var(--ink-2); font-size: 15px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.ulist { display: flex; flex-direction: column; gap: 8px; }
.urow { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left; width: 100%; padding: 12px 14px; border: 0; border-radius: var(--r); background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.urow.off { opacity: .65; }
.uname { font-weight: 800; font-size: 18px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.umeta { color: var(--ink-2); font-size: 14px; }
.tag.admin { background: var(--ink); color: var(--bg, #fff); }
.tag.off { background: #b3261e; color: #fff; }

/* Points, niveaux, hauts faits */
.reward { color: var(--ink); font-weight: 700; }
.sec { margin: 4px 0 -6px; font-size: 20px; }
.lvl-top { display: flex; align-items: baseline; gap: 12px; }
.lvl-n { font-size: 34px; font-weight: 900; }
.lvl-t { font-size: 18px; font-weight: 800; background: var(--hivis); color: var(--on-hivis, #101418); padding: 2px 10px; border-radius: 4px; }
.bar { height: 14px; border-radius: 7px; background: rgba(128,128,128,.28); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--hivis); border-right: 2px solid var(--ink); border-radius: 7px 0 0 7px; }
.sline.streak { color: var(--ink); font-weight: 800; }
.rank-head { display: flex; justify-content: space-between; align-items: baseline; }
.rlist { display: flex; flex-direction: column; gap: 6px; }
.rrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(128,128,128,.12); }
.rrow.me { background: var(--hivis); color: var(--on-hivis, #101418); }
.rrow.me .umeta { color: inherit; opacity: .75; }
.rk { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 900; background: var(--bg); }
.rk.top1 { background: #f2c200; color: #101418; } .rk.top2 { background: #c3c7ce; color: #101418; } .rk.top3 { background: #c98a52; color: #101418; }
.rname { flex: 1; display: flex; flex-direction: column; font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
.rpts { font-weight: 900; white-space: nowrap; }
.rsep { text-align: center; color: var(--ink-2); line-height: 1; }
.badges { display: flex; flex-direction: column; gap: 10px; }
.bfam { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r); background: var(--surface); }
.bmedals { display: grid; grid-template-columns: repeat(2, auto); gap: 6px; flex: none; }
.btext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.medal { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 3px solid var(--ink); font-size: 20px; }
.medal.bronze { background: #c98a52; } .medal.argent { background: #cfd3da; } .medal.or { background: #f2c200; } .medal.platine { background: #8fe3f0; }
.medal.locked { background: rgba(128,128,128,.25); border-color: rgba(128,128,128,.45); }
.medal.locked .medal-ic { filter: grayscale(1); opacity: .35; }
.cele { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.cele-pts { margin: 0; font-size: 22px; font-weight: 900; text-align: center; }
.cele-lvl { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cele-n { font-size: 40px; font-weight: 900; }
.cele-t { font-size: 20px; font-weight: 800; background: var(--hivis); color: #101418; padding: 2px 12px; border-radius: 4px; }
.cele-badge { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; }

/* Clients */
.cust { display: flex; flex-direction: column; gap: 8px; }
.cust-sel { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 14px; border: 2px solid var(--ink); border-left: 8px solid var(--hivis); border-radius: var(--r); background: var(--surface); font-size: 18px; }
.dl-cust { font-size: 15px; }
.tag.cust { background: var(--surface); color: var(--ink); border: 2px solid var(--ink); }
.folder-cover.blank { display: grid; place-items: center; background: rgba(128,128,128,.25); color: var(--ink-2); }
