:root {
    --bg: #f4f1ec;
    --card: #ffffff;
    --ink: #1f2a2e;
    --muted: #6b7378;
    --line: #e4ded5;
    --accent: #2f5d50;
    --accent-ink: #ffffff;
    --today: #fff4d6;
    --radius: 12px;
    --lane-h: 28px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.4;
}
a { color: var(--accent); }
h1, h2 { margin: 0 0 .5em; }
h2 { font-size: 1.25rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }
.container.narrow { max-width: 720px; padding-top: 24px; }
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ---------- En-tête ---------- */
.hero {
    color: #fff;
    text-align: center;
    padding: 48px 16px 64px;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 200' preserveAspectRatio='none'%3E%3Cpath d='M0 200 L0 130 L180 40 L300 110 L460 10 L640 120 L780 60 L950 140 L1080 70 L1200 120 L1200 200Z' fill='%23f4f1ec'/%3E%3C/svg%3E") bottom / 100% 70px no-repeat,
        linear-gradient(160deg, #1d3b4a 0%, #2f5d50 60%, #4b7a5e 100%);
}
.hero.has-photo {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 200' preserveAspectRatio='none'%3E%3Cpath d='M0 200 L0 130 L180 40 L300 110 L460 10 L640 120 L780 60 L950 140 L1080 70 L1200 120 L1200 200Z' fill='%23f4f1ec'/%3E%3C/svg%3E") bottom / 100% 70px no-repeat,
        linear-gradient(rgba(0,0,0,.35), rgba(0,0,0,.45)),
        url("mayen.jpg") center / cover;
}
.hero h1 { font-size: 2.6rem; letter-spacing: .02em; text-shadow: 0 2px 8px rgba(0,0,0,.3); }
.status {
    display: inline-block;
    background: rgba(255,255,255,.95);
    color: var(--ink);
    padding: 14px 22px;
    border-radius: var(--radius);
    font-size: 1.15rem;
    margin: 8px 0 20px;
    min-width: 280px;
}
.status small { display: block; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.status.free > div:first-child { color: #15803d; font-weight: 600; }
.status.busy div + div { margin-top: 6px; }

/* ---------- Boutons ---------- */
.btn {
    font: inherit;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.btn:hover { background: #f7f5f1; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #264d42; }
.btn-lg { font-size: 1.1rem; padding: 12px 24px; }
.btn-ghost { background: transparent; }
.btn-danger { color: #b91c1c; border-color: #f3c6c6; }
.btn-danger:hover { background: #fdecec; }
.spacer { flex: 1; }
.btn[hidden] { display: none; }
.hero .btn-primary { display: block; margin: 0 auto; background: #e07a2f; border-color: #e07a2f; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.hero .btn-primary:hover { background: #c9661f; }

/* ---------- Calendrier ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-toolbar h2 { margin: 0; min-width: 200px; text-align: center; text-transform: capitalize; font-size: 1.5rem; }
.cal-toolbar h1 { margin: 0; }
.cal-toolbar .btn { font-size: 1.1rem; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 14px 0; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 4px; }

.cal-head, .days, .bars { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head div { text-align: center; font-weight: 600; color: var(--muted); padding: 6px 0; font-size: .9rem; }

.calendar { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.week { position: relative; min-height: calc(36px + var(--lanes, 1) * (var(--lane-h) + 4px) + 10px); }
.days { position: absolute; inset: 0; }
.day {
    font: inherit;
    border: 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fff;
    text-align: right;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
}
.day:hover { background: #f3f8f5; }
.day.weekend { background: #fbfaf7; }
.day.other .num { color: #c3bdb3; }
.day.today { background: var(--today); }
.day.today .num {
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
}
.num { font-weight: 600; font-size: .95rem; }

.bars {
    position: relative;
    padding-top: 38px;
    grid-auto-rows: var(--lane-h);
    row-gap: 4px;
    pointer-events: none;
}
.bar {
    pointer-events: auto;
    font: inherit;
    font-size: .9rem;
    border: 0;
    margin: 0 4px;
    padding: 0 10px;
    border-radius: 6px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.bar:hover { filter: brightness(1.08); }
.bar.cont-left { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.cont-right { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }

.hint { color: var(--muted); font-size: .9rem; margin: 12px 0 0; }

/* ---------- Prochaines montées ---------- */
.upcoming { list-style: none; padding: 0; margin: 0; }
.upcoming li {
    border-left: 6px solid;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: #faf8f4;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
}
.upcoming li:hover { background: #f2efe8; }
.upcoming li em { color: var(--muted); font-style: normal; font-size: .9rem; margin-left: 6px; }
.upcoming li.empty { border-left-color: var(--line); color: var(--muted); cursor: default; }
.upcoming .note { color: var(--muted); font-size: .9rem; margin-top: 2px; }

.footer { text-align: center; margin-top: 30px; font-size: .9rem; }
.footer a { color: var(--muted); }

/* ---------- Fenêtre ---------- */
.modal {
    position: fixed; inset: 0;
    background: rgba(20, 30, 30, .5);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    z-index: 10;
}
.modal[hidden] { display: none; }
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
input[type=text], input[type=date], input[type=password] {
    font: inherit;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.duration { color: var(--muted); margin-top: 6px; font-size: .9rem; }
.modal-actions { display: flex; gap: 8px; margin-top: 22px; align-items: center; }

.person-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip { margin: 0; cursor: pointer; }
.chip span {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    border: 2px solid var(--c);
    color: var(--ink);
    font-weight: 600;
}
.chip input:checked + span { background: var(--c); color: var(--t); }
.chip input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

.conflict { background: #fff7e0; border: 1px solid #f2d27a; padding: 10px 12px; border-radius: 8px; margin-top: 14px; font-size: .95rem; }
.form-error { background: #fdecec; color: #b91c1c; padding: 10px 12px; border-radius: 8px; margin-top: 14px; }
.form-error[hidden], .conflict[hidden] { display: none; }

/* ---------- Admin ---------- */
.person-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.person-row input[type=text] { flex: 1; min-width: 140px; width: auto; }
.person-row input[type=color] { width: 48px; height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; cursor: pointer; background: #fff; }
.person-row small { color: var(--muted); min-width: 70px; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    :root { --lane-h: 24px; }
    .hero { padding: 32px 12px 56px; }
    .hero h1 { font-size: 2rem; }
    .status { min-width: 0; width: 100%; font-size: 1rem; }
    .card { padding: 14px 10px; }
    .cal-toolbar h2 { font-size: 1.2rem; min-width: 0; flex: 1; }
    .bar { font-size: .75rem; padding: 0 5px; margin: 0 2px; }
    .day { padding: 4px; }
    .num { font-size: .8rem; }
    .cal-head div { font-size: .75rem; }
}
