/* ============================================================
   Maison — design mobile. Métaphore : un classeur familial à
   onglets colorés. Fond "brume" (oat-green) plutôt que crème,
   encre profonde pour le texte, ambre marigold pour les actions.
   ============================================================ */
:root {
  --encre: #22303a;
  --brume: #e9ede6;
  --craie: #fbfcf9;
  --ambre: #d0862a;
  --ambre-d: #b6711f;
  --sauge: #6f8c74;
  --brique: #bd5138;
  --muted: #6a7680;
  --line: #dde3db;
  --shadow: 0 1px 2px rgba(34,48,58,.06), 0 4px 16px rgba(34,48,58,.06);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -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 {
  font-family: var(--font);
  background: var(--brume);
  color: var(--encre);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); font-size: .82rem; }
.brique { color: var(--brique) !important; }
.spacer { flex: 1; }

/* ---------- Splash ---------- */
.splash { height: 100vh; display: grid; place-items: center; background: var(--encre); color: var(--craie); }
.brand-mark { font-size: 2rem; }

/* ---------- Boutons ---------- */
.btn { border: none; border-radius: 12px; padding: 12px 16px; font-size: .95rem; font-weight: 600; background: #e4e8e1; color: var(--encre); transition: transform .06s ease, filter .15s ease; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ambre); color: #fff; }
.btn-primary:active { background: var(--ambre-d); }
.btn-soft { background: #eef1ec; color: var(--encre); border: 1px solid var(--line); }
.btn-danger { background: #f6e4e0; color: var(--brique); }
.btn-link { background: none; color: var(--ambre-d); font-weight: 600; padding: 10px; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-sm { padding: 8px 12px; font-size: .85rem; margin-top: 8px; }
.icon-btn { background: none; border: none; font-size: 1.4rem; color: var(--encre); padding: 4px 10px; line-height: 1; }
.chip { border: 1px solid var(--line); background: var(--craie); color: var(--ambre-d); border-radius: 999px; padding: 4px 10px; font-size: .74rem; font-weight: 600; }
.chip.ghost { color: var(--muted); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--craie); border-radius: 20px; box-shadow: var(--shadow); padding: 28px 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.5rem; font-weight: 700; }
.brand .brand-mark { display: grid; place-items: center; width: 40px; height: 40px; background: var(--encre); color: var(--craie); border-radius: 12px; font-size: 1.2rem; }
.auth-sub { color: var(--muted); margin: 6px 0 20px; }
.fld { display: block; margin-bottom: 14px; }
.fld > span { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.fld input, .fld textarea, .fld select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  font-size: 1rem; font-family: inherit; background: var(--craie); color: var(--encre);
}
.fld input:focus, .fld textarea:focus, .fld select:focus { outline: 2px solid var(--ambre); border-color: transparent; }
.fld-inline { display: flex; align-items: center; gap: 10px; }
.fld-inline > span { margin: 0; text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--encre); }
.fld-inline input { width: auto; }
.fld input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ambre); }

