/* Morlet et Graziotti : deux familles, un foyer à l'intersection.
   Vert forêt = Morlet, bleu outremer = Graziotti, safran = le foyer, ardoise = commun. */
:root {
  --paper: #f2f5f2;
  --surface: #ffffff;
  --sunken: #e8eee9;
  --ink: #16211b;
  --ink-soft: #55625a;
  --line: #d6ddd7;
  --morlet: #1f5a43;
  --graziotti: #2d4a9a;
  --foyer: #d89a1d;
  --commun: #5b6560;
  --accent: var(--morlet);
  --accent-ink: #ffffff;
  --danger: #b3361f;
  --ok: #2f7a4f;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 33, 27, .07);
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --rail: 15.5rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111613;
    --surface: #1a221d;
    --sunken: #222c26;
    --ink: #e8eee9;
    --ink-soft: #a0aca4;
    --line: #2e3a33;
    --morlet: #4fa77f;
    --graziotti: #7d97e6;
    --foyer: #e6ae3a;
    --commun: #9aa59e;
    --accent: var(--morlet);
    --accent-ink: #0d1510;
    --danger: #ee7d66;
    --ok: #62c28c;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font-text); min-height: 100vh; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.005em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--graziotti) 70%, white); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
.row { display: flex; gap: .75rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.grow { flex: 1; min-width: 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.25rem; padding: 1.25rem 1rem; border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--ink); padding: 0 .35rem; }
.brand svg { width: 3rem; height: auto; flex: none; }
.brand .word { font-family: var(--font-display); font-size: 1.15rem; line-height: 1.1; font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: .15rem; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .75rem; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--sunken); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.nav .badge { background: var(--foyer); color: #20170a; border-radius: 999px; font-size: .75rem; font-weight: 700; padding: 0 .45rem; min-width: 1.25rem; text-align: center; }
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: .6rem; padding: .6rem .5rem 0; border-top: 1px solid var(--line); }
.rail-foot a { color: var(--ink); text-decoration: none; font-weight: 500; }
.main { padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem; min-width: 0; }
.page { max-width: 62rem; margin: 0 auto; }
.page.narrow { max-width: 44rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.topbar { display: none; }

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(18rem, 86vw); height: 100dvh; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 0 100vmax transparent; }
  body.nav-open .rail { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 16, 12, .45); }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; padding: .55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
  .topbar svg { width: 2.4rem; height: auto; }
  .main { padding-top: 1rem; }
}

