/* ==========================================================
   Application du club — feuille de style unique
   ========================================================== */
:root {
  --brand: #c8102e;
  --ink: #121212;
  --bg: #f4f2ef;
  --card: #ffffff;
  --text: #1b1b1b;
  --muted: #6d6a66;
  --line: #e6e2dc;
  --ok: #1d8a4a;
  --ko: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --sidebar: 248px;
  --tabbar: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111; --card: #1c1c1c; --text: #eeeeee; --muted: #9d9893; --line: #2d2b29;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .6em; }
code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.block { display: block; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .03em; }
.ok { color: var(--ok); }
.ic { flex-shrink: 0; }

/* ---------- Structure ---------- */
.sidebar { display: none; }
.main { min-height: 100vh; }
.content { padding: 16px; max-width: 1100px; margin: 0 auto; }
body.with-nav .main { padding-bottom: calc(var(--tabbar) + var(--safe-b) + 12px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-t)) 12px 10px;
  background: var(--ink); color: #fff;
  border-bottom: 3px solid var(--brand);
}
.topbar h1 { flex: 1; font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 4px; }
.topbar .icon-btn { color: #fff; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 12px rgba(0,0,0,.05);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .7rem; position: relative; text-decoration: none;
}
.tabbar a.on { color: var(--brand); font-weight: 600; }
.tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); }

