:root {
  --ink: #17161c;
  --ink-2: #4a4854;
  --muted: #8a8794;
  --line: #e8e6ef;
  --soft: #f4f3f8;
  --card: #ffffff;
  --accent: #5b4bff;
  --accent-ink: #ffffff;
  --accent-soft: #eeecff;
  --danger: #e5484d;
  --ok: #1f9d55;
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: #0e0d14;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- Fond animé ---------- */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; background: radial-gradient(120% 90% at 80% 10%, #1d1840 0%, #0e0d14 60%); }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .75; will-change: transform; }
.b1 { width: 55vmax; height: 55vmax; background: #5b4bff; top: -15vmax; right: -10vmax; animation: float1 22s ease-in-out infinite alternate; }
.b2 { width: 45vmax; height: 45vmax; background: #ff4f8b; bottom: -20vmax; right: 15vmax; animation: float2 26s ease-in-out infinite alternate; }
.b3 { width: 35vmax; height: 35vmax; background: #ffb13d; top: 30vh; right: 35vw; opacity: .45; animation: float3 30s ease-in-out infinite alternate; }
.grain { position: absolute; inset: 0; opacity: .08; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
@keyframes float1 { to { transform: translate(-8vmax, 10vmax) scale(1.1); } }
@keyframes float2 { to { transform: translate(10vmax, -8vmax) scale(.9); } }
@keyframes float3 { to { transform: translate(-12vmax, -6vmax) scale(1.2); } }
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } }

/* ---------- Structure ---------- */
.topbar { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 22px 32px; color: #fff; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: -.01em; font-size: 17px; }
.logo { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: #fff; color: var(--ink); }
.topbar nav { display: flex; gap: 6px; }
.ghost { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); color: #fff; padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; backdrop-filter: blur(8px); }
.ghost:hover { background: rgba(255,255,255,.2); }

.stage { position: relative; z-index: 1; display: flex; align-items: center; gap: 64px; min-height: calc(100vh - 90px); padding: 8px 32px 48px 7vw; }
.hero { color: #fff; max-width: 520px; }
.hero h1 { font-size: clamp(36px, 5vw, 64px); line-height: 1.02; letter-spacing: -.035em; margin: 0 0 18px; font-weight: 800; }
.hero p { font-size: 18px; line-height: 1.5; color: rgba(255,255,255,.72); margin: 0; }

/* ---------- Carte ---------- */
.card { background: var(--card); width: 360px; flex-shrink: 0; border-radius: var(--radius); box-shadow: 0 30px 80px -20px rgba(0,0,0,.55); overflow: hidden; }
.view { padding: 22px; }
.view h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.field { display: block; margin-top: 10px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 4px 2px; }
.field input, .field textarea, .field select, .chips {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; outline: none; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 44px; }
.field input:focus, .field textarea:focus, .field select:focus, .chips:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; cursor: text; }
.chips input { flex: 1; min-width: 140px; border: 0; padding: 4px; box-shadow: none !important; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; font-weight: 500; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; width: 20px; height: 20px; border-radius: 50%; line-height: 1; }
.chip button:hover { background: rgba(91,75,255,.15); }

.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; transition: transform .1s, background .15s, opacity .15s;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover { background: #4a39f0; }
.primary:active, .secondary:active { transform: scale(.98); }
.primary:disabled { opacity: .35; cursor: not-allowed; }
.secondary { background: var(--soft); color: var(--ink); }
.secondary:hover { background: var(--line); }
.block { width: 100%; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-weight: 600; font-size: 13px; padding: 4px; }
.danger { color: var(--danger); }

/* ---------- Zone fichiers ---------- */
.add-big { width: 100%; display: flex; align-items: center; gap: 14px; background: none; border: 0; padding: 6px 0 18px; cursor: pointer; text-align: left; border-bottom: 1px solid var(--line); }
.plus { width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: 300; transition: transform .2s; }
.add-big:hover .plus { transform: rotate(90deg); }
.add-big strong { display: block; font-size: 18px; letter-spacing: -.01em; }
.add-big small { font-size: 13px; color: var(--muted); }
.add-big small a { cursor: pointer; font-weight: 600; text-decoration: none; }

.files { border-bottom: 1px solid var(--line); margin: -4px -22px 0; }
.file-list { list-style: none; margin: 0; padding: 0 12px; max-height: 210px; overflow: auto; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.file-list li:hover { background: var(--soft); }
.file-list .name { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .size { font-size: 12px; color: var(--muted); white-space: nowrap; }
.file-list .rm { border: 0; background: none; color: var(--muted); cursor: pointer; width: 26px; height: 26px; border-radius: 50%; font-size: 16px; flex-shrink: 0; }
.file-list .rm:hover { background: var(--line); color: var(--ink); }
.file-list .more { color: var(--muted); font-size: 13px; }
.files-foot { display: flex; align-items: center; justify-content: space-between; padding: 8px 22px 10px; font-size: 13px; color: var(--muted); }

.ext { width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; font-size: 9px; font-weight: 700; text-transform: uppercase; color: #fff; background: #8a8794; letter-spacing: .02em; overflow: hidden; }
.ext[data-kind="image"] { background: #1f9d55; }
.ext[data-kind="video"] { background: #e5484d; }
.ext[data-kind="audio"] { background: #f08c00; }
.ext[data-kind="doc"] { background: #3b82f6; }
.ext[data-kind="archive"] { background: #6b5b3e; }
.ext[data-kind="folder"] { background: var(--accent); }
.ext img { width: 100%; height: 100%; object-fit: cover; }

.seg { display: flex; background: var(--soft); border-radius: 999px; padding: 3px; margin: 16px 0 4px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.options { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.options summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 6px; }
.options summary::-webkit-details-marker { display: none; }
.options summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 16px; }
.options[open] summary::before { transform: rotate(90deg); }
.options .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.card-foot { margin-top: 18px; }
.limits { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Progression ---------- */
.progress-view { text-align: center; padding: 30px 22px 24px; }
.ring { width: 190px; height: 190px; margin: 0 auto 18px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--soft); }
.ring .bar { stroke: var(--accent); transition: stroke-dashoffset .3s linear; stroke-linecap: round; }
.ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; font-weight: 800; letter-spacing: -.04em; }
.ring .pct small { font-size: 20px; font-weight: 600; color: var(--muted); }
.progress-view h2 { font-size: 20px; }
.progress-view p { margin: 4px 0; font-size: 14px; color: var(--ink-2); }
.progress-view .secondary { margin-top: 18px; }

/* ---------- Terminé ---------- */
.done-view { text-align: center; padding: 34px 22px 24px; }
.done-icon { width: 76px; height: 76px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 16px; animation: pop .4s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.done-view p { color: var(--ink-2); font-size: 14px; line-height: 1.5; margin: 4px 0 18px; }
.linkbox { display: flex; gap: 6px; background: var(--soft); border-radius: 14px; padding: 6px; margin-bottom: 12px; }
.linkbox input { flex: 1; min-width: 0; border: 0; background: none; padding: 0 8px; font-size: 13px; outline: none; }
.linkbox .primary { padding: 9px 16px; font-size: 14px; }
.warn { background: #fff4e5; color: #8a4b00; border-radius: 12px; padding: 10px 12px; font-size: 13px; text-align: left; }

/* ---------- Glisser-déposer ---------- */
.drop-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(91,75,255,.88); color: #fff; display: grid; place-items: center; text-align: center; }
.drop-overlay div { border: 3px dashed rgba(255,255,255,.7); border-radius: 32px; padding: 60px 80px; font-size: 32px; font-weight: 800; letter-spacing: -.02em; pointer-events: none; }
.drop-overlay small { display: block; font-size: 16px; font-weight: 500; opacity: .8; margin-top: 8px; }

/* ---------- Tiroir historique ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(8,7,14,.5); backdrop-filter: blur(3px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(560px, 100vw); background: #fff; display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.3); animation: slide .25s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 8px; }
.drawer header h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.close { border: 0; background: var(--soft); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.disk { padding: 4px 24px 16px; font-size: 13px; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--soft); margin-top: 6px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.history { list-style: none; margin: 0; padding: 0 12px 24px; overflow: auto; flex: 1; min-height: 0; }
.history li { padding: 14px 12px; border-top: 1px solid var(--line); }
.history .top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.history .t { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .meta { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.history .actions { display: flex; flex-wrap: wrap; gap: 2px; margin: 6px 0 0 -4px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #e7f6ee; color: var(--ok); white-space: nowrap; }
.badge.off { background: var(--soft); color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- Paramètres ---------- */
.settings { overflow: auto; flex: 1; min-height: 0; padding: 0 24px 32px; }
.panel { border-top: 1px solid var(--line); padding: 20px 0 24px; }
.panel h3 { margin: 0 0 4px; font-size: 16px; letter-spacing: -.01em; }
.panel p { margin: 0 0 4px; line-height: 1.5; }
.panel .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel > .primary { margin-top: 16px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
@media (max-width: 520px) { .panel .row { grid-template-columns: 1fr; } }

/* ---------- Confirmation ---------- */
.confirm-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(8,7,14,.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; }
.confirm { background: #fff; border-radius: 18px; padding: 22px; width: min(400px, 100%); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); animation: pop .2s ease-out; }
.confirm p { margin: 0 0 18px; font-size: 15px; line-height: 1.5; color: var(--ink); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-actions button { padding: 10px 18px; font-size: 14px; }
.primary-danger { background: var(--danger); }
.primary-danger:hover { background: #cf3a3f; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); }

/* ---------- Page de téléchargement ---------- */
.dl-card { width: 420px; }
.dl-head { padding: 26px 24px 16px; }
.dl-icon { width: 52px; height: 52px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 14px; }
.dl-head h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; line-height: 1.25; word-break: break-word; }
.dl-head .meta { font-size: 14px; color: var(--muted); margin-top: 6px; }
.dl-message { margin: 0 24px 14px; padding: 12px 14px; background: var(--soft); border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.dl-files { list-style: none; margin: 0; padding: 0 12px; max-height: 330px; overflow: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.dl-files li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; }
.dl-files li:hover { background: var(--soft); }
.dl-files .info { flex: 1; min-width: 0; }
.dl-files .name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-files .size { font-size: 12px; color: var(--muted); }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); background: none; border: 0; cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: var(--line); color: var(--ink); }
.dl-foot { padding: 18px 24px 22px; }
.dl-foot p { text-align: center; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.center-view { padding: 36px 24px 28px; text-align: center; }
.center-view p { color: var(--ink-2); font-size: 14px; line-height: 1.5; }

.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(8,7,14,.92); display: grid; place-items: center; padding: 56px 16px 16px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: calc(100vh - 80px); border-radius: 12px; }
.lightbox audio { width: min(480px, 90vw); }
.lightbox .close { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,.15); color: #fff; }
.lightbox .cap { position: absolute; top: 20px; left: 20px; right: 64px; color: #fff; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .topbar { padding: 16px; }
  .stage { flex-direction: column; justify-content: flex-start; gap: 24px; padding: 8px 16px 32px; min-height: auto; }
  .hero { text-align: center; }
  .hero h1 { font-size: 32px; }
  .hero p { font-size: 15px; }
  .card, .dl-card { width: 100%; max-width: 440px; }
  .topbar .ghost { padding: 7px 12px; font-size: 13px; }
}
