*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:       #140b0e;
    --surface:  #1e1216;
    --surface2: #2a1820;
    --border:   #3d2530;
    --accent:   #f43f5e;
    --accent-h: #fb7185;
    --green:    #22c55e;
    --orange:   #f59e0b;
    --text:     #fbeff2;
    --muted:    #b190a0;
    --radius:   14px;
}

body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 1.25rem; line-height: 1.5; }
a { color: var(--accent-h); }
.wrap { max-width: 860px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; }
.card h2 { font-size: 1.02rem; margin-bottom: .9rem; }
h1 { font-size: 1.35rem; font-weight: 800; margin-bottom: .3rem; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.hint { font-size: .78rem; color: var(--muted); margin-top: .35rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.logo { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); }
.logo-text { font-size: 1.3rem; font-weight: 800; letter-spacing: -.4px; }
.logo-text span { color: var(--accent-h); }
.back-link { display: inline-flex; gap: .4rem; font-size: .8rem; color: var(--muted); text-decoration: none; margin-bottom: 1rem; }

label, .label { display: block; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .35rem; }
input[type=text], input[type=number], textarea, select {
    width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; color: var(--text);
    font-size: .95rem; padding: .65rem .85rem; font-family: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: .9rem; }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline > input, .inline > select { flex: 1; min-width: 140px; width: auto; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem; background: var(--accent); color: #fff;
    border: none; border-radius: 9px; font-size: .92rem; font-weight: 700; padding: .7rem 1.15rem; cursor: pointer;
    text-decoration: none; font-family: inherit; white-space: nowrap;
}
.btn:hover { background: var(--accent-h); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); }
.btn-danger { background: transparent; color: #fda4af; border: 1px solid rgba(244,63,94,.45); }
.btn-sm { font-size: .8rem; padding: .45rem .8rem; }
.btn-big { font-size: 1.05rem; padding: .95rem 1.4rem; }
.btn-block { width: 100%; }
label.btn { text-transform: none; letter-spacing: 0; margin: 0; }
.btn.disabled { opacity: .5; pointer-events: none; }
/* Champ fichier masqué mais toujours actionnable par son libellé (iPhone compris). */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }

.alert { border-radius: 9px; padding: .75rem 1rem; font-size: .875rem; margin-bottom: 1rem; display: flex; gap: .6rem; align-items: flex-start; }
.alert svg { flex-shrink: 0; margin-top: 2px; }
.alert-error   { background: rgba(244,63,94,.12); border: 1px solid rgba(244,63,94,.35); color: #fda4af; }
.alert-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert-info    { background: rgba(251,113,133,.08); border: 1px solid rgba(251,113,133,.3); color: #fecdd3; }
.alert-warn    { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.35); color: #fcd34d; }

.pill { display: inline-flex; align-items: center; font-size: .7rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.pill-ok { background: rgba(34,197,94,.15); color: #86efac; }
.pill-off { background: rgba(245,158,11,.15); color: #fcd34d; }

/* ── Liste ── */
.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.video-card { display: block; text-decoration: none; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; }
.video-card:hover { border-color: var(--accent); }
.video-card .t { font-weight: 700; margin-bottom: .25rem; }
.video-card .m { font-size: .78rem; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; border: 1px dashed var(--border); border-radius: 12px; }

/* ── Édition ── */
.grid-edit { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.25rem; align-items: start; }
.qr-box { background: #fff; border-radius: 12px; padding: .6rem; }
.qr-box svg { display: block; width: 100%; height: auto; }
.link-box { font-family: 'Courier New', monospace; font-size: .72rem; word-break: break-all; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; color: var(--muted); max-height: 4.5em; overflow: hidden; }

.player { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.player .overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; text-align: center; padding: 1rem; background: rgba(0,0,0,.55); }
.player .overlay[hidden] { display: none; }
.play-btn { width: 76px; height: 76px; border-radius: 999px; border: none; background: var(--accent); color: #fff; font-size: 1.9rem; cursor: pointer; box-shadow: 0 6px 24px rgba(244,63,94,.45); padding-left: 6px; }
.progress { width: min(320px, 80%); height: 8px; background: rgba(255,255,255,.15); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ── Enregistreur ── */
.recorder { display: none; }
.recorder.open { display: block; }
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 99px; background: var(--accent); margin-right: .35rem; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.rec-status { position: absolute; top: .6rem; left: .7rem; background: rgba(0,0,0,.6); color: #fff; font-size: .85rem; padding: .25rem .6rem; border-radius: 999px; }

/* ── Visionnage (téléphone) ── */
body.viewer { padding: 0; }
.viewer-wrap { max-width: 720px; margin: 0 auto; padding: 1rem; }
.viewer .player { aspect-ratio: auto; min-height: 56vh; border-radius: 14px; }
.viewer .player video { max-height: 80vh; }
.viewer h1 { margin-top: 1rem; }
.viewer .desc { white-space: pre-wrap; color: var(--muted); margin-top: .4rem; }
.lock-note { font-size: .74rem; color: var(--muted); margin-top: 1.25rem; display: flex; gap: .4rem; align-items: center; }

footer { margin-top: 1.5rem; font-size: .78rem; color: var(--muted); text-align: center; }

@media (max-width: 760px) {
    body { padding: .75rem; }
    .grid-edit { grid-template-columns: 1fr; }
    .card { padding: 1.1rem; }
}
