/* ══════════════════════════════════════════════════
   Xpo — Feuille de styles
   ══════════════════════════════════════════════════ */

/* ── Variables ── */
:root {
    --bg:           #F2F2F7;
    --surface:      #FFFFFF;
    --surface2:     #F2F2F7;
    --border:       rgba(60,60,67,.12);
    --label:        #000000;
    --label2:       rgba(60,60,67,.6);
    --label3:       rgba(60,60,67,.3);
    --fill:         rgba(120,120,128,.18);
    --fill2:        rgba(120,120,128,.13);
    --danger:       #FF3B30;
    --blue:         #007AFF;
    --green:        #34C759;
    --orange:       #FF9500;
    --pink:         #FF2D55;
    --indigo:       #5856D6;
    --purple:       #AF52DE;
    --r-card:       16px;
    --shadow:       0 2px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    --shadow-modal: 0 20px 60px rgba(0,0,0,.18);
    --topbar-h:     52px;
    --bottombar-h:  52px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:           #161616;
        --surface:      #2C2C2E;
        --surface2:     #1C1C1E;
        --border:       rgba(255,255,255,.1);
        --label:        #FFFFFF;
        --label2:       rgba(235,235,245,.6);
        --label3:       rgba(235,235,245,.3);
        --fill:         rgba(120,120,128,.24);
        --fill2:        rgba(120,120,128,.16);
        --shadow:       0 2px 16px rgba(0,0,0,.4);
        --shadow-modal: 0 20px 60px rgba(0,0,0,.6);
    }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

