/* Valeurs reprises de la maquette validée (design/maquette-finale.html). */
:root {
  --bg: #FFFFFF;
  --surf: #F1F4F2;
  --surf2: #E4EAE7;
  --ink: #0D1714;
  --muted: #5A6661;
  --line: #DCE3DF;
  --accent: #0B6B4D;
  --on-accent: #FFFFFF;
  --accent-soft: #DDEFE7;
  --sheet: #FFFFFF;
  --scrim: rgba(10, 20, 16, .38);
  --hatch-a: #F3F4F4;
  --hatch-b: #E6E9E8;
  --danger: #A3261B;
  --danger-soft: #FBEAE8;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Lexend, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum";
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.ic { width: 1em; height: 1em; flex: none; display: inline-block; vertical-align: -.12em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ───────── Connexion ───────── */
.login {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(48px + env(safe-area-inset-top)) 18px 48px;
}
.login-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
}
.login-brand .ic { font-size: 22px; }
.login h1 { font-size: 32px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; margin-top: 12px; }
.login-form { display: flex; flex-direction: column; margin-top: 28px; }
.login-form label { font-size: 17px; font-weight: 600; margin: 14px 4px 8px; }
.field {
  width: 100%; height: 60px; padding: 0 18px;
  border-radius: 16px; border: 2px solid transparent; background: var(--surf);
  font-size: 20px; font-weight: 500;
}
.field:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 62px; margin-top: 24px; border-radius: 18px;
  background: var(--accent); color: var(--on-accent); font-size: 19px; font-weight: 600;
}
.primary:disabled { opacity: .6; }
.form-error {
  margin-top: 16px; padding: 12px 16px; border-radius: 14px;
  background: var(--danger-soft); color: var(--danger); font-size: 16px; font-weight: 500;
}

/* ───────── Application : téléphone ───────── */
.loading { padding: 48px 18px; color: var(--muted); text-align: center; }
body.locked { overflow: hidden; }
.pad {
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 18px calc(110px + env(safe-area-inset-bottom));
}
.pad > h1 { font-size: 32px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
.code { font-weight: 700; white-space: nowrap; letter-spacing: -.02em; line-height: 1.05; }
.code.fit-xs { white-space: normal; overflow-wrap: anywhere; }
.code.none { font-size: 24px !important; white-space: normal; font-weight: 600; }
.note { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13.5px; color: var(--muted); margin-top: 18px; }
.lab { font-size: 15px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.arrow { width: 56px; height: 56px; border-radius: 16px; background: var(--surf); display: grid; place-items: center; font-size: 26px; }
.arrow:disabled { opacity: .3; }
.mod {
  display: inline-flex; align-items: center; gap: 4px; vertical-align: 1px;
  margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none;
}
.mod .ic { font-size: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); flex: none; }

/* Accueil */
.hero { background: var(--accent); color: var(--on-accent); border-radius: 26px; padding: 22px 22px 24px; margin-top: 20px; }
.hero .code { font-size: min(54px, 14.4vw); margin-top: 6px; }
.hero .code.fit-l { font-size: min(64px, 17vw); }
.hero .code.fit-s { font-size: min(42px, 11.2vw); }
.hero .code.fit-xs { font-size: min(30px, 8vw); }
.tom { display: block; background: var(--surf); border-radius: 22px; padding: 18px 22px; margin-top: 10px; width: 100%; text-align: left; }
.tom .lab { color: var(--muted); }
.tom .code { font-size: 34px; margin-top: 4px; }
.tom .code.fit-xs { font-size: 24px; }
.sec { font-size: 15px; font-weight: 600; color: var(--muted); margin: 28px 4px 8px; letter-spacing: .08em; text-transform: uppercase; }
.row { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 64px; padding: 8px 16px; border-radius: 16px; text-align: left; background: var(--surf); }
.row + .row { margin-top: 2px; }
.row .d { width: 52px; text-align: center; flex: none; }
.row .d b { display: block; font-size: 24px; font-weight: 600; line-height: 1.1; }
.row .d small { display: block; font-size: 13px; color: var(--muted); }
.row .c { font-size: 23px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.row .c.none { font-size: 16px; color: var(--muted); font-weight: 400; }
.row .dot { margin-left: auto; }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 62px; border-radius: 18px; background: var(--surf2); font-size: 19px; font-weight: 600; width: 100%; margin-top: 18px; }
.logout { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin: 10px auto 0; padding: 0 16px; font-size: 15px; color: var(--muted); }
.sync {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 10px 14px; border-radius: 14px;
  background: #FFF4D6; color: #5C4300; font-size: 14.5px; line-height: 1.35;
}
.fail h1 { margin-top: 20px; }
.fail p { margin-top: 12px; font-size: 18px; color: var(--muted); }

/* Barre du bas */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 6px 16px max(22px, calc(env(safe-area-inset-bottom) + 6px));
}
.tabs-in { max-width: 528px; height: 56px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; }
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 14px; font-weight: 500; color: var(--muted); border-radius: 14px; }
.tabs button .ic { font-size: 24px; }
.tabs button.on { color: var(--ink); background: var(--accent-soft); }

