:root{
  /* Thème clair “institutionnel” */
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15, 23, 42, .10);

  --brand: #0b2a3a;
  --brand2: #11465f;

  --shadow: 0 10px 25px rgba(2, 8, 23, .08);
  --radius: 14px;

  --focus: rgba(17, 70, 95, .18);
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; font-family: ui-serif, Georgia, "Times New Roman", serif; background:var(--bg); color:var(--text); }

/* Topbar */
.topbar{
  height:74px;
  display:grid;
  grid-template-columns: 180px 1fr 260px;
  align-items:center;
  gap:12px;
  padding:0 16px;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  border-bottom:1px solid rgba(255,255,255,.15);
  color:#fff;
}

.topbar__left{ display:flex; align-items:center; }
.sitebadge{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size:.85rem;
  padding:6px 10px;
  border-radius:999px;
  background: rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.18);
}

.brand{ line-height:1.15; }
.brand--center{ text-align:center; }
.brand__title{ font-weight:700; letter-spacing:.2px; font-size:1.25rem; }
.brand__subtitle{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: rgba(255,255,255,.86);
  font-size:.92rem;
  margin-top:4px;
}
/* Brand avec blason */
.brand--with-logo{
  display: inline-flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.brand__logo{
  height: 44px;          /* taille maîtrisée */
  width: auto;           /* respecte le ratio */
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}

.brand__text{
  display: flex;
  flex-direction: column;
  align-items: center;
}

.topbar__actions{ display:flex; justify-content:flex-end; gap:10px; }

/* Boutons */
.btn{
  cursor:pointer;
  border:1px solid rgba(255,255,255,.22);
  background:rgba(255,255,255,.10);
  color:#fff;
  padding:9px 12px;
  border-radius:12px;
  transition:.15s;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size:.92rem;
}
.btn:hover{ background:rgba(255,255,255,.16); }
.btn:focus{ outline:none; box-shadow: 0 0 0 4px rgba(255,255,255,.18); }

.btn--primary{
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.30);
}
.btn--ghost{
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover{ background: rgba(15,23,42,.05); }
.btn--ghost:focus{ box-shadow: 0 0 0 4px var(--focus); }

/* Layout */
.layout{
  height: calc(100% - 74px);
  display:grid;
  grid-template-columns: 360px 1fr;
}

.sidebar{
  padding:16px;
  overflow:auto;
  border-right:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.65));
}

.sidebar h2{
  margin:6px 0 14px;
  font-size:1.1rem;
  font-weight:700;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.panel{
  background: var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:14px;
  margin-bottom:12px;
  box-shadow: var(--shadow);
}

.panel__title{
  font-weight:700;
  margin-bottom:12px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Radios/Checks */
.radio, .check{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 0;
  user-select:none;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Layer items (miniatures + infos) */
.layeritem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.layeritem__main{
  display:flex;
  align-items:center;
  gap:10px;
  flex: 1;
  cursor:pointer;
  user-select:none;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.layeritem__thumb{
  width:54px;
  height:54px;
  border-radius:12px;
  object-fit:cover;
  border:1px solid var(--border);
  background:#fff;
}

.layeritem__text{ display:flex; flex-direction:column; gap:2px; }
.layeritem__name{ font-weight:700; }
.layeritem__meta{ color: var(--muted); font-size:.85rem; }

.layeritem__actions{ flex:0 0 auto; }

.divider{
  border:none;
  height:1px;
  background: rgba(15,23,42,.08);
  margin:12px 0;
}

/* Opacité */
.opacity{
  display:grid;
  grid-template-columns: 1fr;
  gap:6px;
  margin:10px 0 2px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.opacity label{ color: var(--muted); font-size:.9rem; }
input[type="range"]{ width:100%; }

.hint{ color: var(--muted); font-size:.92rem; margin:10px 0 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
.small{ color: var(--muted); font-size:.95rem; margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }

/* Map */
.mapwrap{ position:relative; }
#map{ height:100%; width:100%; }

.credit{
  position:absolute;
  right:10px;
  bottom:10px;
  background: rgba(255,255,255,.85);
  border:1px solid var(--border);
  padding:8px 10px;
  border-radius:12px;
  font-size:.86rem;
  color: var(--text);
  max-width:min(520px, 90vw);
  box-shadow: var(--shadow);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Modal infos */
.modal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 99999; /* au-dessus de Leaflet */
}

.modal[aria-hidden="false"]{ display:block; }

.modal__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(2,6,23,.42);
  z-index: 0;
}

.modal__card{
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 28px));
  margin: 70px auto 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(2,6,23,.20);
  overflow: hidden;
}

.modal__header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:14px 14px;
  border-bottom:1px solid var(--border);
}

.modal__kicker{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size:.82rem;
  color: var(--muted);
}
.modal__title{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight:800;
  font-size:1.05rem;
}

.modal__body{
  padding:14px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  line-height:1.45;
}
.modal__body p{ margin:0 0 10px; }
.modal__body .meta{
  color: var(--muted);
  font-size:.92rem;
}

/* Mobile-first improvements */
.btn--mobile{
  display:none;
}

/* Mobile layout: carte plein écran + panneau repliable */
@media (max-width: 900px){

  /* Topbar compacte */
  .topbar{
    height: auto;          /* IMPORTANT : annule le 74px desktop */
    position: sticky;      /* reste en haut quand on scroll */
    top: 0;
    z-index: 6000;         /* au-dessus de Leaflet */
  }

  .brand__title{ font-size:1.1rem; }
  .brand__subtitle{ font-size:.9rem; }
  .brand__logo{
    height: 36px;
  }


  .topbar__left{ display:none; } /* cache "Cartographie" (badge) sur mobile */

  .topbar__actions{
    justify-content:flex-start;
    flex-wrap:wrap;
    gap:8px;
  }

  .btn{
    padding:8px 10px;
    border-radius:12px;
  }

  .btn--mobile{
    display:inline-flex; /* montre "Cartes" */
  }

  /* Layout: carte plein écran */
  .layout{
    height: calc(100% - 110px); /* topbar plus haute sur mobile */
    grid-template-columns: 1fr;
    grid-template-rows: 1fr; /* seulement la carte */
  }

  .mapwrap{
    grid-column: 1 / -1;
    grid-row: 1 / -1;
  }

  /* Sidebar devient un drawer */
  .sidebar{
    position: fixed;
    left: 10px;
    right: 10px;
    top: 92px;                 /* juste sous la topbar */
    max-height: calc(100vh - 110px);
    width: auto;

    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);

    transform: translateY(-130%);
    transition: transform .2s ease;
    z-index: 5000;

    overflow:auto;
  }

  .sidebar.sidebar--open{
    transform: translateY(0);
  }

  /* Pour que la carte reste bien visible */
  #map{
    height: 100%;
  }
}