body {
    background: var(--bg);
    color: var(--label);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
    font-size: 15px; line-height: 1.5;
    height: 100vh; height: 100dvh;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ══════════════════════════════════════════════════
   LOGO
   ══════════════════════════════════════════════════ */
.logo-long {
    -webkit-mask-image: url("../images/logo_long.svg"); mask-image: url("../images/logo_long.svg");
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-size: contain; mask-size: contain;
    -webkit-mask-position: left center; mask-position: left center;
    background-color: currentColor;
}
.sidebar-logo-icon { width: 28px; height: 36px; flex-shrink: 0; filter: none; }
.login-logo-icon   { width: 40px; height: 52px; min-width: 40px; min-height: 52px; margin-bottom: 1.1rem; flex-shrink: 0; filter: none; }
@media (prefers-color-scheme: dark) {
    .sidebar-logo-icon, .login-logo-icon { filter: invert(1); }
}
.mob-logo-long { width: 80px; height: 28px; color: var(--label); }

/* ══════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════ */
.layout { display: flex; height: 100vh; overflow: hidden; max-width: 100vw; }

.sidebar {
    width: 248px; flex-shrink: 0; background: var(--bg);
    padding: 1.5rem 1rem;
    display: flex; flex-direction: column; gap: 1.5rem;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo { display: flex; align-items: center; gap: .75rem; padding: .25rem .5rem; color: inherit; cursor: default; }

.nav-section-label { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--label3); padding: 0 .6rem; margin-bottom: .25rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: .65rem;
    padding: .6rem .75rem; border-radius: 10px;
    color: var(--label2); text-decoration: none;
    font-size: .9rem; font-weight: 500;
    transition: background .12s, color .12s;
    cursor: pointer; -webkit-user-select: none; user-select: none;
}
.nav a:hover  { background: var(--fill2); color: var(--label); }
.nav a.active { background: var(--fill);  color: var(--label); font-weight: 600; }
.nav-icon { width: 16px; height: 16px; display: block; flex-shrink: 0; opacity: .6; }
.nav a.active .nav-icon, .nav a:hover .nav-icon { opacity: 1; }

@media (prefers-color-scheme: light) {
    .nav a.active { background: rgba(120,120,128,.16); }
}

/* ── Sidebar filters ── */
.sidebar-filters { display: flex; flex-direction: column; gap: .35rem; }

.filter-chip {
    display: flex; align-items: center; gap: .55rem;
    width: 100%; padding: .42rem .75rem; border-radius: 10px;
    background: transparent; border: 1.5px solid transparent;
    cursor: pointer; font-family: inherit; font-size: .85rem; font-weight: 500; color: var(--label);
    transition: background .12s, border-color .12s;
}
.filter-chip:hover    { background: var(--fill2); }
.filter-chip.on       { background: var(--fill2); border-color: var(--border); }
.filter-chip.disabled { opacity: .3; pointer-events: none; }
.filter-chip span     { flex: 1; text-align: left; }

@media (prefers-color-scheme: light) {
    .filter-chip.on           { background: transparent; border-color: rgba(0,0,0,.8); }
    .filter-chip.on .fc-icon svg  { stroke: #000000; }
    .filter-chip.on .fc-check svg { stroke: #000000; }
}
@media (prefers-color-scheme: dark) {
    .filter-chip.on              { background: transparent; border-color: rgba(255,255,255,.6); }
    .filter-chip:not(.on)        { background: transparent; border-color: transparent; }
    .filter-chip:not(.on):hover  { background: rgba(255,255,255,.07); }
}

.fc-icon { width: 15px; height: 15px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.fc-icon svg { width: 14px; height: 14px; stroke: var(--label2); fill: none; stroke-width: 2; }
.fc-check { width: 14px; height: 14px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; }
.fc-check svg { width: 13px; height: 13px; stroke: var(--label); fill: none; stroke-width: 2.5; }
.filter-chip.on .fc-check { opacity: 1; }
.fc-dot { display: none; }
.fc-toggle { display: none; }
.sidebar-footer { margin-top: auto; }

/* ── Weather widget ── */
.weather-widget {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--label2);
  padding: .4rem .5rem;
  border-radius: 8px;
  margin-bottom: .5rem;
  width: fit-content;
}
.weather-widget .weather-icon { display: flex; align-items: center; }
.weather-widget .weather-icon img { opacity: .6; filter: none; }
.weather-widget .weather-temp { letter-spacing: -.02em; color: var(--label2); }
@media (prefers-color-scheme: dark) {
  .weather-widget .weather-icon img { filter: invert(1) !important; opacity: .6; }
}
.weather-widget .weather-rain.no-rain { color: var(--label3); background: transparent; }
.weather-widget .weather-rain {
  font-size: .7rem;
  font-weight: 400;
  color: #007AFF;
  background: rgba(0,122,255,.1);
  padding: 1px 5px;
  border-radius: 4px;
}
/* ── Weather tooltip 6h ── */
.weather-widget { position: relative; cursor: pointer; }
.weather-widget        { position: relative; }
.weather-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.14);
  padding: .5rem .65rem;
  width: max-content;
  z-index: 600;
  gap: .2rem;
  flex-direction: column;
  white-space: nowrap;
  pointer-events: none;
}
@media (max-width: 768px) {
  .weather-tooltip { position: absolute; top: calc(100% + 8px); bottom: auto; right: 1rem; left: auto; }
}
.weather-widget[data-tip-open] .weather-tooltip { display: flex; }
.wtip-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  color: var(--label);
}
.wtip-time { color: var(--label2); min-width: 38px; }
.wtip-icon { opacity: .6; flex-shrink: 0; }
.wtip-temp { font-weight: 600; }
.wtip-precip {
  font-size: .7rem;
  color: #007AFF;
  background: rgba(0,122,255,.1);
  padding: 1px 4px;
  border-radius: 4px;
}
@media (prefers-color-scheme: dark) {
  .wtip-icon { filter: invert(1); }
  .wtip-precip { background: rgba(64,156,255,.15); color: #4d9eff; }
}
/* Mobile : sur la ligne du page-header, aligné à droite */
.mob-weather {
  margin-bottom: 0;
  flex-shrink: 0;
  background: none;
  padding: 0;
}
@media (min-width: 769px) {
  .mob-weather { display: none !important; }
  #modal-detail { display: none !important; }
}
@media (prefers-color-scheme: dark) {
  .weather-widget .weather-rain.no-rain { color: var(--label3); background: transparent; }
.weather-widget .weather-rain { background: rgba(64,156,255,.15); color: #4d9eff; }
}

/* ── Sidebar search ── */
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
input[type="search"]::-webkit-search-decoration     { -webkit-appearance: none; }

.sidebar-search-wrap { position: relative; }
.sidebar-search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 13px; height: 13px; opacity: .4; pointer-events: none; }
.sidebar-search-wrap .search-input { width: 100%; background: var(--fill2); border-color: transparent; font-size: .8rem; padding: .45rem 1.9rem; }
.sidebar-search-wrap .search-input:focus { background: var(--surface); border-color: rgba(60,60,67,.2); }

@media (prefers-color-scheme: light) {
    .sidebar-search-wrap svg { opacity: .6; }
    .sidebar-search-wrap .search-input { background: rgba(120,120,128,.16); }
    .sidebar-search-wrap .search-input::placeholder { color: rgba(0,0,0,.4); }
}

.search-clear { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; background: transparent; transition: opacity .12s; }
.search-clear:hover { opacity: .6; }
.icon-clear { display: block; width: 14px; height: 14px; flex-shrink: 0; -webkit-mask-image: url("../ui/circle-cross.svg"); mask-image: url("../ui/circle-cross.svg"); -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-position: center; mask-position: center; background-color: var(--label2); }

/* ── Main ── */
.main { flex: 1; padding: 0 2.5rem 2rem; min-width: 0; overflow-y: auto; overflow-x: hidden; position: relative; }

/* ══════════════════════════════════════════════════
   PAGE HEADER
   ══════════════════════════════════════════════════ */
.page-header { margin-bottom: .20rem; display: flex; flex-direction: column; justify-content: center; height: calc(1.5rem + 40px + 1.5rem); }
.page-header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.5px; margin-bottom: .2rem; }
.page-header p  { font-size: .9rem; color: var(--label2); }
.count-label    { font-size: .85rem; color: var(--label2); }