@media (min-width: 900px) {
  body.with-nav .main { margin-left: var(--sidebar); padding-bottom: 24px; }
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
    background: var(--ink); color: #ddd; padding: 16px 12px; z-index: 30;
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 1.25rem; padding: 4px 8px 18px; letter-spacing: .04em; text-decoration: none; }
  .sidebar .brand img { border-radius: 10px; }
  .sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #cfcac4; text-decoration: none; }
  .sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
  .sidebar nav a.on { background: var(--brand); color: #fff; }
  .sidebar nav a span { flex: 1; }
  .nav-sep { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8a857f; padding: 16px 12px 6px; }
  .sidebar .me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; color: #fff; text-decoration: none; }
  .sidebar .me:hover { background: rgba(255,255,255,.06); }
  .sidebar .me small { display: block; color: #9a958f; }
  .topbar { padding: 14px 24px; }
  .content { padding: 24px; }
}

/* ---------- Composants ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; border: 1px solid var(--line); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.grid-2 { display: grid; gap: 0 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ic { opacity: .5; margin-bottom: 8px; }
.empty h2 { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none !important; min-height: 44px; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-danger { background: transparent; color: var(--ko); border-color: var(--ko); }
.btn-ghost { background: transparent; }
.btn-small { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border: 0; background: transparent; color: inherit; border-radius: 50%; cursor: pointer; font-size: 1.1rem; text-decoration: none !important;
}
.icon-btn:hover { background: rgba(127,127,127,.15); }
.icon-btn.tiny { width: 28px; height: 28px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--brand); color: #fff; border-radius: 10px; font-size: .72rem; font-weight: 700;
}
.sidebar nav a.on .badge { background: #fff; color: var(--brand); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(127,127,127,.15); color: var(--text); vertical-align: middle; }
.tag-ok { background: rgba(29,138,74,.15); color: var(--ok); }
.tag-muted { color: var(--muted); }

.belt {
  display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: .78rem; font-weight: 700;
  border: 1px solid rgba(0,0,0,.18); white-space: nowrap; vertical-align: middle; min-width: 64px; text-align: center;
}
.belt.has-stripe { padding-right: 18px; }
.belt-none { background: transparent; color: var(--muted); border-style: dashed; }

.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.avatar-txt { color: #fff; font-weight: 700; }

.flash { margin: 12px 16px 0; padding: 12px 14px; border-radius: 10px; background: #eef3ff; color: #1f3d7a; border: 1px solid #cfdcf7; }
.content .flash, .login-card .flash { margin: 0 0 12px; }
.flash-success { background: #e9f7ef; color: #1d6b3d; border-color: #c4e8d2; }
.flash-error { background: #fdecea; color: #96271b; border-color: #f5c6c0; }
@media (min-width: 900px) { .flash { margin: 16px 24px 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-b) + 16px); transform: translate(-50%, 20px);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 200; opacity: 0; transition: .25s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--ko); }

/* ---------- Formulaires ---------- */
.form label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 12px; color: var(--muted); }
.form input:not([type=checkbox]):not([type=radio]):not([type=color]), .form select, .form textarea,
.filters select, .cand-row select, .cand-row input, .grade-row input:not([type=checkbox]):not([type=color]), .inline-form select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; min-height: 44px;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.form input[type=color] { display: block; margin-top: 4px; width: 64px; height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: none; }
.form .check { display: flex; gap: 8px; align-items: center; color: var(--text); font-weight: 500; }
.form .check input { width: 20px; height: 20px; accent-color: var(--brand); }
.form.narrow { max-width: 520px; }
.grid-form { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .grid-form { grid-template-columns: 1fr 1fr; } }
.row-2 { display: flex; gap: 12px; } .row-2 .w-icon { width: 90px; }
.form fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 16px; }
.form legend { font-weight: 700; padding: 0 6px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.inline, .inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.inline-form select { width: auto; margin: 0; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--line); }
.photo-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.photo-field label { margin: 0; }
.sub-form { margin-top: 12px; }
.sub-form summary, .actions-card summary { list-style: none; display: inline-flex; }
.sub-form summary::-webkit-details-marker, .actions-card summary::-webkit-details-marker { display: none; }
.sub-form[open] summary { margin-bottom: 12px; }
.actions-card { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.actions-card form { margin: 0; }
.actions-card details[open] { flex-basis: 100%; }
.actions-card details form { margin-top: 8px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.search { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 16px; padding: 10px 0; color: var(--text); outline: none; min-width: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.filters select { width: auto; margin: 0; min-height: 38px; padding: 6px 10px; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-radius: 999px; color: var(--muted); white-space: nowrap; text-decoration: none; }
.tabs a.on { background: var(--ink); color: #fff; }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; padding: 10px 0; }
.list li:last-child { border-bottom: 0; }
.list li:has(> .row-link) { padding: 0; }
.row-link { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 4px; color: inherit; text-decoration: none !important; border-radius: 10px; }
.row-link:hover, .row-link.on { background: rgba(127,127,127,.08); }
.ch-icon { width: 40px; height: 40px; border-radius: 12px; background: rgba(127,127,127,.12); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.ch-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: rgba(127,127,127,.1); color: var(--text); text-decoration: none !important; font-size: .9rem; }
.date-chip { width: 48px; text-align: center; background: var(--brand); color: #fff; border-radius: 10px; padding: 4px 0; flex-shrink: 0; line-height: 1.1; }
.date-chip b { display: block; font-size: 1.2rem; } .date-chip span { font-size: .7rem; text-transform: uppercase; }
.date-chip.past { background: var(--muted); }
dl.info { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
dl.info dt { color: var(--muted); font-size: .88rem; } dl.info dd { margin: 0; overflow-wrap: anywhere; }
.notes { margin-top: 12px; padding: 10px 12px; background: rgba(242,194,0,.12); border-radius: 10px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline li .muted { flex: 1; }

/* ---------- Accueil ---------- */
.hero { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.hero h2 { font-size: 1.6rem; margin: 0; }
.hero p { margin: 0; }
.oss { color: var(--brand); font-size: 1rem; margin-left: 4px; }
.my-grade { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.my-grade .belt { font-size: 1rem; padding: 8px 14px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--text); text-decoration: none !important; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.7rem; color: var(--brand); } .stat span { font-size: .82rem; color: var(--muted); }
.install-banner {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--ink); color: #fff; border: 0; font: inherit; font-weight: 600; cursor: pointer;
}
.ios-hint { font-size: .9rem; }
.hub { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hub-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--text); text-decoration: none !important; box-shadow: var(--shadow); }
.hub-item .ic { color: var(--brand); }

/* ---------- Connexion ---------- */
.login-page { background: var(--ink) radial-gradient(circle at 50% -20%, color-mix(in srgb, var(--brand) 55%, transparent), transparent 60%) no-repeat; min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.4); text-align: center; }
.login-card.wide { max-width: 560px; text-align: left; }
.login-card .form { text-align: left; margin-top: 16px; }
.login-logo { border-radius: 20px; margin-bottom: 12px; }
.login-card h1 { font-size: 1.35rem; }
.checks { list-style: none; padding: 0; } .checks .ok { color: var(--ok); } .checks .ko { color: var(--ko); font-weight: 700; }

/* ---------- Profil ---------- */
.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-head h2 { margin-bottom: 6px; }
.logout-form { text-align: center; margin: 24px 0; }
.password-card { border: 2px solid var(--ok); }
.creds { background: var(--bg); padding: 12px; border-radius: 10px; line-height: 1.8; overflow-wrap: anywhere; }

/* ---------- Discussions ---------- */
.chat-layout { padding: 0 !important; max-width: none !important; }
.channel-pane { background: var(--card); min-height: calc(100vh - 60px); padding: 8px; }
.channel-pane .row-link { padding: 10px 8px; }
.conversation { display: none; }
.in-channel .channel-pane { display: none; }
.in-channel .conversation { display: flex; flex-direction: column; height: calc(100dvh - 60px - var(--safe-t) - var(--tabbar) - var(--safe-b)); }
.conv-head { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain;
  background: var(--bg) repeating-linear-gradient(45deg, transparent 0 22px, rgba(127,127,127,.03) 22px 23px); }
.msg-loading, .msg-empty { text-align: center; margin: auto; }
.load-older { align-self: center; margin-bottom: 8px; }
.day-sep { text-align: center; margin: 12px 0 6px; }
.day-sep span { background: var(--card); color: var(--muted); font-size: .75rem; padding: 3px 10px; border-radius: 999px; box-shadow: var(--shadow); }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; margin-top: 6px; }
.msg.grouped { margin-top: 1px; }
.msg-avatar { width: 32px; flex-shrink: 0; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--card); padding: 6px 10px 4px; border-radius: 4px 14px 14px 14px; box-shadow: 0 1px 1px rgba(0,0,0,.06); min-width: 70px; overflow-wrap: anywhere; }
.msg.grouped .bubble { border-radius: 14px; }
.msg.mine .bubble { background: color-mix(in srgb, var(--brand) 14%, var(--card)); border-radius: 14px 4px 14px 14px; }
.msg-author { font-size: .8rem; font-weight: 700; color: var(--brand); margin-bottom: 1px; }
.msg-text { white-space: normal; }
.msg-text a { word-break: break-all; }
.msg-meta { font-size: .68rem; color: var(--muted); text-align: right; margin-top: 2px; display: flex; justify-content: flex-end; gap: 6px; align-items: center; }
.msg-del { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: .75rem; opacity: 0; }
.msg:hover .msg-del, .msg:focus-within .msg-del { opacity: 1; }
@media (pointer: coarse) { .msg-del { opacity: .6; } }
.msg.deleted .bubble { font-style: italic; color: var(--muted); }
.msg-img { display: block; border: 0; padding: 0; margin: 2px 0 4px; background: none; cursor: zoom-in; border-radius: 10px; overflow: hidden; }
.msg-img img { display: block; max-width: min(260px, 60vw); max-height: 320px; border-radius: 10px; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px; background: var(--card); border-top: 1px solid var(--line); }
.composer.readonly { justify-content: center; padding: 14px; }
.composer-input { flex: 1; background: var(--bg); border-radius: 22px; border: 1px solid var(--line); padding: 4px 12px; }
.composer textarea { width: 100%; border: 0; background: transparent; resize: none; font: inherit; font-size: 16px; color: var(--text); padding: 7px 0; max-height: 160px; outline: none; display: block; }
.composer .send { background: var(--brand); color: #fff; width: 44px; height: 44px; }
.composer .attach { color: var(--muted); width: 44px; height: 44px; }
.attach-preview { position: relative; display: inline-block; margin: 6px 0 2px; }
.attach-preview img { max-height: 110px; border-radius: 10px; display: block; }
.attach-x { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #222; color: #fff; cursor: pointer; }
.conv-empty { margin: auto; }
@media (min-width: 900px) {
  .chat-layout { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 63px); }
  .channel-pane, .in-channel .channel-pane { display: block; border-right: 1px solid var(--line); min-height: 0; overflow-y: auto; }
  .conversation, .in-channel .conversation { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .conv-head { display: flex; flex-direction: column; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
  .chat-page .topbar .icon-btn[aria-label="Retour"] { display: none; }
  .msg { max-width: 70%; }
}

/* ---------- Galerie ---------- */
.year-title { margin: 8px 0 12px; color: var(--muted); font-weight: 700; }
.album-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }
@media (min-width: 640px) { .album-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .album-grid { grid-template-columns: repeat(4, 1fr); } .album-grid.small-grid { grid-template-columns: repeat(4, 1fr); } }
.album-card { display: flex; flex-direction: column; gap: 2px; color: var(--text); text-decoration: none !important; min-width: 0; }
.album-card b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 6px; }
.album-cover { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: rgba(127,127,127,.15); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.album-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.album-card:hover .album-cover img { transform: scale(1.04); }
.album-count { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; padding: 2px 8px; border-radius: 999px; }
.album-head { margin-bottom: 12px; }
.dropzone {
  display: flex; align-items: center; gap: 14px; padding: 18px; margin-bottom: 16px; cursor: pointer;
  border: 2px dashed color-mix(in srgb, var(--brand) 50%, var(--line)); border-radius: var(--radius);
  background: color-mix(in srgb, var(--brand) 5%, var(--card)); color: var(--text) !important; font-weight: 400 !important;
}
.dropzone .ic { color: var(--brand); }
.dropzone.over, .dropzone:hover { background: color-mix(in srgb, var(--brand) 12%, var(--card)); }
.dropzone.has-files { border-style: solid; border-color: var(--ok); }
.upload-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.upload-summary { font-weight: 700; }
.upload-row { display: grid; grid-template-columns: 1fr 90px auto; gap: 10px; align-items: center; font-size: .85rem; background: var(--card); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); }
.upload-row progress { width: 90px; accent-color: var(--brand); }
.upload-row.error { border-color: var(--ko); color: var(--ko); }
.upload-row.done .st { color: var(--ok); }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
@media (min-width: 640px) { .photo-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; } }
@media (min-width: 1000px) { .photo-grid { grid-template-columns: repeat(6, 1fr); } }
.photo-tile { aspect-ratio: 1; padding: 0; border: 0; background: rgba(127,127,127,.15); cursor: zoom-in; overflow: hidden; border-radius: 4px; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile.new { animation: pop .35s ease; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }

.lightbox { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; align-items: center; justify-content: center; color: #fff; touch-action: pan-y; }
.lb-stage { position: absolute; inset: 56px 0 0; display: flex; align-items: center; justify-content: center; padding: 8px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.lb-top { position: absolute; top: 0; left: 0; right: 0; height: 56px; padding: var(--safe-t) 8px 0 14px; display: flex; align-items: center; gap: 12px; z-index: 2; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.lb-caption { flex: 1; font-size: .85rem; opacity: .8; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lb-count { font-size: .85rem; opacity: .8; }
.lb-actions { display: flex; gap: 4px; }
.lb-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 1.1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none !important; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 52px; height: 72px; border: 0; background: rgba(255,255,255,.08); color: #fff; font-size: 2.4rem; cursor: pointer; border-radius: 10px; }
.lb-prev { left: 8px; } .lb-next { right: 8px; }
@media (pointer: coarse) { .lb-nav { display: none; } }

/* ---------- Membres ---------- */
.member-list { display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.member-row { display: grid; grid-template-columns: 52px 1fr auto; grid-template-areas: "av name grade" "av join age"; gap: 2px 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none !important; }
.member-row:hover { background: rgba(127,127,127,.06); }
.member-row > :nth-child(1) { grid-area: av; } .member-row .m-name { grid-area: name; } .member-row .m-grade { grid-area: grade; text-align: right; }
.member-row .m-join { grid-area: join; } .member-row .m-age { grid-area: age; text-align: right; } .member-row .m-since { display: none; }
.member-row.head { display: none; }
.member-row.inactive { opacity: .55; }
.mobile-label { color: var(--muted); }
@media (min-width: 760px) {
  .member-row { grid-template-columns: 52px 1.6fr 150px 110px 110px 70px; grid-template-areas: none; }
  .member-row > *, .member-row > :nth-child(1), .member-row .m-name, .member-row .m-grade, .member-row .m-join, .member-row .m-age { grid-area: auto; text-align: left; }
  .member-row .m-since { display: block; }
  .member-row.head { display: grid; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg); }
  .mobile-label { display: none; }
}
.grade-dist summary { cursor: pointer; font-weight: 600; }
.grade-dist[open] summary { margin-bottom: 12px; }

/* ---------- Passages de grade ---------- */
.cand-table, .grade-table { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.cand-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; align-items: center; }
.cand-row .c-name { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.cand-row select, .cand-row input { margin: 0; }
.cand-row.head { display: none; }
.cand-row.r-reussi { border-left: 4px solid var(--ok); } .cand-row.r-echoue { border-left: 4px solid var(--ko); } .cand-row.r-absent { opacity: .65; }
.result { font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: rgba(127,127,127,.12); white-space: nowrap; }
.result.r-reussi { background: rgba(29,138,74,.15); color: var(--ok); } .result.r-echoue { background: rgba(192,57,43,.12); color: var(--ko); }
@media (min-width: 900px) {
  .cand-table { gap: 0; }
  .cand-row { grid-template-columns: 1.4fr 1fr 1.1fr 1fr 1.2fr 32px; border-radius: 0; border-width: 0 0 1px; padding: 8px 4px; }
  .cand-row .c-name { grid-column: auto; }
  .cand-row.head { display: grid; font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
}
.avail-list { max-height: 460px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.avail-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; flex-wrap: wrap; }
.avail-row input { width: 20px; height: 20px; accent-color: var(--brand); }
.avail-row .arrow { color: var(--muted); }
.grade-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.grade-row.head { display: none; }
.grade-row input { margin: 0 !important; }
.grade-row input[type=color] { width: 48px; height: 36px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: none; }
.stripe-cell { display: flex; gap: 6px; align-items: center; }
.grade-row.new { border-style: dashed; }
@media (min-width: 900px) {
  .grade-table { gap: 0; }
  .grade-row { grid-template-columns: 120px 1fr 1fr 60px 90px 80px 90px 60px 32px; border-radius: 0; border-width: 0 0 1px; padding: 6px 4px; }
  .grade-row.head { display: grid; font-size: .72rem; text-transform: uppercase; color: var(--muted); }
}

/* ---------- Impression (listes d'examen) ---------- */
@media print {
  .sidebar, .tabbar, .topbar-actions, .topbar .icon-btn, .no-print, .form-actions, .flash, .toolbar { display: none !important; }
  body, .main { background: #fff !important; margin: 0 !important; padding: 0 !important; color: #000; }
  .topbar { position: static; background: none; color: #000; border: 0; }
  .card { box-shadow: none; border: 0; }
  .cand-row { grid-template-columns: 1.4fr 1fr 1.1fr 1fr 1.2fr 0 !important; border-radius: 0; border-width: 0 0 1px !important; }
  .cand-row.head { display: grid !important; }
  .cand-row select, .cand-row input { border: 0; background: none; appearance: none; padding: 0; }
}
