/* ==========================================================================
   MVA Terrain — feuille de style
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --surface-3: #e7e5df;
  --text: #17171c;
  --text-2: #55555f;
  --muted: #8a8a93;
  --border: rgba(23, 23, 28, 0.08);
  --border-strong: rgba(23, 23, 28, 0.16);
  --accent: #3346d3;
  --accent-hover: #2a3bb8;
  --accent-soft: rgba(51, 70, 211, 0.1);
  --accent-ink: #ffffff;
  --ok: #13795b;
  --ok-soft: rgba(19, 121, 91, 0.12);
  --warn: #a35a07;
  --warn-soft: rgba(214, 133, 18, 0.14);
  --danger: #c4323b;
  --danger-soft: rgba(196, 50, 59, 0.1);
  --mark: rgba(255, 196, 0, 0.35);
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05), 0 1px 1px rgba(20, 20, 30, 0.03);
  --shadow-md: 0 6px 24px -8px rgba(20, 20, 40, 0.18), 0 2px 6px rgba(20, 20, 40, 0.06);
  --shadow-lg: 0 18px 50px -12px rgba(20, 20, 40, 0.3);
  --topbar-bg: rgba(244, 243, 239, 0.82);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 62px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0e11;
    --surface: #17181c;
    --surface-2: #1f2025;
    --surface-3: #2a2b31;
    --text: #f3f3f5;
    --text-2: #b4b4bd;
    --muted: #82828c;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --accent: #8191ff;
    --accent-hover: #97a4ff;
    --accent-soft: rgba(129, 145, 255, 0.14);
    --accent-ink: #0d0e11;
    --ok: #4cc79a;
    --ok-soft: rgba(76, 199, 154, 0.13);
    --warn: #f0ae4c;
    --warn-soft: rgba(240, 174, 76, 0.13);
    --danger: #ff6b72;
    --danger-soft: rgba(255, 107, 114, 0.12);
    --mark: rgba(255, 196, 0, 0.28);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 28px -10px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 20px 60px -10px rgba(0, 0, 0, 0.8);
    --topbar-bg: rgba(13, 14, 17, 0.8);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e11;
  --surface: #17181c;
  --surface-2: #1f2025;
  --surface-3: #2a2b31;
  --text: #f3f3f5;
  --text-2: #b4b4bd;
  --muted: #82828c;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent: #8191ff;
  --accent-hover: #97a4ff;
  --accent-soft: rgba(129, 145, 255, 0.14);
  --accent-ink: #0d0e11;
  --ok: #4cc79a;
  --ok-soft: rgba(76, 199, 154, 0.13);
  --warn: #f0ae4c;
  --warn-soft: rgba(240, 174, 76, 0.13);
  --danger: #ff6b72;
  --danger-soft: rgba(255, 107, 114, 0.12);
  --mark: rgba(255, 196, 0, 0.28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px -10px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 20px 60px -10px rgba(0, 0, 0, 0.8);
  --topbar-bg: rgba(13, 14, 17, 0.8);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.icon { flex: none; display: block; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

#app { min-height: 100%; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  transition: transform 0.12s var(--ease), background-color 0.2s, opacity 0.2s, box-shadow 0.2s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.block { width: 100%; }
.btn.lg { min-height: 54px; font-size: 17px; border-radius: 16px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -8px var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.38; box-shadow: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text-2);
  transition: background-color 0.15s, transform 0.12s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.subtle { width: 34px; height: 34px; color: var(--muted); }

.link-btn { color: var(--accent); font-weight: 600; font-size: 15px; padding: 10px 14px; border-radius: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.demo { background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10.5px; }

/* ---------- Écrans d'accueil et de verrouillage ---------- */