/* ══════════════════════════════════════════════════
   SEARCH INPUT
   ══════════════════════════════════════════════════ */
.search-input { width: 100%; padding: .52rem .75rem .52rem 2rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--label); font-size: .875rem; font-family: inherit; outline: none; transition: border-color .15s; }
.search-input:focus { border-color: rgba(60,60,67,.3); }

/* ══════════════════════════════════════════════════
   CARDS GRID
   ══════════════════════════════════════════════════ */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 1rem; }

.elem-card {
    position: relative;
    background: var(--surface); border-radius: var(--r-card);
    box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    transition: transform .15s, box-shadow .15s, opacity .25s;
    border: 1px solid var(--border); cursor: pointer;
    transform: translateZ(0); will-change: transform;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    min-width: 0; max-width: 100%;
}
.elem-card > .card-img { border-radius: var(--r-card) var(--r-card) 0 0; overflow: hidden; }
.elem-card:hover  { transform: translateY(-5px) translateZ(0); box-shadow: 0 12px 36px rgba(0,0,0,.22), 0 4px 10px rgba(0,0,0,.15); }
.elem-card::after  { content: ''; position: absolute; bottom: -1rem; left: 0; right: 0; height: 1rem; }
.elem-card::before { content: ''; position: absolute; top: -5px; left: 0; right: 0; height: 5px; }
.elem-card.dimmed { opacity: .3; }

.card-img { position: relative; height: 172px; overflow: hidden; flex-shrink: 0; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .3s; opacity: 0; will-change: transform; }
.card-img img.loaded { opacity: 1; }
.panel-resizing .card-img img { transition: none; }
.card-img-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.card-img-ph svg { width: 32px; height: 32px; opacity: .25; color: white; }

.badges-tl { position: absolute; bottom: 7px; left: 7px; right: 90px; display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 4px; }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 3px 7px; height: 22px; border-radius: 99px; font-size: .68rem; font-weight: 700; color: white; white-space: nowrap; }
.badge-new      { background: var(--indigo); }
.badge-lastdays { background: var(--danger); }
.badge-finished { background: rgba(120,120,128,.55); }
.badge-event    { background: var(--purple); }
.badge-upcoming { background: var(--blue); }

.badge-new::before, .badge-lastdays::before, .badge-finished::before, .badge-event::before, .badge-upcoming::before { content: ''; display: inline-block; width: 10px; height: 10px; flex-shrink: 0; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-position: center; mask-position: center; background-color: white; }
.badge-new::before      { -webkit-mask-image: url("../ui/stars.svg");          mask-image: url("../ui/stars.svg"); }
.badge-event::before    { -webkit-mask-image: url("../ui/bolt.svg");           mask-image: url("../ui/bolt.svg"); }
.badge-lastdays::before { -webkit-mask-image: url("../ui/clock.svg");          mask-image: url("../ui/clock.svg"); }
.badge-finished::before { -webkit-mask-image: url("../ui/clock.svg");          mask-image: url("../ui/clock.svg"); }
.badge-upcoming::before { -webkit-mask-image: url("../ui/calendar-clock.svg"); mask-image: url("../ui/calendar-clock.svg"); }

.badge-open { position: absolute; bottom: 7px; right: 7px; display: inline-flex; align-items: center; gap: 3px; padding: 3px 7px; height: 22px; border-radius: 99px; font-size: .68rem; font-weight: 700; white-space: nowrap; background: white; border: none; cursor: pointer; }

