/* =====================================================================
   IOA Événements — styles
   Pensé d'abord pour le téléphone : gros boutons, texte lisible,
   contraste fort. Thème clair ou sombre selon le réglage du téléphone.
   ===================================================================== */

:root {
    --bg: #f2f4f7;
    --surface: #ffffff;
    --text: #262626;
    --muted: #5b6474;
    --border: #d9dee6;
    --primary: #fc2e44;          /* rouge IOA (le « o » du logo) : actions principales */
    --primary-text: #ffffff;
    --dark: #333333;
    --success-bg: #e5f6ec; --success-text: #136c3a;
    --error-bg: #fde8e6;   --error-text: #a3261a;
    --info-bg: #e7effc;    --info-text: #1d4f9c;
    --amber-bg: #fff2d6;   --amber-text: #8a5800;
    --radius: 12px;
    --tap: 48px;                 /* hauteur minimale d'une zone tactile */
    --accent: var(--primary);    /* couleur du tournoi (Réglages du projet), rouge IOA par défaut */
}

/* Thème sombre : suit le téléphone (« Auto »), sauf choix « Clair » ou « Sombre » dans le menu */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b111b;
        --surface: #151d2a;
        --text: #eef1f6;
        --muted: #9aa4b5;
        --border: #2a3546;
        --dark: #eef1f6;
        --success-bg: #12341f; --success-text: #8be0ae;
        --error-bg: #3d1713;   --error-text: #ffaa9e;
        --info-bg: #142a4d;    --info-text: #a9c8ff;
        --amber-bg: #3a2b0b;   --amber-text: #ffd27a;
    }
}
:root[data-theme="dark"] {
        --bg: #0b111b;
        --surface: #151d2a;
        --text: #eef1f6;
        --muted: #9aa4b5;
        --border: #2a3546;
        --dark: #eef1f6;
        --success-bg: #12341f; --success-text: #8be0ae;
        --error-bg: #3d1713;   --error-text: #ffaa9e;
        --info-bg: #142a4d;    --info-text: #a9c8ff;
        --amber-bg: #3a2b0b;   --amber-text: #ffd27a;
    }

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--primary); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
p { margin: 0 0 0.75rem; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }

/* ---------- En-tête ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: #333333; color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
/* Mot « ioa » comme dans le logo : le « o » en rouge */
.brand-ioa { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; margin-right: 6px; }
.brand-ioa span { color: var(--primary); }