.auth {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-inner {
  position: relative;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  animation: rise 0.45s var(--ease) both;
}
.auth-inner h1 {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-top: 10px;
}
.auth-inner .lead { color: var(--text-2); margin-top: 10px; font-size: 16px; }
.auth-back { margin: 0 0 6px -8px; }

.welcome { text-align: left; }
.welcome-head { display: flex; align-items: center; gap: 14px; padding-top: 4px; }
.welcome-head .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
.welcome-head .brand-mark .icon { width: 26px; height: 26px; }
.welcome-head h1 { font-size: 30px; margin: 0; }
.welcome .lead { margin-top: 18px; }
.brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #4b5cf0, #2532a8);
  box-shadow: 0 14px 30px -12px #3346d3, inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.feature-list { list-style: none; padding: 0; margin: 24px 0 20px; display: grid; gap: 12px; }
.feature-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-weight: 500;
}
.feature-list .icon { color: var(--accent); }
.welcome .install-card { margin-bottom: 24px; }
.welcome .btn { margin-top: auto; }

.step-dots { display: flex; gap: 6px; margin: 8px 0 18px; }
.step-dots span { width: 22px; height: 4px; border-radius: 4px; background: var(--surface-3); transition: background-color 0.3s; }
.step-dots span.on { background: var(--accent); }

.auth-form { display: grid; gap: 14px; margin-top: 28px; }

.pin-step { align-items: stretch; }
.pin-step.lock { align-items: center; text-align: center; padding-top: 5vh; }
.pin-step.lock .lead { margin-bottom: 6px; }
.pin-area { margin-top: 28px; display: flex; flex-direction: column; align-items: center; }
.pin-area.busy .keypad { opacity: 0.5; pointer-events: none; }
.pin-area.shake .pin-dots { animation: shake 0.42s var(--ease); }
.pin-dots { display: flex; gap: 18px; height: 22px; align-items: center; }
.pin-dots span {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s var(--ease);
}
.pin-dots span.on { background: var(--accent); border-color: var(--accent); transform: scale(1.12); }
.pin-error { min-height: 40px; padding-top: 10px; color: var(--danger); font-size: 14px; font-weight: 500; text-align: center; max-width: 300px; }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 26px; margin-top: 6px; transition: opacity 0.2s; }
.key {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  display: grid;
  place-items: center;
  transition: background-color 0.1s, transform 0.1s;
  user-select: none;
}
.key:active { background: var(--surface-3); transform: scale(0.94); }
.key-fn { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.lock .link-btn { margin-top: 22px; }

.avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #6c3fd8);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.avatar.xl { width: 72px; height: 72px; font-size: 24px; margin-bottom: 8px; box-shadow: var(--shadow-md); }

/* ---------- Coque ---------- */

.shell { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: calc(var(--safe-top) + 58px);
  padding: var(--safe-top) 16px 0;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar-back { margin-left: -10px; color: var(--accent); }
.topbar-title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.is-sub .topbar-title { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  transition: background-color 0.25s, color 0.25s;
}
.sync-pill.ok { color: var(--ok); background: var(--ok-soft); }
.sync-pill.pending { color: var(--accent); background: var(--accent-soft); }
.sync-pill.offline { color: var(--warn); background: var(--warn-soft); }
.sync-pill.busy .icon { animation: spin 0.9s linear infinite; }

.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
}
.is-sub .view { padding-bottom: calc(var(--safe-bottom) + 28px); }
/* « backwards » + retrait de la classe : un transform résiduel casserait le position:fixed du bouton flottant. */
.view.enter { animation: fade-in 0.28s var(--ease) backwards; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
  transition: transform 0.3s var(--ease);
}
.is-sub .tabbar { transform: translateY(110%); }
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.2s;
}
.tabbar a .icon { transition: transform 0.2s var(--ease); }
.tabbar a.active { color: var(--accent); }
.tabbar a.active .icon { transform: translateY(-1px) scale(1.06); }

/* ---------- Formulaires ---------- */

.screen-intro { color: var(--text-2); font-size: 15px; margin: 2px 4px 14px; }

