:root {
    --bg: #f5f1ea;
    --surface: rgba(255, 253, 249, 0.97);
    --surface-2: #efe9df;
    --text: #0d2b35;
    --muted: #6b7778;
    --border: #dcd3c5;
    --accent: #1c7e8f;
    --accent-soft: rgba(28, 126, 143, 0.12);
    --origin: #0d2b35;
    --seasonal: #ef9155;
    --seasonal-soft: rgba(239, 145, 85, 0.18);
    --old: #a7a29a;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%230d2b35' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --shadow: 0 10px 30px -12px rgba(13, 43, 53, 0.35);
    --radius: 10px;
    --panel-w: 400px;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
#map { position: absolute; inset: 0; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }

/* ---------- Barre du haut ---------- */
.topbar {
    position: absolute; top: 12px; left: 12px; right: 12px; z-index: 3;
    display: flex; gap: 10px; align-items: center; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand, .search input {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); height: 44px;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 14px; font-weight: 650; white-space: nowrap; }
.brand svg { width: 20px; height: 20px; fill: var(--accent); }
.search { position: relative; flex: 0 1 380px; min-width: 0; }
.search input {
    width: 100%; padding: 0 14px; font-size: 15px; color: var(--text); outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
#search-results {
    position: absolute; top: 50px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); max-height: 60vh; overflow-y: auto;
}
#search-results li {
    display: grid; grid-template-columns: 48px 1fr auto; gap: 8px; align-items: center;
    padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