/* ---------- Composants ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radius-sm); padding: .5rem .95rem; cursor: pointer; font-weight: 600; text-decoration: none; line-height: 1.2; min-height: 2.5rem; }
.btn:hover { background: var(--sunken); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.small { min-height: 2rem; padding: .25rem .65rem; font-size: .875rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font: inherit; }
label.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }
label.field > .hint { font-weight: 400; color: var(--ink-soft); font-size: .8rem; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=datetime-local], input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: .55rem .7rem; min-height: 2.5rem; font-weight: 400; }
textarea { resize: vertical; min-height: 5rem; }
input[type=checkbox], input[type=radio] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.checks label { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.form-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.error { color: var(--danger); font-weight: 600; font-size: .9rem; }
.notice { border-left: 4px solid var(--foyer); background: color-mix(in srgb, var(--foyer) 14%, var(--surface)); padding: .7rem .9rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.empty { text-align: center; color: var(--ink-soft); padding: 2.2rem 1rem; }
.empty strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 1.15rem; margin-bottom: .25rem; }

.chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; border: 1px solid var(--line); border-radius: 999px; padding: .08rem .6rem .08rem .45rem; background: var(--surface); color: var(--ink); white-space: nowrap; }
.chip::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--c, var(--commun)); flex: none; }
.chip[data-space=foyer] { --c: var(--foyer); } .chip[data-space=morlet] { --c: var(--morlet); } .chip[data-space=graziotti] { --c: var(--graziotti); } .chip[data-space=commun] { --c: var(--commun); }
.chip.plain::before { display: none; } .chip.plain { padding-left: .6rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .35rem .9rem; cursor: pointer; font-weight: 600; }
.tabs button[aria-pressed="true"], .tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tabs .badge { margin-left: .3rem; background: var(--foyer); color: #20170a; border-radius: 999px; padding: 0 .4rem; font-size: .75rem; }

.avatar { --h: 150; width: 2.2rem; height: 2.2rem; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff; background: hsl(var(--h) 38% 36%); }
.avatar.sm { width: 1.7rem; height: 1.7rem; font-size: .7rem; }
.avatar.lg { width: 3rem; height: 3rem; font-size: 1.1rem; }

/* ---------- Connexion ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-box { width: min(26rem, 100%); }
.auth-hero { text-align: center; margin-bottom: 1.5rem; }
.auth-hero svg { width: 13rem; height: auto; margin: 0 auto .75rem; }
.auth-hero h1 { font-size: 2.2rem; }
.auth-hero p { color: var(--ink-soft); margin-top: .3rem; }
.qr { background: #fff; padding: .5rem; border-radius: var(--radius-sm); width: 15rem; margin: 0 auto; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; background: var(--sunken); padding: .4rem .6rem; border-radius: var(--radius-sm); word-break: break-all; text-align: center; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .8rem; font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--sunken); padding: .8rem 1rem; border-radius: var(--radius-sm); }
.code-input { text-align: center; font-size: 1.4rem; letter-spacing: .25em; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- Fil d'actualité ---------- */
.feed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 1.5rem; align-items: start; }
@media (max-width: 1050px) { .feed-layout { grid-template-columns: 1fr; } .side { order: -1; } }
.side .card h3 { margin-bottom: .6rem; }
.post-head { display: flex; align-items: center; gap: .65rem; }
.post-head .who { font-weight: 700; }
.post-body { margin: .7rem 0 .2rem; }
.post-img { margin-top: .7rem; border-radius: var(--radius-sm); overflow: hidden; background: var(--sunken); cursor: zoom-in; }
.post-img img { width: 100%; max-height: 26rem; object-fit: cover; }
.post-foot { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; }
.composer textarea { min-height: 4.5rem; }