.form { display: flex; flex-direction: column; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 6px 16px;
  margin-bottom: 14px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 12px 4px 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.optional, .req {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}
.req { color: var(--accent); }

.field { display: block; padding: 10px 0; }
.field + .field, .field + .multi, .multi + .field, .multi + .multi { border-top: 1px solid var(--border); }
.label { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }

.input, textarea {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  padding: 8px 0;
  resize: none;
  line-height: 1.45;
}
textarea { min-height: 2.6em; field-sizing: content; max-height: 40vh; }
.input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
.input.lg {
  padding: 15px 16px;
  font-size: 18px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input.lg:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input.invalid { color: var(--danger); }

.field.with-icon { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.field.with-icon.top { align-items: flex-start; }
.field.with-icon.top > .icon { margin-top: 12px; }
.field.with-icon > .icon { color: var(--muted); }
.field.with-icon:focus-within > .icon { color: var(--accent); }

.multi .field-error + .multi-row { border-top: 1px solid var(--border); }
.field-error { font-size: 13px; color: var(--danger); padding-left: 32px; margin-top: -2px; }
.field-error:not(:empty) { padding-bottom: 6px; }

.add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 0 12px 1px;
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
}

/* Consentement RGPD */
.consent-card { padding: 14px 16px 4px; transition: border-color 0.2s, box-shadow 0.2s; }
.consent-card.needed { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.consent { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; }
.consent input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  margin-top: 2px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background-color 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.22s var(--ease);
}
.consent input:checked + .switch { background: var(--ok); }
.consent input:checked + .switch::after { transform: translateX(20px); }
.consent input:focus-visible + .switch { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.consent-text { display: flex; flex-direction: column; gap: 2px; font-size: 14.5px; color: var(--text-2); }
.consent-text strong { display: flex; gap: 8px; align-items: baseline; color: var(--text); font-size: 15.5px; font-weight: 650; }
.consent.needed strong { color: var(--accent); }
.consent-note { font-size: 13px; color: var(--muted); margin: 12px 0 0 64px; }
.consent-sep { height: 1px; background: var(--border); margin: 14px 0 14px 64px; }
.consent-more { margin: 8px 0 0 64px; font-size: 14px; color: var(--text-2); }
.consent-more summary { color: var(--accent); font-weight: 600; cursor: pointer; padding: 6px 0 10px; list-style: none; }
.consent-more summary::-webkit-details-marker { display: none; }
.consent-more p { padding: 10px 12px; margin-bottom: 12px; border-radius: 12px; background: var(--surface-2); line-height: 1.5; }

.code-input { font-size: 26px !important; letter-spacing: 0.12em; font-weight: 600; padding: 4px 0 6px !important; }

.form-footer {
  position: sticky;
  bottom: 0;
  margin: 4px -16px 0;
  padding: 14px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  margin-bottom: calc(-1 * (var(--tabbar-h) + var(--safe-bottom) + 28px));
  background: linear-gradient(to bottom, transparent, var(--bg) 22px);
}
.is-sub .form-footer {
  padding-bottom: calc(var(--safe-bottom) + 14px);
  margin-bottom: calc(-1 * (var(--safe-bottom) + 28px));
}
.hint { color: var(--muted); font-size: 13.5px; text-align: center; margin-bottom: 10px; }

/* ---------- Liste des codes ---------- */

.codes-screen { position: relative; }

.search-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -16px -16px 0;
  padding: 12px 16px 10px;
  background: var(--bg);
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 8px 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); }

.filters {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline: -16px;
  padding-inline: 16px;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 36px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 6px 0 4px;
  padding: 11px 13px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
}
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner .icon { margin-top: 1px; }

.results-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); font-weight: 600; margin: 8px 4px 8px; min-height: 30px; }
.keep-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  transition: background-color 0.2s, color 0.2s, opacity 0.2s;
}
.keep-btn:disabled { opacity: 0.6; }
.keep-btn.done { background: var(--ok-soft); color: var(--ok); opacity: 1; }

