/* Site de classe 2nde TNE — thème clair/sombre automatique, mobile d'abord. */
:root {
  color-scheme: light dark;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --text: #1b1e2b;
  --muted: #5b6075;
  --border: #dcdfeb;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #e6e5fc;
  --ok: #0f7b4d;   --ok-soft: #dcf5e8;
  --warn: #9a5b00; --warn-soft: #fdf0d5;
  --danger: #b42318; --danger-soft: #fde4e1;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 24 50 / 6%), 0 4px 14px rgb(20 24 50 / 5%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181b25;
    --surface-2: #222636;
    --text: #e8eaf4;
    --muted: #a0a6bd;
    --border: #2d3248;
    --accent: #8b87ff;
    --accent-text: #11122a;
    --accent-soft: #2a2858;
    --ok: #55d69a;   --ok-soft: #12362a;
    --warn: #f3b955; --warn-soft: #3b2d10;
    --danger: #ff8a7d; --danger-soft: #3d1a17;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: 1.2rem; margin-top: 1.5em; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-text); padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

/* Structure */
main { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }
.narrow { max-width: 460px; margin: 1rem auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.noscript { padding: 1rem; text-align: center; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.section { margin-top: 1.5rem; }
.stack { display: grid; gap: .9rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain > li + li { margin-top: .5rem; }
.faded { opacity: .75; }

/* Barre du haut */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1000px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; }
.nav a { padding: .5rem .8rem; border-radius: 10px; text-decoration: none; color: var(--text); min-height: 40px; display: inline-flex; align-items: center; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 860px) {
  .nav { display: none; flex-direction: column; width: 100%; padding-bottom: .5rem; }
  .nav.open { display: flex; }
  .nav a { min-height: 46px; }
}

/* Cartes, boutons, badges */
.hero { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--border); border-radius: calc(var(--radius) + 6px); padding: clamp(1.25rem, 5vw, 3rem); }
.lead { font-size: 1.1rem; max-width: 60ch; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card-pinned { border-color: var(--accent); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .4rem .8rem; margin-bottom: .4rem; }
.card-head h2 { margin: 0; }
.item p:last-child { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.with-actions > .card { margin-bottom: .3rem; }
.slots li { padding: .4rem 0; border-top: 1px solid var(--border); }
.slots li:first-child { border-top: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-small { min-height: 36px; padding: .25rem .8rem; font-size: .9rem; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: .82rem; text-decoration: underline; cursor: pointer; padding: .25rem 0; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.notice { background: var(--warn-soft); color: var(--warn); padding: .5rem .75rem; border-radius: 10px; font-size: .9rem; }

/* Formulaires */
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .3rem; }
.field label { font-weight: 600; }
.field small { color: var(--muted); }
input, select, textarea { width: 100%; min-height: 44px; padding: .55rem .7rem; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--accent); }
.field-check { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.field-check small { flex-basis: 100%; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: .5rem .75rem; border-radius: 10px; margin: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.copyrow { display: flex; gap: .5rem; }
.copyrow input { flex: 1; min-width: 0; }

/* Dialogues */
.dialog { width: min(92vw, 460px); max-height: 90vh; overflow: auto; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgb(0 0 0 / 50%); }
.dialog h2 { margin-top: 0; }
.dialog-form form { display: grid; gap: 1rem; }

/* États */
.state { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: .8rem 0; }
.state-empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 1.2rem; justify-content: center; text-align: center; }
.state-error { flex-wrap: wrap; color: var(--danger); background: var(--danger-soft); border-radius: var(--radius); padding: .8rem 1rem; }
.state-error p { margin: 0; }
.spinner { width: 1rem; height: 1rem; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.toasts { position: fixed; z-index: 50; right: 1rem; bottom: 1rem; left: 1rem; display: grid; gap: .5rem; justify-items: end; pointer-events: none; }
.toast { pointer-events: auto; max-width: 420px; padding: .7rem 1rem; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: 0 6px 20px rgb(0 0 0 / 25%); }
.toast-error { background: var(--danger); color: #fff; }

/* Onglets, filtres */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: .5rem; }
.seg { min-height: 40px; padding: .3rem 1rem; border: 0; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }

/* Messages */
.chat { display: grid; gap: .6rem; align-content: start; height: min(55vh, 520px); overflow-y: auto; padding: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .8rem; }
.bubble { max-width: min(85%, 520px); padding: .55rem .8rem; border-radius: 14px; background: var(--surface-2); justify-self: start; }
.bubble p { margin: .15rem 0 0; }
.bubble-mine { justify-self: end; background: var(--accent-soft); }
.bubble-meta { display: flex; flex-wrap: wrap; gap: .1rem .6rem; align-items: center; font-size: .85rem; }
.chat-form { display: flex; gap: .5rem; }
.chat-form input { flex: 1; min-width: 0; }

/* Appel */
.call-row { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .6rem .9rem .9rem; margin: 0; display: grid; gap: .5rem; }
.call-row legend { font-weight: 600; padding: 0 .3rem; }
.radios { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.radio { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; cursor: pointer; }

/* ===== Style « appli » façon Instagram : épuré, onglets en bas sur mobile ===== */
:root { --ring: linear-gradient(45deg, #f9ce34, #ee2a7b 55%, #6228d7); }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.card { box-shadow: none; }
.topbar { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); }
.brand { font-weight: 800; letter-spacing: -.02em; }

.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--ring); padding: 2px; }
.avatar > span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: var(--surface); color: var(--text); font-weight: 700; border: 2px solid var(--surface); }
.post { padding: .9rem 1rem 1rem; }
.post-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; }
.post h3 { margin-bottom: .3rem; }

.tabbar { display: none; }
.sheet { width: 100%; max-width: 520px; margin: auto auto 0; border: 0; border-radius: 20px 20px 0 0; padding: .5rem 0 calc(1rem + env(safe-area-inset-bottom)); background: var(--surface); color: var(--text); }
.sheet::backdrop { background: rgb(0 0 0 / 50%); }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: .3rem auto .6rem; }
.sheet-list a { display: flex; align-items: center; gap: .9rem; padding: .85rem 1.4rem; min-height: 52px; color: var(--text); text-decoration: none; font-weight: 500; }
.sheet-list a:hover, .sheet-list a[aria-current="page"] { background: var(--surface-2); }

@media (max-width: 860px) {
  .nav { display: none; }
  .topbar-inner { justify-content: center; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a, .tabbar button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; padding: .3rem 0; background: none; border: 0; color: var(--muted); font: inherit; font-size: .68rem; text-decoration: none; cursor: pointer; }
  .tabbar a[aria-current="page"], .tabbar .is-current { color: var(--text); font-weight: 700; }
  .tabbar a[aria-current="page"] .icon, .tabbar .is-current .icon { stroke-width: 2.6; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  main { padding-top: 1rem; }
  .chat { height: min(52vh, 480px); }
}
@media (min-width: 861px) { .sheet { display: none; } }