/* ---------- Commentaires ---------- */
.kom { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.kom-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.kom-list .kom-list { margin: .6rem 0 0 1.1rem; padding-left: .9rem; border-left: 2px solid var(--line); }
.kom-item { display: flex; gap: .6rem; }
.kom-bubble { background: var(--sunken); border-radius: var(--radius); padding: .5rem .8rem; min-width: 0; }
.kom-bubble .name { font-weight: 700; font-size: .9rem; }
.kom-actions { display: flex; gap: .9rem; font-size: .8rem; margin: .15rem .3rem 0; color: var(--ink-soft); }
.kom-actions button { background: none; border: 0; padding: 0; color: var(--ink-soft); cursor: pointer; font-weight: 600; font-size: inherit; }
.kom-actions button:hover { color: var(--ink); text-decoration: underline; }
.kom-deleted { font-style: italic; color: var(--ink-soft); font-size: .9rem; padding: .2rem 0; }
.kom-form { display: flex; gap: .5rem; align-items: flex-end; margin-top: .6rem; }
.kom-form textarea { min-height: 2.5rem; height: 2.5rem; }
.kom-form.reply { margin-left: 0; }

/* ---------- Galerie ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 1rem; }
.album-card { text-decoration: none; color: inherit; display: block; }
.album-cover { aspect-ratio: 4 / 3; background: var(--sunken); display: grid; place-items: center; color: var(--ink-soft); overflow: hidden; }
.album-cover img { width: 100%; height: 100%; object-fit: cover; }
.album-cover svg { width: 40%; opacity: .5; }
.album-meta { padding: .7rem .9rem .85rem; display: flex; flex-direction: column; gap: .3rem; }
.album-meta strong { font-family: var(--font-display); font-size: 1.05rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .5rem; }
.photo { position: relative; aspect-ratio: 1; background: var(--sunken); border: 0; padding: 0; cursor: pointer; border-radius: var(--radius-sm); overflow: hidden; }
.photo img, .photo video { width: 100%; height: 100%; object-fit: cover; }
.photo .badge { position: absolute; left: .35rem; bottom: .35rem; background: rgba(0, 0, 0, .6); color: #fff; font-size: .72rem; padding: .05rem .4rem; border-radius: 999px; }
.photo .generic { display: grid; place-items: center; height: 100%; color: var(--ink-soft); font-size: .8rem; padding: .5rem; text-align: center; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem; text-align: center; color: var(--ink-soft); }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.progress { height: .4rem; background: var(--sunken); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.upload-row { display: grid; gap: .25rem; font-size: .875rem; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 10, .94); display: grid; grid-template-columns: minmax(0, 1fr) 22rem; color: #f2f5f2; }
.lightbox .stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 3.5rem 1rem 1rem; }
.lightbox .stage img, .lightbox .stage video { max-width: 100%; max-height: calc(100vh - 6rem); object-fit: contain; }
.lightbox .panel { background: var(--surface); color: var(--ink); overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .8rem; }
.lightbox .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .14); border: 0; color: #fff; width: 2.8rem; height: 2.8rem; border-radius: 50%; cursor: pointer; font-size: 1.4rem; }
.lightbox .nav-btn.prev { left: .75rem; } .lightbox .nav-btn.next { right: .75rem; }
.lightbox .close { position: absolute; top: .6rem; left: .75rem; }
@media (max-width: 880px) { .lightbox { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; } .lightbox .stage img, .lightbox .stage video { max-height: 48vh; } }

/* ---------- Calendrier ---------- */
.cal-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.cal-head h2 { min-width: 11rem; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal .dow { padding: .4rem; text-align: center; font-weight: 700; font-size: .8rem; background: var(--sunken); color: var(--ink-soft); }
.cal .day { min-height: 6.3rem; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: .25rem; display: flex; flex-direction: column; gap: .15rem; cursor: pointer; background: transparent; text-align: left; min-width: 0; }
.cal .day:nth-child(7n + 8) { border-left: 0; }
.cal .day.out { background: color-mix(in srgb, var(--sunken) 55%, transparent); color: var(--ink-soft); }
.cal .day.today .num { background: var(--ink); color: var(--paper); }
.cal .day.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal .num { align-self: flex-start; font-size: .8rem; font-weight: 700; min-width: 1.5rem; height: 1.5rem; display: grid; place-items: center; border-radius: 999px; }
.ev { display: block; width: 100%; text-align: left; font-size: .75rem; line-height: 1.25; padding: .08rem .3rem; border-radius: 4px; border: 0; cursor: pointer; background: color-mix(in srgb, var(--ec, var(--commun)) 16%, var(--surface)); color: var(--ink); border-left: 3px solid var(--ec, var(--commun)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev[data-cat=famille] { --ec: var(--morlet); } .ev[data-cat=anniversaire] { --ec: var(--foyer); } .ev[data-cat=sante] { --ec: var(--danger); }
.ev[data-cat=ecole] { --ec: var(--graziotti); } .ev[data-cat=vacances] { --ec: #0f7b8a; } .ev[data-cat=repas] { --ec: #8a4b2a; }
.more { font-size: .72rem; color: var(--ink-soft); padding-left: .3rem; }
.cal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.cal-list li { display: flex; gap: .7rem; align-items: flex-start; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.datebox { flex: none; width: 3.2rem; text-align: center; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.datebox b { display: block; font-family: var(--font-display); font-size: 1.3rem; line-height: 1.2; }
.datebox span { display: block; background: var(--sunken); font-size: .7rem; padding: .05rem; }
@media (max-width: 640px) { .cal .day { min-height: 4.6rem; } .ev { font-size: .66rem; } .cal .dow { font-size: .7rem; padding: .3rem 0; } }

/* ---------- Documents ---------- */
.docs-layout { display: grid; grid-template-columns: 16rem minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 760px) { .docs-layout { grid-template-columns: 1fr; } }
.folder-group h3 { font-size: .9rem; font-family: var(--font-text); color: var(--ink-soft); margin: 1rem 0 .3rem; font-weight: 600; }
.folder-group h3:first-child { margin-top: 0; }
.folder { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; background: none; border: 0; padding: .45rem .6rem; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; }
.folder:hover { background: var(--sunken); }
.folder[aria-current=true] { background: var(--ink); color: var(--paper); }
.doc-row { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.fileico { flex: none; width: 2.4rem; height: 2.9rem; border-radius: 4px; background: var(--sunken); display: grid; place-items: center; font-size: .68rem; font-weight: 800; color: var(--ink-soft); border: 1px solid var(--line); }

/* ---------- Listes ---------- */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.list-card { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .4rem; }
.list-card strong { font-family: var(--font-display); font-size: 1.1rem; }
.item { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.item.done .txt { text-decoration: line-through; color: var(--ink-soft); }
.item .qty { color: var(--ink-soft); font-size: .85rem; }
.item input[type=checkbox] { width: 1.4rem; height: 1.4rem; }

/* ---------- Recettes ---------- */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; }
.recipe-card { text-decoration: none; color: inherit; display: block; }
.recipe-card .ph { aspect-ratio: 3 / 2; background: var(--sunken); display: grid; place-items: center; color: var(--ink-soft); overflow: hidden; }
.recipe-card .ph img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card .body { padding: .75rem .9rem .9rem; display: flex; flex-direction: column; gap: .3rem; }
.recipe-card strong { font-family: var(--font-display); font-size: 1.1rem; }
.recipe-cols { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 1.5rem; }
@media (max-width: 760px) { .recipe-cols { grid-template-columns: 1fr; } }
.recipe-cols ul, .recipe-cols ol { margin: .5rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .35rem; }
.recipe-hero { width: 100%; max-height: 22rem; object-fit: cover; border-radius: var(--radius); }

/* ---------- Messages ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 13rem); min-height: 22rem; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .35rem; padding: .5rem .25rem; }
.msg { max-width: min(34rem, 85%); display: flex; flex-direction: column; gap: .1rem; }
.msg .bubble { background: var(--sunken); border-radius: 14px 14px 14px 4px; padding: .45rem .8rem; }
.msg.mine { align-self: flex-end; }
.msg.mine .bubble { background: var(--accent); color: var(--accent-ink); border-radius: 14px 14px 4px 14px; }
.msg .meta { font-size: .72rem; color: var(--ink-soft); padding: 0 .4rem; }
.msg.mine .meta { text-align: right; }
.chat-form { display: flex; gap: .5rem; padding-top: .6rem; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-form textarea { min-height: 2.5rem; height: 2.5rem; }
.day-sep { align-self: center; font-size: .75rem; color: var(--ink-soft); margin: .6rem 0 .2rem; }

/* ---------- Tâches ---------- */
.task { display: flex; gap: .9rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.task + .task { margin-top: .6rem; }
.task .pts { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.badge-late { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); color: var(--danger); border-radius: 999px; padding: .05rem .55rem; font-size: .78rem; font-weight: 700; }
.badge-wait { background: color-mix(in srgb, var(--foyer) 22%, var(--surface)); border-radius: 999px; padding: .05rem .55rem; font-size: .78rem; font-weight: 700; }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.rank li { display: grid; grid-template-columns: 2.2rem 2.2rem minmax(0, 1fr) auto; gap: .7rem; align-items: center; }
.rank .pos { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; text-align: center; }
.rank li.me .name { font-weight: 800; }
.bar { height: .5rem; border-radius: 999px; background: var(--sunken); margin-top: .3rem; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--foyer); }
.rank li:first-child .bar i { background: var(--morlet); }

/* ---------- Tableaux (admin) ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .82rem; color: var(--ink-soft); font-weight: 600; }
tr.off td { color: var(--ink-soft); }

/* ---------- Fenêtres et messages ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(10, 16, 12, .5); display: grid; place-items: center; padding: 1rem; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(36rem, 100%); max-height: calc(100dvh - 2rem); overflow-y: auto; padding: 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 1rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal.wide { width: min(46rem, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: var(--radius-sm); box-shadow: 0 4px 18px rgba(0, 0, 0, .25); animation: pop .18s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.spinner { padding: 2rem; text-align: center; color: var(--ink-soft); }

/* ---------- Bandeau de la version de démonstration ---------- */
#demo-banner { position: sticky; top: 0; z-index: 60; padding: .35rem 1rem; text-align: center; font-size: .85rem; font-weight: 600; background: var(--foyer); color: #16211b; }

/* ---------- Calendrier des tâches ---------- */
.tcal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tdow { background: var(--sunken); padding: .35rem; text-align: center; font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.tcell { background: var(--surface); min-height: 6.2rem; padding: .3rem; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.tcell.blank { background: var(--paper); }
.tcell .num { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.tcell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.tchip { border-radius: 5px; padding: .1rem .35rem; font-size: .75rem; line-height: 1.25; border-left: 3px solid var(--commun); background: var(--sunken); overflow-wrap: anywhere; }
.tchip .who { font-weight: 700; }
.tchip.todo { border-left-color: var(--graziotti); background: color-mix(in srgb, var(--graziotti) 14%, var(--surface)); }
.tchip.wait { border-left-color: var(--foyer); background: color-mix(in srgb, var(--foyer) 22%, var(--surface)); }
.tchip.done { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, var(--surface)); }
.tchip.late { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--surface)); }
.tagenda { display: none; flex-direction: column; gap: .8rem; }
.tday { display: flex; flex-direction: column; gap: .25rem; }
.wrap-row { flex-wrap: wrap; }
@media (max-width: 760px) {
  .tcal { display: none; }
  .tagenda { display: flex; }
}

/* ---------- Pages qui tiennent dans l'écran (calendriers) ---------- */
.btn.icon { min-width: 2rem; padding: .25rem .6rem; font-size: 1.2rem; line-height: 1; font-weight: 700; }
h1.compact { font-size: 1.35rem; }
.page.fit { max-width: none; display: flex; flex-direction: column; }
@media (min-width: 901px) {
  .main:has(.page.fit) { padding-top: .8rem; padding-bottom: .8rem; }
  .page.fit { height: calc(100dvh - 1.6rem); }
  .page.fit .cal-head { margin-bottom: .5rem; flex: none; }
  .cal-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: .8rem; }
  .cal-layout > .card { overflow-y: auto; align-self: stretch; }
  .cal-layout .cal { height: 100%; grid-template-rows: auto repeat(var(--rows, 6), minmax(0, 1fr)); }
  .cal .day { min-height: 0; overflow: hidden; padding: .15rem .2rem; gap: .08rem; }
  .cal .num { font-size: .72rem; min-width: 1.25rem; height: 1.25rem; }
  .cal .ev { font-size: .68rem; line-height: 1.2; padding: .03rem .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cal .more { font-size: .65rem; color: var(--ink-soft); }
  .cal .dow { padding: .2rem; font-size: .72rem; }
}
@media (max-width: 900px) {
  .cal-layout { display: block; }
  .cal-layout > .card { margin-top: 1rem; }
  .page.fit .cal-head h1 { display: none; }
}

/* ---------- Messagerie par sujets ---------- */
.msg-layout { display: grid; grid-template-columns: 14rem 1fr; gap: 1rem; padding: .8rem; }
.msg-layout .chat { height: calc(100dvh - 13.5rem); min-height: 22rem; min-width: 0; }
.topics { border-right: 1px solid var(--line); padding-right: .8rem; overflow-y: auto; max-height: calc(100dvh - 13.5rem); }
.topics ul { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.topics .topic { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .4rem; text-align: left; border: 0; background: transparent; padding: .4rem .6rem; border-radius: 8px; cursor: pointer; color: var(--ink); font: inherit; }
.topics .topic:hover { background: var(--sunken); }
.topics .topic.on { background: var(--ink); color: var(--paper); font-weight: 700; }
.topics .topic-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topics .badge { background: var(--foyer); color: #20170a; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; }
.topic-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.topic-head h2 { font-size: 1.05rem; margin: 0; }
.reacts { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; min-height: 0; }
.msg.mine .reacts { justify-content: flex-end; }
.react { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 0 .45rem; font-size: .78rem; line-height: 1.5; cursor: pointer; }
.react.mine { border-color: var(--accent); background: var(--sunken); font-weight: 700; }
.react.add { opacity: 0; transition: opacity .15s; }
.msg:hover .react.add, .msg:focus-within .react.add, .react.add[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .react.add { opacity: .7; } }
.picker { display: inline-flex; gap: .15rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .3rem; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.picker .react { border: 0; font-size: 1rem; }
@media (max-width: 760px) {
  .msg-layout { grid-template-columns: 1fr; }
  .topics { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 .5rem; max-height: none; }
  .topics ul { flex-direction: row; overflow-x: auto; }
  .topics .topic { width: auto; white-space: nowrap; border: 1px solid var(--line); }
  .msg-layout .chat { height: calc(100dvh - 19rem); }
}

/* ---------- Tâches : en-tête compact, calendrier plein écran, graphique, suivi par nature ---------- */
.page-head.tight { margin-bottom: .5rem; align-items: center; }
.tcontent { margin-top: .6rem; }
.tasks-fit .tcell { padding: .15rem .2rem; gap: .08rem; min-height: 0; overflow: hidden; }
.tcell .more { font-size: .62rem; color: var(--ink-soft); }
.tcal-head { gap: .6rem; margin-bottom: .4rem; align-items: center; }
.tcal-head h2 { font-size: 1.05rem; margin: 0; }
.tcal-head select { padding: .2rem .4rem; font-size: .85rem; }
.tlegend .tchip { font-size: .68rem; padding: .02rem .3rem; }
.tfit .tcal .tchip { font-size: .66rem; line-height: 1.15; padding: .02rem .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfit .tcal .num { font-size: .7rem; line-height: 1.1; }
.tfit .tdow { font-size: .7rem; padding: .15rem; text-align: center; background: var(--sunken); font-weight: 600; }
@media (min-width: 901px) {
  .tasks-fit .tabs button { padding: .2rem .7rem; font-size: .85rem; }
  .tasks-fit .tcontent { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: .4rem; }
  .tasks-fit .tcontent > div { flex: 1; min-height: 0; }
  .tasks-fit .tfit { height: 100%; display: flex; flex-direction: column; }
  .tasks-fit .tfit .tcal { flex: 1; min-height: 0; grid-template-rows: auto repeat(var(--rows, 6), minmax(0, 1fr)); }
}
@media (max-width: 900px) { .tcell { min-height: 4.5rem; } }
.rank-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.chart-card h3 { margin-bottom: .6rem; }
.chart { display: flex; align-items: flex-end; justify-content: space-around; gap: .6rem; height: 17rem; padding-top: 1.2rem; border-bottom: 1px solid var(--line); }
.ccol { flex: 1; max-width: 4.5rem; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: .2rem; min-width: 0; }
.ccol .cbar { flex: 1; width: 100%; display: flex; align-items: flex-end; min-height: 0; }
.ccol .cbar i { display: block; width: 100%; border-radius: 6px 6px 0 0; background: hsl(var(--h) 38% 40%); min-height: 2px; transition: height .7s cubic-bezier(.2, .8, .2, 1); }
.ccol .cval { font-weight: 700; font-size: .85rem; }
.ccol .cname { position: absolute; }
.chart + * { margin-top: 0; }
.chart-card .chart { position: relative; margin-bottom: 1.6rem; }
.ccol { position: relative; }
.ccol .cname { position: absolute; bottom: -1.5rem; font-size: .75rem; color: var(--ink-soft); white-space: nowrap; }
.minibar { height: .35rem; background: var(--sunken); border-radius: 999px; margin-bottom: .15rem; min-width: 4rem; }
.minibar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
table.bytype td { vertical-align: top; }
@media (max-width: 900px) { .rank-layout { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .ccol .cbar i { transition: none; } }

/* Ajustements : calendrier des tâches plein écran */
@media (min-width: 761px) { .tagenda { display: none !important; } }
@media (max-width: 760px) { .tagenda { display: flex !important; } }
@media (min-width: 901px) {
  body:has(#demo-banner) .page.fit { height: calc(100dvh - 1.6rem - 2.2rem); }
  .tcal-head { flex-wrap: nowrap; }
  .tcal-head > .small { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tcal-head select { max-width: 10.5rem; }
}
@media (max-width: 1450px) { .tlegend { display: none; } }
@media (min-width: 901px) {
  body:has(#demo-banner) .shell { min-height: calc(100vh - 2rem); }
  body:has(#demo-banner) .rail { height: calc(100vh - 2rem); top: 2rem; }
  body:has(#demo-banner) .page.fit { height: calc(100dvh - 1.6rem - 2rem); }
}
.tabs.compact { gap: .3rem; }
.tabs.compact button { padding: .2rem .65rem; font-size: .85rem; }
.ccol .cbar { position: relative; }
.ccol .cbar i { position: absolute; left: 0; bottom: 0; }
