:root {
  --bg: #f6f1e7;
  --card: #fffdf8;
  --ink: #26241f;
  --muted: #6f6a5f;
  --line: #e6dfcf;
  --accent: #2f5d50;
  --accent-soft: #e3ece7;
  --late: #9a5b12;
  --late-bg: #fbefd9;
  --partner: #6b4f8a;
  --partner-soft: #efe9f5;
  --danger: #a33b2b;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 var(--sans);
  padding: env(safe-area-inset-top) 16px calc(32px + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.loading { text-align: center; color: var(--muted); padding-top: 30vh; }

/* ---------- en-tête ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 0 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 34px; height: 34px; }
.brand h1 { font-size: 1.3rem; }
.who { color: var(--muted); font-size: 0.9rem; text-align: right; }
.link-btn {
  background: none; border: 0; padding: 4px 0; color: var(--muted);
  text-decoration: underline; cursor: pointer; font-size: 0.9rem;
}

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: #ebe4d4; padding: 5px; border-radius: 12px; margin-bottom: 16px;
}
.tabs button {
  border: 0; background: transparent; padding: 10px; border-radius: 9px;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tabs .dot { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px;
  background: var(--partner); color: #fff; font-size: 0.75rem; line-height: 20px; }

/* ---------- cartes ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.row { display: flex; align-items: center; gap: 12px; }
.spread { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.bar { height: 10px; background: #ece6d8; border-radius: 6px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .3s; }
.bar.partner > span { background: var(--partner); }

.big-num { font-family: var(--serif); font-size: 1.9rem; line-height: 1; }

/* ---------- retard ---------- */
.late { background: var(--late-bg); border-color: #f0d9ae; }
.late h2 { font-size: 1.15rem; color: var(--late); }
.ok { background: var(--accent-soft); border-color: #cfdfd6; }
.ok h2 { font-size: 1.1rem; color: var(--accent); }
.late .group-title { margin: 14px 0 4px; font-weight: 600; font-size: 0.9rem; color: var(--late); }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 13px 18px; min-height: 48px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.btn.block { width: 100%; }
.btn.light { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.amber { background: var(--late); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- mois ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 22px 0 6px; }
.month-nav .arrow {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); font-size: 1.3rem; cursor: pointer; flex: none;
}
.month-nav .arrow:disabled { opacity: .3; cursor: default; }
.month-title { text-align: center; }
.month-title h2 { font-size: 1.45rem; }
.month-title p { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.back-now { display: block; margin: 0 auto 8px; }
.month-progress { margin: 8px 0 14px; }

/* ---------- jours ---------- */
.days { list-style: none; margin: 0; padding: 0; }
.day {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; overflow: hidden;
}
.day.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day-main { display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 10px; }

.check {
  flex: none; width: 34px; height: 34px; margin-top: 2px; border-radius: 50%;
  border: 2px solid #c9c0ad; background: #fff; cursor: pointer; display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.check svg { width: 18px; height: 18px; opacity: 0; }
.check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.check[aria-checked="true"] svg { opacity: 1; }
.check:focus-visible, .btn:focus-visible, .arrow:focus-visible { outline: 3px solid #9cc3b5; outline-offset: 2px; }

.day-body { flex: 1; min-width: 0; }
.day-label { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tag-next { background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 7px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.passage { margin-top: 3px; font-family: var(--serif); font-size: 1.08rem; }
.passage .t { color: var(--muted); font-family: var(--sans); font-size: 0.75rem; font-weight: 700; display: inline-block; width: 26px; }
.passage a { font-family: var(--sans); font-size: 0.8rem; margin-left: 6px; }
.passage.rest { color: var(--muted); font-style: italic; }
.day.done .passage { color: var(--muted); }

.day-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.p-badge {
  font-size: 0.75rem; font-weight: 600; color: var(--partner); background: var(--partner-soft);
  border-radius: 8px; padding: 2px 7px; white-space: nowrap;
}
.note-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; min-width: 44px; height: 36px;
  padding: 0 9px; cursor: pointer; font-size: 0.85rem; color: var(--muted);
}
.note-btn.has { color: var(--partner); border-color: #d6c9e6; background: var(--partner-soft); font-weight: 700; }

/* ---------- notes ---------- */
.notes { border-top: 1px dashed var(--line); padding: 12px; background: #fcfaf4; }
.note { margin-bottom: 10px; }
.note .meta { font-size: 0.78rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.note .meta b { color: var(--ink); }
.note.theirs .meta b { color: var(--partner); }
.note p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
textarea {
  width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  background: #fff; resize: vertical;
}
.note-form { display: flex; flex-direction: column; gap: 8px; }
.note-form .btn { align-self: flex-end; min-height: 42px; padding: 9px 16px; }

/* ---------- formulaires ---------- */
.auth { padding-top: 6vh; }
.auth .hero { text-align: center; margin-bottom: 22px; }
.auth .hero img { width: 64px; height: 64px; }
.auth .hero h1 { font-size: 1.9rem; margin-top: 10px; }
.auth .hero p { color: var(--muted); margin: 6px 0 0; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #9cc3b5; border-color: var(--accent); }
.error { color: var(--danger); font-weight: 600; min-height: 1.4em; margin: 4px 0 8px; }
.switch { text-align: center; margin-top: 14px; }

/* ---------- binôme ---------- */
.code {
  font-family: ui-monospace, Menlo, monospace; font-size: 1.8rem; letter-spacing: .18em;
  text-align: center; background: var(--partner-soft); color: var(--partner);
  border-radius: 12px; padding: 12px; margin: 10px 0; user-select: all;
}
.duo { display: grid; gap: 16px; }
.person .spread b { font-size: 1.05rem; }
.feed .item { padding: 10px 0; border-top: 1px solid var(--line); }
.feed .item:first-of-type { border-top: 0; }
.feed .where { font-size: 0.8rem; color: var(--muted); }
.feed .where button { padding: 0; }

.confirm-box { margin-top: 10px; padding: 12px; border-radius: 10px; background: #fbeeea; }
.confirm-box .row { margin-top: 8px; flex-wrap: wrap; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 0.95rem;
  max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 10;
}

/* ---------- choix du départ ---------- */
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
}
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.choice-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.choice-body b { font-size: 1.05rem; }
.preview { font-family: var(--serif); font-size: 0.95rem; color: var(--accent); margin-top: 4px; }
.rep-pick { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.rep-pick select { min-height: 44px; }

/* ---------- installer ---------- */
.who .sep { margin: 0 6px; color: var(--line); }
#sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(30, 28, 24, .45); }
.sheet-panel {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(0,0,0,.18);
}
.sheet-panel h2 { font-size: 1.2rem; }
.sheet-x { border: 0; background: #efe9dc; width: 38px; height: 38px; border-radius: 50%; font-size: 1rem; cursor: pointer; flex: none; }
.steps { margin: 0; padding-left: 22px; }
.steps li { margin-bottom: 10px; padding-left: 4px; }
.steps .muted { display: block; }
.ico { display: inline-block; border: 1.5px solid currentColor; border-radius: 4px; padding: 0 4px; font-size: .8rem; line-height: 1.3; }

/* ---------- admin ---------- */
.tabs { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile .big-num { font-size: 1.7rem; margin-bottom: 4px; }
.table-wrap { overflow-x: auto; }
.members { width: 100%; border-collapse: collapse; font-size: .9rem; }
.members th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; padding: 8px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.members td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.members tr:last-child td { border-bottom: 0; }
.sheet-panel .spread { flex-wrap: nowrap; align-items: flex-start; }
.brand h1 { white-space: nowrap; }
.svg-ico {
  width: 1.45em; height: 1.45em; vertical-align: -0.38em; margin: 0 2px;
  color: #0a84ff; background: #eef4ff; border-radius: 6px; padding: 2px;
}
