:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --text: #1f2328;
    --muted: #6a6f76;
    --border: #e2e0db;
    --accent: #1f6feb;
    --accent-text: #ffffff;
    --danger: #c62828;
    --ok-bg: #e7f5ea;
    --ok-text: #1b5e20;
    --err-bg: #fdecec;
    --err-text: #8e1c1c;
    --info-bg: #e8f0fd;
    --info-text: #17407e;
    --radius: 10px;
    color-scheme: light;
}

/* Dark: when the system asks for it (theme "Auto"), or when chosen explicitly. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #16181c;
        --surface: #1f2228;
        --text: #e6e6e6;
        --muted: #9aa0a6;
        --border: #30343b;
        --accent: #4c8dff;
        --ok-bg: #1d3323;
        --ok-text: #a5d6a7;
        --err-bg: #3a1d1d;
        --err-text: #f4a8a8;
        --info-bg: #1b2a44;
        --info-text: #a9c5f5;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #16181c;
    --surface: #1f2228;
    --text: #e6e6e6;
    --muted: #9aa0a6;
    --border: #30343b;
    --accent: #4c8dff;
    --ok-bg: #1d3323;
    --ok-text: #a5d6a7;
    --err-bg: #3a1d1d;
    --err-text: #f4a8a8;
    --info-bg: #1b2a44;
    --info-text: #a9c5f5;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }

.container { max-width: 760px; margin: 0 auto; padding: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Header */
.site-header {
    display: flex; flex-wrap: wrap; gap: .5rem 1rem;
    align-items: center; justify-content: space-between;
    padding: .75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.user-nav { display: flex; gap: 1rem; align-items: center; font-size: .95rem; }
.who { font-weight: 600; }

/* Cards & lists */
.card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: .75rem;
    color: inherit;
    text-decoration: none;
}
a.card:hover { border-color: var(--accent); }
.narrow { max-width: 440px; margin: 2rem auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; }
.grid .card { display: flex; flex-direction: column; }

