/* ChiliDate — mobile d'abord, puis tablette / bureau */
:root {
  --bg: #FBF7F2; --card: #FFFFFF; --line: #E8DFD5; --line-soft: #F1EAE2;
  --ink: #1F1A17; --ink-2: #4A423C; --muted: #6B625B;
  --chili: #B02A17; --chili-dark: #7F1D10; --chili-soft: #FBEDE8;
  --yes: #1F7A4D; --yes-bg: #DDF1E5; --yes-line: #A9D9BC;
  --maybe: #8A5A00; --maybe-bg: #FCEBC4; --maybe-line: #EBC877;
  --no: #6B625B; --no-bg: #EEE9E4; --no-line: #E0D8CF;
  --radius: 14px;
  --font: Inter, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-title: "Space Grotesk", var(--font);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); }
a { color: var(--chili); }
a:hover { color: var(--chili-dark); }
h1, h2, h3 { font-family: var(--font-title); letter-spacing: -0.01em; margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2563EB; outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- en-tête */
.topbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { font-family: var(--font-title); font-size: 20px; }
.brand small { display: none; color: var(--muted); font-size: 12px; }
.badge-admin { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--ink); color: #fff; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; font-weight: 500; }
.btn:hover { color: var(--ink); border-color: #CDBFB1; }
.btn-primary { background: var(--chili); border-color: var(--chili); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--chili-dark); border-color: var(--chili-dark); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--chili); }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------------- mise en page */
.layout { max-width: 1200px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--chili); }
.eyebrow.closed { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--ink-2); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--chili-soft); color: var(--chili-dark); font-size: 15px; }
.notice.ok { background: var(--yes-bg); color: var(--yes); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.18); }