.code-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.code-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px 12px;
  animation: rise 0.32s var(--ease) both;
}
.code-card.is-pending { border-style: dashed; border-color: var(--border-strong); }
.cc-head { display: flex; gap: 12px; align-items: flex-start; }
.cc-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}
.cc-titles { flex: 1; min-width: 0; }
.cc-titles h3 { font-size: 16.5px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.3; margin-top: 1px; overflow-wrap: anywhere; }
.cc-titles p { font-size: 14px; color: var(--text-2); margin-top: 1px; overflow-wrap: anywhere; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.cc-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 13px;
  background: var(--surface-2);
  text-align: left;
  transition: background-color 0.2s, transform 0.12s;
}
.cc-code:active { transform: scale(0.985); }
.cc-code .mono { font-size: 24px; font-weight: 650; letter-spacing: 0.14em; overflow-wrap: anywhere; }
.cc-copy {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s, color 0.2s;
}
.cc-code.copied { background: var(--ok-soft); }
.cc-code.copied .cc-copy { color: var(--ok); }

.cc-infos { display: flex; gap: 8px; margin-top: 10px; font-size: 14.5px; color: var(--text-2); }
.cc-infos .icon { margin-top: 2px; color: var(--muted); }
.cc-meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); font-weight: 500; }

.skeleton { animation: none; }
.sk { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-title { height: 18px; width: 55%; }
.sk-line { height: 14px; width: 38%; margin-top: 8px; }
.sk-code { height: 50px; margin-top: 14px; border-radius: 13px; }

.list-end { display: flex; justify-content: center; min-height: 20px; padding: 18px 0; }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }

.empty { text-align: center; padding: 34px 20px 10px; color: var(--muted); display: flex; flex-direction: column; align-items: center; max-width: 340px; margin: 0 auto; }
.empty > .icon { opacity: 0.6; margin-bottom: 14px; }
.empty h3 { color: var(--text); font-size: 18px; font-weight: 650; margin-bottom: 6px; }
.empty p { font-size: 14.5px; margin-bottom: 18px; }

.fab {
  position: fixed;
  right: max(16px, calc(50vw - 320px + 16px));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  padding: 0 20px 0 16px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  font-size: 15.5px;
  box-shadow: var(--shadow-lg), 0 10px 24px -10px var(--accent);
  transition: transform 0.15s var(--ease);
  animation: pop 0.4s 0.1s var(--ease) both;
}
.fab:active { transform: scale(0.95); }

/* ---------- Réglages ---------- */

.settings .card { padding: 0 16px; }
.profile-card { display: flex; align-items: center; gap: 14px; padding: 16px !important; }
.profile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.profile-text strong { font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
.profile-text span { font-size: 13.5px; color: var(--muted); }
.profile-edit { padding: 6px 16px 14px !important; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 0;
  text-align: left;
  font-size: 15.5px;
  color: var(--text);
}
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-row > .icon:last-child { color: var(--muted); }
.list-row.danger { color: var(--danger); }
.list-row.danger .row-icon { background: var(--danger-soft); color: var(--danger); }
.row-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); flex: none; }
.row-label { flex: 1; font-weight: 500; }
.row-label small { color: var(--muted); font-size: 14px; font-weight: 500; }
.row-value { color: var(--text-2); font-variant-numeric: tabular-nums; }
.row-action { color: var(--accent); font-weight: 600; font-size: 14.5px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--text-2); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.error-row { color: var(--danger); font-size: 13.5px; align-items: flex-start; }
.error-row .icon { margin-top: 2px; }
.list-row.static .btn { margin: 4px 0; }

