:root {
  --cream: #F7F1E6;
  --paper: #FFFDF8;
  --brown: #3B2A1E;
  --brown-2: #6B5444;
  --muted: #8A7563;
  --gold: #B08A45;
  --gold-soft: #EFE2C8;
  --line: #E3D6C1;
  --ok: #3D7A4F;
  --ok-soft: #E3F0E4;
  --warn: #A9701A;
  --warn-soft: #FBEFD8;
  --err: #A33A2C;
  --err-soft: #F8E2DE;
  --serif: "Cormorant Garamond", "Didot", "Bodoni 72", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--cream);
  color: var(--brown);
  font-family: var(--sans);
  display: flex; flex-direction: column;
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 28px 12px;
  border-bottom: 1px solid var(--line);
}
.brand-name { font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: .5px; line-height: 1; }
.brand-sub { font-size: 12px; letter-spacing: 3.5px; text-transform: uppercase; color: var(--gold); margin-top: 5px; }
.net {
  display: flex; align-items: center; gap: 8px; font-size: 15px; padding: 8px 14px;
  border-radius: 999px; background: var(--paper); border: 1px solid var(--line);
}
.net .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.net.on .dot { background: var(--ok); }
.net.off { background: var(--warn-soft); border-color: #E9CF9E; color: #7A4F0E; }
.net.off .dot { background: var(--warn); }

main { flex: 1; display: flex; min-height: 0; }
.screen { flex: 1; display: flex; flex-direction: column; padding: 20px 28px max(20px, env(safe-area-inset-bottom)); min-height: 0; }

/* Accueil */
.clock { text-align: center; margin: 2vh 0 3vh; }
.time { font-family: var(--serif); font-size: clamp(64px, 13vw, 132px); font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.date { font-size: clamp(18px, 2.4vw, 24px); color: var(--brown-2); margin-top: 8px; }
.date::first-letter { text-transform: uppercase; }
.actions { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-height: 520px; }
.action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  border: 0; border-radius: 22px; padding: 18px; min-height: 120px;
  font-size: clamp(20px, 2.8vw, 28px); font-weight: 600; letter-spacing: .2px;
  box-shadow: 0 1px 0 rgba(59,42,30,.06), 0 8px 24px -14px rgba(59,42,30,.45);
  transition: transform .08s ease;
}
.action:active { transform: scale(.98); }
.action svg { width: 46px; height: 46px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.actions.two { grid-template-columns: 1fr 1fr; max-height: 420px; }
.actions.two .action { font-size: clamp(24px, 3.4vw, 34px); }
.actions.two .action svg { width: 60px; height: 60px; }
.a-in { background: #3D6B4A; color: #FDFBF5; }
.a-bs { background: var(--gold-soft); color: var(--brown); border: 1px solid #E2CFA6; }
.a-be { background: var(--paper); color: var(--brown); border: 1px solid var(--line); }
.a-out { background: var(--brown); color: #FBF6EC; }
.foot { display: flex; gap: 20px; justify-content: center; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.link { background: none; border: 0; color: var(--brown-2); font-size: 16px; text-decoration: underline; text-underline-offset: 4px; padding: 10px; }
.pending { color: #7A4F0E; background: var(--warn-soft); padding: 8px 14px; border-radius: 999px; font-size: 15px; }

/* Étapes */
.step-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.step-head h1 { font-family: var(--serif); font-size: clamp(30px, 4vw, 42px); font-weight: 600; margin: 0; }
.back { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 20px; font-size: 18px; min-width: 120px; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; overflow-y: auto; align-content: start; padding-bottom: 8px; }
.names button {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px; min-height: 92px;
  font-size: 24px; font-weight: 600; padding: 12px;
}
.names button:active { background: var(--gold-soft); }
.names .empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 18px; padding: 40px; }

.pin-action { text-align: center; font-size: 20px; color: var(--brown-2); margin: 0 0 14px; }
.dots { display: flex; justify-content: center; gap: 18px; height: 26px; margin-bottom: 6px; }
.dots span { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--brown-2); }
.dots span.f { background: var(--brown); border-color: var(--brown); }
.pin-error { text-align: center; color: var(--err); font-size: 18px; min-height: 28px; margin: 6px 0 10px; font-weight: 600; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(440px, 100%); margin: 0 auto; }
.pad button {
  height: clamp(64px, 9vh, 86px); border-radius: 18px; border: 1px solid var(--line); background: var(--paper);
  font-size: 32px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.pad button:active { background: var(--gold-soft); }
.pad .k-alt { font-size: 28px; color: var(--brown-2); }
.pad .k-ok { background: var(--brown); color: #FBF6EC; font-size: 22px; font-weight: 600; border: 0; }
.pad .k-ok:disabled { opacity: .35; }

/* Résultat */
.result { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; }
.result-icon { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; }
.result-icon svg { width: 64px; height: 64px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.result.ok .result-icon { background: var(--ok-soft); color: var(--ok); }
.result.err .result-icon { background: var(--err-soft); color: var(--err); }
.result.queued .result-icon { background: var(--warn-soft); color: var(--warn); }
.result-msg { font-family: var(--serif); font-size: clamp(30px, 4.4vw, 46px); font-weight: 600; margin: 8px 0 0; max-width: 900px; line-height: 1.15; }
.result-sub { font-size: 19px; color: var(--brown-2); margin: 0; max-width: 720px; }
.countdown { width: 260px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 18px; }
.countdown div { height: 100%; width: 100%; background: var(--gold); transform-origin: left; }
.btn-home { margin-top: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 26px; font-size: 18px; }

/* Compteur de la semaine (après un départ) */
.week { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 16px 26px; margin-top: 6px; min-width: min(560px, 90vw); }
.week-line { font-size: 22px; font-weight: 600; }
.week-bar { height: 10px; border-radius: 5px; background: var(--line); margin: 10px 0 8px; overflow: hidden; }
.week-bar div { height: 100%; background: var(--gold); border-radius: 5px; }
.week-detail { font-size: 18px; color: var(--brown-2); }

/* Code créé au premier passage */
.newpin { background: var(--paper); border: 2px solid var(--gold); border-radius: 20px; padding: 18px 34px; margin-top: 8px; }
.newpin-label { font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); }
.newpin-code { font-family: ui-monospace, Menlo, monospace; font-size: 72px; font-weight: 700; letter-spacing: 18px; margin: 4px 0 6px 18px; }
.newpin-warn { font-size: 18px; line-height: 1.5; color: var(--brown); margin: 0; }

/* Mes heures */
.me-note { color: var(--brown-2); margin: 0 0 12px; }
.me-table-wrap { overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.me-table { width: 100%; border-collapse: collapse; font-size: 18px; font-variant-numeric: tabular-nums; }
.me-table th, .me-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.me-table th { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.me-table .w { color: var(--warn); font-size: 15px; }

/* Appairage */
.pair { max-width: 620px; margin: 6vh auto 0; text-align: center; }
.pair h1 { font-family: var(--serif); font-size: 38px; margin: 0 0 12px; }
.pair p { font-size: 18px; color: var(--brown-2); line-height: 1.5; }
.pair form { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pair input { font-size: 26px; letter-spacing: 4px; text-transform: uppercase; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); color: var(--brown); width: 300px; text-align: center; }
.pair button { font-size: 20px; padding: 14px 26px; border-radius: 14px; border: 0; background: var(--brown); color: #FBF6EC; font-weight: 600; }

dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--paper); color: var(--brown); max-width: 640px; padding: 26px 30px; }
dialog::backdrop { background: rgba(59, 42, 30, .35); }
dialog h2 { font-family: var(--serif); font-size: 30px; margin: 0 0 10px; }
dialog p { font-size: 17px; line-height: 1.55; }
dialog button { background: var(--brown); color: #FBF6EC; border: 0; border-radius: 12px; padding: 12px 22px; font-size: 17px; }

@media (max-width: 640px) {
  .top { padding: 12px 16px 10px; }
  .brand-name { font-size: 24px; }
  .net { font-size: 13px; padding: 6px 10px; }
  .screen { padding: 14px 16px; }
  .actions { grid-template-columns: 1fr; gap: 12px; }
  .action { flex-direction: row; justify-content: flex-start; min-height: 76px; padding: 14px 20px; font-size: 20px; }
  .action svg { width: 34px; height: 34px; }
  .names { grid-template-columns: 1fr 1fr; }
  .names button { min-height: 72px; font-size: 19px; }
  .back { min-width: 0; padding: 10px 14px; font-size: 16px; }
}
@media (max-height: 700px) and (min-width: 641px) {
  .clock { margin: 0 0 2vh; }
  .action { min-height: 96px; }
}