/* ---------------------------------------------------------------- formulaires */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 15px; }
.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #D9CCBF; border-radius: 8px; background: #fff; font-size: 16px; /* ≥16px : pas de zoom iOS */ }
textarea.input { resize: vertical; min-height: 80px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; color: var(--ink-2); min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--chili); }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* ---------------------------------------------------------------- liste des sondages */
.poll-list { display: flex; flex-direction: column; gap: 8px; }
.poll-link { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 10px; background: var(--bg); border: 1px solid transparent; text-decoration: none; color: var(--ink); }
.poll-link:hover { color: var(--ink); border-color: var(--line); }
.poll-link[aria-current="page"] { background: var(--chili-soft); border-color: #F0C9BE; }
.poll-link b { font-weight: 600; }
.poll-link span { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- vote par cartes (mobile d'abord) */
.date-cards { display: flex; flex-direction: column; gap: 10px; }
.date-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: #fff; }
.date-card.best { border-color: #E9B3A6; background: #FFFAF8; }
.date-card.chosen { border: 2px solid var(--yes); }
.date-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.date-label { display: flex; flex-direction: column; }
.date-label b { font-family: var(--font-title); font-size: 18px; }
.date-label span { font-size: 14px; color: var(--ink-2); }
.tally { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.pill.y { background: var(--yes-bg); color: var(--yes); }
.pill.m { background: var(--maybe-bg); color: var(--maybe); }
.pill.best { background: var(--chili); color: #fff; }
.pill.chosen { background: var(--yes); color: #fff; }
.who { font-size: 13px; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.seg button { min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 15px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px; }
.seg button[aria-pressed="true"].y { background: var(--yes-bg); color: var(--yes); border-color: var(--yes); }
.seg button[aria-pressed="true"].m { background: var(--maybe-bg); color: var(--maybe); border-color: var(--maybe); }
.seg button[aria-pressed="true"].n { background: var(--no-bg); color: var(--ink-2); border-color: var(--no); }
.seg svg { width: 16px; height: 16px; flex: none; }

/* Barre d'enregistrement collée en bas sur mobile */
.savebar { position: sticky; bottom: 0; margin: 0 -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; justify-content: space-between; border-radius: 0 0 var(--radius) var(--radius); }
.savebar .btn-primary { flex: 1; }
.savebar .muted { font-size: 13px; }

/* ---------------------------------------------------------------- tableau des réponses */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table.answers { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 14px; }
.answers th, .answers td { padding: 8px; border-bottom: 1px solid var(--line-soft); text-align: center; white-space: nowrap; }
.answers thead th { font-weight: 600; font-size: 13px; vertical-align: bottom; }
.answers thead th.best { background: var(--chili-soft); color: var(--chili-dark); }
.answers th[scope="row"], .answers thead th:first-child { position: sticky; left: 0; background: #fff; text-align: left; z-index: 1; max-width: 140px; overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--line-soft); }
.answers tfoot td, .answers tfoot th { font-weight: 700; border-bottom: none; }
.cell { display: inline-flex; width: 36px; height: 30px; border-radius: 6px; align-items: center; justify-content: center; font-weight: 700; }
.cell.y { background: var(--yes-bg); color: var(--yes); }
.cell.m { background: var(--maybe-bg); color: var(--maybe); }
.cell.n { background: var(--no-bg); color: var(--muted); }
.cell svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- PIN */
.pin-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.pin-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }
.pin-logo { width: 64px; height: 64px; border-radius: 18px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.pin-logo svg { width: 34px; height: 34px; }
.pin-box h1 { font-size: 28px; }
.pin-input { text-align: center; font-size: 26px; letter-spacing: .4em; font-weight: 600; padding-left: .4em; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.keypad button { height: 60px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font-size: 24px; font-weight: 500; touch-action: manipulation; }
.keypad button:active { background: var(--chili-soft); }
.pin-error { color: var(--chili); font-weight: 500; min-height: 1.4em; margin: 0; }
.pin-box form { width: 100%; display: flex; flex-direction: column; gap: 14px; }

/* ---------------------------------------------------------------- admin */
.date-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 44px; gap: 8px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-btn svg { width: 16px; height: 16px; }
.admin-poll { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.admin-poll .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-poll .close-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-poll .close-row select { flex: 1 1 200px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; }
.chip button { width: 32px; height: 32px; border: none; background: transparent; border-radius: 50%; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.chip button svg { width: 12px; height: 12px; }

/* ---------------------------------------------------------------- écrans plus larges */
@media (min-width: 640px) {
  .topbar { padding: 14px 24px; }
  .brand small { display: block; }
  .layout { padding: 24px; }
  .card { padding: 22px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .date-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .savebar { position: static; margin: 0; padding: 0; background: none; border: none; justify-content: flex-end; }
  .savebar .btn-primary { flex: none; min-width: 220px; }
  .date-row { grid-template-columns: 200px 130px 44px; }
}
@media (min-width: 960px) {
  .layout { flex-direction: row; align-items: flex-start; padding: 32px; gap: 28px; }
  .layout > aside { flex: 0 0 290px; position: sticky; top: 90px; }
  .layout > main { flex: 1 1 auto; min-width: 0; }
  .answers { font-size: 15px; }
}
/* Mobile : une seule vue à la fois (liste OU sondage) */
@media (max-width: 959px) {
  body.viewing-poll .layout > aside { display: none; }
  body:not(.viewing-poll) .layout > main.poll-main { display: none; }
}
@media (min-width: 960px) { .only-mobile { display: none !important; } }
fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 4px; }
.pre { white-space: pre-line; }

/* Ajustements mobile : boutons de vote empilés (icône au-dessus du libellé), titres plus compacts */
h1 { font-size: 26px; line-height: 1.15; }
.seg button { flex-direction: column; gap: 2px; font-size: 14px; line-height: 1.2; }
.seg .q { font-weight: 800; font-size: 15px; line-height: 16px; }
.date-head { flex-wrap: wrap; }
.date-label b { white-space: nowrap; }
@media (min-width: 640px) {
  h1 { font-size: 32px; }
  .seg button { flex-direction: row; gap: 6px; font-size: 15px; }
}
