/* Charte dynax : bleu nuit, bleu, cyan — polices Dynax Sans */
@font-face { font-family: "Dynax Sans Display"; src: url("fonts/DynaxSansDisplay-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Dynax Sans UI"; src: url("fonts/DynaxSansUI-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Dynax Sans UI"; src: url("fonts/DynaxSansUI-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Dynax Sans UI"; src: url("fonts/DynaxSansUI-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --navy: #011a45;
  --blue: #0878b5;
  --cyan: #20bfe3;
  --bg: #f5fafc;
  --surface: #ffffff;
  --surface-2: #eef5f9;
  --line: #d9e7ef;
  --text: #011a45;
  --muted: #5b6f88;
  --danger: #d64545;
  --glass: rgba(1, 26, 69, .55);
  --brand-gradient: linear-gradient(135deg, #20bfe3, #0878b5 48%, #011a45);
  --font-display: "Dynax Sans Display", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-label: "Dynax Sans UI", var(--font-body);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font-body);
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1132px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(var(--bg) 75%, rgba(245, 250, 252, 0));
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-tile { width: 46px; height: 46px; border-radius: 12px; box-shadow: 0 6px 16px rgba(8, 120, 181, .25); }
.topbar h1 { margin: 0; font: 700 28px/1 var(--font-display); letter-spacing: -.01em; color: var(--navy); }
.brand-sub { margin: 4px 0 0; font-family: var(--font-label); font-size: 11px; font-weight: 500; letter-spacing: .12em; color: var(--blue); }

.icon-btn {
  flex: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--navy); font-size: 22px; line-height: 1;
}
.icon-btn.small { width: 32px; height: 32px; border: 0; font-size: 18px; background: transparent; color: var(--muted); }

/* ---------- Bandeau d'installation */
.hint {
  display: flex; align-items: center; gap: 10px;
  max-width: 1100px; margin: 0 16px 12px; padding: 12px 8px 12px 16px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  font-size: 14px; box-shadow: 0 4px 14px rgba(1, 26, 69, .06);
}
@media (min-width: 1132px) { .hint { margin: 0 auto 12px; } }
.hint p { margin: 0; flex: 1; }
.hint.ios { align-items: flex-start; padding: 16px 8px 16px 16px; }
.hint.ios p { font-size: 15px; }

.steps { display: grid; gap: 12px; margin: 12px 0 0; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 12px; }
.steps small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.step-icon {
  flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface-2); color: var(--blue); font-size: 18px; font-weight: 700;
}
.step-icon svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Liste */
.list {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  max-width: 1132px; margin: 0 auto; padding: 4px 16px;
}

.card {
  position: relative; isolation: isolate;
  display: flex; flex-direction: column; justify-content: flex-end;
  aspect-ratio: 3 / 2; padding: 18px; border: 0; border-radius: 22px; overflow: hidden;
  text-align: left; color: #fff;
  background: var(--navy) center / cover no-repeat;
  box-shadow: 0 12px 28px rgba(1, 26, 69, .18);
  transition: transform .15s ease;
}
.card::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(1, 26, 69, 0) 35%, rgba(1, 26, 69, .88));
}
.card:active { transform: scale(.98); }
.card.past { filter: saturate(.3); }

.card-count {
  position: absolute; top: 14px; right: 14px;
  min-width: 80px; padding: 10px 14px; border-radius: 16px; text-align: center;
  background: var(--brand-gradient);
  box-shadow: 0 6px 16px rgba(1, 26, 69, .3);
}
.card.past .card-count { background: var(--glass); }
.card-count .num {
  display: block; font: 700 36px/1 var(--font-display);
  font-variant-numeric: tabular-nums; color: #fff;
}
.card-count .unit {
  display: block; margin-top: 5px;
  font: 500 11px/1.2 var(--font-label); letter-spacing: .1em; text-transform: uppercase; color: #dff6fc;
}
.card-title {
  display: block; margin-bottom: 4px;
  font: 700 23px/1.15 var(--font-display); overflow-wrap: anywhere;
  text-shadow: 0 1px 10px rgba(1, 26, 69, .5);
}
.card-sub { display: block; font-size: 14px; color: #dbe9f5; }
.card-date::first-letter { text-transform: uppercase; }
.clock { font-variant-numeric: tabular-nums; }
.clock:not(:empty)::before { content: " · "; }

/* ---------- État vide */
.empty { padding: 15vh 24px 0; text-align: center; color: var(--muted); }
.empty-icon { width: 88px; height: 88px; margin: 0 auto 16px; border-radius: 22px; box-shadow: 0 12px 28px rgba(8, 120, 181, .25); }
.empty p { margin: 0 0 24px; font-size: 17px; }

/* ---------- Signature */
.by { padding: 32px 16px 0; text-align: center; }
.by a {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 13px/1 var(--font-label); letter-spacing: .04em; color: var(--muted); text-decoration: none;
}
.by img { height: 26px; width: auto; }

/* ---------- Bouton + */
.fab {
  position: fixed; z-index: 6;
  right: max(20px, calc((100vw - 1132px) / 2 + 20px));
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 62px; height: 62px; border: 0; border-radius: 20px;
  background: var(--brand-gradient); color: #fff;
  font-size: 34px; font-weight: 400; line-height: 1;
  box-shadow: 0 10px 24px rgba(8, 120, 181, .4);
}

/* ---------- Boutons */
.btn {
  height: 46px; padding: 0 20px; border: 0; border-radius: 12px;
  font-weight: 700; white-space: nowrap;
}
.btn.small { height: 34px; padding: 0 14px; border-radius: 10px; font-size: 14px; }
.btn.wide { display: block; width: 100%; margin-top: 10px; }
.btn.primary { background: linear-gradient(135deg, var(--blue), var(--navy)); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--navy); }
.btn.danger { background: transparent; color: var(--danger); padding: 0 8px; }
.btn:disabled { opacity: .6; }
.link-btn {
  display: block; margin: 8px auto 0; padding: 4px 8px; border: 0; background: none;
  color: var(--muted); font-size: 14px; text-decoration: underline;
}

/* ---------- Vue détaillée */
.detail {
  position: fixed; inset: 0; z-index: 20; isolation: isolate;
  display: flex; flex-direction: column; color: #fff;
  background: var(--navy) center / cover no-repeat;
}
.detail::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(1, 26, 69, .25), rgba(1, 26, 69, .65) 55%, rgba(1, 26, 69, .94));
}
.detail-top {
  display: flex; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 0;
}
.detail-top .icon-btn {
  border: 0; color: #fff; background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.detail-body {
  width: 100%; max-width: 720px; margin-top: auto; align-self: center;
  padding: 24px 16px calc(48px + env(safe-area-inset-bottom));
  text-align: center;
}
.detail-body h2 {
  margin: 0 0 24px;
  font: 700 clamp(30px, 8vw, 52px)/1.1 var(--font-display); letter-spacing: -.01em;
  overflow-wrap: anywhere; text-shadow: 0 2px 16px rgba(1, 26, 69, .5);
}
.timer { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.timer div {
  padding: 16px 2px 12px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 18px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.timer div:first-child { border: 0; background: var(--brand-gradient); }
.timer b {
  display: block; font: 700 clamp(26px, 8vw, 60px)/1 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.timer span {
  display: block; margin-top: 8px;
  font: 500 11px/1.2 var(--font-label); letter-spacing: .1em; text-transform: uppercase; color: #cfe6f5;
}
.detail-msg { margin: 0; font: 700 clamp(28px, 7vw, 44px)/1.2 var(--font-display); }
.detail-date { margin: 20px 0 0; color: #dbe9f5; font-size: 17px; }
.detail-date::first-letter { text-transform: uppercase; }

/* ---------- Fenêtres (feuille en bas sur téléphone) */
dialog.sheet {
  width: min(480px, calc(100vw - 24px)); max-width: 100%; max-height: calc(100dvh - 24px);
  padding: 0; border: 0; border-radius: 24px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 20px 50px rgba(1, 26, 69, .25);
}
dialog::backdrop {
  background: rgba(1, 26, 69, .45);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
@media (max-width: 600px) {
  dialog.sheet {
    width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}
dialog h2 { margin: 0 0 16px; font: 700 22px/1.2 var(--font-display); color: var(--navy); }
#form-edit, .menu { padding: 20px; }

.photo-pick {
  display: grid; place-items: center;
  aspect-ratio: 16 / 9; border: 2px dashed var(--line); border-radius: 16px;
  background: var(--surface-2) center / cover no-repeat;
  color: var(--blue); font-weight: 700;
}
.photo-pick.has-photo { border-style: solid; }
.photo-pick.has-photo .photo-label {
  padding: 8px 14px; border-radius: 999px; background: var(--glass); color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}

.field { display: block; margin-top: 14px; min-width: 0; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.field input {
  display: block; width: 100%; min-width: 0; height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.field input::-webkit-date-and-time-value { text-align: left; }
.field input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; border-color: transparent; }
.row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }

.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; font-size: 15px; }
.check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--blue); }

.actions { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.grow { flex: 1; }

.note { margin: 8px 0 0 30px; font-size: 13px; color: var(--muted); }
.note.flush { margin: 0; }
.menu h3 { margin: 0 0 4px; font: 700 16px/1.3 var(--font-display); color: var(--navy); }
.menu hr { margin: 20px 0 16px; border: 0; border-top: 1px solid var(--line); }
.btn.close { margin-top: 24px; }
