/* =====================================================================
   Maseek — styles de l'application (softpop neobrutalism)
   Écrit à la main, sans framework : seules les classes réellement
   utilisées par les gabarits existent ici (~20 Ko au lieu d'un Tailwind).
   ===================================================================== */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/static/fonts/inter.woff2) format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 500 700; font-display: swap; src: url(/static/fonts/grotesk.woff2) format("woff2"); }

:root {
  --cream: #fdf4e3; --paper: #fffdf7; --ink: #1a1a2e; --blue: #5b8def; --blue-deep: #3a5fcc;
  --coral: #ff8a6b; --yellow: #ffd56b; --mint: #8fd9c0; --lilac: #c9b6f2; --muted: #6b6b80;
  --danger: #e5484d; --border: #1a1a2e;
  color-scheme: light;
}
/* Sombre : choix explicite (cookie) OU préférence système sans choix. Aucun
   script inline nécessaire, donc aucune exception dans la CSP. */
[data-theme="dark"] {
  --cream: #15151f; --paper: #1f1f2e; --ink: #ede7db; --blue: #4a76d8; --blue-deep: #9ab4ff;
  --coral: #b85a41; --yellow: #9a7d2e; --mint: #2f7d63; --lilac: #6b5a9e; --muted: #9d9db2;
  --danger: #ff6b70; --border: #ede7db;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream: #15151f; --paper: #1f1f2e; --ink: #ede7db; --blue: #4a76d8; --blue-deep: #9ab4ff;
    --coral: #b85a41; --yellow: #9a7d2e; --mint: #2f7d63; --lilac: #6b5a9e; --muted: #9d9db2;
    --danger: #ff6b70; --border: #ede7db;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; border: 0 solid; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; line-height: 1.5; -webkit-tap-highlight-color: transparent; scroll-padding-top: 24px; }
body { min-height: 100vh; background: var(--cream); color: var(--ink); font-family: "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .font-display { font-family: "Space Grotesk", system-ui, sans-serif; font-weight: 700; line-height: 1.2; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; cursor: pointer; }
ul, ol { list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* --- Composants -------------------------------------------------------- */
.ms-card { background: var(--paper); border: 2px solid var(--border); border-radius: 14px; box-shadow: 4px 4px 0 var(--border); }
.card-link { transition: transform .08s ease; }
@media (hover: hover) { .card-link:hover { transform: translateY(-2px); } }
.card-link:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--border); }
.ms-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-family: "Space Grotesk", sans-serif;
  border: 2px solid var(--border); border-radius: 11px; padding: 10px 18px; background: var(--paper); color: var(--ink);
  box-shadow: 3px 3px 0 var(--border); cursor: pointer; transition: transform .08s ease, box-shadow .08s ease; line-height: 1.25; text-align: center; }
@media (hover: hover) { .ms-btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--border); } }
.ms-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--border); }
.ms-btn:disabled, .ms-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 var(--border); }
.ms-btn-blue { background: var(--blue); color: #fff; }
.ms-btn-coral { background: var(--coral); color: var(--ink); }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-xxs { padding: 3px 9px; font-size: 12px; border-radius: 8px; box-shadow: 2px 2px 0 var(--border); }
.btn-icon { padding: 8px 10px; }
.ms-input { width: 100%; border: 2px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--paper); color: var(--ink); font-size: 15px; outline: none; }
.ms-input:focus { box-shadow: 3px 3px 0 var(--blue); }
.ms-input:disabled { opacity: .7; }
.input-sm { padding: 6px 10px; }
.input-xs { padding: 4px 8px; }
.ms-label { font-weight: 600; font-size: 14px; margin-bottom: 6px; display: block; }
textarea.ms-input { resize: vertical; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; border: 2px solid var(--border); white-space: nowrap; }
.pill-md { font-size: 14px; }
.chip { display: inline-block; border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); }
.chip-sm { padding: 4px 12px; font-size: 13px; }
.chip-on { background: var(--ink); color: var(--paper); }
.chip-partial, .chip-yellow { background: var(--yellow); }
.chip-mint { background: var(--mint); }
.check-chip { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; border: 2px solid var(--ink); background: var(--paper); }
.check-chip input, .check-lg { width: 18px; height: 18px; accent-color: var(--blue); }
.box { border: 2px solid var(--border); border-radius: 10px; }
.box-cream { border: 2px solid var(--border); border-radius: 10px; background: var(--cream); }
.code-box { display: block; overflow-x: auto; white-space: nowrap; border-radius: 10px; padding: 8px 12px; font-size: 12px; background: var(--cream); border: 2px solid var(--ink); }
.msg-ok { font-size: 14px; font-weight: 600; color: var(--blue-deep); }
.msg-err { font-size: 14px; font-weight: 600; color: var(--danger); }
.locked-note { border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; background: var(--mint); border: 2px solid var(--ink); }
.stars { display: inline-flex; }
.star-on { color: #f5a623; }
.star-off { color: var(--muted); }
.star-btn { font-size: 26px; line-height: 1; padding: 0 2px; }
.unread-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--coral); border: 1px solid var(--ink); }
.period-bar { display: inline-block; width: 8px; height: 40px; border-radius: 999px; }
.link-btn { background: none; border: 0; padding: 0; }
.border-top { border-top: 2px solid var(--ink); }