/* Calendrier */
.chead { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; margin: 4px 0 14px; }
.chead h1 { text-align: center; font-size: 25px; font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
.todaylink { display: block; margin: 0 auto 12px; min-height: 40px; font-size: 16px; font-weight: 600; color: var(--ink); background: var(--accent-soft); padding: 8px 16px; border-radius: 999px; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.grid .h { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.cell { position: relative; min-height: 76px; border-radius: 10px; background: var(--surf); display: flex; flex-direction: column; align-items: center; padding: 6px 2px 4px; }
.cell b { font-size: 17px; font-weight: 600; line-height: 1.2; margin-bottom: 4px; }
.cell span { font-size: 11px; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; max-width: 100%; overflow-wrap: anywhere; text-align: center; }
.cell span.sm { font-size: min(9.5px, 2.6vw); letter-spacing: -.04em; }
/* Code saisi très long : la case garde sa taille, le code complet est dans la fiche. */
.cell span.long { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-size: 9.5px; }
.cell .dot { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; }
.cell.today { background: var(--accent); }
.cell.today * { color: var(--on-accent); }
.cell.today .dot { background: var(--on-accent); }
.cell.sel { box-shadow: 0 0 0 3px var(--ink) inset; }
.cell.today.sel { box-shadow: 0 0 0 3px var(--ink) inset, 0 0 0 5px var(--accent) inset; }
.cell.out { background: repeating-linear-gradient(135deg, var(--hatch-a) 0 6px, var(--hatch-b) 6px 7px); }
.cell.out b { color: var(--muted); font-weight: 400; opacity: .6; }
.cell.blank { background: none; }

/* Fiche du jour (feuille qui monte du bas) */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 21; transform: translateX(-50%);
  width: 100%; max-width: 560px; max-height: calc(100% - 24px); overflow-y: auto;
  background: var(--sheet); border-radius: 28px 28px 0 0;
  padding: 10px 22px calc(34px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
}
.handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 18px; }
.chip { display: inline-block; font-size: 14px; font-weight: 600; padding: 3px 12px; border-radius: 999px; background: var(--accent); color: var(--on-accent); margin-bottom: 10px; }
.chip.soft { background: var(--surf2); color: var(--ink); }
.sheet .d { font-size: 24px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.sheet .d:focus { outline: none; }
.sheet .lab { display: block; font-size: 14px; color: var(--muted); margin-top: 18px; }
.sheet .code { font-size: min(56px, 15vw); }
.sheet .code.fit-s { font-size: min(44px, 11.7vw); }
.sheet .code.fit-xs { font-size: min(32px, 8.5vw); }
.orig { margin-top: 10px; font-size: 16px; color: var(--muted); }
.orig b { color: var(--ink); font-weight: 600; }
.snav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.snav button { min-height: 60px; border-radius: 16px; background: var(--surf); font-size: 16px; font-weight: 600; line-height: 1.2; padding: 6px; }
.snav button:disabled { opacity: .35; }
.close { width: 100%; height: 56px; margin-top: 10px; border-radius: 16px; border: 2px solid var(--line); font-size: 17px; font-weight: 600; }
.edit-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px;
  border-radius: 14px; border: 2px solid var(--line); font-size: 16px; font-weight: 600; text-align: left;
}
.link:disabled { opacity: .5; }

/* Modification */
.edit .code.cur { font-size: 32px; overflow-wrap: anywhere; white-space: normal; }
.code-input { margin-top: 8px; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.snav .save { background: var(--accent); color: var(--on-accent); }

/* ───────── Ordinateur ───────── */
.desk { max-width: 1180px; margin: 0 auto; }
.dhead { display: flex; align-items: center; gap: 16px; padding: 22px 36px; border-bottom: 1px solid var(--line); }
.dhead h1 { font-size: 30px; font-weight: 600; letter-spacing: -.01em; min-width: 260px; text-align: center; }
.dhead .todaylink { margin: 0 0 0 12px; }
.dhead .note { margin: 0 0 0 auto; }
.dhead .logout { margin: 0; }
.desk-sync { padding: 16px 36px 0; }
.desk-sync .sync { margin: 0; }
.desk-error { margin: 12px 36px 0; }
.strip { display: flex; gap: 12px; padding: 20px 36px 0; }
.strip .s { flex: 1; border-radius: 18px; padding: 16px 20px; background: var(--surf); min-width: 0; }
.strip .s.main { flex: 1.6; background: var(--accent); color: var(--on-accent); }
.strip .s small { font-size: 14px; font-weight: 500; opacity: .85; }
.strip .s .code { font-size: 36px; margin-top: 2px; }
.strip .s .code.fit-xs { font-size: 26px; }
.strip .s.main .orig, .strip .s.main .orig b { color: var(--on-accent); opacity: .92; }
.strip .s.main .link { border-color: rgba(255, 255, 255, .45); min-height: 44px; }
.dgrid { padding: 18px 36px 36px; }
.dgrid .grid { gap: 6px; }
.dgrid .cell { min-height: 96px; align-items: flex-start; padding: 10px 12px; text-align: left; }
.dgrid .cell span { font-size: 18px; margin-top: auto; padding-bottom: 6px; letter-spacing: -.01em; text-align: left; }
.dgrid .cell .dot { top: 10px; right: 10px; }

/* Tablette : même mise en page que le téléphone, cases plus lisibles. */
@media (min-width: 600px) {
  .cell { min-height: 84px; }
  .cell span { font-size: 13px; }
  .cell span.sm, .cell span.long { font-size: 12px; }
}

@media (min-width: 900px) {
  .sheet { top: 50%; bottom: auto; transform: translate(-50%, -50%); max-width: 460px; border-radius: 28px; padding-bottom: 28px; }
  .handle { display: none; }
}