/* Menu du compte (pastille avec initiales) */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
    display: grid; place-items: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: #2a3546; color: #fff; font-weight: 700; font-size: 0.95rem;
}
.menu-panel {
    position: absolute; right: 0; top: 48px;
    min-width: 240px; padding: 8px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.menu-who { padding: 8px; margin: 0 0 4px; border-bottom: 1px solid var(--border); font-size: 0.9rem; word-break: break-all; }
.menu-panel form { margin: 0; }
.menu-link {
    display: block; width: 100%; min-height: var(--tap);
    padding: 12px 8px; text-align: left;
    background: none; border: 0; border-radius: 8px;
    color: var(--text); font: inherit; text-decoration: none; cursor: pointer;
}
.menu-link:hover { background: var(--bg); }
.menu-danger { color: var(--error-text); }

/* ---------- Mise en page ---------- */
.container {
    max-width: 720px; margin: 0 auto;
    padding: 16px;
    padding-bottom: max(32px, env(safe-area-inset-bottom));
}
.card {
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin-bottom: 16px;
}
.card-summary { cursor: pointer; font-weight: 700; color: var(--primary); min-height: 32px; }
.card-summary { list-style: none; }
.card-summary::-webkit-details-marker { display: none; }
details[open] > .card-summary { margin-bottom: 12px; }

.auth { max-width: 420px; margin: 24px auto 0; }

/* ---------- Formulaires ---------- */
.form label { display: block; font-weight: 600; margin-bottom: 14px; }
.form input[type=text], .form input[type=email], .form input[type=password],
.form input[type=tel], .form input[type=date], .form input[type=time],
.form input[type=number], .form input[type=url],
.form select, .form textarea {
    display: block; width: 100%; margin-top: 6px;
    min-height: var(--tap); padding: 10px 12px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
    font: inherit; font-weight: 400;   /* 17px : évite le zoom automatique de l'iPhone */
}
.form input[readonly] { background: var(--bg); color: var(--muted); }
.form input:focus, .form select:focus, .form textarea:focus {
    outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
    border-color: var(--primary);
}
.form .check { display: flex; align-items: center; gap: 10px; font-weight: 400; min-height: var(--tap); }
.form .check input { width: 22px; height: 22px; margin: 0; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: var(--tap); padding: 10px 18px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-block { display: flex; width: 100%; }
.btn-small { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; }
.btn-ghost-danger { color: var(--error-text); }

/* ---------- Messages ---------- */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; word-break: break-word; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error   { background: var(--error-bg);   color: var(--error-text); }
.alert-info    { background: var(--info-bg);    color: var(--info-text); }

/* ---------- Pastilles ---------- */
.badge {
    display: inline-block; padding: 2px 8px; margin-left: 4px;
    border-radius: 999px; font-size: 0.75rem; font-weight: 700; vertical-align: middle;
}
.badge-dark  { background: var(--dark); color: var(--bg); }
.badge-grey  { background: var(--border); color: var(--muted); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; margin-bottom: 10px;
}
.list-item.is-off { opacity: 0.6; }
.list-main { flex: 1 1 220px; min-width: 0; word-break: break-word; }
.list-actions { display: flex; gap: 8px; }
.list-actions form { margin: 0; }

/* =====================================================================
   Étapes 2 à 7 : navigation, listes, fiches, contenus, messagerie, programme
   ===================================================================== */

/* ---------- En-tête : logo, projet, cloche ---------- */
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand-logo { height: 30px; width: auto; display: block; }
.project-chip {
    flex: 1 1 auto; min-width: 0;
    padding: 6px 12px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.1); color: #fff;
    font-size: 0.85rem; font-weight: 600; text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bell { position: relative; color: #fff; display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; }
.icon { width: 24px; height: 24px; flex-shrink: 0; }
.btn .icon { width: 20px; height: 20px; margin-right: 6px; }

/* Pastille de compteur (non lus) */
.count {
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 999px; background: var(--primary); color: #fff;
    font-size: 0.72rem; font-weight: 800; line-height: 20px; text-align: center;
}
.count[hidden] { display: none; }
.bell .count { position: absolute; top: 0; right: -2px; }
.count-static { display: inline-block; vertical-align: middle; }
.count-inline { margin-left: 4px; font-weight: 800; }

/* ---------- Barre de navigation du bas ---------- */
body.has-tabs .container { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
}
.tab {
    position: relative; flex: 1; max-width: 120px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px; border-radius: 10px;
    color: var(--muted); font-size: 0.72rem; font-weight: 600; text-decoration: none;
}
.tab.is-active { color: var(--primary); }
.tab .count { position: absolute; top: 0; left: 55%; }

/* ---------- Titres et outils de page ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head h1 { margin-bottom: 0.75rem; }
.crumb { margin: 0 0 8px; font-size: 0.9rem; }
.crumb a { text-decoration: none; }
.card-title { margin-top: 0; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.help { padding: 12px 14px; margin-bottom: 16px; border-radius: 10px; background: var(--info-bg); color: var(--info-text); font-size: 0.92rem; }
.help ol { margin: 6px 0 0; padding-left: 20px; }
.help code { font-size: 0.85em; word-break: break-all; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.inline-form input[type=text], .inline-form select {
    flex: 1 1 140px; min-height: 40px; padding: 6px 10px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
.secondary-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.secondary-actions form { margin: 0; }
.subcard { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.list-flat .list-item { border-radius: 10px; }
.list-plain { padding-left: 18px; }
.logo-preview { display: block; max-height: 80px; max-width: 200px; margin: 8px 0; border-radius: 8px; background: #fff; padding: 4px; }
.btn-success { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn-big { min-height: 56px; font-size: 1.1rem; }
.btn-block + .btn-block, form + .btn-block, .btn-block + form, .btn-block + .items, .items + .btn-block { margin-top: 10px; }

/* Filtres */
.filters { margin-bottom: 12px; }
.day-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.day-nav input[type=date] {
    flex: 1 1 150px; min-height: 40px; padding: 6px 10px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-row select {
    flex: 1 1 120px; min-height: 40px; padding: 6px 8px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem;
}

/* Choix sous forme de pastilles (types, formats, personnes...) */
.choices { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.choices legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.form .choice { display: inline-block; margin: 0 6px 8px 0; font-weight: 400; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
    display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer;
}
.choice input:checked + span { background: var(--dark); color: var(--bg); border-color: var(--dark); font-weight: 700; }
.choice input:focus-visible + span { outline: 3px solid var(--primary); }
.choice-urgent input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Onglets segmentés (galerie) */
.segmented { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.segmented a {
    flex-shrink: 0; padding: 8px 12px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-size: 0.9rem; font-weight: 600; text-decoration: none;
}
.segmented a.is-active { background: var(--dark); color: var(--bg); border-color: var(--dark); }
.segmented-small a { padding: 5px 10px; font-size: 0.8rem; }

/* ---------- Statuts ---------- */
.st { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; vertical-align: middle; background: var(--border); color: var(--text); }
.st-request-new, .st-content-pending { background: var(--amber-bg); color: var(--amber-text); }
.st-request-assigned, .st-request-in_progress, .st-match-live { background: var(--info-bg); color: var(--info-text); }
.st-request-shot { background: #ede4fb; color: #5b2a9c; }
.st-request-delivered, .st-content-approved, .st-match-finished { background: var(--success-bg); color: var(--success-text); }
.st-content-published { background: var(--dark); color: var(--bg); }
.st-content-changes_requested, .st-request-cancelled { background: var(--error-bg); color: var(--error-text); }
.badge-urgent { background: var(--primary); color: #fff; margin: 0 4px 0 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .st-request-shot { background: #2e1f4a; color: #d4bbff; } }
:root[data-theme="dark"] .st-request-shot { background: #2e1f4a; color: #d4bbff; }

/* ---------- Listes d'éléments (demandes, contenus, canaux) ---------- */
.items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.item {
    display: flex; gap: 12px; align-items: center;
    padding: 12px 14px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); text-decoration: none;
}
.item.is-urgent { border-left: 5px solid var(--primary); }
.item.is-off { opacity: 0.55; }
.item-time { flex: 0 0 64px; display: flex; flex-direction: column; text-align: center; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 700; word-break: break-word; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.item-chevron { color: var(--muted); }
.notif.is-read { opacity: 0.6; }
.channel-item .count { flex-shrink: 0; }

/* Missions : actions sous la carte */
.mission { margin-bottom: 14px; }
.mission > .item { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.mission-actions {
    display: flex; gap: 8px; flex-wrap: wrap; padding: 10px;
    background: var(--surface); border: 1px solid var(--border); border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}
.mission-actions > form, .mission-actions > details, .mission-actions > a { flex: 1 1 140px; }
.mission-actions .btn, .actions-bar .btn { width: 100%; }
.shot-box summary { list-style: none; }
.shot-box summary::-webkit-details-marker { display: none; }
.shot-box[open] summary { margin-bottom: 8px; }
.shot-box .form input[type=text] { margin-bottom: 8px; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.actions-bar > * { flex: 1 1 160px; }
.inline-details { display: inline-block; }
.inline-details[open] { display: block; width: 100%; padding: 10px; margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; }
.inline-details summary { list-style: none; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] > summary { margin-bottom: 10px; }

/* ---------- Fiches (demande, contenu) ---------- */
.detail.is-urgent { border-left: 5px solid var(--primary); }
.detail-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 12px 0; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: 0; word-break: break-word; }
.text-block { padding: 10px 12px; border-radius: 10px; background: var(--bg); word-break: break-word; margin-bottom: 10px; }
.internal-note { padding: 10px 12px; border-radius: 10px; background: var(--amber-bg); color: var(--amber-text); margin-bottom: 10px; }
.thread { list-style: none; padding: 0; margin: 0 0 12px; }
.thread li { padding: 10px 0; border-bottom: 1px solid var(--border); word-break: break-word; }
.thread li.is-system { font-size: 0.88rem; color: var(--muted); padding: 6px 0; }
.thread-head { margin-bottom: 2px; }
.mention { color: var(--primary); }

/* Contenus */
.player { background: #000; border-radius: 10px; overflow: hidden; margin: 12px 0; display: flex; justify-content: center; }
.player video, .player img { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.player.ratio-9-16 video, .player.ratio-9-16 img { max-height: 75vh; width: auto; max-width: 100%; }
.decision .btn-block { margin-bottom: 10px; }
.decision details summary { list-style: none; }
.decision details summary::-webkit-details-marker { display: none; }
.decision details[open] summary { margin-bottom: 10px; }
.versions { list-style: none; padding: 0; margin: 0; }
.versions > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.approval { margin-top: 6px; padding-left: 10px; border-left: 3px solid var(--border); }
.approval-approved { border-color: #1f9d55; }
.approval-changes_requested { border-color: var(--primary); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.tile-media { position: relative; aspect-ratio: 16 / 9; background: #1d2430; display: grid; place-items: center; color: #9aa4b5; }
.tile-media.ratio-9-16 { aspect-ratio: 4 / 5; }
.tile-media.ratio-1-1 { aspect-ratio: 1; }
.tile-media img { width: 100%; height: 100%; object-fit: cover; }
.tile-icon .icon { width: 36px; height: 36px; }
.tile-format { position: absolute; left: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 0.72rem; font-weight: 700; }
.tile-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; word-break: break-word; }

/* Barre de progression d'envoi */
.progress { position: relative; height: 28px; border-radius: 8px; background: var(--bg); overflow: hidden; margin-bottom: 12px; border: 1px solid var(--border); }
.progress[hidden] { display: none; }
.progress-bar { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--primary); transition: width 0.2s; }
.progress-text { position: relative; display: block; text-align: center; line-height: 26px; font-size: 0.85rem; font-weight: 700; }

/* ---------- Messagerie ---------- */
.chat-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.msg { max-width: 85%; align-self: flex-start; }
.msg.is-mine { align-self: flex-end; text-align: right; }
.msg-author { font-size: 0.78rem; font-weight: 700; color: var(--muted); margin: 0 0 2px 4px; }
.msg-bubble { display: inline-block; text-align: left; padding: 8px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); word-break: break-word; }
.msg.is-mine .msg-bubble { background: var(--dark); color: var(--bg); border-color: var(--dark); }
.msg.is-mine .msg-bubble a { color: inherit; }
.msg-photo { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; margin-bottom: 4px; }
.msg-time { font-size: 0.7rem; color: var(--muted); margin: 2px 6px 0; }
.composer {
    position: sticky; bottom: calc(70px + env(safe-area-inset-bottom));
    display: flex; gap: 8px; align-items: flex-end;
    padding: 8px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}
.composer textarea {
    flex: 1; min-height: 44px; max-height: 140px; padding: 10px 12px; resize: none;
    border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit;
}
.composer-photo { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; color: var(--muted); cursor: pointer; flex-shrink: 0; }
.composer-photo.has-file { color: var(--primary); background: var(--bg); }
.composer-hint { margin: 6px 4px; }

/* ---------- Programme ---------- */
.court h2 { margin-top: 1rem; }
.match { padding: 12px 14px; margin-bottom: 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.match-live { border-left: 5px solid #2f6fdb; }
.match-finished { opacity: 0.8; }
.match-when { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.match-players { margin: 6px 0; font-size: 1.05rem; }
.match-players .is-winner { font-weight: 800; }
.match-players .is-winner::after { content: " ✓"; color: #1f9d55; }
.match-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.match-actions form { margin: 0; }

/* ---------- Tableau de bord ---------- */
.event-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.event-head h1 { margin: 2px 0; }
.event-head p { margin: 0; }
.event-logo { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; background: #fff; padding: 4px; flex-shrink: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat {
    display: flex; flex-direction: column; padding: 10px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.stat strong { font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: 0.78rem; color: var(--muted); }
.stat.is-alert { border-color: var(--primary); }
.stat.is-alert strong { color: var(--primary); }
.stat.is-zero { opacity: 0.6; }

/* Page de connexion : logo */
.auth-logo { display: block; margin: 8px auto 20px; max-width: 280px; width: 70%; height: auto; }
.auth-logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .auth-logo-light { display: none; }
    :root:not([data-theme="light"]) .auth-logo-dark { display: block; max-width: 200px; }
}
:root[data-theme="dark"] .auth-logo-light { display: none; }
:root[data-theme="dark"] .auth-logo-dark { display: block; max-width: 200px; }

@media (min-width: 640px) {
    .stats { grid-template-columns: repeat(6, 1fr); }
}

/* ---------- Courts en direct (v2) ---------- */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.live-court { padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.live-court h2 { margin: 0 0 8px; }
.scoreboard { border-radius: 10px; background: #1b1f27; color: #fff; padding: 8px 10px; font-variant-numeric: tabular-nums; }
.scoreboard.is-near { box-shadow: 0 0 0 3px #f0b429; }
.scoreboard.is-matchpoint { box-shadow: 0 0 0 3px var(--primary); }
.sb-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 1.05rem; }
.sb-row + .sb-row { border-top: 1px solid rgba(255, 255, 255, 0.12); }
.sb-serve { width: 12px; color: #f0e130; font-size: 0.7rem; }
.sb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sb-set { width: 22px; text-align: center; color: #c9ced8; }
.sb-set.is-won { color: #fff; font-weight: 800; }
.sb-points { min-width: 34px; text-align: center; padding: 2px 4px; border-radius: 6px; background: var(--primary); font-weight: 800; }
.sb-points:empty { background: none; }
.sb-text { font-size: 1rem; padding: 4px 0; }
.live-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.live-next { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }


/* ---------- Moments de la vidéo ---------- */
.timecode, .remark-time { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--info-bg); color: var(--info-text); font-weight: 700; font-variant-numeric: tabular-nums; text-decoration: none; }
.remarks { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px; }
.remark { display: flex; gap: 8px; align-items: baseline; padding: 8px 10px; border-radius: 10px; background: var(--bg); color: var(--text); text-decoration: none; }
.remark > span:nth-child(2) { flex: 1; min-width: 0; word-break: break-word; }
[data-insert-time] { margin-bottom: 10px; }

/* ---------- Calendrier ---------- */
.week-label { flex: 1 1 auto; text-align: center; }
.cal-day { margin-bottom: 14px; }
.cal-day h2 { font-size: 1.05rem; margin: 12px 0 6px; }
.cal-day.is-today h2 { color: var(--primary); }
.cal-item.is-clash { border-color: #f0b429; box-shadow: 0 0 0 2px #f0b429 inset; }
.inline-form input[type=datetime-local] {
    flex: 1 1 180px; min-height: 40px; padding: 6px 10px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}

/* ---------- Partenaires et rapport ---------- */
.partner-item { align-items: flex-start; }
.partner-logo-small { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; flex-shrink: 0; }
.target-line { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; align-items: center; margin-top: 4px; }
progress.meter { width: 100%; height: 10px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; background: var(--border); overflow: hidden; }
progress.meter::-webkit-progress-bar { background: var(--border); border-radius: 999px; }
progress.meter::-webkit-progress-value { background: #1f9d55; border-radius: 999px; }
progress.meter::-moz-progress-bar { background: #1f9d55; border-radius: 999px; }
.report-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.report-title { flex: 1; min-width: 0; }
.report-title h1 { margin: 2px 0; }
.report-title p { margin: 0; }
.report-logo { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 12px; padding: 4px; flex-shrink: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.8rem; padding: 6px 6px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; word-break: break-word; }
.table tr.is-done td { background: var(--success-bg); }
.table progress.meter { margin-top: 6px; }
.report-url { font-size: 0.85rem; }


/* ---------- Fiche du match, tableau du tournoi, récap ---------- */
.caption-box { white-space: normal; padding: 12px; margin-bottom: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); line-height: 1.5; }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li + li { margin-top: 6px; }
.bracket { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; margin: 0 -4px 16px; -webkit-overflow-scrolling: touch; }
.bracket-round { flex: 0 0 220px; display: flex; flex-direction: column; justify-content: space-around; gap: 8px; }
.bracket-round h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 4px; }
.bracket-match { display: block; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: inherit; text-decoration: none; font-size: 0.9rem; }
.bracket-match > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bracket-match .is-winner { font-weight: 800; }
.bracket-match .is-winner::after { content: " ✓"; color: #1f9d55; }
.bracket-match.is-live { border-color: var(--primary); }
a.bracket-match:hover { border-color: var(--dark); }

@media print {
    .topbar, .tabs, .no-print, .alert { display: none !important; }
    body, .card { background: #fff !important; color: #000 !important; }
    .container { max-width: none; padding: 0 !important; }
    .card { border: 1px solid #ccc; break-inside: avoid; }
    a { color: #000; text-decoration: none; }
    .report-url::after { content: ""; }
}

/* ---------- Tchat : émojis et réactions ---------- */
.emoji-picker { position: relative; flex-shrink: 0; }
.emoji-picker summary { list-style: none; font-size: 1.3rem; }
.emoji-picker summary::-webkit-details-marker { display: none; }
.emoji-panel {
    position: absolute; bottom: 52px; left: -52px; z-index: 30;
    width: min(340px, calc(100vw - 24px)); padding: 6px;
    border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.emoji-tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-bottom: 4px; }
.emoji-tab { flex: 0 0 auto; width: 38px; height: 36px; border: 0; border-radius: 8px; background: none; font-size: 1.15rem; cursor: pointer; opacity: 0.55; }
.emoji-tab.is-active { opacity: 1; background: var(--bg); box-shadow: inset 0 -2px 0 var(--primary); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; max-height: 220px; overflow-y: auto; overscroll-behavior: contain; }
.emoji-grid[hidden] { display: none; }
.emoji-name { margin: 4px 4px 0; }
.emoji, .reaction-choice { width: 38px; height: 38px; border: 0; border-radius: 8px; background: none; font-size: 1.35rem; cursor: pointer; }
.emoji:hover, .reaction-choice:hover { background: var(--bg); }
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 2px 4px 0; }
.msg.is-mine .msg-reactions { justify-content: flex-end; }
.reaction-form { margin: 0; }
.reaction {
    display: inline-flex; align-items: center; gap: 3px; min-height: 28px; padding: 2px 8px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
    font: inherit; font-size: 0.85rem; cursor: pointer;
}
.reaction.is-mine { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.reaction-add { position: relative; }
.reaction-add summary {
    list-style: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px;
    color: var(--muted); font-size: 0.9rem; cursor: pointer; opacity: 0.55;
}
.reaction-add summary::-webkit-details-marker { display: none; }
.msg:hover .reaction-add summary, .reaction-add[open] summary { opacity: 1; background: var(--bg); }
.reaction-palette {
    position: absolute; bottom: 32px; left: 0; z-index: 25; display: grid; grid-template-columns: repeat(6, 38px); gap: 2px; padding: 4px;
    border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.msg.is-mine .reaction-palette { left: auto; right: 0; }

/* ---------- Thème, couleur du tournoi, drapeaux ---------- */
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
.form input[type=color] { width: 64px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.theme-switch { display: flex; gap: 6px; padding: 6px 12px 10px; }
.theme-switch button { flex: 1; padding: 6px 4px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 0.8rem; cursor: pointer; }
.theme-switch button.is-active { background: var(--dark); color: var(--bg); border-color: var(--dark); font-weight: 700; }
.project-chip { display: flex; align-items: center; gap: 8px; border: 1px solid transparent; }
.project-chip.has-accent { border-color: var(--accent); }
.chip-logo { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; background: #fff; flex-shrink: 0; }
.chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
    .project-chip.has-logo { flex: 0 1 auto; padding: 4px 10px 4px 4px; }
    .project-chip.has-logo .chip-name { font-size: 0.78rem; max-width: 34vw; }
}
.event-head { border-left: 4px solid var(--accent); padding-left: 12px; }
.live-court h2, .court > h2 { color: var(--accent); }
.scoreboard { border-left: 4px solid var(--accent); }
.flag { white-space: nowrap; }
.flag-emoji { font-size: 1.05em; }
.flag-code { font-size: 0.75em; color: var(--muted); font-weight: 600; }
.scoreboard .flag-code { color: #c9ced8; }
/* Score qui vient de changer */
@keyframes score-flash { 0% { background: #f0e130; color: #111; } 100% { background: transparent; } }
.is-flash { animation: score-flash 1.6s ease-out; border-radius: 4px; }
.sb-points.is-flash { animation: none; box-shadow: 0 0 0 3px #f0e130; }
/* Accueil : en direct maintenant */
.now-live { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 8px; }
.now-live a { text-decoration: none; color: inherit; }
.now-live .scoreboard { font-size: 0.95rem; }
.now-live .court-name { display: block; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: #c9ced8; margin-bottom: 2px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.section-head a { font-size: 0.9rem; }

/* ---------- Direct vidéo ---------- */
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; }
.video-frame video, .video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.live-court h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn-watch { flex-shrink: 0; }
.btn-watch .icon { width: 18px; height: 18px; }
form.inline { display: inline; }
.offline-banner { padding: 10px 14px; margin-bottom: 14px; border-radius: 10px; background: var(--amber-bg); color: var(--amber-text); font-weight: 600; }
.item.is-mine { border-left: 5px solid var(--accent); }
.item form { align-self: center; }
.player-link { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.player-link:hover { color: var(--primary); }
.visual-canvas { display: block; width: 100%; max-width: 420px; height: auto; margin: 10px auto 12px; border-radius: 10px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25); }
.seg-btn { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 0.85rem; cursor: pointer; }
.seg-btn.is-active { background: var(--dark); color: var(--bg); border-color: var(--dark); font-weight: 700; }
/* ---------- Récap : barre des journées ---------- */
.day-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.day-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 8px 10px; border-radius: 12px;
            border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; line-height: 1.2; }
.day-chip strong { font-size: 1rem; }
.day-chip span { font-size: 0.75rem; color: var(--muted); }
.day-chip small { margin-top: 3px; font-size: 0.7rem; font-weight: 700; color: var(--accent); }
.day-chip.is-today { border-color: var(--accent); }
.day-chip.is-empty { opacity: 0.6; }
.day-chip.is-active { background: var(--dark); border-color: var(--dark); color: var(--bg); opacity: 1; }
.day-chip.is-active span, .day-chip.is-active small { color: var(--bg); }
.day-chip-all { min-width: 84px; }
.recap-day h3 { margin: 0 0 8px; font-size: 1rem; }
.recap-day p { margin: 0 0 4px; }
.stats-form td { vertical-align: middle; }
.stats-form td:nth-child(2) { text-align: center; }
.stats-form input[type=text] { width: 100%; min-width: 0; max-width: 110px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; text-align: center; }
.stats-form td:last-child input { margin-left: auto; display: block; }

/* Proposition d'installation de l'application (première utilisation) */
.install-card { border-left: 4px solid var(--accent, #fc2e44); }
.install-head { display: flex; gap: 12px; align-items: center; }
.install-head img { border-radius: 10px; flex: none; }
.install-head p { margin: 2px 0 0; }
.install-steps { margin: 10px 0 0 18px; padding: 0; }
.install-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.install-card[hidden], .install-steps[hidden], .install-actions [hidden] { display: none; }
