/* ==========================================================================
   Maison Familiale Taverney - Thierion de Monclin à Dorénaz
   ========================================================================== */

/* ---------- Thèmes ----------
   Chaque thème redéfinit les mêmes variables. Le choix est mémorisé dans le navigateur
   (assets/js/theme.js) et appliqué via l'attribut data-theme de <html>. */
:root {
  /* Constantes communes */
  --radius: 18px;
  --radius-sm: 12px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Instrument Serif', Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Nuit (thème par défaut) */
  --bg: #07090f;
  --bg-glow: #10152a;
  --surface-solid: #121726;
  --text: #eef1f7;
  --text-2: #cfd4e1;
  --text-strong: #ffffff;
  --muted: #8d95aa;
  --faint: #5d6579;
  --gold: #f5c27a;
  --accent-rgb: 245 194 122;
  --accent-hover: #ffd08f;
  --on-accent: #17130c;
  --violet: #8b7cf6;
  --violet-rgb: 139 124 246;
  --teal: #34d3c5;
  --rose: #f47b8f;
  --rose-rgb: 244 123 143;
  --green: #4ade80;
  --green-rgb: 74 222 128;
  --danger-text: #ffc2cc;
  --ok-text: #bff5d2;
  --ink-rgb: 255 255 255;
  --well-rgb: 5 7 13;
  --line-rgb: 238 241 247;
  --panel-rgb: 14 18 29;
  --blob-1: #6d4df2;
  --blob-2: #e58f5b;
  --blob-3: #16a79a;
  --blob-k: 1;
  --grid-k: 1;
  --grad: linear-gradient(120deg, var(--gold), #f19d7a 35%, var(--violet) 70%, var(--teal));
  --shadow-k: .6;

  /* Dérivés */
  --surface: rgb(var(--ink-rgb) / 0.045);
  --surface-2: rgb(var(--ink-rgb) / 0.075);
  --border: rgb(var(--ink-rgb) / 0.09);
  --border-strong: rgb(var(--ink-rgb) / 0.16);
  --shadow: 0 30px 80px -20px rgb(0 0 0 / var(--shadow-k)), 0 0 0 1px var(--border);
  color-scheme: dark;
}

/* Noir intégral pour écrans AMOLED : aucun fond coloré, aucune animation de fond. */
:root[data-theme="amoled"] {
  --bg: #000000;
  --bg-glow: #000000;
  --surface-solid: #0b0b0b;
  --text: #f2f2f2;
  --text-2: #cfcfcf;
  --muted: #8a8a8a;
  --faint: #5c5c5c;
  --well-rgb: 0 0 0;
  --panel-rgb: 0 0 0;
  --blob-k: 0;
  --grid-k: 0;
  --shadow-k: 0;
  --grad: linear-gradient(120deg, var(--gold), #f19d7a 50%, #f5e6c8);
}
:root[data-theme="amoled"] .glass { background: #000; backdrop-filter: none; -webkit-backdrop-filter: none; border-color: rgb(var(--ink-rgb) / .13); }
:root[data-theme="amoled"] .viewer,
:root[data-theme="amoled"] .viewer-bar,
:root[data-theme="amoled"] .sidebar { background: #000; }
:root[data-theme="amoled"] .blob { animation: none; }

/* Océan : bleus profonds. */
:root[data-theme="ocean"] {
  --bg: #050a14;
  --bg-glow: #0b1b36;
  --surface-solid: #0f1a2e;
  --text: #ecf4ff;
  --text-2: #c9d8ee;
  --muted: #8598b6;
  --faint: #566886;
  --gold: #5ec8ff;
  --accent-rgb: 94 200 255;
  --accent-hover: #8fdaff;
  --on-accent: #03111e;
  --violet: #7c8cff;
  --violet-rgb: 124 140 255;
  --teal: #2dd4bf;
  --well-rgb: 3 8 18;
  --panel-rgb: 10 18 34;
  --blob-1: #1e40af;
  --blob-2: #0ea5e9;
  --blob-3: #0d9488;
  --grad: linear-gradient(120deg, var(--gold), var(--violet) 55%, var(--teal));
}

/* Forêt : verts alpins et sable. */
:root[data-theme="foret"] {
  --bg: #060d0a;
  --bg-glow: #0e2219;
  --surface-solid: #0f1c16;
  --text: #edf6f0;
  --text-2: #cbded2;
  --muted: #88a394;
  --faint: #587262;
  --gold: #8fdcaa;
  --accent-rgb: 143 220 170;
  --accent-hover: #aee8c2;
  --on-accent: #05140b;
  --violet: #d9c58f;
  --violet-rgb: 217 197 143;
  --teal: #5ec2b7;
  --well-rgb: 3 9 6;
  --panel-rgb: 10 22 16;
  --blob-1: #166534;
  --blob-2: #a3893f;
  --blob-3: #0f766e;
  --grad: linear-gradient(120deg, var(--gold), var(--teal) 50%, var(--violet));
}

/* Clair : pour la lumière du jour. */
:root[data-theme="clair"] {
  --bg: #f4f1ea;
  --bg-glow: #ffffff;
  --surface-solid: #ffffff;
  --text: #1b1e27;
  --text-2: #363b49;
  --text-strong: #000000;
  --muted: #5d6475;
  --faint: #8a90a0;
  --gold: #a8691b;
  --accent-rgb: 168 105 27;
  --accent-hover: #bd7a26;
  --on-accent: #ffffff;
  --violet: #6d5ae6;
  --violet-rgb: 109 90 230;
  --teal: #0f9488;
  --rose: #d6455f;
  --rose-rgb: 214 69 95;
  --green: #16a34a;
  --green-rgb: 22 163 74;
  --danger-text: #b4233f;
  --ok-text: #126b33;
  --ink-rgb: 24 28 40;
  --well-rgb: 255 255 255;
  --line-rgb: 40 44 58;
  --panel-rgb: 255 255 255;
  --blob-1: #c4b5fd;
  --blob-2: #fdba74;
  --blob-3: #5eead4;
  --blob-k: 1.3;
  --grid-k: .8;
  --shadow-k: .14;
  --grad: linear-gradient(120deg, var(--gold), #d9673f 35%, var(--violet) 70%, var(--teal));
  color-scheme: light;
}
:root[data-theme="clair"] .glass { background: linear-gradient(180deg, rgb(255 255 255 / .82), rgb(255 255 255 / .6)); }
:root[data-theme="clair"] .input { background: rgb(255 255 255 / .9); }
:root[data-theme="clair"] .btn-primary { box-shadow: 0 10px 24px -12px rgb(var(--accent-rgb) / .7); }
:root[data-theme="clair"] .page { box-shadow: 0 12px 34px -14px rgb(24 28 40 / .35), 0 0 0 1px rgb(24 28 40 / .08); }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: rgb(var(--accent-rgb) / 0.35); }

/* ---------- Fond animé ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(ellipse at top, var(--bg-glow) 0%, var(--bg) 60%); }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); animation: drift 26s ease-in-out infinite alternate; }
.b1 { width: 46vw; height: 46vw; left: -10vw; top: -14vw; background: var(--blob-1); opacity: calc(.35 * var(--blob-k)); }
.b2 { width: 38vw; height: 38vw; right: -8vw; top: 10vh; background: var(--blob-2); opacity: calc(.28 * var(--blob-k)); animation-delay: -8s; }
.b3 { width: 40vw; height: 40vw; left: 30vw; bottom: -22vw; background: var(--blob-3); opacity: calc(.25 * var(--blob-k)); animation-delay: -16s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4vw, 3vh) scale(1.08); }
  100% { transform: translate(-3vw, -2vh) scale(0.96); }
}
.grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgb(var(--ink-rgb) / .035) 1px, transparent 1px), linear-gradient(90deg, rgb(var(--ink-rgb) / .035) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
  opacity: var(--grid-k);
}
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } * { transition: none !important; } }

/* ---------- Composants ---------- */
.glass {
  background: linear-gradient(180deg, rgb(var(--ink-rgb) / .07), rgb(var(--ink-rgb) / .03));
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--border);
}
.muted { color: var(--muted); }
/* Marge invisible : l'italique déborde de sa boîte et serait sinon coupé par le dégradé. */
.gradient-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; padding: .06em .16em .12em .04em; margin: -.06em -.16em -.12em -.04em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 700; font-size: 14px; letter-spacing: .01em; white-space: nowrap;
  transition: transform .2s var(--ease), background .2s, border-color .2s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--gold); color: var(--on-accent); box-shadow: 0 10px 30px -10px rgb(var(--accent-rgb) / .6); }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn-danger { background: rgb(var(--rose-rgb) / .12); border-color: rgb(var(--rose-rgb) / .3); color: var(--danger-text); }
.btn-danger:hover { background: rgb(var(--rose-rgb) / .2); }
.btn-success { background: rgb(var(--green-rgb) / .12); border-color: rgb(var(--green-rgb) / .3); color: var(--ok-text); }
.btn-success:hover { background: rgb(var(--green-rgb) / .2); }
.btn-block { width: 100%; padding: 14px 20px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  transition: background .2s, border-color .2s, transform .2s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn svg, .btn svg { width: 18px; height: 18px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input {
  width: 100%; padding: 13px 15px; border-radius: var(--radius-sm);
  background: rgb(var(--well-rgb) / .55); border: 1px solid var(--border);
  outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: rgb(var(--accent-rgb) / .6); box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / .12); background: rgb(var(--well-rgb) / .75); }
.input.invalid { border-color: rgb(var(--rose-rgb) / .7); box-shadow: 0 0 0 4px rgb(var(--rose-rgb) / .12); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d95aa' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
select.input option { background: var(--surface-solid); }

.password-wrap { position: relative; }
.password-wrap .input { padding-right: 48px; }
.password-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 9px; }
.password-wrap button:hover { color: var(--text); background: var(--surface); }
.password-wrap svg { width: 18px; height: 18px; }

.captcha-row { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: center; }
.captcha-img { height: 50px; width: 138px; border-radius: 10px; background: #f3efe7; object-fit: cover; display: block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.captcha-row .input { letter-spacing: .25em; font-weight: 700; text-transform: lowercase; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; animation: rise .35s var(--ease); }
.alert-error { background: rgb(var(--rose-rgb) / .1); border: 1px solid rgb(var(--rose-rgb) / .3); color: var(--danger-text); }
.alert-ok { background: rgb(var(--green-rgb) / .08); border: 1px solid rgb(var(--green-rgb) / .28); color: var(--ok-text); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); background: var(--surface); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-pending { color: var(--gold); border-color: rgb(var(--accent-rgb) / .3); background: rgb(var(--accent-rgb) / .08); }
.pill-approved { color: var(--green); border-color: rgb(var(--green-rgb) / .3); background: rgb(var(--green-rgb) / .08); }
.pill-rejected { color: var(--rose); border-color: rgb(var(--rose-rgb) / .3); background: rgb(var(--rose-rgb) / .08); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   Pages d'authentification
   ========================================================================== */
.auth-layout {
  min-height: 100vh; display: grid; grid-template-columns: 1.15fr minmax(360px, 460px);
  gap: clamp(32px, 6vw, 96px); align-items: center;
  max-width: 1240px; margin: 0 auto; padding: 48px clamp(16px, 5vw, 56px);
}
.auth-hero { animation: rise .9s var(--ease) both; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px; padding: 7px 14px 7px 8px;
  border-radius: 99px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2);
}
.eyebrow .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: var(--on-accent); }
.eyebrow .dot svg { width: 13px; height: 13px; }
.display {
  font-family: var(--display); font-weight: 400; line-height: .92; letter-spacing: -.02em;
  font-size: clamp(56px, 8.4vw, 118px); margin: 28px 0 18px;
}
.display em { font-style: italic; }
.families { font-size: clamp(20px, 2.3vw, 28px); font-weight: 300; margin: 0; color: var(--text-2); letter-spacing: -.01em; }
.families strong { font-weight: 700; }
.place { display: inline-flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--muted); font-weight: 600; }
.place svg { width: 16px; height: 16px; color: var(--gold); }
.skyline { margin-top: 44px; width: 100%; max-width: 620px; height: auto; display: block; opacity: .9; }
.skyline .draw { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw 3.2s var(--ease) .4s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.auth-card { border-radius: 26px; padding: clamp(26px, 4vw, 40px); box-shadow: var(--shadow); animation: rise .9s var(--ease) .12s both; position: relative; }
.auth-card::before { content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: linear-gradient(160deg, rgb(var(--accent-rgb) / .5), transparent 35%, transparent 65%, rgb(var(--violet-rgb) / .45)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.auth-card h2 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.02em; }
.auth-card > p.muted { margin: 0 0 26px; }
.lock-badge { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: rgb(var(--accent-rgb) / .1); border: 1px solid rgb(var(--accent-rgb) / .25); color: var(--gold); margin-bottom: 20px; }
.lock-badge svg { width: 22px; height: 22px; }
.switch { text-align: center; margin: 22px 0 0; color: var(--muted); font-size: 14px; }
.fineprint { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 18px; font-size: 12px; color: var(--faint); }
.fineprint svg { width: 14px; height: 14px; }

.success-state { text-align: center; padding: 10px 0; animation: rise .5s var(--ease); }
.success-state .check { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 20px; display: grid; place-items: center; background: rgb(var(--green-rgb) / .1); border: 1px solid rgb(var(--green-rgb) / .3); color: var(--green); }
.success-state .check svg { width: 34px; height: 34px; }
.success-state h2 { margin-bottom: 10px; }

.center-layout { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.center-layout .auth-card { width: 100%; max-width: 480px; }
.request-card { background: rgb(var(--well-rgb) / .5); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin: 20px 0 24px; display: grid; gap: 4px; }
.request-card strong { font-size: 17px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; padding-top: 40px; gap: 36px; }
  .skyline { display: none; }
  .display { margin-top: 20px; }
}
@media (max-width: 420px) {
  .captcha-row { grid-template-columns: 1fr auto; }
  .captcha-row .input { grid-column: 1 / -1; }
}

/* ==========================================================================
   Application
   ========================================================================== */
.app { overflow: hidden; }
.topbar {
  position: fixed; top: 12px; left: 12px; right: 12px; height: 64px; z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 12px; border-radius: var(--radius);
  border-color: var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--grad); display: grid; place-items: center; color: var(--on-accent); box-shadow: 0 8px 24px -8px rgb(var(--accent-rgb) / .6); }
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text strong { font-family: var(--display); font-weight: 400; font-size: 21px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--violet), var(--teal)); color: #0b0e17; font-size: 12px; font-weight: 800; }

.menu-btn { position: relative; }
.menu-btn .bars { width: 18px; height: 12px; position: relative; }
.menu-btn .bars i { position: absolute; left: 0; height: 2px; border-radius: 2px; background: currentColor; transition: transform .35s var(--ease), opacity .2s, width .35s var(--ease); }
.menu-btn .bars i:nth-child(1) { top: 0; width: 18px; }
.menu-btn .bars i:nth-child(2) { top: 5px; width: 12px; }
.menu-btn .bars i:nth-child(3) { top: 10px; width: 15px; }
.menu-open .menu-btn .bars i:nth-child(1) { transform: translateY(5px) rotate(45deg); width: 18px; }
.menu-open .menu-btn .bars i:nth-child(2) { opacity: 0; }
.menu-open .menu-btn .bars i:nth-child(3) { transform: translateY(-5px) rotate(-45deg); width: 18px; }

.shell { position: fixed; inset: 88px 12px 12px; display: flex; gap: 12px; }

/* ---------- Menu latéral ---------- */
.sidebar {
  width: 330px; flex: none; border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
  transition: margin-left .45s var(--ease), opacity .3s, transform .45s var(--ease);
}
.sidebar-collapsed .sidebar { margin-left: -342px; opacity: 0; pointer-events: none; }
.sidebar-head { padding: 16px 16px 10px; }
.sidebar-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px 12px; }
.sidebar-title h2 { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.sidebar-title span { font-size: 12px; color: var(--faint); }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search .input { padding: 11px 14px 11px 38px; font-size: 14px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; scrollbar-width: thin; scrollbar-color: rgb(var(--ink-rgb) / .12) transparent; }
.nav-group { margin-bottom: 4px; }
.nav-cat {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; background: none;
  border-radius: 12px; text-align: left; transition: background .2s;
}
.nav-cat:hover { background: var(--surface); }
.nav-cat .cat-icon { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--gold); }
.nav-cat .cat-icon svg { width: 17px; height: 17px; }
.nav-cat .cat-label { flex: 1; font-weight: 700; font-size: 14px; }
.nav-cat .cat-count { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 2px 8px; border-radius: 99px; }
.nav-cat .cat-count.done { color: var(--green); border-color: rgb(var(--green-rgb) / .3); background: rgb(var(--green-rgb) / .08); }
.nav-cat .chev { width: 16px; height: 16px; color: var(--faint); transition: transform .3s var(--ease); }
.nav-group.open .chev { transform: rotate(90deg); }
.nav-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .4s var(--ease); }
.nav-group.open .nav-items { grid-template-rows: 1fr; }
.nav-items > ul { overflow: hidden; list-style: none; margin: 0; padding: 0 0 0 26px; position: relative; }
.nav-items > ul::before { content: ''; position: absolute; left: 26px; top: 4px; bottom: 8px; width: 1px; background: var(--border); }