.footnote { font-size: 13px; color: var(--muted); margin: -4px 6px 14px; }
.install-card { display: flex; gap: 12px; padding: 14px 16px !important; color: var(--text-2); font-size: 14px; }
.install-card > .icon { color: var(--accent); margin-top: 2px; }
.install-card p { margin-top: 4px; line-height: 1.55; }
.install-card p .icon { display: inline-block; vertical-align: -2px; color: var(--accent); }
.install-title { color: var(--text); font-size: 15px; font-weight: 650; }
.install-why { color: var(--muted); font-size: 13px; }
.install-btn { margin: 10px 0 6px; min-height: 42px; font-size: 15px; }
.about { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  padding: 12px 16px 12px 12px;
  border-radius: 18px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-16px) scale(0.97);
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none; background: rgba(127, 127, 127, 0.22); }
.toast-success .toast-icon { background: var(--ok); color: #fff; }
.toast-error .toast-icon { background: var(--danger); color: #fff; }
.toast-offline .toast-icon { background: var(--warn); color: #fff; }
.toast-text { display: flex; flex-direction: column; font-size: 15px; line-height: 1.3; min-width: 0; }
.toast-text strong { font-weight: 650; }
.toast-text span { opacity: 0.72; font-size: 13.5px; margin-top: 1px; }

/* ---------- Feuille de confirmation ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 10, 15, 0.42);
  opacity: 0;
  transition: opacity 0.25s;
}
.sheet-backdrop.show { opacity: 1; }
.sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 8px calc(var(--safe-bottom) + 8px);
  padding: 10px 20px 16px;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateY(40px);
  transition: transform 0.35s var(--ease);
}
.sheet-backdrop.show .sheet { transform: none; }
.sheet-grabber { width: 38px; height: 5px; border-radius: 5px; background: var(--surface-3); margin: 0 auto 16px; }
.sheet h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.sheet p { color: var(--text-2); margin-top: 8px; font-size: 15px; }
.sheet-actions { display: grid; gap: 6px; margin-top: 20px; }

/* ---------- Animations ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.8) translateY(10px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes shake {
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Petits écrans (iPhone SE…) */
@media (max-height: 680px) {
  .keypad { grid-template-columns: repeat(3, 66px); gap: 10px 22px; }
  .key { width: 66px; height: 66px; font-size: 26px; }
  .welcome { padding-top: 0; }
  .feature-list { margin: 16px 0 14px; gap: 10px; }
  .feature-list li { padding: 11px 14px; }
  .welcome .install-why { display: none; }
  .welcome .install-btn { margin: 8px 0 0; min-height: 40px; }
  .welcome .install-card { margin-bottom: 16px; }
  .welcome .lead { margin-top: 12px; }
}

@media (min-width: 700px) {
  .view { padding-top: 24px; }
}

/* ---------- Kit de poche ---------- */

.badge.muted { background: var(--surface-2); color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.qr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: transform 0.12s var(--ease);
}
.qr-card:active { transform: scale(0.97); }
.qr-img { display: block; width: 100%; max-width: 180px; aspect-ratio: 1; border-radius: 12px; overflow: hidden; margin-bottom: 8px; }
.qr-img svg, .qr-full-img svg { display: block; width: 100%; height: 100%; }
.qr-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 15px; }
.qr-title .icon { color: var(--accent); }
.qr-detail { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.qr-zoom {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 650;
}

.qr-full {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
  background: #fff;
  color: #111;
  opacity: 0;
  transition: opacity 0.22s;
}
.qr-full.show { opacity: 1; }
.qr-full-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; width: 100%; }
.qr-full-img { width: min(84vw, 62vh, 460px); aspect-ratio: 1; margin-bottom: 18px; }
.qr-full strong { font-size: 24px; letter-spacing: -0.02em; }
.qr-full span { font-size: 16px; color: #555; overflow-wrap: anywhere; }
.qr-full small { margin-top: 26px; color: #888; font-size: 13px; }

.table-card { padding: 0 !important; overflow: hidden; }
.kit-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.kit-table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.kit-table tbody th, .kit-table td { padding: 14px 16px; text-align: left; vertical-align: middle; }
.kit-table tbody tr + tr > * { border-top: 1px solid var(--border); }
.kit-table tbody th { font-weight: 600; white-space: nowrap; }
.kit-table tbody th .icon { display: inline-block; vertical-align: -4px; margin-right: 8px; color: var(--accent); }
.kit-table td { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.kit-date { text-transform: capitalize; }