.pulse-dot { width: 7px; height: 7px; border-radius: 50%; position: relative; flex-shrink: 0; }
.pulse-dot::before { content: ''; position: absolute; inset: -3px; border-radius: 50%; background: inherit; opacity: .4; animation: pulse 1.5s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: .4; } 100% { transform: scale(2.4); opacity: 0; } }

.card-body  { padding: .85rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.card-title { font-size: 1rem; font-weight: 700; line-height: 1.3; color: var(--label); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta  { display: flex; align-items: center; gap: 4px; font-size: .82rem; color: var(--label2); overflow: hidden; }
.card-meta svg { width: 11px; height: 11px; flex-shrink: 0; opacity: .5; }
.card-venue-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card-desc  { font-size: .75rem; color: var(--label2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }

.card-actions { display: flex; align-items: center; justify-content: space-between; padding-top: .65rem; margin-top: .4rem; border-top: 1px solid var(--border); }
.act-left, .act-right { display: flex; gap: 2px; align-items: center; }
.act-btn { width: 36px; height: 36px; border-radius: 10px; background: none; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--label2); transition: background .12s, color .12s; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.act-btn:hover  { background: var(--fill2); color: var(--label); }
.act-btn svg    { width: 18px; height: 18px; }
@media (prefers-color-scheme: dark) { .act-btn img { filter: invert(1); } }
.act-btn.a-ts   { color: var(--blue); }
.act-btn.a-fav  { color: var(--pink); }
.act-btn.a-seen { color: var(--green); }
.act-btn.a-hid  { color: var(--orange); }
.act-btn.a-ts svg, .act-btn.a-fav svg { fill: currentColor; }

/* ══════════════════════════════════════════════════
   DETAIL PANEL
   ══════════════════════════════════════════════════ */
.detail-panel { width: 0; flex-shrink: 0; background: var(--surface); overflow: hidden; position: sticky; top: 0; height: 100vh; transition: width .22s cubic-bezier(.32,.72,0,1); display: flex; flex-direction: column; }
.main { transition: none; }
.cards-grid { width: 100% !important; }
.detail-panel.open { width: 320px; z-index: 10; overflow: visible; }
.detail-collapse-btn { position: absolute; left: -16px; top: 50%; transform: translateY(-50%); width: 32px; height: 56px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: -2px 0 8px rgba(0,0,0,.08); cursor: pointer; display: none; align-items: center; justify-content: center; color: var(--label2); z-index: 1; transition: background .12s, color .12s; }
.detail-collapse-btn:hover { background: var(--fill2); color: var(--label); }
.detail-collapse-btn svg { width: 14px; height: 14px; }
.detail-panel.open .detail-collapse-btn { display: flex; }
.modal-close-row { display: none; }
.detail-scroll { overflow-y: auto; flex: 1; padding: 1.5rem; overscroll-behavior: contain; }
.detail-block  { margin-top: 1.25rem; }

.detail-img { border-radius: 12px; overflow: hidden; height: 190px; background: #c4c4c8; position: relative; margin-bottom: 1rem; }
.detail-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .3s; opacity: 0; }
.detail-img img.loaded { opacity: 1; }
.detail-title    { font-size: 1.05rem; font-weight: 700; letter-spacing: -.3px; line-height: 1.3; margin-bottom: .25rem; }
.detail-title + .detail-block { margin-top: 0; }
.detail-meta-row { display: flex; align-items: flex-start; gap: .45rem; font-size: .82rem; color: var(--label2); margin-bottom: .3rem; }
.detail-meta-row svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 2px; opacity: .5; }
.detail-desc     { font-size: .82rem; color: var(--label); line-height: 1.55; }

.hours-status-row { display: flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 500; margin-bottom: .75rem; padding: .5rem .65rem; border-radius: 8px; background: var(--fill2); }
.hours-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hours-list { display: flex; flex-direction: column; }
.hours-row  { display: flex; justify-content: space-between; padding: .45rem 0; font-size: .82rem; color: var(--label2); border-bottom: 1px solid var(--border); }
.hours-row:last-child { border-bottom: none; }
.hours-row.today { color: var(--label); font-weight: 600; }

.detail-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 0; }
.det-act-btn { flex: 1; min-width: 70px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: .5rem .4rem; border-radius: 8px; border: none; cursor: pointer; font-size: .75rem; font-weight: 600; font-family: inherit; background: var(--fill2); color: var(--label2); transition: all .12s; }
.det-act-btn:hover      { background: var(--fill); color: var(--label); }
.det-act-btn svg        { width: 12px; height: 12px; }
.det-act-btn.a-ts       { background: var(--blue);   color: #fff; }
.det-act-btn.a-fav      { background: var(--pink);   color: #fff; }
.det-act-btn.a-seen     { background: var(--green);  color: #fff; }
.det-act-btn.a-hid      { background: var(--orange); color: #fff; }
.det-act-btn.a-ts svg, .det-act-btn.a-fav svg { fill: currentColor; }
.det-act-btn.a-seen svg, .det-act-btn.a-hid svg { fill: none; stroke: currentColor; }

/* ══════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════ */
.modal-backdrop { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); align-items: center; justify-content: center; flex-direction: column; gap: .75rem; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: 20px; padding: 1.5rem; width: 100%; max-width: 440px; box-shadow: var(--shadow-modal); animation: modal-in .22s cubic-bezier(.32,.72,0,1); }
@keyframes modal-in { from { opacity: 0; transform: scale(.96) translateY(10px); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-title  { font-size: 1.05rem; font-weight: 700; }
.modal-close  { width: 30px; height: 30px; border-radius: 99px; background: var(--fill); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: .8rem; color: var(--label2); }
.modal-close:hover { background: var(--fill2); }

/* ══════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .52rem 1rem; border-radius: 10px; border: none; font-size: .875rem; font-weight: 600; font-family: inherit; cursor: pointer; transition: opacity .12s, background .12s; }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary                      { background: var(--label); color: var(--surface); }
.btn-primary:hover:not(:disabled) { opacity: .85; }
.btn-ghost                        { background: var(--fill2); color: var(--label2); }
.btn-ghost:hover:not(:disabled)   { background: var(--fill);  color: var(--label); }
.btn-sm   { padding: .38rem .75rem; font-size: .8rem; }
.btn-full { width: 100%; padding: .75rem; margin-top: .5rem; }
.btn-danger                      { color: var(--danger); background: rgba(255,59,48,.08); }
.btn-danger:hover:not(:disabled) { background: rgba(255,59,48,.14); }

/* ══════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: .3rem; padding: .65rem 0; }
.field label  { font-size: .78rem; font-weight: 600; color: var(--label2); }
.field input  { background: var(--fill2); border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; font-size: .875rem; font-family: inherit; color: var(--label); outline: none; transition: border-color .15s, background .15s; }
.field input:focus   { border-color: rgba(60,60,67,.3); background: var(--surface); }
.field input.valid   { border-color: var(--green); }
.field input.invalid { border-color: var(--danger); }
.field-hint  { font-size: .72rem; color: var(--label3); }
.field-avail { font-size: .72rem; display: flex; align-items: center; gap: 4px; }

.flash { padding: .7rem 1rem; border-radius: 10px; font-size: .875rem; font-weight: 500; margin-bottom: 1rem; }
.flash.error   { background: rgba(255,59,48,.1);  color: var(--danger); }
.flash.success { background: rgba(52,199,89,.12); color: #1a7a34; }

/* ══════════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════════ */
#login-screen { position: fixed; inset: 0; z-index: 500; background: var(--bg); display: none; align-items: center; justify-content: center; padding: 1.5rem; }
#login-screen.open { display: flex; }
.login-box { background: var(--surface); border-radius: 20px; padding: 2.25rem 2rem; width: 100%; max-width: 360px; box-shadow: var(--shadow-modal); overflow: visible; }
.login-sub { font-size: .875rem; color: var(--label2); margin-bottom: 1.75rem; }

/* ══════════════════════════════════════════════════
   EMPTY / SPINNER
   ══════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--label2); grid-column: 1/-1; }
.empty-icon  { font-size: 2.2rem; margin-bottom: .65rem; }
.empty-icon img { width: 56px; height: 56px; opacity: .35; }
@media (prefers-color-scheme: dark) { .empty-icon img { filter: invert(1); } }

.spinner-wrap { display: flex; align-items: center; justify-content: center; padding: 4rem; grid-column: 1/-1; }
.spinner { width: 26px; height: 26px; border: 2.5px solid var(--border); border-top-color: var(--label); border-radius: 50%; animation: spin .65s linear infinite; }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ══════════════════════════════════════════════════
   USER AREA
   ══════════════════════════════════════════════════ */
.user-area { display: flex; flex-direction: column; gap: .35rem; }
.user-info-card { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; background: var(--fill2); border-radius: 12px; }
.user-avatar { display: none; }
.user-name  { font-weight: 700; font-size: .875rem; color: var(--label); }
.user-email { font-size: .72rem; color: var(--label2); }
.icon-btn { width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--fill); color: var(--label2); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover        { background: var(--fill2); color: var(--label); }
.icon-btn-danger:hover { background: rgba(255,59,48,.12); color: var(--danger); }

/* ══════════════════════════════════════════════════
   SETTINGS POPOVER
   ══════════════════════════════════════════════════ */

@keyframes popover-in { from { opacity: 0; transform: scale(.95) translateY(6px); } to { opacity: 1; transform: none; } }
.settings-section { padding: .9rem 0; }
.settings-section:last-child { padding-bottom: 0; }
.settings-label { font-size: .75rem; font-weight: 600; color: var(--label2); text-transform: uppercase; letter-spacing: .04em; }
.settings-danger-zone { margin-top: .25rem; }

#detail-backdrop { display: none; }

/* ══════════════════════════════════════════════════
   RESPONSIVE — ≤768px
   ══════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .user-avatar { display: flex; }

    .layout { height: 100dvh; }
    .main { padding: calc(var(--topbar-h) + .75rem) 1rem calc(50px + env(safe-area-inset-bottom, 0px) + 5.5rem); width: 100%; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: none; -webkit-overflow-scrolling: touch; }
    .page-header { margin-bottom: .75rem; height: auto; }
    .page-header h1 { font-size: 1.3rem; }
    .cards-grid { grid-template-columns: 1fr; gap: .75rem; max-width: 100%; }
    .elem-card:hover { transform: translateZ(0); box-shadow: var(--shadow); }

    /* Mobile : on cache le detail-panel desktop, on utilise #modal-detail (modal-backdrop) */
    .detail-panel { display: none !important; width: 0 !important; overflow: hidden !important; }
    #modal-detail .modal { max-height: calc(var(--real-vh,100vh) - var(--topbar-h) - var(--bottombar-h) - 4rem - env(safe-area-inset-bottom,0px)); overflow-y: auto; }
    #modal-detail .detail-img { border-radius: 12px; margin: 0 0 1rem 0; height: 190px; position: relative; }

    .modal-close-row { display: flex; justify-content: flex-end; width: 100%; max-width: 440px; flex-shrink: 0; pointer-events: none; }
    .modal-close-row .btn { pointer-events: none; background: rgba(255,255,255,.18); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.25); font-weight: 600; }
    .modal-backdrop.open .modal-close-row .btn { pointer-events: auto; }

    .modal-backdrop { justify-content: flex-start !important; padding: 2rem 1.5rem 1.5rem !important; z-index: 450 !important; }
    .detail-actions { display: grid !important; grid-template-columns: 1fr 1fr; }
    .detail-actions:has(> :nth-child(3):last-child) { display: flex !important; }


    #settings-logout { display: block !important; }

    /* Map ouverte : cacher bottombar, afficher bouton fermer dans topbar */
    body.map-open .mob-bottombar { display: none !important; }
    body.map-open .mob-topbar-nav { display: none !important; }
    body.map-open .mob-topbar-map-close { display: flex !important; }
}



/* ══════════════════════════════════════════════════
   TOP BAR mobile
   ══════════════════════════════════════════════════ */
.mob-topbar { display: none; }

@media (max-width: 768px) {
    .mob-topbar { display: flex; align-items: center; justify-content: space-between; position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 370; background: var(--bg); padding: 0 1rem; box-shadow: 0 1px 8px rgba(0,0,0,.06); }
    .mob-topbar-logo { display: flex; align-items: center; }
    .mob-topbar-nav  { display: flex; align-items: center; gap: 2px; }

    .mob-nav-btn { position: relative; width: 36px; height: 36px; border-radius: 10px; border: none; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--label3); transition: background .12s, color .12s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
    .mob-nav-btn svg    { width: 18px; height: 18px; }
    .mob-nav-btn:hover  { background: var(--fill2); color: var(--label); }
    .mob-nav-btn.active { background: var(--fill);  color: var(--label); }

    .mob-nav-badge { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); display: none; pointer-events: none; }
    .mob-nav-btn.has-badge .mob-nav-badge { display: block; }

    .mob-topbar-account { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
    .mob-account-btn { width: 30px; height: 30px; border-radius: 50%; background: var(--fill); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--label2); font-size: .8rem; font-weight: 700; transition: background .12s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
    .mob-account-btn:hover { background: var(--fill2); }
    .mob-account-btn svg { width: 16px; height: 16px; }
}

/* ══════════════════════════════════════════════════
   BOTTOM BAR mobile
   ══════════════════════════════════════════════════ */
.mob-bottombar { display: none !important; }

@media (max-width: 768px) {
    .mob-bottombar { display: flex !important; align-items: center; position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 2rem); left: 2rem; right: 2rem; z-index: 350; gap: .6rem; background: none; box-shadow: none; height: auto; padding: 0; }

    .mob-search-pill { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; height: 50px; background: rgba(0,0,0,.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-radius: 99px; box-shadow: 0 8px 32px rgba(0,0,0,.25); padding-left: .85rem; padding-right: .5rem; }
    .mob-search-pill svg { flex-shrink: 0; width: 14px; height: 14px; opacity: .5; color: #fff; pointer-events: none; margin-right: .4rem; }
    .mob-search-pill .search-input { flex: 1; min-width: 0; background: transparent; border: none; color: #fff; padding: 0; font-size: 16px; outline: none; line-height: 1; }
    .mob-search-pill .search-input::placeholder { color: rgba(255,255,255,.45); }

    .mob-search-clear { position: static; transform: none; flex-shrink: 0; background: transparent; width: 28px; height: 28px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
    .mob-search-clear .icon-clear { width: 16px; height: 16px; background-color: rgba(255,255,255,.65); }

    .mob-bar-btn { flex-shrink: 0; position: relative; display: flex; align-items: center; justify-content: center; width: 50px; height: 50px; border-radius: 50%; border: none; background: rgba(0,0,0,.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 8px 32px rgba(0,0,0,.25); color: #fff; cursor: pointer; transition: opacity .12s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; padding: 0; overflow: visible; }
    .mob-bar-btn svg    { width: 17px; height: 17px; flex-shrink: 0; position: relative; z-index: 1; transition: opacity .15s, transform .2s cubic-bezier(.32,.72,0,1); }
    .mob-bar-btn:active { opacity: .7; }
    .mob-bar-btn.active { background: #fff; color: #000; }
    #mob-filter-btn.sheet-open { background: #fff; color: #000; }

    .mob-bar-cross { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-45deg) scale(.7); opacity: 0; transition: opacity .15s, transform .2s cubic-bezier(.32,.72,0,1); pointer-events: none; width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; }
    .mob-bar-cross svg { width: 17px; height: 17px; stroke: #000; transition: none; transform: none; opacity: 1; }

    .mob-bar-btn.active > svg, .mob-bar-btn.sheet-open > svg { opacity: 0; transform: rotate(45deg) scale(.7); }
    .mob-bar-btn.sheet-open .mob-bar-cross { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    #mob-map-btn.active .mob-bar-cross     { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    .mob-bar-btn.active:not(.sheet-open) > svg     { opacity: 1; transform: none; }
    .mob-bar-btn.active:not(.sheet-open) .mob-bar-cross { opacity: 0; transform: translate(-50%, -50%) rotate(-45deg) scale(.7); }
    #mob-map-btn.active > svg         { opacity: 0; transform: rotate(45deg) scale(.7); }
    #mob-map-btn.active .mob-bar-cross svg { stroke: #000; }

    .mob-filter-count { display: none; position: absolute; top: -3px; right: -3px; background: var(--danger); color: #fff; font-size: .6rem; font-weight: 800; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; line-height: 16px; text-align: center; pointer-events: none; }
    #mob-filter-btn.active .mob-filter-count { display: block; }
}

/* ══════════════════════════════════════════════════
   SEARCH OVERLAY mobile
   ══════════════════════════════════════════════════ */
#search-overlay { display: none; position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0; z-index: 200; background: var(--bg); flex-direction: column; overflow: hidden; }
#search-overlay.open { display: flex; }

.so-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 1rem 1rem calc(50px + env(safe-area-inset-bottom, 0px) + 3.5rem); }
.so-header { display: flex; align-items: baseline; gap: .6rem; margin-bottom: 1rem; }
.so-title  { font-size: 1.3rem; font-weight: 700; letter-spacing: -.5px; }
.so-count  { font-size: .85rem; color: var(--label2); }
.so-empty  { display: flex; flex-direction: column; align-items: center; gap: .75rem; padding: 4rem 2rem; text-align: center; color: var(--label2); font-size: .9rem; }
.so-empty .empty-icon { font-size: 2.5rem; }




/* ══════════════════════════════════════════════════
   FILTER BOTTOM SHEET
   ══════════════════════════════════════════════════ */
#filter-sheet-backdrop { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.25); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); transition: opacity .32s cubic-bezier(.32,.72,0,1); }
#filter-sheet-backdrop.open { display: block; }

#filter-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 310; background: var(--surface2); border-radius: 20px 20px 0 0; border-top: 1px solid var(--border); padding: 0 1rem calc(env(safe-area-inset-bottom,0px) + 7rem) 1rem; transform: translateY(100%); transition: transform .32s cubic-bezier(.32,.72,0,1); box-shadow: 0 -4px 32px rgba(0,0,0,.10); }
#filter-sheet.open { transform: translateY(0); }

@media (prefers-color-scheme: light) { #filter-sheet { background: #e5e5ea; } }

.sheet-handle { display: none; }
.sheet-title  { display: none; }
.sheet-toggle { display: none; }

.sheet-filters { display: flex; flex-direction: column; gap: .5rem; padding-top: .85rem; }

.sheet-filter-row { display: flex; align-items: center; gap: .65rem; padding: .6rem .9rem; border-radius: 12px; background: rgba(120,120,128,.06); border: 1.75px solid transparent; -webkit-tap-highlight-color: transparent; transition: background .15s, border-color .15s; cursor: pointer; width: 100%; font-family: inherit; text-align: left; }
.sheet-filter-row:active   { background: rgba(120,120,128,.2); }
.sheet-filter-row.on       { background: rgba(120,120,128,.06); border-color: var(--border); }
.sheet-filter-row.disabled { opacity: .35; pointer-events: none; }

@media (prefers-color-scheme: light) {
    .sheet-filter-row:not(.on) { background: rgba(120,120,128,.14); border-color: transparent; }
    .sheet-filter-row.on       { background: transparent; border-color: rgba(0,0,0,.8); }
}
@media (prefers-color-scheme: dark) {
    .sheet-filter-row         { background: rgba(120,120,128,.16); }
    .sheet-filter-row.on      { background: transparent; border-color: rgba(255,255,255,.6); }
}

.sheet-filter-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sheet-filter-icon svg { width: 17px; height: 17px; stroke: var(--label2); fill: none; stroke-width: 2; }
.sheet-filter-label { flex: 1; font-size: .95rem; font-weight: 500; color: var(--label); line-height: 1.2; }
.sheet-filter-check { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; }
.sheet-filter-check svg { width: 16px; height: 16px; stroke: var(--label); fill: none; stroke-width: 2.5; }
.sheet-filter-row.on .sheet-filter-check { opacity: 1; }

/* ── Classes utilitaires (remplace styles inline JS) ───────────────────── */
.det-act-btn-hide  { width: 100%; margin-top: 0; margin-bottom: 0; }
.det-act-btn-share { width: 100%; margin-top: 0; color: var(--label2); }
.det-act-btn-share svg { stroke: var(--label2); }
.detail-block-actions, #mh-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.detail-block-actions > *, #mh-actions > * { flex: 1; text-decoration: none; }
.btn-field-action     { margin-top: .5rem; }
.btn-danger           { color: var(--danger); }
.btn-full-center      { width: 100%; justify-content: center; }
.field-mt             { margin-top: .35rem; }
.flash-mb             { margin-bottom: 1rem; }
.sidebar-user-info    { flex: 1; min-width: 0; }
.sidebar-user-actions { display: flex; gap: .25rem; flex-shrink: 0; }
.link-blue            { color: var(--blue); }
.no-info-text         { font-size: .875rem; color: var(--label2); }
.avail-ok             { color: var(--green); }
.avail-ko             { color: var(--danger); }

/* ── Anti-zoom iOS mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px !important; }
  a, button, [role="button"], label, select, input, textarea { touch-action: manipulation; }
}

/* ══════════════════════════════════════════════════
   SHARE POPOVER
   ══════════════════════════════════════════════════ */
.share-popover {
  position: absolute;
  z-index: 900;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  padding: .75rem;
  width: 300px;
  animation: modal-in .15s cubic-bezier(.32,.72,0,1);
}
.share-popover-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--label3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .5rem;
}
.share-popover-row {
  display: flex;
  gap: .4rem;
  align-items: center;
}
.share-popover-input {
  flex: 1;
  min-width: 0;
  background: var(--fill2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .38rem .6rem;
  font-size: .78rem;
  font-family: inherit;
  color: var(--label2);
  outline: none;
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-popover-copy {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  flex-shrink: 0;
  padding: .38rem .7rem;
  border-radius: 8px;
  border: none;
  background: var(--label);
  color: var(--surface);
  font-size: .8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .12s;
  white-space: nowrap;
}
.share-popover-copy svg { width: 13px; height: 13px; flex-shrink: 0; stroke: var(--surface); }
.share-popover-copy:hover { opacity: .85; }
.share-popover-copy.copied { background: var(--green); }