.nav-doc {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 16px; border: 0; background: none;
  text-align: left; border-radius: 10px; margin: 2px 0; font-size: 13.5px; color: var(--text-2); position: relative;
  transition: background .2s, color .2s;
}
.nav-doc:hover { background: var(--surface); color: var(--text); }
.nav-doc.active { background: linear-gradient(90deg, rgb(var(--accent-rgb) / .16), rgb(var(--accent-rgb) / .03)); color: var(--text-strong); }
.nav-doc.active::before { content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.nav-doc svg { width: 16px; height: 16px; flex: none; color: var(--rose); }
.nav-doc .doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-missing { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; font-size: 13px; color: var(--faint); }
.nav-missing .ring { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 1.5px dashed var(--faint); }
.nav-missing .tag { margin-left: auto; white-space: nowrap; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.nav-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad); transition: width 1.2s var(--ease); }

.scrim { display: none; }

/* ---------- Contenu ---------- */
.content { flex: 1; min-width: 0; position: relative; border-radius: var(--radius); overflow: hidden; }

.home { height: 100%; overflow-y: auto; padding: clamp(24px, 4vw, 56px); animation: fade .5s var(--ease); }
.home-hero { max-width: 900px; }
.home-hero .hello { color: var(--gold); font-weight: 700; font-size: 14px; letter-spacing: .04em; }
.home-hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 6vw, 80px); line-height: .98; letter-spacing: -.02em; margin: 12px 0 16px; }
.home-hero h1 em { font-style: italic; }
.home-hero p { color: var(--muted); max-width: 620px; font-size: 16px; margin: 0; }


