@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,500;0,600;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --paper: #EEF0EA;
  --paper-raised: #F7F8F4;
  --ink: #23282B;
  --ink-soft: #5B6360;
  --line: #D6D6C8;
  --teal: #2F6F62;
  --teal-dark: #234F45;
  --danger: #A8503E;
  --radius: 3px;
  --font-head: 'Lora', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--teal-dark); }

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 32px;
}

.masthead .stamp {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.masthead .stamp span {
  color: var(--teal-dark);
}

h1 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.25;
  margin: 0 0 6px;
  max-width: 34ch;
}

.lede {
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0 0 32px;
}

.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 22px;
}

.field { margin-bottom: 20px; }

.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password], input[type=date], textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

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

textarea { resize: vertical; min-height: 70px; }

.hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14.5px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--teal);
  color: #fff;
}

.btn:hover { background: var(--teal-dark); }

.btn.secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn.secondary:hover { border-color: var(--ink-soft); }

.btn.ghost {
  background: transparent;
  border: none;
  color: var(--teal-dark);
  padding: 6px 4px;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.row-repeat {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.row-repeat .field { flex: 1; margin-bottom: 0; }

.check-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  padding-bottom: 10px;
}

.check-inline input { width: auto; }

.remove-x {
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 16px;
  padding: 8px;
}

.remove-x:hover { color: var(--danger); }

.option-swatch {
  width: 14px; height: 14px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}

.result-box {
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.result-box .link {
  font-family: var(--font-body);
  font-size: 15px;
  background: #fff;
  border: 1px dashed var(--line);
  padding: 10px 14px;
  border-radius: var(--radius);
  display: inline-block;
  margin: 12px 0;
  word-break: break-all;
}

/* ---- Poll page ---- */

.poll-desc { white-space: pre-wrap; color: var(--ink-soft); margin-bottom: 28px; max-width: 65ch; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.editor-bar input[type=text], .editor-bar input[type=email] {
  width: auto;
  min-width: 160px;
}

.editing-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13.5px;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
}

.editing-flag strong { color: var(--ink); }

.editing-flag button {
  border: none;
  background: none;
  color: var(--teal-dark);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}

.section-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
  margin: 40px 0 4px;
}

.search-box {
  width: 100%;
  max-width: 280px;
  margin: 12px 0 14px;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.grid-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); }

/* ---- Calendrier ---- */

table.cal { border-collapse: collapse; width: 100%; table-layout: fixed; }

table.cal th.dow-col {
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: lowercase;
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

table.cal td.cal-cell {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
  height: 66px;
  padding: 6px;
  position: relative;
  touch-action: none;
}

table.cal td.cal-cell.out {
  background: repeating-linear-gradient(135deg, var(--paper) 0 8px, #E6E5DA 8px 16px);
  color: var(--ink-soft);
  touch-action: auto;
}

table.cal td.cal-cell.out .cal-daynum { color: var(--ink-soft); opacity: 0.6; }

table.cal td.cal-cell.proposed { cursor: pointer; background: var(--paper-raised); }
table.cal td.cal-cell.proposed:hover { background: #EAF0EC; }

table.cal td.cal-cell.cal-selecting { background: #D7E5DE; }

table.cal td.cal-cell.cal-draft {
  box-shadow: inset 0 0 0 2px var(--draft-color, var(--teal));
}

table.cal td.cal-cell.cal-highlight {
  background: #F4E8CC;
}
table.cal td.cal-cell.cal-highlight.proposed:hover { background: #EFDFB8; }

.cal-daynum {
  font-family: var(--font-head);
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 4px;
}

.cal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

/* ---- Modale de sélection ---- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(35, 40, 43, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
}

.modal-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 16px;
}

.modal-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.modal-option {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink);
}

.modal-option.active { border-color: var(--ink); background: var(--paper); }

.modal-option.clear { color: var(--ink-soft); font-style: italic; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Bulle de survol ---- */

.tooltip {
  position: fixed;
  display: none;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--radius);
  max-width: 240px;
  pointer-events: none;
  z-index: 60;
}

.tooltip.visible { display: block; }

/* ---- Tableau croisé ---- */

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

table.crosstab th, table.crosstab td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px 12px;
  text-align: center;
  white-space: nowrap;
}

table.crosstab th.corner { background: var(--paper-raised); }

table.crosstab th.ct-opt-head {
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-soft);
}

table.crosstab td.name-col {
  text-align: left;
  font-weight: 500;
  background: var(--paper-raised);
}

table.crosstab tr.editing-row td.name-col { background: #E4EFEA; }

.name-link {
  border: none;
  background: none;
  color: var(--ink);
  font-weight: 500;
  font-family: var(--font-body);
  font-size: 14.5px;
  cursor: pointer;
  padding: 0;
}

.name-link:hover { color: var(--teal-dark); text-decoration: underline; }

.ct-cell.empty { color: var(--line); }

.ct-toggle {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  min-width: 30px;
  padding: 4px 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--ink);
}

.ct-toggle.active {
  background: #F4E8CC;
  border-color: #C08A2E;
}

.empty-state {
  color: var(--ink-soft);
  font-size: 13.5px;
  padding: 14px;
  text-align: center;
}

.foot-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.status-msg {
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

.status-msg.ok { color: var(--teal-dark); }
.status-msg.err { color: var(--danger); }

.center-card { max-width: 420px; margin: 90px auto; }

footer.note {
  margin-top: 40px;
  font-size: 12.5px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

@media (max-width: 640px) {
  h1 { font-size: 26px; }
  .card { padding: 18px; }
}