#search-results li[aria-selected="true"], #search-results li:hover { background: var(--accent-soft); }
#search-results .code { font-weight: 700; font-variant-numeric: tabular-nums; }
#search-results .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#search-results .name small { display: block; color: var(--muted); }
#search-results .count { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------- Panneau ---------- */
.panel {
    position: absolute; z-index: 2; top: 68px; left: 12px; max-height: calc(100% - 104px); width: var(--panel-w);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.panel[hidden] { display: none; }
#panel-body { overflow-y: auto; flex: 1; padding: 18px 18px 12px; }
.icon-btn {
    border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%;
    font-size: 20px; line-height: 1; cursor: pointer;
}
.panel-close { position: absolute; top: 12px; right: 12px; z-index: 1; }
.back-btn {
    border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; margin-bottom: 10px;
    font-size: 14px;
}

.ap-head { padding-right: 36px; }
.ap-code { font-size: 34px; font-weight: 750; letter-spacing: 0.5px; line-height: 1; }
.ap-code small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.ap-name { margin: 6px 0 2px; font-size: 16px; font-weight: 600; }
.ap-place { color: var(--muted); font-size: 14px; }
.page-link { display: inline-block; margin-top: 6px; font-size: 13px; text-decoration: none; }
.page-link:hover { text-decoration: underline; }
.stats { display: flex; gap: 8px; margin: 14px 0; }
.stat { flex: 1; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.note { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; }

.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.tools input, .tools select {
    height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px;
    background-color: var(--bg); color: var(--text); font: inherit; font-size: 14px; min-width: 0;
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.tools input:focus, .tools select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tools input:hover, .tools select:hover { border-color: var(--muted); }
/* Menus déroulants : flèche maison, texte tronqué proprement */
.tools select {
    appearance: none; -webkit-appearance: none; cursor: pointer;
    padding-right: 30px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
    background-image: var(--chevron); background-repeat: no-repeat;
    background-position: right 11px center; background-size: 10px 6px;
}
.tools select::-ms-expand { display: none; }

.dest-list { list-style: none; margin: 0; padding: 0; }
.dest {
    display: grid; grid-template-columns: 46px 1fr auto; gap: 4px 10px; align-items: baseline;
    padding: 10px 8px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.dest:hover, .dest.hover { background: var(--accent-soft); }
.dest .code { font-weight: 700; font-variant-numeric: tabular-nums; }
.dest .city { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest .km { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dest .airlines { grid-column: 2 / -1; color: var(--muted); font-size: 13px; line-height: 1.35; }
.empty { color: var(--muted); padding: 20px 4px; text-align: center; }

.route-head { display: flex; align-items: center; gap: 10px; font-size: 28px; font-weight: 750; padding-right: 36px; }
.route-head .arrow { color: var(--muted); font-weight: 400; }
.route-cities { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
.airline { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.airline-name { font-weight: 650; }
button.airline-name.link { border: 0; background: none; padding: 0; cursor: pointer; font-size: 15px; color: var(--text); text-align: left; }
button.airline-name.link:hover { color: var(--accent); text-decoration: underline; }
#search-results .code.cie { color: var(--accent); }
.airline-codes { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
.period-line { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 14px; }
.badge {
    font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.seasonal { background: var(--seasonal-soft); color: var(--seasonal); }
.badge.old { background: var(--surface-2); color: var(--muted); }
.badge.neutral { background: var(--surface-2); color: var(--text); }
.dest .tags { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.dest.old .code, .dest.old .city { color: var(--muted); }

.legend {
    position: absolute; z-index: 2; right: 56px; bottom: 30px; display: flex; gap: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    box-shadow: var(--shadow); padding: 7px 14px; font-size: 12px; color: var(--text);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sw { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--accent); border-radius: 2px; }
.sw.sea { border-color: var(--seasonal); }
.sw.old { border-top: 3px dashed var(--old); }
.src { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- Divers ---------- */
.hint, .loading {
    position: absolute; z-index: 2; left: 50%; transform: translateX(-50%); bottom: 44px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    box-shadow: var(--shadow); padding: 9px 16px; font-size: 14px; white-space: nowrap;
}
.hint[hidden], .loading[hidden] { display: none; }
.credits { position: absolute; z-index: 2; left: 12px; bottom: 8px; }
.link-btn { border: 0; background: none; padding: 0; font-size: inherit; color: inherit; cursor: pointer; }
.foot-links { display: flex; gap: 2px; align-items: center; background: var(--surface); border-radius: 6px; padding: 3px 4px; font-size: 12px; box-shadow: 0 1px 4px rgba(20, 30, 45, 0.12); }
.foot-links > * { color: var(--muted); text-decoration: none; padding: 0 5px; }
.foot-links > *:hover { color: var(--text); text-decoration: underline; }
.foot-links .lang { font-family: ui-monospace, Menlo, Consolas, monospace; border-left: 1px solid var(--border); }
dialog {
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text);
    max-width: 560px; width: calc(100% - 32px); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h2 { margin-top: 0; font-size: 18px; }
.hublot-logo { display: inline-block; margin: 2px 0 4px; }
.hublot-logo img { display: block; height: 34px; width: auto; }
dialog li { margin-bottom: 6px; font-size: 14px; }
.btn { border: 0; background: var(--accent); color: #fff; border-radius: 8px; padding: 8px 16px; cursor: pointer; }

.maplibregl-popup-content {
    background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px 10px;
    box-shadow: var(--shadow); font-size: 13px;
}
.maplibregl-popup-tip { display: none; }
.maplibregl-ctrl-group { background: var(--surface); }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* ---------- Mobile : panneau en bas ---------- */
@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; top: 8px; left: 8px; right: 8px; gap: 6px; }
    .brand { display: none; }
    .search { flex: 1 1 100%; }
    .panel {
        top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 55%;
        border-radius: var(--radius) var(--radius) 0 0;
    }
    .hint { bottom: 76px; white-space: normal; width: calc(100% - 32px); text-align: center; }
    .legend { left: 8px; right: auto; bottom: 30px; gap: 10px; padding: 6px 10px; }
    .panel:not([hidden]) ~ .legend { display: none; }
    .credits { bottom: 4px; left: 8px; }
    .panel:not([hidden]) ~ .credits { display: none; }
}

/* tour.voyage : marque, police des titres, lien « composer un circuit » */
@font-face { font-family: "Bricolage"; src: url("/fonts/bricolage.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter-var.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
.brand { text-decoration: none; color: var(--text); }
.brand img { height: 26px; width: auto; display: block; }
.brand span { font-family: "Bricolage", "Inter", sans-serif; font-weight: 650; }
.ap-code, .route-head { font-family: "Bricolage", "Inter", sans-serif; }
.plan-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; background: var(--text); color: #fffdf9; border-radius: 8px;
             padding: 8px 14px; font-weight: 600; font-size: 14px; text-decoration: none; }
.plan-link:hover { background: #163f4c; }
.plan-link span { color: #ef9155; }

/* offres sur une liaison */
.offers { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.offers h3 { font-size: 15px; margin: 0 0 6px; }
.offers-wait { color: var(--muted); font-size: 13px; }
.offers-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 2px; }
.offers-list li { display: grid; grid-template-columns: 92px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); align-items: start; }
.o-date { font-size: 12.5px; color: var(--muted); padding-top: 3px; }
.o-list { display: grid; gap: 4px; }
.o-item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; font-size: 13.5px; }
.o-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-price { font-variant-numeric: tabular-nums; }
.o-item.best .o-price { color: #b45518; }
.o-book { font-size: 12px; font-weight: 600; background: var(--text); color: #fffdf9; border-radius: 6px; padding: 3px 9px; text-decoration: none; }
.offers-more { margin-top: 8px; color: var(--accent); font-weight: 600; font-size: 13px; }

.o-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 8px 0 10px; }
.o-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--surface-2); }
.o-seg button { border: 0; background: none; border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.o-seg button[aria-pressed=true] { background: var(--text); color: #fffdf9; }
.o-stops { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.o-stops select { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 12.5px; padding: 3px 6px; color: var(--text); }
.o-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.o-dates label { display: grid; gap: 3px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.o-dates input { font: inherit; font-size: 14px; text-transform: none; letter-spacing: 0; border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px; color: var(--text); background: var(--surface); }
.o-leg { padding: 8px 0; border-bottom: 1px solid var(--border); }
.o-leg-head { margin: 0 0 5px; font-size: 13px; color: var(--muted); }
.o-leg-head b { color: var(--text); }
.o-near { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.o-near button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.o-near button:hover { border-color: var(--text); }
.o-total { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 4px; font-size: 14px; }
.o-total b { font-size: 18px; color: #b45518; }
