:root {
  --bg: #0e0d0c;
  --panel: #191715;
  --panel-2: #221f1c;
  --line: #2f2b27;
  --text: #f3eee8;
  --muted: #a39b91;
  --accent: #f2a03d;
  --accent-ink: #1a1206;
  --ok: #6fcf8f;
  --danger: #ff6b5e;
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* Boutons et champs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px;
  padding: 11px 18px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #ffb257; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 13px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); cursor: pointer; font-size: 18px; flex: none; }
.icon-btn:hover { background: rgba(255,255,255,.16); }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input.in {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; outline: none; font-size: 16px;
}
input.in:focus { border-color: var(--accent); }
input.code-in { font-family: var(--mono); letter-spacing: .18em; text-transform: uppercase; font-size: 20px; text-align: center; }

/* Accueil */
.home { max-width: 980px; margin: 0 auto; padding: 48px 20px 64px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; letter-spacing: -.01em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.brand-mark i { width: 14px; height: 14px; border: 3px solid var(--accent-ink); border-radius: 50%; }
.hero h1 { font-size: clamp(34px, 6vw, 58px); line-height: 1.02; letter-spacing: -.03em; margin: 40px 0 14px; max-width: 760px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); font-size: 18px; max-width: 620px; line-height: 1.5; margin: 0 0 32px; }
.promise { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 36px; }
.promise span { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.promise b { color: var(--ok); margin-right: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card h2 { margin: 0 0 4px; font-size: 19px; }
.card p.sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.card .btn { width: 100%; margin-top: 4px; }
.mygroups { margin-top: 40px; }
.mygroups h3 { font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 12px; }
.glist { display: grid; gap: 10px; }
.gitem { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; text-decoration: none; }
.gitem:hover { border-color: #4a443d; }
.gitem small { color: var(--muted); }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 6px 0 0; }

/* Vue groupe */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(14,13,12,.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .gname { flex: 1; min-width: 0; }
.topbar .gname strong { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .gname small { color: var(--muted); font-size: 13px; }
.codechip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 14px; cursor: pointer; }
.codechip code { font-family: var(--mono); font-size: 15px; letter-spacing: .14em; color: var(--accent); }
.codechip span { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 18px 16px 120px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs button.on { background: var(--panel-2); color: var(--text); }
.spacer { flex: 1; }

.drop {
  border: 1.5px dashed #4a443d; border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted);
  margin-bottom: 18px; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop strong { color: var(--text); display: block; font-size: 16px; margin-bottom: 4px; }
.drop.over { border-color: var(--accent); background: rgba(242,160,61,.06); }
.drop .hint { font-size: 13px; margin-top: 8px; }

.queue { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 14px; margin-bottom: 18px; }
.qrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.qrow:last-child { border-bottom: 0; }
.qrow .qn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qrow .qs { color: var(--muted); font-variant-numeric: tabular-nums; }
.qrow .bar { grid-column: 1 / -1; height: 5px; background: var(--bg); border-radius: 9px; overflow: hidden; }
.qrow .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.qrow.done .bar i { background: var(--ok); }
.qrow.fail .qs { color: var(--danger); }
.qhead { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 13px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; } }
.tile { position: relative; aspect-ratio: 1; background: var(--panel); border-radius: 8px; overflow: hidden; cursor: pointer; border: 0; padding: 0; display: block; width: 100%; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.tile:hover img { transform: scale(1.03); }
.tile .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-family: var(--mono); font-size: 14px; text-transform: uppercase; }
.tile .badge { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.62); border-radius: 6px; padding: 3px 7px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .res { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.62); border-radius: 6px; padding: 3px 7px; font-size: 11px; font-weight: 700; color: var(--accent); }
.tile .chk { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.3); display: none; place-items: center; font-size: 14px; font-weight: 800; }
.selecting .tile .chk { display: grid; }
.tile.sel .chk { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tile.sel img { opacity: .75; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

.selbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 8px 8px 18px; box-shadow: 0 12px 40px rgba(0,0,0,.5); z-index: 30; max-width: calc(100% - 24px);
}
.selbar span { font-weight: 600; white-space: nowrap; }

.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 46px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; min-width: 230px; padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.5); z-index: 40; }
.menu-pop button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.menu-pop button:hover { background: rgba(255,255,255,.06); }
.menu-pop button.danger { color: var(--danger); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu-pop .lbl { padding: 8px 12px 4px; font-size: 12px; color: var(--muted); }

/* Visionneuse */
.lb { position: fixed; inset: 0; background: #000; z-index: 100; display: flex; flex-direction: column; }
.lb-top { display: flex; align-items: center; gap: 12px; padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); }
.lb-title { flex: 1; min-width: 0; }
.lb-title strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-title span { color: var(--muted); font-size: 13px; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; overflow: hidden; touch-action: pan-y pinch-zoom; }
.lb-stage img, .lb-stage video { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.lb-top, .lb-bottom { position: relative; z-index: 2; }
.lb-stage .nofmt { text-align: center; color: var(--muted); padding: 24px; line-height: 1.6; }
.lb-stage .loading { position: absolute; color: var(--muted); font-size: 14px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0; background: rgba(255,255,255,.07); font-size: 34px; cursor: pointer; border-radius: 10px; }
.lb-nav.prev { left: 10px; } .lb-nav.next { right: 10px; }
@media (max-width: 700px) { .lb-nav { display: none; } }
.lb-bottom { display: flex; gap: 10px; justify-content: center; padding: 12px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.lb-info { position: absolute; right: 12px; top: 70px; width: min(360px, calc(100% - 24px)); background: rgba(25,23,21,.96); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 14px; z-index: 3; }
.lb-info dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; }
.lb-info dt { color: var(--muted); }
.lb-info dd { margin: 0; word-break: break-all; }
.lb-info code { font-family: var(--mono); font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 200; max-width: calc(100% - 32px); text-align: center; }

.tile:not(.sel) .chk { color: transparent; }
.topbar .gname small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
@media (max-width: 560px) {
  .topbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .codechip { padding: 4px; }
  .codechip code { display: none; }
  .codechip span { padding: 7px 12px; font-size: 13px; }
  .drop { padding: 18px 14px; font-size: 14px; }
  .drop .hint { font-size: 12px; }
  .selbar { left: 10px; right: 10px; transform: none; padding: 6px 6px 6px 14px; gap: 6px; }
  .selbar span { flex: 1; font-size: 14px; }
  .selbar .btn { padding: 8px 11px; }
  #selall { display: none; }
}

/* iPhone guide */
.guide { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: -6px 0 18px; overflow: hidden; }
.guide summary { cursor: pointer; padding: 14px 16px; font-weight: 700; font-size: 15px; list-style: none; display: flex; align-items: center; gap: 10px; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: '+'; margin-left: auto; color: var(--muted); font-size: 20px; font-weight: 400; }
.guide[open] summary::after { content: '−'; }
.guide-ico { width: 18px; height: 26px; border: 2px solid var(--accent); border-radius: 5px; flex: none; position: relative; }
.guide-ico::after { content: ''; position: absolute; left: 50%; bottom: 2px; width: 5px; height: 2px; margin-left: -2.5px; background: var(--accent); border-radius: 2px; }
.guide-body { padding: 0 16px 16px; font-size: 14px; line-height: 1.55; }
.guide-warn { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: rgba(242,160,61,.1); border: 1px solid rgba(242,160,61,.3); }
.guide-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.guide section { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.guide h4 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.guide ol { margin: 0; padding-left: 20px; }
.guide li { margin-bottom: 4px; }
.guide-note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.guide-dl { margin-top: 12px; }
.guide-dl p { margin: 0; color: var(--muted); }
.tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.tag.best { background: var(--ok); color: #082312; }

/* Folders, one per person */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (min-width: 700px) { .folders { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; } }
.folders .empty { grid-column: 1 / -1; }
.folder { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; cursor: pointer; text-align: left; transition: border-color .15s, transform .08s; }
.folder:hover { border-color: #4a443d; }
.folder:active { transform: scale(.98); }
.mosaic { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px; aspect-ratio: 1; border-radius: 9px; overflow: hidden; }
.mosaic img, .mosaic i { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--panel-2); }
.fmeta { padding: 10px 4px 4px; }
.fmeta strong { display: flex; align-items: center; gap: 6px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmeta small { color: var(--muted); font-size: 13px; }
.you { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 2px 7px; }
.crumb { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ctitle strong { display: block; font-size: 18px; }
.ctitle small { color: var(--muted); font-size: 13px; }