.section-title { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 44px 0 14px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.cat-card {
  text-align: left; padding: 20px; border-radius: var(--radius); display: flex; flex-direction: column; gap: 14px;
  transition: transform .35s var(--ease), border-color .3s, background .3s; animation: rise .6s var(--ease) both;
}
.cat-card:hover { transform: translateY(-4px); border-color: rgb(var(--accent-rgb) / .35); background: linear-gradient(180deg, rgb(var(--ink-rgb) / .09), rgb(var(--ink-rgb) / .03)); }
.cat-card .top { display: flex; justify-content: space-between; align-items: center; }
.cat-card .cat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgb(var(--accent-rgb) / .1); color: var(--gold); border: 1px solid rgb(var(--accent-rgb) / .2); }
.cat-card .cat-icon svg { width: 20px; height: 20px; }
.cat-card h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.cat-card .meta { font-size: 13px; color: var(--muted); }
.cat-card .bar { height: 4px; }

/* ---------- Liseuse PDF ---------- */
.viewer { height: 100%; display: flex; flex-direction: column; animation: fade .35s var(--ease); background: rgb(var(--well-rgb) / .55); border: 1px solid var(--border); border-radius: var(--radius); }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: rgb(var(--panel-rgb) / .7); backdrop-filter: blur(16px); }
.doc-info { flex: 1 1 100px; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.doc-info .cat { font-size: 11px; color: var(--gold); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.doc-info .title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-group { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: 13px; background: var(--surface); border: 1px solid var(--border); }
.tool-group .icon-btn { width: 34px; height: 34px; border: 0; background: none; border-radius: 10px; }
.tool-group .icon-btn:hover { background: var(--surface-2); }
.page-input { width: 44px; text-align: center; padding: 6px 4px; border-radius: 8px; background: rgb(var(--well-rgb) / .6); border: 1px solid var(--border); font-weight: 700; font-size: 13px; outline: none; }
.page-input:focus { border-color: rgb(var(--accent-rgb) / .6); }
.page-total, .zoom-val { font-size: 13px; color: var(--muted); font-weight: 600; padding: 0 6px; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.zoom-val { background: none; border: 0; }
.zoom-val:hover { color: var(--text); }

.stage { flex: 1; overflow: auto; position: relative; scroll-behavior: smooth; scrollbar-color: rgb(var(--ink-rgb) / .18) transparent; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 28px 20px 60px; min-width: min-content; }
.page {
  position: relative; background: #fff; border-radius: 6px; flex: none;
  box-shadow: 0 1px 0 rgb(var(--ink-rgb) / .06), 0 24px 60px -18px rgba(0,0,0,.8), 0 0 0 1px rgba(0,0,0,.2);
  animation: rise .5s var(--ease) both;
}
.page canvas { display: block; width: 100%; height: 100%; border-radius: inherit; }
.page .page-num { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--faint); font-weight: 600; }
.page.loading::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(100deg, #f1f1f1 30%, #fafafa 50%, #f1f1f1 70%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.viewer-status { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); gap: 12px; pointer-events: none; }
.viewer-status .spinner { width: 34px; height: 34px; border-width: 3px; color: var(--gold); margin: 0 auto 12px; }
.viewer:fullscreen { border-radius: 0; background: var(--bg); }

/* ---------- Administration ---------- */
.admin-main { height: 100%; overflow-y: auto; padding: clamp(20px, 3.5vw, 44px); }
.admin-main h1 { font-family: var(--display); font-weight: 400; font-size: clamp(36px, 5vw, 58px); margin: 0 0 6px; letter-spacing: -.02em; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); margin: 24px 0; }
.tab { border: 0; background: none; padding: 9px 16px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
.tab.active { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.tab .badge { background: var(--gold); color: var(--on-accent); font-size: 11px; padding: 1px 7px; border-radius: 99px; }
.panel { border-radius: var(--radius); padding: 6px; margin-bottom: 22px; }
.panel-head { padding: 16px 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 17px; }
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 180px; }
.row .name { font-weight: 700; }
.row .sub { font-size: 13px; color: var(--muted); }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row .input { padding: 8px 12px; font-size: 13.5px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 6px 16px 16px; }
.dropzone {
  grid-column: 1 / -1; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 30px 16px; text-align: center;
  cursor: pointer; transition: border-color .2s, background .2s; color: var(--muted);
}
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: rgb(var(--accent-rgb) / .05); color: var(--text); }
.dropzone svg { width: 30px; height: 30px; color: var(--gold); margin-bottom: 8px; }
.dropzone strong { color: var(--text); }
.upload-grid .full { grid-column: 1 / -1; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(30px); opacity: 0; z-index: 100; padding: 12px 18px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; transition: transform .4s var(--ease), opacity .3s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { border-color: rgb(var(--rose-rgb) / .4); color: var(--danger-text); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .user-chip span:last-child { display: none; }
  .user-chip { padding: 4px; }
  .sidebar {
    position: fixed; left: 12px; top: 88px; bottom: 12px; z-index: 25; width: min(340px, calc(100vw - 24px));
    background: rgb(var(--panel-rgb) / .92); transform: translateX(calc(-100% - 20px)); opacity: 1; margin-left: 0 !important; pointer-events: auto;
  }
  .menu-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .sidebar-collapsed .sidebar { opacity: 1; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .menu-open .scrim { opacity: 1; pointer-events: auto; }
  .upload-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { top: 8px; left: 8px; right: 8px; height: 58px; gap: 10px; padding: 0 8px; }
  .shell { inset: 74px 8px 8px; }
  .sidebar { top: 74px; left: 8px; bottom: 8px; }
  .brand-mark { display: none; }
  .brand-text strong { font-size: 18px; }
  #admin-link span { display: none; }
  .viewer-bar { gap: 6px; padding: 8px; }
  .doc-info { flex-basis: calc(100% - 50px); order: 0; }
  .tool-group.zoom .zoom-fit { display: none; }
  .pages { padding: 16px 10px 50px; gap: 16px; }
}

/* ---------- Façade (page de connexion) ---------- */
.mt-24 { margin-top: 24px; }
.facade { margin: 40px 0 0; max-width: 640px; position: relative; }
.facade-svg { width: 100%; height: auto; display: block; overflow: visible; }
.facade-svg .draw, .facade-svg .draw-group rect { stroke-dasharray: 2400; stroke-dashoffset: 2400; animation: draw 3.4s var(--ease) .3s forwards; }
.facade-svg .draw-group rect { stroke: rgb(var(--line-rgb) / .55); stroke-width: 2.5; animation-delay: 1.4s; animation-duration: 2.2s; }
.facade-svg .faint { stroke: rgb(var(--line-rgb) / .18); stroke-width: 2; }
.facade-svg .ground { stroke: rgb(var(--line-rgb) / .28); stroke-width: 2; }
.facade-svg .glass-pane { opacity: 0; animation: fade 1.6s var(--ease) 1.8s forwards; }
.facade-svg .person { fill: rgb(var(--line-rgb) / .35); opacity: 0; animation: fade 1s var(--ease) 2.4s forwards; }
.facade-photo { width: 100%; display: block; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow); filter: saturate(.9); }
.facade.has-photo .facade-svg { display: none; }
.facade figcaption { margin-top: 12px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }

.steps { list-style: none; padding: 0; margin: 44px 0 0; display: grid; gap: 18px; max-width: 460px; }
.steps li { display: flex; gap: 16px; align-items: flex-start; }
.steps li > span { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; border: 1px solid rgb(var(--accent-rgb) / .35); color: var(--gold); background: rgb(var(--accent-rgb) / .08); }
.steps strong { display: block; }
.steps p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.strength { height: 4px; margin-top: 4px; }
.strength i { transition: width .4s var(--ease), background .3s; }
@media (max-width: 900px) { .facade { display: none; } .steps { margin-top: 28px; } }
.row .edit:not([hidden]) { display: flex; gap: 8px; flex-wrap: wrap; }
.row .edit .input:first-child { flex: 1; min-width: 200px; }
.row .edit select.input { width: auto; }
@media (max-width: 1200px) and (min-width: 641px) { .tool-group.zoom .zoom-fit { display: none; } .viewer-bar { gap: 6px; } }

/* ---------- Accueil : téléchargement groupé ---------- */
.hero-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 26px; }
.hero-actions .muted { font-size: 13px; }
.cat-card { flex-direction: row; align-items: center; gap: 16px; padding: 18px 20px; }
.cat-card h3 { font-size: 15.5px; }
.cat-card .cat-icon { flex: none; }

/* ---------- Administration : rubriques et projection ---------- */
.cat-row { align-items: flex-start; }
.cat-row .cat-fields { flex: 1; min-width: 240px; display: grid; grid-template-columns: 150px 1fr; gap: 10px; }
.cat-row textarea.input { grid-column: 1 / -1; min-height: 96px; resize: vertical; font-size: 13.5px; line-height: 1.5; }
.cat-row .hint { grid-column: 1 / -1; font-size: 12px; color: var(--faint); margin-top: -4px; }
.cat-row .actions { flex-direction: column; align-items: stretch; }
.cat-row .order { display: flex; gap: 6px; }
.cat-row .order .btn { flex: 1; }
.facade-admin { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 18px; padding: 6px 16px 16px; align-items: start; }
.facade-preview { border-radius: 14px; border: 1px solid var(--border); background: rgb(var(--well-rgb) / .5); min-height: 180px; display: grid; place-items: center; overflow: hidden; color: var(--faint); font-size: 14px; }
.facade-preview img { width: 100%; display: block; }
.facade-admin .dropzone { grid-column: auto; }
@media (max-width: 900px) {
  .cat-row .cat-fields { grid-template-columns: 1fr; }
  .facade-admin { grid-template-columns: 1fr; }
}
.cat-row > .cat-icon { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: rgb(var(--accent-rgb) / .1); color: var(--gold); border: 1px solid rgb(var(--accent-rgb) / .2); margin-top: 2px; }
.cat-row > .cat-icon svg { width: 19px; height: 19px; }

/* ---------- Mon compte ---------- */
a.user-chip { color: var(--text); transition: background .2s, border-color .2s; }
a.user-chip:hover { text-decoration: none; background: var(--surface-2); border-color: var(--border-strong); }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-top: 26px; align-items: start; }
.account-form { margin: 0; }
.account-body { padding: 4px 16px 18px; }
.account .small { font-size: 13.5px; margin: 0 0 16px; }
.account code { font-size: 12.5px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
.danger-zone { border-color: rgb(var(--rose-rgb) / .25); }
.danger-zone .panel-head h2 { color: var(--danger-text); }

/* ---------- Sélecteur de thème ---------- */
.theme-slot { position: relative; }
.theme-slot.floating { position: fixed; top: 16px; right: 16px; z-index: 50; }
.theme-slot.floating .theme-btn { background: var(--surface-2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 210px; padding: 6px;
  border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  animation: rise .25s var(--ease);
}
.theme-menu-title { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 6px; }
.theme-option { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 0; background: none; border-radius: 10px; font-size: 14px; font-weight: 600; text-align: left; }
.theme-option:hover { background: var(--surface-2); }
.theme-option[aria-checked="true"] { background: rgb(var(--accent-rgb) / .14); color: var(--text-strong); }
.theme-option[aria-checked="true"]::after { content: '✓'; margin-left: auto; color: var(--gold); font-weight: 800; }
.theme-swatch { display: inline-flex; flex: none; }
.theme-swatch i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--surface-solid); box-shadow: 0 0 0 1px var(--border-strong); }
.theme-swatch i + i { margin-left: -6px; }
@media (max-width: 640px) { .theme-slot.floating { top: 10px; right: 10px; } }