.trip-list, .people, .days, .chips { list-style: none; padding: 0; margin: 0; }
.trip-card { display: flex; flex-direction: column; gap: .15rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips li { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .3rem .9rem; }
.person { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.person .row-form { flex: 1 1 260px; }
.day h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
.breadcrumb { margin: 0; font-size: .9rem; }
.description { white-space: normal; }

/* Trip header & tabs */
.trip-header h1 { margin-bottom: .1rem; }
.trip-header p { margin-top: 0; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab { padding: .5rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab.disabled { opacity: .45; cursor: default; }

/* Theme switch */
.theme-switch { display: flex; gap: 2px; margin-left: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.theme-switch button { background: none; color: var(--muted); font-weight: 400; font-size: .85rem; padding: .2rem .6rem; border-radius: 999px; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
@media (max-width: 520px) { .theme-name { display: none; } }

/* Forms */
.stack { display: flex; flex-direction: column; gap: .9rem; }
.row { display: flex; flex-wrap: wrap; gap: .9rem; }
.row > label { flex: 1 1 160px; }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.row-form > input { flex: 1 1 160px; width: auto; }
.grow { flex: 1 1 200px; }
.add-people { display: flex; flex-direction: column; gap: .4rem; }
.add-people .hint { margin: 0; }
.inline { display: inline; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
.hint { font-weight: 400; font-size: .85rem; color: var(--muted); }
input, textarea {
    font: inherit; color: inherit;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .55rem .7rem;
    width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
legend { font-weight: 600; padding: 0 .3rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.check { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; }
.check input { width: auto; }

button, .button {
    font: inherit; font-weight: 600;
    display: inline-block;
    background: var(--accent); color: var(--accent-text);
    border: 0; border-radius: 8px;
    padding: .6rem 1.1rem;
    cursor: pointer;
    text-decoration: none;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.danger { background: var(--danger); }
button.small { padding: .3rem .7rem; font-size: .85rem; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; text-decoration: underline; }

.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; margin: 1rem 0; }
.name-grid button { padding: .9rem; font-size: 1.05rem; }

.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; }
.danger-zone form { margin-top: 1rem; }

/* Messages */
.flash { padding: .7rem 1rem; border-radius: 8px; margin: 0 0 1rem; }
.flash ul { margin: 0; padding-left: 1.2rem; }
.flash-success { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

pre.cmd {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: .6rem .8rem; overflow-x: auto; font-size: .85rem;
}

/* Transports */
select {
    font: inherit; color: inherit;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .55rem .7rem;
}
.transport-group h2 { margin-top: 1.25rem; }
.transport { display: flex; flex-direction: column; gap: .5rem; }
.transport.mine { border-left: 4px solid var(--accent); }
.transport-main { display: flex; gap: .75rem; align-items: flex-start; }
.transport-icon { font-size: 1.4rem; line-height: 1.2; width: 1.8rem; text-align: center; }
.transport .chips li { padding: .1rem .6rem; }
.transport .notes { margin: 0; }
.transport-footer { display: flex; gap: 1rem; align-items: center; justify-content: flex-end; }
.badge { background: var(--info-bg); color: var(--info-text); border-radius: 999px; padding: .1rem .6rem; margin-right: auto; }
.row-actions { display: flex; gap: 1rem; align-items: center; }
.leg-block h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.transport-lines { list-style: none; padding: 0; margin: .3rem 0 0; display: flex; flex-direction: column; gap: .35rem; }
.transport-line { display: flex; gap: .5rem; align-items: baseline; font-size: .95rem; }
.transport-line .transport-icon { font-size: 1.05rem; width: 1.4rem; }
.transport-line.mine strong { color: var(--accent); }
.people-legs { list-style: none; padding: 0; margin: 0; }
.people-legs h2 { margin: 0 0 .5rem; font-size: 1.05rem; display: flex; gap: .5rem; align-items: center; }
.people-legs .badge { margin-right: 0; font-size: .8rem; font-weight: 400; }
.leg-row { display: grid; grid-template-columns: 4.5rem 1fr; gap: .5rem; align-items: baseline; padding: .2rem 0; }
.leg-label { font-size: .85rem; color: var(--muted); }
.leg-row .transport-lines { margin: 0; }
.kind { display: inline-block; font-size: .75rem; border-radius: 999px; padding: 0 .5rem; margin-left: .4rem; vertical-align: middle; border: 1px solid var(--border); color: var(--muted); }
.kind-groupe { background: var(--info-bg); color: var(--info-text); border-color: transparent; }
.nights { margin-top: .5rem; padding-top: .4rem; border-top: 1px dashed var(--border); }

/* Checklists */
.checklist-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.checklist h2 { margin: 0; font-size: 1.1rem; }
.check-list { list-style: none; padding: 0; margin: .5rem 0; }
.check-list li { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); }
.check-list li:last-child { border-bottom: 0; }
.grow-form { flex: 1; }
.check-item {
    display: flex; align-items: center; gap: .65rem; width: 100%;
    background: none; color: var(--text); font-weight: 400; text-align: left;
    padding: .55rem .2rem; border-radius: 0;
}
.check-item.static { padding-left: .2rem; }
.check-item .box {
    flex: none; width: 1.25rem; height: 1.25rem; border: 2px solid var(--muted); border-radius: 5px;
    display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700;
}
.check-item[aria-pressed="true"] .box { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.check-item[aria-pressed="true"] .label { color: var(--muted); text-decoration: line-through; }
.add-items { margin-top: .75rem; }
.table-wrap { overflow-x: auto; padding: 0; }
.followup { border-collapse: collapse; width: 100%; font-size: .9rem; }
.followup th, .followup td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.followup th[scope="row"] { text-align: left; white-space: normal; min-width: 10rem; }
.followup td.yes { color: var(--ok-text); background: var(--ok-bg); font-weight: 700; }
.followup td.no { color: var(--muted); }
.followup .total { color: var(--muted); font-size: .85rem; }

/* Place fields with suggestions */
.place-field { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
.row > .place-field { flex: 1 1 200px; }
.place-wrap { position: relative; }
.place-wrap input { padding-right: 2.2rem; }
.place-pin { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); filter: grayscale(1); opacity: .35; font-size: .95rem; }
.place-pin.located { filter: none; opacity: 1; }
.place-suggestions {
    position: absolute; z-index: 1000; left: 0; right: 0; top: calc(100% + 2px);
    list-style: none; margin: 0; padding: .25rem 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .15); max-height: 16rem; overflow-y: auto;
}
.place-suggestions li { padding: .5rem .75rem; cursor: pointer; font-weight: 400; font-size: .92rem; }
.place-suggestions li:hover, .place-suggestions li.active { background: var(--info-bg); color: var(--info-text); }

/* Maps */
.map { height: 340px; padding: 0; overflow: hidden; z-index: 0; }
#carte { scroll-margin-top: 1rem; }
.map-pin { display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1;
    background: var(--surface); border: 2px solid var(--accent); border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.map-pin-stay { border-color: #8e44ad; }
.map-pin-retour { border-color: #e67e22; }
.map-pin-sur_place { border-color: #2e9d57; }
.route { stroke: var(--accent); stroke-dasharray: 6 6; }
.route-start { stroke: var(--accent); fill: var(--surface); fill-opacity: 1; }
.route.route-retour, .route-start.route-retour { stroke: #e67e22; }
.route.route-sur_place, .route-start.route-sur_place { stroke: #2e9d57; }
.leaflet-container { font: inherit; background: var(--bg); }
.leaflet-popup-content { font-size: .9rem; line-height: 1.4; }
.map-legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; color: var(--muted); }
.map-legend li { display: flex; align-items: center; gap: .4rem; }
.legend-line { display: inline-block; width: 22px; border-top: 3px dashed var(--accent); }
.legend-line.route-retour { border-color: #e67e22; }
.legend-line.route-sur_place { border-color: #2e9d57; }
.small-title { font-size: 1rem; margin: 0 0 .5rem; }
.missing-places { padding-left: 1.1rem; }
/* Darker map tiles with the dark theme */
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.75) invert(1) hue-rotate(180deg) saturate(.6); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .leaflet-tile-pane { filter: brightness(.75) invert(1) hue-rotate(180deg) saturate(.6); }
}

/* Suggestions */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.filter { text-decoration: none; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: .25rem .8rem; font-size: .9rem; }
.filter.active { color: var(--text); border-color: var(--accent); background: var(--surface); font-weight: 600; }
.filter .count { color: var(--muted); font-weight: 400; margin-left: .2rem; }
.suggestion { display: flex; flex-direction: column; gap: .45rem; scroll-margin-top: 1rem; }
.suggestion.status-refusee { opacity: .7; }
.suggestion-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.suggestion h3 { margin: 0; font-size: 1.05rem; }
.suggestion p { margin: 0; }
.planned { font-weight: 600; font-size: .95rem; }
.status-badge { font-size: .75rem; border-radius: 999px; padding: .1rem .6rem; white-space: nowrap; border: 1px solid var(--border); color: var(--muted); }
.status-badge.status-approuvee { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.status-badge.status-refusee { background: var(--err-bg); color: var(--err-text); border-color: transparent; }
.votes { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.vote { display: inline-flex; align-items: center; gap: .3rem; background: var(--bg); color: var(--text); border: 1px solid var(--border);
    border-radius: 999px; padding: .25rem .75rem; font-weight: 400; font-size: .9rem; }
.vote.static { cursor: default; }
.vote-for[aria-pressed="true"] { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-text); }
.vote-against[aria-pressed="true"] { background: var(--err-bg); color: var(--err-text); border-color: var(--err-text); }
.voters { display: flex; flex-direction: column; }
.by { margin-right: auto; }
@media (max-width: 520px) { .vote-label { display: none; } }
.map-pin-activity { border-color: #d35400; }
.map-pin-proposee { opacity: .75; border-style: dashed; }
.admin-panel { display: flex; flex-direction: column; gap: .5rem; padding: .6rem .7rem; border: 1px dashed var(--border); border-radius: 8px; background: var(--bg); }
.admin-panel .decide { display: flex; flex-wrap: wrap; gap: .4rem; }
.admin-panel .schedule { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.admin-panel .schedule label { flex: 0 1 auto; }
.admin-panel input[type="date"], .admin-panel input[type="time"] { width: auto; padding: .35rem .5rem; }
.activity-line a { color: inherit; text-decoration-color: var(--border); }