/* --- En-tête, logo, tiroir ---------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; padding-top: max(16px, env(safe-area-inset-top)); border-bottom: 2px solid var(--ink); gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-family: "Space Grotesk", sans-serif; font-size: 24px; font-weight: 700; }
.logo-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 18px; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.icon-btn { font-size: 24px; line-height: 1; transition: transform .08s; }
.icon-btn:hover { transform: translateY(-2px); }
.bell-count { position: absolute; right: -10px; top: -4px; display: flex; align-items: center; justify-content: center; height: 20px; min-width: 20px; padding: 0 4px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--coral); border: 2px solid var(--ink); }
.profile-btn { display: flex; align-items: center; gap: 12px; border-radius: 10px; padding: 2px 4px; }
.avatar-40, .avatar-44, .avatar-56, .avatar-96 { border-radius: 50%; object-fit: cover; border: 2px solid var(--ink); flex-shrink: 0; }
.avatar-40 { width: 40px; height: 40px; } .avatar-44 { width: 44px; height: 44px; } .avatar-56 { width: 56px; height: 56px; } .avatar-96 { width: 96px; height: 96px; }
.avatar-initials { display: flex; align-items: center; justify-content: center; font-weight: 700; background: var(--yellow); font-size: 14px; }
.avatar-96.avatar-initials { font-size: 30px; }
[data-lightbox] { cursor: zoom-in; }
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-veil { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.drawer-panel { position: absolute; right: 0; top: 0; height: 100%; width: 100%; max-width: 24rem; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; background: var(--cream); padding: 24px; border-left: 2px solid var(--ink); }
.install-banner { margin-bottom: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-radius: 12px; border: 2px solid var(--ink); padding: 12px; font-size: 14px; font-weight: 600; background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); }

/* --- Mise en page -------------------------------------------------------- */
.container { margin: 0 auto; max-width: 64rem; padding-left: 24px; padding-right: 24px; }
.container-sm { margin: 0 auto; max-width: 48rem; padding-left: 24px; padding-right: 24px; }
.auth-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 48px 16px; }
.legal-links { margin-top: 32px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; font-size: 12px; color: var(--muted); }
.legal-links a:hover, .site-footer a:hover { text-decoration: underline; }
.role-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px; text-align: center; font-size: 14px; font-weight: 600; cursor: pointer; }
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
.role-card:has(input:checked) { background: var(--yellow); transform: translate(-1px,-1px); }
.role-card:has(input:focus-visible) { outline: 3px solid var(--blue); }
.grid-cards { display: grid; gap: 20px; }
.grid-2 { display: grid; gap: 16px; }
.grid-3 { display: grid; }
.grid-4 { display: grid; gap: 16px; }
.dispo-form, .doc-form { display: grid; gap: 12px; }
@media (min-width: 640px) {
  .grid-cards, .grid-2, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .span-2 { grid-column: span 2 / span 2; }
  .dispo-form { grid-template-columns: auto auto 1fr auto; align-items: end; }
  .doc-form { grid-template-columns: 1fr 1fr auto; align-items: end; }
}
@media (min-width: 1024px) {
  .grid-cards { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
}
.sticky-actions { position: sticky; bottom: 16px; z-index: 5; }
.user-row { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 768px) { .user-row { flex-direction: row; align-items: center; justify-content: space-between; } }

/* --- Images, galerie, dépôt ---------------------------------------------- */
.cover-thumb { height: 128px; width: 100%; object-fit: cover; border-bottom: 2px solid var(--ink); }
.cover-hero { height: 224px; width: 100%; object-fit: cover; border-radius: 16px; border: 2px solid var(--ink); }
.cover-edit { height: 160px; width: 100%; max-width: 28rem; object-fit: cover; border-radius: 10px; border: 2px solid var(--ink); }
.thumb-128 { height: 128px; width: 128px; object-fit: cover; border-radius: 10px; border: 2px solid var(--ink); }
.thumb-96 { height: 96px; width: 96px; object-fit: cover; border-radius: 10px; border: 2px solid var(--ink); }
.zoom { cursor: zoom-in; }
.corner { position: absolute; right: 6px; top: 6px; }
.dropzone { display: flex; height: 120px; width: 100%; max-width: 28rem; cursor: pointer; flex-direction: column; align-items: center; justify-content: center; border-radius: 10px; border: 2px dashed var(--ink); font-size: 14px; color: var(--muted); text-align: center; padding: 8px; }
.dropzone-sm { height: 96px; width: 96px; font-size: 12px; }
.file-btn { cursor: pointer; }
.qr { border: 2px solid var(--ink); border-radius: 12px; background: #fff; }
.lightbox { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.8); padding: 16px; }
.lightbox img { max-height: 90vh; max-width: 90vw; border-radius: 12px; border: 2px solid var(--ink); object-fit: contain; }
.lightbox .lb-close { position: absolute; right: 16px; top: 16px; }
.lightbox .lb-prev { position: absolute; left: 16px; }
.lightbox .lb-next { position: absolute; right: 16px; }

/* --- Autocomplétion ville ------------------------------------------------- */
.city-ac { position: relative; }
.city-ac ul { position: absolute; z-index: 20; margin-top: 4px; width: 100%; min-width: 16rem; overflow: hidden; border-radius: 10px; border: 2px solid var(--ink); background: var(--paper); box-shadow: 0 8px 20px rgba(0,0,0,.15); }
.city-ac li button { display: block; width: 100%; padding: 8px 12px; text-align: left; font-size: 14px; }
.city-ac li button:hover, .city-ac li button[aria-selected="true"] { background: var(--cream); }

/* --- Signalement / invitation (déplié) ------------------------------------ */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.report summary { cursor: pointer; }
.report-form { margin-top: 8px; width: 100%; max-width: 24rem; border-radius: 10px; border: 2px solid var(--ink); background: var(--cream); padding: 12px; }
.invite summary { display: inline-flex; }

/* --- Messagerie ----------------------------------------------------------- */
.messages-pane { display: flex; gap: 16px; height: calc(100vh - 9rem); }
.threads { display: flex; width: 100%; flex-direction: column; }
.threads-list { flex: 1; overflow-y: auto; }
.thread { display: block; border-radius: 10px; border: 2px solid transparent; padding: 8px 12px; }
.thread-active { border-color: var(--ink); background: var(--cream); }
.conversation { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.chat { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.chat-log { flex: 1; overflow-y: auto; border-radius: 10px; border: 2px solid var(--ink); background: var(--cream); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-form { margin-top: 12px; display: flex; align-items: flex-end; gap: 8px; }
.bubble-row { display: flex; flex-direction: column; align-items: flex-start; }
.bubble-row.mine { align-items: flex-end; }
.bubble { max-width: 75%; border-radius: 16px; border: 2px solid var(--ink); padding: 6px 12px; font-size: 14px; background: var(--paper); color: var(--ink); }
.mine .bubble { background: var(--blue); color: #fff; }
.bubble-name { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 600; opacity: .8; }
.bubble-meta { display: block; margin-top: 2px; text-align: right; font-size: 10px; opacity: .7; }
.seen-by { margin-top: 2px; font-size: 10px; color: var(--muted); }
.show-mobile { display: inline-flex; }
@media (max-width: 767px) { .hide-mobile { display: none !important; } }
@media (min-width: 768px) { .threads { width: 20rem; flex-shrink: 0; } .show-mobile { display: none; } }
@media (max-width: 479px) { .hide-xs { display: none; } }

/* --- Visite guidée -------------------------------------------------------- */
.tour { position: fixed; inset: 0; z-index: 100; }
.tour-veil { position: absolute; inset: 0; background: rgba(20,18,28,.62); }
.tour-halo { pointer-events: none; position: absolute; border-radius: 12px; border: 2px solid var(--ink); box-shadow: 0 0 0 9999px rgba(20,18,28,.62); transition: all .2s; }
.tour-card { position: absolute; left: 50%; width: min(26rem, calc(100vw - 2rem)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 20px; }

/* --- Pages légales -------------------------------------------------------- */
.legal-header { border-bottom: 2px solid rgba(26,26,46,.15); padding: 16px 0; }
.legal-main { margin: 0 auto; width: 100%; max-width: 48rem; flex: 1; padding: 40px 16px; }
.legal-prose { line-height: 1.7; }
.legal-prose h1 { font-size: 2rem; line-height: 1.15; margin-bottom: .35em; }
.legal-prose .legal-updated { color: var(--muted); font-size: .9rem; margin-bottom: 2.5rem; }
.legal-prose h2 { font-size: 1.25rem; margin-top: 2.2rem; margin-bottom: .6rem; padding-bottom: .3rem; border-bottom: 2px solid var(--ink); }
.legal-prose p { margin-bottom: 1rem; }
.legal-prose ul { list-style: disc; padding-left: 1.4rem; margin-bottom: 1rem; }
.legal-prose li { margin-bottom: .4rem; }
.legal-prose a { color: var(--blue-deep); text-decoration: underline; }
.legal-prose strong { font-weight: 600; }
.legal-prose address { font-style: normal; background: var(--paper); border: 2px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.site-footer { margin-top: auto; border-top: 2px solid rgba(26,26,46,.15); padding: 24px 16px; font-size: 14px; color: var(--muted); }
.footer-row { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.site-footer nav a { font-weight: 600; }
@media (min-width: 640px) { .footer-row { flex-direction: row; justify-content: space-between; text-align: left; } }

/* --- Tableaux / facture --------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; font-size: 14px; border-collapse: collapse; }
.data-table th { padding: 8px 12px; text-align: left; font-weight: 600; border-bottom: 2px solid var(--ink); }
.data-table td { padding: 8px 12px; vertical-align: top; border-bottom: 1px solid var(--ink); }
.invoice-table { border-collapse: collapse; }
.invoice-table th { padding: 8px 0; text-align: left; border-bottom: 2px solid var(--ink); }
.invoice-table th.text-right { text-align: right; }
.invoice-table td { padding: 8px 0; border-bottom: 1px solid rgba(26,26,46,.2); }
.invoice-table tfoot td { border-bottom: 0; }
.tf-top td { border-top: 2px solid var(--ink); }
@media print {
  .no-print { display: none !important; }
  body { background: #fff !important; }
  .invoice-sheet { box-shadow: none !important; border: none !important; margin: 0 !important; }
}

/* --- Utilitaires ---------------------------------------------------------- */
.flex { display: flex; } .inline-flex { display: inline-flex; } .grid { display: grid; } .block { display: block; } .inline-block { display: inline-block; }
.flex-col { flex-direction: column; } .flex-wrap { flex-wrap: wrap; } .flex-1 { flex: 1 1 0%; } .shrink-0 { flex-shrink: 0; } .min-w-0 { min-width: 0; }
.items-center { align-items: center; } .items-start { align-items: flex-start; } .items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; } .justify-center { justify-content: center; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.gap-x-3 { column-gap: 12px; } .gap-x-4 { column-gap: 16px; } .gap-x-6 { column-gap: 24px; } .gap-y-1 { row-gap: 4px; } .gap-y-2 { row-gap: 8px; }
.space-y-1 > * + * { margin-top: 4px; } .space-y-2 > * + * { margin-top: 8px; } .space-y-3 > * + * { margin-top: 12px; } .space-y-4 > * + * { margin-top: 16px; } .space-y-6 > * + * { margin-top: 24px; }
.relative { position: relative; } .overflow-hidden { overflow: hidden; } .h-full { height: 100%; } .min-h-screen { min-height: 100vh; }
.w-full { width: 100%; } .w-auto { width: auto; } .w-16 { width: 4rem; } .w-20 { width: 5rem; } .w-24 { width: 6rem; } .w-28 { width: 7rem; } .w-40 { width: 10rem; } .w-52 { width: 13rem; } .w-56 { width: 14rem; }
.max-w-xs { max-width: 20rem; } .max-w-md { max-width: 28rem; } .max-w-lg { max-width: 32rem; } .min-w-64 { min-width: 16rem; }
.p-0 { padding: 0; } .p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; } .p-8 { padding: 32px; } .p-10 { padding: 40px; }
.px-3 { padding-left: 12px; padding-right: 12px; } .px-4 { padding-left: 16px; padding-right: 16px; } .py-2 { padding-top: 8px; padding-bottom: 8px; } .py-8 { padding-top: 32px; padding-bottom: 32px; } .pt-2 { padding-top: 8px; } .pt-3 { padding-top: 12px; } .pb-1 { padding-bottom: 4px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; } .mt-10 { margin-top: 40px; } .mt-auto { margin-top: auto; }
.ml-2 { margin-left: 8px; } .ml-auto { margin-left: auto; } .mr-2 { margin-right: 8px; }
.text-xxs { font-size: 10px; } .text-xs { font-size: 12px; line-height: 1.4; } .text-sm { font-size: 14px; line-height: 1.45; } .text-base { font-size: 16px; } .text-lg { font-size: 18px; } .text-xl { font-size: 20px; } .text-2xl { font-size: 24px; } .text-3xl { font-size: 30px; } .text-4xl { font-size: 36px; }
.font-normal { font-weight: 400; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; } .font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.text-muted { color: var(--muted); } .text-ink { color: var(--ink); } .text-blue-deep { color: var(--blue-deep); }
.text-center { text-align: center; } .text-right { text-align: right; } .uppercase { text-transform: uppercase; } .tracking-widest { letter-spacing: .1em; }
.underline { text-decoration: underline; } .leading-relaxed { line-height: 1.625; } .leading-tight { line-height: 1.25; }
.whitespace-pre-wrap { white-space: pre-wrap; } .break-words { overflow-wrap: anywhere; } .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rounded-lg { border-radius: 10px; } .bg-cream { background: var(--cream); } .bg-paper { background: var(--paper); } .cursor-pointer { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 639px) { h1.text-3xl { font-size: 26px; } .topbar { padding-left: 16px; padding-right: 16px; } .container { padding-left: 16px; padding-right: 16px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* =====================================================================
   Navigation façon application : menu en haut sur ordinateur, barre
   d'onglets en bas sur téléphone (le pouce l'atteint, comme une appli).
   ===================================================================== */
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 200; background: var(--yellow); border: 2px solid var(--ink); border-radius: 10px; padding: 8px 14px; font-weight: 700; }
.skip-link:focus { top: 8px; }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--cream); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topnav { display: none; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; margin-left: 6px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--coral); color: var(--ink); border: 2px solid var(--ink); line-height: 1; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around; gap: 2px;
  background: var(--paper); border-top: 2px solid var(--ink); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tab { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0; color: var(--muted); font-size: 11px; font-weight: 600; }
.tab-icon { position: relative; display: grid; place-items: center; width: 52px; height: 30px; border-radius: 999px; font-size: 19px; border: 2px solid transparent; transition: background .12s; }
.tab-icon .nav-badge { position: absolute; top: -6px; right: 2px; margin: 0; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.is-active { color: var(--ink); }
.tab.is-active .tab-icon { background: var(--yellow); border-color: var(--ink); }
.has-tabbar main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.has-tabbar .sticky-actions { bottom: calc(80px + env(safe-area-inset-bottom)); }
@media (min-width: 1024px) {
  .topbar { display: grid; grid-template-columns: auto 1fr auto; }
  .topnav { display: flex; justify-content: center; gap: 4px; }
  .topnav-link { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; border: 2px solid transparent; white-space: nowrap; }
  .topnav-link:hover { border-color: var(--ink); }
  .topnav-link.is-active { background: var(--ink); color: var(--paper); }
  .tabbar { display: none; }
  .has-tabbar main { padding-bottom: 32px; }
  .has-tabbar .sticky-actions { bottom: 16px; }
}
@media (min-width: 1024px) and (max-width: 1180px) { .topbar .profile-btn .hide-xs { display: none; } }

/* --- Cartes d'accès (accueil) : tuiles compactes en 2 colonnes sur mobile -- */
.feature-card { display: flex; flex-direction: column; padding: 20px; }
.feature-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.feature-emoji { font-size: 26px; line-height: 1; }
.feature-title { font-size: 18px; margin-bottom: 4px; }
.feature-desc { font-size: 14px; color: var(--muted); }
@media (max-width: 639px) {
  .feature-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .feature-card { padding: 14px; }
  .feature-title { font-size: 15px; }
  .feature-desc { font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .feature-top { flex-direction: column; }
  .feature-badge { white-space: normal; font-size: 11px; }
}

/* --- Bandeau de statut, toasts ------------------------------------------ */
.status-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toast { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); z-index: 80; transform: translateX(-50%); width: min(30rem, calc(100vw - 24px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink); font-size: 14px; font-weight: 600; color: var(--ink); animation: toast-in .25s ease-out; }
.toast.is-leaving { opacity: 0; transform: translate(-50%, -12px); transition: opacity .25s, transform .25s; }
.toast-close { font-size: 14px; padding: 4px 6px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }

/* --- Mobile : confort de saisie ----------------------------------------- */
@media (max-width: 639px) {
  /* < 16 px, iOS zoome sur le champ à chaque focus et la page « saute ». */
  input.ms-input, select.ms-input, textarea.ms-input { font-size: 16px !important; }
  .ms-btn { min-height: 42px; }
  .btn-xs, .btn-xxs { min-height: 32px; }
  .chip-scroll { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 2px 16px 8px; scrollbar-width: none; }
  .chip-scroll::-webkit-scrollbar { display: none; }
  .chip-scroll > * { flex-shrink: 0; }
  .page-head h1 { font-size: 24px; }
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }

/* --- Mot de passe : bouton afficher / masquer ----------------------------- */
.pw-wrap { position: relative; }
.pw-wrap .ms-input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 6px 8px; font-size: 13px; font-weight: 600; color: var(--muted); border-radius: 8px; }
.pw-toggle:hover { color: var(--ink); }

/* --- Filtres repliables ---------------------------------------------------- */
.filters-panel { margin-bottom: 16px; }
.filters-panel > summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.filters-panel[open] > summary { margin-bottom: 12px; }
.filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 11px; }

/* --- Navigation interne d'une longue page (dossier) ----------------------- */
.section-nav { position: sticky; top: 72px; z-index: 20; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px 20px; padding: 8px 4px; background: var(--cream); }
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a { flex-shrink: 0; }
@media (max-width: 639px) { .section-nav { top: 70px; margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; } }
[id] { scroll-margin-top: 140px; }

/* --- États vides ------------------------------------------------------------ */
.empty-state { padding: 40px 24px; text-align: center; }
.empty-state .empty-emoji { font-size: 40px; margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin-bottom: 16px; }
.filter-place { width: 13rem; }
@media (max-width: 639px) { .filter-place { width: 100%; } }
.save-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper); box-shadow: 4px 4px 0 var(--ink); }
.thread { display: flex; gap: 10px; align-items: center; padding: 10px; }
.thread:hover { background: var(--cream); }
.thread-avatar { flex-shrink: 0; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink); background: var(--lilac); font-weight: 700; font-family: "Space Grotesk", sans-serif; }
.thread-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-time { flex-shrink: 0; font-size: 11px; color: var(--muted); }
.thread-unread .thread-time { color: var(--ink); font-weight: 700; }
@media (max-width: 1023px) {
  .has-tabbar .messages-pane { height: calc(100dvh - 76px - 72px - 40px - env(safe-area-inset-bottom)); }
  .has-tabbar main:has(.messages-pane) { padding-bottom: calc(76px + env(safe-area-inset-bottom)); padding-top: 16px; }
}
/* --- Accueil : résumé actionnable ------------------------------------------- */
.home-summary { display: grid; gap: 16px; }
@media (min-width: 768px) { .home-summary { grid-template-columns: 3fr 2fr; } }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 10px; background: var(--cream); }
.pick:hover { background: var(--yellow); }
.pick-go { font-weight: 700; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border: 2px solid var(--ink); border-radius: 10px; }
.stat-n { font-family: "Space Grotesk", sans-serif; font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-l { font-size: 12px; font-weight: 600; text-align: center; }
.cta-card { background: var(--lilac); display: flex; flex-direction: column; justify-content: center; }
/* Bouton d'action flottant (fiche d'offre, mobile) : au-dessus des onglets. */
.fab-apply { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 35; padding: 12px 20px; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--coral); box-shadow: 3px 3px 0 var(--ink); font-family: "Space Grotesk", sans-serif; font-weight: 700; }
@media (min-width: 1024px) { .fab-apply { display: none; } }

/* =====================================================================
   iPhone : clavier et transitions
   ===================================================================== */
/* Fond identique pendant un changement de page : plus d'éclair blanc. */
html { background: var(--cream); }
/* Navigations classiques (envoi de formulaire) : fondu au lieu d'un écran
   blanc, sur les navigateurs qui le savent (Safari 18.2+, Chrome 126+). */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .14s; }
/* En-tête et onglets restent immobiles pendant le fondu. */
.topbar { view-transition-name: topbar; }
.tabbar { view-transition-name: tabbar; }

/* Saisie en cours sur écran tactile : pas d'onglets au-dessus du clavier. */
@media (max-width: 1023px) and (hover: none) {
  html.kb-open .tabbar, html.kb-open .fab-apply { display: none; }
  html.kb-open .has-tabbar .sticky-actions { bottom: 8px; }
}

/* Conversation ouverte sur mobile : plein écran, calée sur la zone visible
   (--vvh/--vvo posés par app.js d'après visualViewport). */
@media (max-width: 1023px) {
  html.chat-mode, html.chat-mode body { overflow: hidden; overscroll-behavior: none; height: 100%; }
  html.chat-mode .topbar, html.chat-mode .tabbar, html.chat-mode .threads, html.chat-mode .install-banner { display: none; }
  html.chat-mode .conversation { position: fixed; left: 0; right: 0; top: 0; z-index: 45; display: flex; flex-direction: column;
    height: var(--vvh, 100dvh); transform: translateY(var(--vvo, 0px)); background: var(--cream);
    padding: calc(10px + env(safe-area-inset-top)) 12px calc(8px + env(safe-area-inset-bottom)); }
  html.chat-mode .chat-log { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  html.chat-mode .chat-form { margin-top: 8px; }
  html.chat-mode .chat-form textarea { max-height: 30vh; }
}

/* Choix de fichier : gros bouton lisible au lieu du contrôle natif minuscule. */
.file-pick { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; cursor: pointer; }
.file-pick input { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-pick:focus-within .ms-btn { outline: 3px solid var(--blue); outline-offset: 2px; }
/* Code de confirmation : gros chiffres espacés, faciles à relire. */
.code-input { font-size: 28px; font-weight: 700; letter-spacing: .4em; text-align: center; font-family: ui-monospace, monospace; }
/* Liste de ce qui manque avant de soumettre le dossier. */
.todo-list { display: grid; gap: 6px; margin-bottom: 16px; }
.todo-list a { display: flex; gap: 8px; align-items: baseline; font-size: 14px; font-weight: 600; text-decoration: underline; }
