:root {
    --color-primary: #2f6f4f;
    --color-primary-dark: #234f38;
    --color-yes: #2f9e5c;
    --color-yes-bg: #e6f6ec;
    --color-maybe: #b8860b;
    --color-maybe-bg: #fdf3d9;
    --color-no: #c0392b;
    --color-no-bg: #fbe7e4;
    --color-text: #22282b;
    --color-muted: #62707a;
    --color-border: #dbe2e5;
    --color-bg: #f4f7f6;
    --radius: 10px;
    font-size: 16px;
}

* { box-sizing: border-box; }

/* Page affichée dans une iframe (index.html) : on récupère la hauteur
   de l'en-tête et du pied de page, inutiles dans ce contexte. */
body.embedded .site-header,
body.embedded .site-footer { display: none; }
body.embedded .container { padding-top: 4px; }
/* Le titre est déjà affiché par index.html : on ne le répète pas ici. */
body.embedded .poll-head h1 { display: none; }

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.45;
}

.site-header {
    background: var(--color-primary);
    padding: 6px 8px;
}

.site-header .brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 4px 2px 8px;
}

.site-footer {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.78rem;
    padding: 8px 6px 10px;
}

h1 { font-size: 1.3rem; margin: 0 0 3px; }
h2 { font-size: 1.05rem; margin: 0 0 6px; }

.intro p { color: var(--color-muted); }

.card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 6px 3px;
    margin-bottom: 8px;
}

.card-danger {
    border-color: #f0c4bd;
    background: #fff8f7;
}

.field {
    margin-bottom: 8px;
}

.field label {
    display: block;
    font-weight: 600;
    margin-bottom: 3px;
    font-size: 0.95rem;
}

.hint {
    color: var(--color-muted);
    font-size: 0.82rem;
    margin: 1px 0 5px;
}

input[type="text"],
input[type="date"],
textarea {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
}

input:focus, textarea:focus, button:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-block { display: block; width: 100%; margin-top: 8px; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
    background: #fff;
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-danger {
    background: #fff;
    color: var(--color-no);
    border-color: var(--color-no);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--color-muted);
    cursor: pointer;
    padding: 6px 10px;
}

.date-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.date-row input[type="date"] { flex: 1 1 150px; }
.date-row input.date-label-input { flex: 1 1 130px; }

#add-date { margin-top: 4px; }

.alert {
    padding: 7px 9px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.92rem;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert-error {
    background: var(--color-no-bg);
    color: var(--color-no);
    border: 1px solid #f0c4bd;
}
.alert-success {
    background: var(--color-yes-bg);
    color: var(--color-primary-dark);
    border: 1px solid #bfe3cd;
}

.badge {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 4px;
}

.poll-head { padding: 0 4px; }
.poll-head .description { color: var(--color-muted); white-space: pre-line; }
.poll-head .organizer { color: var(--color-muted); font-size: 0.9rem; }

/* --- Case de disponibilité à cycle, directement dans le tableau (une seule ligne) --- */
.cell-vote-form { margin: 0; }

/* Toutes les cases de vote ont exactement la même largeur et la même hauteur,
   quelle que soit la largeur de la colonne ; elles sont centrées dans la cellule. */
.cycle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: none;
    margin: 0 auto;
    padding: 0;
    border-radius: 8px;
    border: 1.5px solid var(--color-border);
    background: #fff;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-muted);
    -webkit-tap-highlight-color: transparent;
}

.cycle-btn.cycle-yes {
    background: var(--color-yes-bg);
    border-color: var(--color-yes);
    color: var(--color-yes);
}
.cycle-btn.cycle-maybe {
    background: var(--color-maybe-bg);
    border-color: var(--color-maybe);
    color: var(--color-maybe);
}
/* Case vide = « non disponible ». Volontairement neutre : un tableau encore peu
   rempli ne doit pas apparaître comme un mur de rouge. */
.cycle-btn.cycle-none,
.cycle-btn.cycle-no {
    background: #fff;
    border-color: var(--color-border);
    color: var(--color-muted);
}

/* --- Tableau des résultats --- */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.results-table {
    border-collapse: collapse;
    width: 100%;
}

.results-table th,
.results-table td {
    padding: 3px 2px;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    font-size: 0.85rem;
}

.results-table thead th {
    background: #f0f4f2;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.25;
}

.day-abbr, .day-date { display: inline; }

.sticky-col {
    position: sticky;
    left: 0;
    background: #fff;
    text-align: left !important;
    z-index: 1;
    box-shadow: 2px 0 3px rgba(0,0,0,0.04);
    max-width: 78px;
    min-width: 58px;
    padding-left: 3px !important;
    padding-right: 3px !important;
    line-height: 1.2;
    /* Un nom trop long se replie sur plusieurs lignes au lieu de déborder sur la
       première case de vote — mais sans jamais couper un mot en plein milieu :
       la colonne s'élargit juste ce qu'il faut pour le mot le plus long. */
    overflow: hidden;
    overflow-wrap: normal;
}
/* Doit être plus spécifique que « .results-table td { white-space: nowrap } »,
   sinon un nom long déborde sur la première case de vote au lieu de se replier. */
.results-table th.sticky-col,
.results-table td.sticky-col { white-space: normal; }

thead .sticky-col { background: #f0f4f2; z-index: 2; font-size: 0.72rem; }
tfoot .sticky-col { background: #f0f4f2; }

/* Nom du participant : 2 lignes maximum, le reste est tronqué par « … ».
   Le nom complet reste lisible via l'infobulle (attribut title). */
.name-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* « .results-table th » étant plus spécifique, il faut préfixer par le tableau,
   sinon la taille de police ci-dessous est ignorée. */
.results-table th.slot-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: none;
}

.sticky-col { font-weight: 600; }

.vote-cell { padding: 2px 1px !important; }

.best-col { color: var(--color-yes); }

.inline-form { display: inline; }
.link-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0;
}

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-size: 0.85rem; }
.copy-btn { white-space: nowrap; }

.date-manage-list, .response-manage-list {
    list-style: none;
    padding: 0;
    margin: 0 0 7px;
}
.date-manage-list li, .response-manage-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid var(--color-border);
    gap: 8px;
}
.date-manage-list li:last-child, .response-manage-list li:last-child { border-bottom: none; }

.response-summary { display: flex; flex-direction: column; gap: 4px; }
.vote-summary { display: flex; gap: 4px; flex-wrap: wrap; }
.mini-vote { font-size: 0.95rem; }

.date-slot-tag {
    display: inline-block;
    background: #f0f4f2;
    color: var(--color-muted);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 999px;
    margin-left: 6px;
}

.add-date-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.add-date-form input[type="date"] { flex: 1 1 150px; }
.add-date-form input[type="text"] { flex: 1 1 130px; }