/* ---------- Verrou PIN ---------- */
.lock { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; background: var(--encre); color: var(--craie); }
.brand-lock .brand-mark { background: var(--craie); color: var(--encre); }
.lock-hi { color: #b9c4cb; margin: 4px 0; }
.lock-err { color: #f0a999; height: 18px; font-size: .85rem; }
.pin-dots { display: flex; gap: 14px; margin: 8px 0 6px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #7e8c94; }
.dot.on { background: var(--craie); border-color: var(--craie); }
.pinpad { display: grid; grid-template-columns: repeat(3, 74px); gap: 14px; margin-top: 10px; }
.key { width: 74px; height: 74px; border-radius: 50%; border: 1px solid #3a4a54; background: #2c3b45; color: var(--craie); font-size: 1.5rem; }
.key:active { background: #384854; }
.bio-btn { color: #cdd6db; margin-top: 6px; }

/* ---------- Coquille ---------- */
.shell { min-height: 100vh; padding-bottom: calc(72px + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--brume); padding-top: var(--safe-t); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 8px; }
.topbar .title { font-size: 1.25rem; flex: 1; }
.content { padding: 14px; max-width: 640px; margin: 0 auto; }

/* ---------- Barre d'onglets + FAB ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: center;
  background: var(--craie); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); height: calc(60px + var(--safe-b));
}
.tab { background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .66rem; padding: 6px 10px; flex: 1; }
.tab-icon { font-size: 1.25rem; }
.tab.active { color: var(--ambre-d); }
.fab {
  position: fixed; right: 18px; bottom: calc(74px + var(--safe-b)); z-index: 45;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--ambre); color: #fff; font-size: 1.8rem; line-height: 1;
  box-shadow: 0 6px 18px rgba(180,113,31,.4); display: flex; align-items: center; justify-content: center;
}
.fab:active { background: var(--ambre-d); }

/* ---------- Cartes ---------- */
.card { position: relative; background: var(--craie); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tab-strip { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; }
.card-body { padding: 14px 14px 14px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-head h2 { font-size: 1rem; }
.card-go { color: var(--muted); font-size: 1.3rem; }
.card-lines { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.dash { display: flex; flex-direction: column; gap: 12px; }
.dash-line { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.dash-line span:first-child { flex: 1; }
.dash-line em { font-style: normal; }
.dash-line input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--sauge); }

/* ---------- Listes ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row-card .card-body { padding: 12px 12px 12px 18px; }
.row-body { display: flex; align-items: center; gap: 12px; }
.rc-check { width: 24px; height: 24px; accent-color: var(--sauge); flex-shrink: 0; }
.rc-main { flex: 1; min-width: 0; }
.rc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-sub { margin-top: 2px; }
.rc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.row-card.done .rc-title { text-decoration: line-through; color: var(--muted); }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }

/* ---------- Vide ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-icon { font-size: 2.6rem; }

/* ---------- Sheet (formulaire) ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(34,48,58,.4); display: flex; align-items: flex-end; opacity: 0; transition: opacity .2s ease; }
.sheet-wrap.open { opacity: 1; }
.sheet {
  width: 100%; max-height: 92vh; background: var(--brume);
  border-radius: 22px 22px 0 0; transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; padding-bottom: var(--safe-b);
}
.sheet-wrap.open .sheet { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; background: var(--line); border-radius: 2px; margin: 10px auto 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 10px; }
.sheet-head h2 { font-size: 1.1rem; }
.sheet-body { overflow-y: auto; padding: 4px 16px 12px; }
.sheet-actions { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--craie); }
.sheet-actions .btn { flex: 1; }
.sheet-actions > span { flex: 1; }

/* ---------- Check-lists éditables ---------- */
.checklines { display: flex; flex-direction: column; gap: 8px; }
.cl-row { display: flex; align-items: center; gap: 8px; }
.cl-row input[type="text"] { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: .95rem; background: var(--craie); }
.cl-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--sauge); }

/* ---------- Pièces jointes ---------- */
.att-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.att-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.att-file { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--craie); font-size: .85rem; text-decoration: none; color: var(--encre); }
.att-add { width: 72px; height: 72px; border-radius: 10px; border: 1.5px dashed var(--line); background: var(--craie); font-size: 1.6rem; color: var(--muted); }

/* ---------- Grille "Plus" ---------- */
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.more-tile { background: var(--craie); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; color: var(--encre); }
.more-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 1.4rem; background: #eef1ec; }
.section-h { margin: 20px 4px 10px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- Recherche ---------- */
.search-wrap { margin-bottom: 14px; }
.search-input { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 14px; font-size: 1rem; background: var(--craie); }
.search-input:focus { outline: 2px solid var(--ambre); }

/* ---------- Réglages ---------- */
.settings { display: flex; flex-direction: column; gap: 12px; }
.set-title { font-weight: 600; margin-bottom: 2px; }

/* ---------- Scan ---------- */
.scan { position: fixed; inset: 0; z-index: 80; background: #000; display: flex; align-items: center; justify-content: center; }
.scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; width: 72%; max-width: 320px; aspect-ratio: 3/2; border: 3px solid rgba(255,255,255,.85); border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan-cancel { position: absolute; bottom: calc(28px + var(--safe-b)); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 90; background: var(--encre); color: var(--craie); padding: 12px 18px; border-radius: 12px; font-size: .9rem; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s ease, transform .25s ease; max-width: 88%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--brique); }
.toast-warn { background: var(--ambre-d); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (min-width: 720px) {
  .tabbar { max-width: 640px; margin: 0 auto; border-radius: 16px 16px 0 0; border: 1px solid var(--line); }
}
