/* ════════════════════════════════════════════════════════════════════════
   Cairn Life — mobile layer (additive; loaded after app.css)
   Mobile spec: P0 responsive + tab bar; P1 quick-ref/biometric; P2 capture;
   P3 devices/sync. Desktop (>1024px) is untouched — every rule is gated by a
   max-width media query or a .cl-* class only used on mobile screens.
   ════════════════════════════════════════════════════════════════════════ */

/* Always neutralise the old desktop-only overlay (markup also removed). */
#mobile-warning { display: none !important; }

/* Cairn line-icons (replacing emoji) — colour + alignment in their containers */
.cl-emoji svg, .cl-doorico svg, .cl-call svg, .cl-emerg h3 svg { display: block; }
.cl-secrow .cl-emoji { color: var(--forest, #365D49); }   /* LifeBook = forest */
.cl-doorico { color: var(--forest, #365D49); }             /* core/system = forest */
/* Help / feedback / automations (scan, upload, talk, connect) = standout support blue */
.cl-door.cl-support .cl-doorico { color: var(--support, #3B5BDB); }

/* CSS vars reused from app.css: --forest --clay --sage --plan-bg etc.
   Fallbacks here so the mobile layer renders even if a var is missing. */
:root {
  --cl-tabbar-h: 64px;
  --cl-safe-bottom: env(safe-area-inset-bottom, 0px);
  --cl-safe-top: env(safe-area-inset-top, 0px);
}

/* ── Mobile chrome elements are hidden on desktop by default ─────────────── */
/* #cl-nav (bottom tab bar) + #cl-top (context switcher) are the live ids;
   #cl-tabbar is the legacy id kept for safety. All are mobile-only. */
#cl-tabbar, #cl-nav, #cl-top, #cl-lock, .cl-only-mobile { display: none; }

/* ════════════════════════ PHONE  (≤ 600px) ════════════════════════ */
@media (max-width: 600px) {

  html, body { font-size: 15px; }

  /* Mobile dashboard: drop the progress widget (the squares/pill live on the LifeBook) */
  .hm-prog, .clh-pcard { display: none !important; }

  /* Hide the desktop sidebar; content goes full-width with room for the tab bar */
  #sidebar { display: none !important; }
  /* Only force the app visible once signed in (body.cl-authed set by boot) —
     otherwise the app content shows alongside the sign-in screen when logged out */
  body.cl-authed #main-screen { display: block !important; }
  body:not(.cl-authed) #main-screen { display: none !important; }
  #content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: calc(14px + var(--cl-safe-top)) 16px calc(var(--cl-tabbar-h) + var(--cl-safe-bottom) + 20px) 16px !important;
    min-height: 100vh;
    box-sizing: border-box;
  }

  /* Auth: just the sign-in card, centred — no marketing wall on phones */
  #auth-screen { flex-direction: column !important; height: auto !important; min-height: 100vh; }
  .auth-marketing { display: none !important; }            /* skip the big marketing wall on phones */
  .auth-form-panel { width: 100% !important; min-height: 100vh; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: calc(var(--cl-safe-top) + 28px) 18px calc(var(--cl-safe-bottom) + 28px) !important; }
  .auth-mobile-intro { display: block; width: 100%; max-width: 420px; margin: 0 auto 22px; }
  .auth-mobile-intro .ami-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
  .auth-mobile-intro .ami-brand img { width: 30px; height: 30px; border-radius: 7px; }
  .auth-mobile-intro .ami-brand span { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 20px; color: var(--black); }
  .auth-mobile-intro .ami-beta { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--estate-accent-dark); background: var(--estate-accent-light); border: 1px solid var(--estate-accent-mid); border-radius: 999px; padding: 1px 7px; }
  .auth-mobile-intro .ami-title { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 26px; line-height: 1.15; margin: 0 0 10px; color: var(--black); }
  .auth-mobile-intro .ami-sub { font-size: 15px; line-height: 1.5; color: var(--grey-600, #555); margin: 0 0 18px; }
  .auth-mobile-intro .ami-usps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 11px; }
  .auth-mobile-intro .ami-usps li { display: flex; align-items: center; gap: 11px; font-size: 14px; color: var(--black); }
  .auth-mobile-intro .ami-usps svg { color: var(--teal, #365D49); flex: none; }
  .auth-box { width: 100%; max-width: 420px !important; margin: 0 auto; }
  .auth-box { max-width: 100% !important; }
  .auth-cols { flex-direction: column !important; }

  /* Make tap targets and inputs finger-friendly; 16px inputs prevent iOS zoom */
  .form-input, input, select, textarea { font-size: 16px !important; min-height: 46px; }
  textarea { min-height: 92px; }
  .btn, button.btn { min-height: 46px; }
  a, button { -webkit-tap-highlight-color: rgba(54,93,73,.12); }

  /* Cards / grids collapse to a single column */
  .card { width: 100% !important; }
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .lp-grid, .field-grid, .two-col { grid-template-columns: 1fr !important; display: block !important; }

  /* Modals become near-full-screen sheets */
  .modal { max-width: 94vw !important; width: 94vw !important; margin: 0 auto; }

  /* Feedback panel: truly centred, capped height, clears the tab bar */
  #fb-fab { bottom: calc(var(--cl-tabbar-h) + var(--cl-safe-bottom) + 12px) !important; }
  #fb-panel {
    bottom: calc(var(--cl-tabbar-h) + var(--cl-safe-bottom) + 12px) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: min(460px, calc(100vw - 16px)) !important;
    max-height: calc(100vh - var(--cl-tabbar-h) - var(--cl-safe-bottom) - 80px) !important;
    overflow-y: auto !important;
  }

  /* ── Bottom tab bar ──────────────────────────────────────────────────── */
  #cl-tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 800;
    height: calc(var(--cl-tabbar-h) + var(--cl-safe-bottom));
    padding-bottom: var(--cl-safe-bottom);
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border, #E0E0E0);
  }
  .cl-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--grey-400, #999);
    background: none; border: none; cursor: pointer; padding: 6px 0;
  }
  .cl-tab svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.9; }
  .cl-tab.on { color: var(--forest, #365D49); }
  .cl-tab.on.cl-estate { color: var(--clay, #F0631F); }

  /* Mobile-only blocks become visible */
  .cl-only-mobile { display: block; }

  /* extra top room so the fixed avatar doesn't sit on the page title */
  #content { padding-top: calc(56px + var(--cl-safe-top)) !important; }
  /* Opaque cover across the very top so scrolled content never shows behind the pill or the sticky tabs */
  #main-screen::before { content:''; position:fixed; top:0; left:0; right:0; height:calc(56px + var(--cl-safe-top)); background:var(--cream,#F5F0EB); z-index:25; pointer-events:none; }
  /* Tab pills scroll away with the page on mobile (not pinned) — consistent with the title */
  .page-tabs { position: static !important; }
}

/* ════════════════ POCKET CHROME — top avatar + bottom nav (≤600px) ════════════════ */
@media (max-width: 600px) {

  /* Top-left context switcher (which plan/estate) */
  #cl-top {
    position: fixed; top: calc(8px + var(--cl-safe-top)); left: 14px; right: auto; z-index: 820;
    display: flex;
  }
  .cl-ctx {
    display: inline-flex; align-items: center; gap: 7px; background: #E7EEEA; color: var(--forest,#365D49);
    border: none; border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
  }
  .cl-ctx.estate { background: #FBEDE4; color: var(--clay,#C2410C); }
  .cl-ctx-ico { display: inline-flex; }
  .cl-ctx-ico svg { width: 16px; height: 16px; }
  .cl-ctx-chev { opacity: .7; }
  .cl-avatar {
    width: 40px; height: 40px; border-radius: 50%; background: var(--forest,#365D49); color: #fff;
    font-weight: 700; font-size: 14px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15);
  }

  /* Bottom nav with a raised central Add button */
  #cl-nav {
    display: flex; align-items: center; justify-content: space-around;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 800;
    height: calc(var(--cl-tabbar-h) + var(--cl-safe-bottom));
    padding-bottom: var(--cl-safe-bottom);
    background: #062922; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,.08);
  }
  .cl-navi {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 600; color: #8fa394; background: none; border: none;
  }
  .cl-navi svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.9; }
  .cl-navi.on { color: #fff; }
  #cl-nav.estate .cl-navi.on { color: var(--clay,#F0631F); }

  .cl-add {
    flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%;
    background: var(--forest,#365D49); color: #fff; border: 4px solid #062922;
    margin-top: -22px; box-shadow: 0 6px 16px rgba(54,93,73,.4);
    display: flex; align-items: center; justify-content: center;
  }
  .cl-add svg { width: 26px; height: 26px; stroke: #fff; fill: none; stroke-width: 2.4; }
  .cl-add:active { transform: scale(.94); }
  .cl-add.cl-add-estate { background: var(--clay,#F0631F); box-shadow: 0 6px 16px rgba(240,99,31,.4); }

  /* Feedback launcher must clear the bottom nav bar */
  #hf-launcher { bottom: calc(var(--cl-tabbar-h) + var(--cl-safe-bottom) + 14px) !important; right: 14px !important; }

  /* Compact icon-only Feedback button on phones (per handoff) */
  #hf-toggle { padding: 0 !important; width: 46px; height: 46px; border-radius: 50% !important; gap: 0 !important; justify-content: center; }
  #hf-toggle > span:not(#hf-dot) { display: none !important; }
  #hf-toggle > svg { width: 20px; height: 20px; }
}

/* ════════════════ ADD / Me SHEET (bottom sheet) ════════════════ */
.cl-sheet-bg { position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,.4);
  display: none; align-items: flex-end; }
.cl-sheet-bg.show { display: flex; }
.cl-sheet { background: var(--cream,#F5F0EB); width: 100%; border-radius: 22px 22px 0 0;
  padding: 0 16px calc(20px + var(--cl-safe-bottom)); max-height: 86%; overflow-y: auto;
  animation: cl-up .28s ease; }
@keyframes cl-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.cl-grab { width: 38px; height: 5px; background: var(--grey-300,#ccc); border-radius: 3px; margin: 10px auto 4px; }
.cl-sheet-h { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 12px;
  font-size: 17px; font-weight: 700; }
.cl-sheet-h .cl-x { font-size: 22px; color: var(--grey-500,#767676); background: none; border: none; }
.cl-door { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--border,#E0E0E0); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.cl-door:active { background: var(--grey-100,#f5f5f5); }
.cl-doorico { width: 42px; height: 42px; border-radius: 11px; background: var(--plan-bg,#E7EEEA);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.cl-door b { font-size: 15px; display: block; color: var(--black,#1A1A1A); }
.cl-door i { font-size: 12px; color: var(--grey-500,#767676); font-style: normal; }
.cl-door .cl-cost { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--support,#3B5BDB);
  background: var(--support-light,#EDF2FF); padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.cl-door .cl-cost.free { color: var(--forest,#365D49); background: var(--plan-bg,#E7EEEA); }
.cl-door .cl-chev { margin-left: auto; color: var(--grey-300,#ccc); font-size: 20px; }

/* secrow inner column + ring + chevron (shared) */
.cl-secmid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cl-secrow .cl-chev { margin-left: auto; color: var(--grey-300,#ccc); font-size: 20px; }
.cl-ring { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; position: relative; }
.cl-ring::after { content: ''; position: absolute; inset: 7px; background: #fff; border-radius: 50%; }
.cl-ring span { position: relative; z-index: 1; font-size: 16px; font-weight: 700; color: var(--support,#3B5BDB); }

/* ════════════════ MULTI-PAGE SCANNER ════════════════ */
#cl-mp { position: fixed; inset: 0; z-index: 1200; background: #0b0b0b; display: none;
  flex-direction: column; color: #fff; }
#cl-mp.show { display: flex; }
#cl-mp .cl-mp-top { display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--cl-safe-top)) 18px 10px; font-size: 14px; }
#cl-mp .cl-x { font-size: 24px; background: none; border: none; color: #fff; }
#cl-mp .cl-mp-stage { flex: 1; position: relative; display: flex; overflow: hidden; }
#cl-mp video { flex: 1; width: 100%; object-fit: cover; background: #1c1c1c; }
#cl-mp .cl-cam-frame { position: absolute; inset: 8% 8%; border: 2.5px solid var(--clay,#F0631F);
  border-radius: 12px; pointer-events: none; }
#cl-mp .cl-mp-hint { text-align: center; font-size: 13px; opacity: .85; padding: 8px; }
#cl-mp .cl-mp-film { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px; min-height: 56px; }
#cl-mp .cl-thumb { width: 42px; height: 54px; border-radius: 5px; background-size: cover; background-position: center;
  flex-shrink: 0; position: relative; border: 1px solid rgba(255,255,255,.3); }
#cl-mp .cl-thumb span { position: absolute; bottom: -2px; right: -2px; background: var(--clay,#F0631F); color: #fff;
  font-size: 9px; font-weight: 700; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
#cl-mp .cl-mp-bar { display: flex; align-items: center; justify-content: center; gap: 24px;
  padding: 8px 0 calc(24px + var(--cl-safe-bottom)); }
#cl-mp .cl-shutter { width: 66px; height: 66px; border-radius: 50%; background: #fff;
  border: 5px solid rgba(255,255,255,.4); }
#cl-mp .cl-shutter:active { transform: scale(.93); }
#cl-mp .cl-mp-done { background: var(--forest,#365D49); color: #fff; border: none; border-radius: 99px;
  padding: 13px 22px; font-size: 14px; font-weight: 700; }
#cl-mp .cl-mp-done:disabled { opacity: .4; }

/* Tablet (601–1024): keep desktop sidebar but tighten content padding */
@media (min-width: 601px) and (max-width: 1024px) {
  /* Bottom inset clears the floating Help & feedback launcher so Save / Next
     are never hidden underneath it (matches the desktop rule in app.css). */
  #content { padding: calc(52px + var(--cl-safe-top)) 20px 110px !important; }
}

/* ════════════════════ MOBILE COMPONENTS (class-scoped) ════════════════════
   These render inside #content on phones; safe on desktop because the elements
   are only injected by mobile.js when a phone viewport is detected. */

.cl-addbtn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--forest,#365D49); color: #fff; border: none; border-radius: 12px; padding: 13px;
  font-size: 14px; font-weight: 600; margin-bottom: 16px; box-shadow: 0 3px 10px rgba(54,93,73,.28); }
.cl-addbtn svg { stroke: #fff; fill: none; }
.cl-addbtn:active { transform: scale(.99); }
.cl-intro-h { font-size: 18px; font-weight: 700; color: var(--black,#1A1A1A); padding: 4px 4px 2px; }
.cl-intro-sub { font-size: 13px; color: var(--grey-500,#767676); padding: 0 4px 12px; }
.cl-advice-btn { display: inline-flex; align-items: center; margin-top: 12px; background: var(--support,#3B5BDB);
  color: #fff; border: none; border-radius: 10px; padding: 10px 15px; font-size: 13px; font-weight: 600; }
.cl-advice-btn:active { transform: scale(.99); }
/* Pill-shaped to match the Call/Add pills it sits above (Emergency card) —
   white/outline so it reads as the secondary action next to the orange ones. */
.cl-edit-btn { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; background: #fff;
  color: var(--forest,#365D49); border: 1px solid var(--border,#E0E0E0); border-radius: 999px;
  padding: 8px 15px; font-size: 13px; font-weight: 600; margin-top: 4px; }
.cl-edit-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.cl-h { font-family: 'Playfair Display', Georgia, serif; font-size: 24px; font-weight: 600; letter-spacing: 0; color: #244033; margin: 2px 0 2px; }
.cl-sub { font-size: 13px; color: var(--grey-500,#767676); margin-bottom: 16px; }

/* Handoff banner */
.cl-handoff {
  display: flex; align-items: center; gap: 12px; background: #fff;
  border: 1px solid var(--border,#E0E0E0); border-radius: 14px; padding: 13px;
  margin-bottom: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.05);
}
.cl-handoff .cl-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--plan-bg,#E7EEEA);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cl-handoff .cl-ic svg { width: 21px; height: 21px; stroke: var(--forest,#365D49); fill: none; stroke-width: 1.8; }
.cl-handoff .cl-t1 { font-size: 13.5px; font-weight: 600; color: var(--black,#1A1A1A); }
.cl-handoff .cl-t2 { font-size: 12px; color: var(--grey-500,#767676); }
.cl-handoff .cl-go { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--clay,#F0631F); }

/* Emergency quick-reference card */
.cl-emerg { background: linear-gradient(135deg,#365D49,#244033); color: #fff; border-radius: 18px;
  padding: 18px; margin-bottom: 16px; }
.cl-emerg h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cl-emerg .cl-emerg-sub { font-size: 12px; opacity: .85; margin: 3px 0 14px; }
.cl-erow { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid rgba(255,255,255,.16); }
.cl-erow .cl-elabel { font-size: 11px; opacity: .8; }
.cl-erow .cl-eval { font-size: 15px; font-weight: 600; }
.cl-erow .cl-call { margin-left: auto; background: var(--clay,#F0631F); color: #fff; border: none;
  border-radius: 99px; padding: 9px 15px; font-size: 13px; font-weight: 700; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; }
.cl-erow .cl-call.cl-muted { background: rgba(255,255,255,.16); }
/* "Add" affordance for an empty emergency slot — opens the single Emergency update panel */
.cl-eadd { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; background: var(--clay,#F0631F); color: #fff; border: none; border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.cl-eadd svg { display: block; }
.cl-erow .cl-eval.cl-emuted { opacity: .5; font-weight: 500; }
.cl-emerg-empty { font-size: 13px; opacity: .9; line-height: 1.5; }

/* Generic mobile card + list rows */
.cl-card { background: #fff; border: 1px solid var(--border,#E0E0E0); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.cl-secrow { display: flex; align-items: center; gap: 13px; background: #fff; border: 1px solid var(--border,#E0E0E0);
  border-radius: 14px; padding: 13px; margin-bottom: 9px; width: 100%; text-align: left; cursor: pointer; }
.cl-secrow:active { background: var(--grey-100,#F5F5F5); }
.cl-secrow .cl-emoji { width: 42px; height: 42px; border-radius: 11px; background: var(--plan-bg,#E7EEEA);
  display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.cl-secrow .cl-nm { font-size: 14.5px; font-weight: 600; color: var(--black,#1A1A1A); }
.cl-secrow .cl-ds { font-size: 12px; color: var(--grey-500,#767676); }
.cl-badge { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.cl-badge.done { background: var(--support-light,#EDF2FF); color: var(--support,#3B5BDB); } /* progress/done = Support Blue */
.cl-badge.part { background: #FFF4E0; color: #B27300; }
.cl-badge.todo { background: var(--grey-100,#F5F5F5); color: var(--grey-500,#767676); }

/* Progress ring card */
.cl-progress { display: flex; align-items: center; gap: 16px; background: #fff;
  border: 1px solid var(--border,#E0E0E0); border-radius: 16px; padding: 16px; margin-bottom: 16px; }
.cl-progress .cl-pct { font-size: 13px; color: var(--grey-600,#555); }
.cl-progress .cl-pct b { color: var(--forest,#365D49); }

/* Section group label */
.cl-grouplabel { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--grey-500,#767676); margin: 8px 2px 10px; }

/* Primary mobile button */
.cl-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--forest,#365D49); color: #fff; font-weight: 600; font-size: 15px;
  padding: 14px; border-radius: 13px; border: none; cursor: pointer; }
.cl-btn:active { background: var(--forest-d,#244033); }
.cl-btn.ghost { background: #fff; color: var(--forest,#365D49); border: 1.5px solid var(--border,#E0E0E0); }
.cl-btn.clay { background: var(--clay,#F0631F); }

/* Device rows */
.cl-device { display: flex; align-items: center; gap: 14px; background: #fff;
  border: 1px solid var(--border,#E0E0E0); border-radius: 14px; padding: 15px; margin-bottom: 11px; }
.cl-device.this { border-color: var(--forest,#365D49); background: #fbfcfb; }
.cl-device .cl-di { width: 46px; height: 46px; border-radius: 12px; background: var(--plan-bg,#E7EEEA);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cl-device .cl-di svg { width: 25px; height: 25px; stroke: var(--forest,#365D49); fill: none; stroke-width: 1.7; }
.cl-device .cl-dnm { font-size: 14.5px; font-weight: 600; color: var(--black,#1A1A1A); }
.cl-device .cl-dmeta { font-size: 12px; color: var(--grey-500,#767676); }
.cl-syncpill { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 11px;
  font-weight: 600; color: var(--forest,#365D49); background: var(--plan-bg,#E7EEEA); padding: 5px 10px; border-radius: 99px; }
.cl-syncpill .cl-dot { width: 7px; height: 7px; border-radius: 50%; background: #2e9e5b; }

/* QR */
.cl-qr { width: 160px; height: 160px; margin: 4px auto 0; background: #fff; border: 1px solid var(--border,#E0E0E0);
  border-radius: 16px; padding: 12px; }
.cl-qr svg { width: 100%; height: 100%; }

/* Capability pill (feature detection result) */
.cl-cap { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  padding: 4px 9px; border-radius: 99px; margin: 0 6px 6px 0; }
.cl-cap.ok { background: var(--plan-bg,#E7EEEA); color: var(--forest,#365D49); }
.cl-cap.no { background: #FFF4E0; color: #B27300; }

/* ── Camera scan overlay ─────────────────────────────────────────────────── */
#cl-cam { position: fixed; inset: 0; z-index: 1200; background: #0b0b0b; display: none;
  flex-direction: column; color: #fff; }
#cl-cam.show { display: flex; }
#cl-cam .cl-cam-top { display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--cl-safe-top)) 18px 10px; font-size: 15px; }
#cl-cam .cl-cam-x { font-size: 26px; background: none; border: none; color: #fff; }
#cl-cam video, #cl-cam .cl-cam-mock { flex: 1; width: 100%; object-fit: cover; background: #1c1c1c; }
#cl-cam .cl-cam-frame { position: absolute; inset: 22% 10% auto 10%; height: 46%;
  border: 2.5px solid var(--clay,#F0631F); border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
#cl-cam .cl-cam-hint { text-align: center; font-size: 13px; opacity: .85; padding: 10px; }
#cl-cam .cl-shutter { width: 68px; height: 68px; border-radius: 50%; background: #fff;
  border: 5px solid rgba(255,255,255,.4); margin: 4px auto calc(24px + var(--cl-safe-bottom)); display: block; }

/* ── Biometric lock overlay ──────────────────────────────────────────────── */
#cl-lock { position: fixed; inset: 0; z-index: 1300; background: radial-gradient(900px 700px at 50% 0%,#0e4135,#062922 70%);
  color: #fff; text-align: center; padding: 0 36px; flex-direction: column; align-items: center; justify-content: center; }
#cl-lock.show { display: flex; }
#cl-lock .cl-stones { display: flex; flex-direction: column; align-items: center; gap: 5px; margin-bottom: 26px; }
#cl-lock .cl-stone { border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%; }
#cl-lock .s1 { width: 64px; height: 26px; background: var(--clay,#F0631F); }
#cl-lock .s2 { width: 84px; height: 30px; background: var(--sage,#859E84); }
#cl-lock .s3 { width: 106px; height: 36px; background: var(--forest,#365D49); filter: brightness(1.4); }
#cl-lock h2 { font-size: 22px; font-weight: 700; }
#cl-lock .cl-locklogo { width: 200px; max-width: 60%; height: auto; border-radius: 16px; margin-bottom: 22px; }
#cl-lock p { font-size: 13px; opacity: .8; margin-top: 6px; }
#cl-lock .cl-faceid { width: 76px; height: 76px; border-radius: 20px; border: 2.5px solid rgba(255,255,255,.5);
  display: flex; align-items: center; justify-content: center; margin: 30px auto 12px; background: none; transition: .3s; }
#cl-lock .cl-faceid svg { width: 40px; height: 40px; stroke: #fff; fill: none; stroke-width: 2; }
#cl-lock .cl-faceid.scanning { border-color: var(--clay,#F0631F); box-shadow: 0 0 28px rgba(240,99,31,.5); }
#cl-lock .cl-lockstatus { font-size: 13px; opacity: .9; min-height: 18px; }
#cl-lock .cl-pwlink { margin-top: 18px; font-size: 13px; color: #cfe0d7; text-decoration: underline; background: none; border: none; }

/* Voice */
.cl-mic { width: 88px; height: 88px; border-radius: 50%; background: var(--clay,#F0631F); display: flex;
  align-items: center; justify-content: center; margin: 6px auto; border: none; }
.cl-mic svg { width: 38px; height: 38px; }
.cl-mic.live { animation: cl-pulse 1.4s infinite; }
@keyframes cl-pulse { 0% { box-shadow: 0 0 0 0 rgba(240,99,31,.45); } 70% { box-shadow: 0 0 0 24px rgba(240,99,31,0); } 100% { box-shadow: 0 0 0 0 rgba(240,99,31,0); } }
.cl-transcript { background: #fff; border: 1px solid var(--border,#E0E0E0); border-radius: 13px; padding: 15px;
  font-size: 15px; line-height: 1.55; color: var(--grey-700,#444); min-height: 90px; margin: 14px 0; }

@media (prefers-reduced-motion: reduce) {
  .cl-mic.live { animation: none; }
}

/* ════════════════ LIFEBOOK EDITOR — mobile cleanup (≤600px) ════════════════
   The existing wizard/editor (lifebook.js) is built for a 4-column desktop grid.
   On phones the old rules only dropped to 2 columns, leaving fields cramped and
   the nav row awkward. These overrides give a clean single-column edit screen.
   Loaded after app.css, so equal-specificity selectors win without !important
   where possible; a few use !important to beat the app's own @media(768px). */
@media (max-width: 600px) {

  /* One field per row — collapse every span and the repeater sub-grids */
  .field-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .field-grid .span-1,
  .field-grid .span-2,
  .field-grid .span-3,
  .field-grid .span-4,
  .field-grid .full { grid-column: 1 / -1 !important; }
  .repeater-card .field-grid { gap: 12px !important; }

  /* Editor card: lighter padding, smaller chrome, room for the tab bar */
  .wizard-card { padding: 18px 16px !important; border-radius: 14px; border-left-width: 3px; }
  .wizard-card-icon { margin-bottom: 6px; }
  .wizard-card-icon svg { width: 24px; height: 24px; }
  .wizard-section-title { font-size: 19px !important; line-height: 1.25; }
  .wizard-section-subtitle { font-size: 13px; }

  /* Labels / inputs: comfortable, no iOS zoom */
  .form-label { font-size: 13px; }
  .form-input, .form-select, .form-textarea { font-size: 16px !important; padding: 12px !important; }
  .form-hint { font-size: 11.5px; }
  .group-header { margin-top: 10px; }

  /* Scan button → full-width tap target */
  .scan-btn { width: 100%; justify-content: center; padding: 13px !important; }

  /* Wizard nav: tidy wrapping row, real tap targets, no stray spacer push */
  .wizard-nav { flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 18px; }
  .wizard-nav .spacer { display: none; }
  .wizard-nav .save-indicator { order: -1; flex-basis: 100%; }
  .wizard-nav .btn { flex: 1 1 auto; min-height: 48px; }
  .wizard-nav .btn-primary { flex-basis: 100%; order: 3; }   /* Next/Finish gets its own full-width row */

  /* Repeater cards */
  .repeater-card { padding: 14px !important; }
  .repeater-head { gap: 10px; }

  /* Full-plan overview: toolbar wraps, sections go full width */
  .full-plan-toolbar { justify-content: flex-start !important; }
  .plan-section { padding: 16px !important; }

  /* Sticky progress header (if present) shouldn't crowd the small screen */
  .lifebook-sticky-header { padding: 10px 4px !important; }
}

/* ════════════════ FULL-PLAN OVERVIEW — mobile rebuild (≤600px) ════════════════
   The overview (renderFullPlan) is a desktop 2-column layout: a read panel + a
   floating "Sections" side-nav, under a fixed-height sticky header whose negative
   margins were tuned to the desktop 32px content padding. On a phone that header
   detaches and the toolbar buttons float over the content, while the side-nav
   squeezes the read panel to an unreadable strip. This makes it a single, clean,
   top-to-bottom column. */
@media (max-width: 600px) {

  /* Sticky white header on mobile (like desktop): pinned, white, with the action
     buttons stacked ABOVE the title. Inset (no negative margins) to avoid the
     horizontal-overflow issue the full-bleed version caused. */
  .lifebook-sticky-header {
    position: static !important;
    z-index: 29;
    height: auto !important;
    background: var(--cream,#F5F0EB) !important;
    margin: 0 0 14px 0 !important;
    padding: 2px 0 10px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    border-bottom: none !important;
    box-shadow: none !important;
  }
  /* Action buttons (Edit / Download / Print / Share / Close) sit above the title. */
  .lifebook-sticky-header .full-plan-toolbar { order: -1; }
  /* Scan/upload chips: show the example document only, drop the "— what it fills" text on mobile. */
  .lb2-accel-fills { display: none !important; }
  .lifebook-sticky-name { font-size: 22px !important; margin-bottom: 2px; }
  .lifebook-sticky-sub { margin-top: 2px; }
  .lifebook-sticky-pct { white-space: normal !important; }
  .lifebook-sticky-bar-track { width: 100% !important; max-width: 200px; }

  /* Toolbar: horizontal, swipeable row of compact buttons — no floating cards */
  .full-plan-toolbar {
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px !important;
    padding-bottom: 4px;
  }
  .full-plan-toolbar::-webkit-scrollbar { display: none; }
  .full-plan-toolbar .btn { flex: 0 0 auto; white-space: nowrap; }
  /* Icon-only header buttons must be perfectly square */
  .full-plan-toolbar .btn[aria-label] { width: 40px !important; height: 40px !important; padding: 0 !important; }

  /* Scan/upload accelerator chips must wrap and never overflow the card width */
  .lb2-accel {
    max-width: 100% !important; white-space: normal !important; height: auto !important;
    text-align: left !important; line-height: 1.4 !important; align-items: flex-start !important;
  }
  .lb2-accel + *, .lb2-accel { min-width: 0; }

  /* The teal left-stripe reads as a broken edge on the coloured chapter cards */
  .plan-context .card { border-left: none !important; }

  /* Layout: one column, and drop the in-page side-nav (redundant — the bottom
     tab bar + the read list already cover navigation) */
  .lifebook-layout { display: block !important; }
  .lifebook-main { width: 100% !important; }
  .lifebook-sidenav { display: none !important; }

  /* Read rows: stack label above value, full width (kills the 180px label squeeze) */
  .plan-section { padding: 16px !important; scroll-margin-top: 12px !important; }
  .plan-field-row { flex-direction: column !important; gap: 2px !important; padding: 9px 0 !important; }
  .plan-field-label { min-width: 0 !important; font-size: 12.5px !important; color: var(--grey-500,#767676) !important; }
  .plan-field-value { font-size: 15px !important; }
  .plan-section-title { font-size: 16px !important; }
  .plan-edit-btn { opacity: 1 !important; }  /* always visible on touch (no hover) */

  /* Feedback FAB sits above the tab bar, not over the content */
  #fb-fab { z-index: 850; }
}

/* ════════════════ MOBILE DASHBOARD — chapters + Help & advice ════════════════
   Injected by clHome() on phones only. Mirrors the desktop dashboard (chapters
   from lb2Progress) and adds a support-blue Help & advice block. */
.cl-blue { color: var(--support, #3B5BDB) !important; }

/* LifeBook module — forest green like the desktop dashboard card */
.cl-dash { padding: 18px; background: var(--forest, #365D49); border: none; color: #fff; }
.cl-dashtop { display: flex; align-items: baseline; justify-content: space-between; }
.cl-dashtop b { font-size: 15px; color: #fff; }
.cl-dashtop span { font-size: 11.5px; color: rgba(255,255,255,.78); }
.cl-dbar { height: 7px; border-radius: 6px; background: rgba(255,255,255,.22); overflow: hidden; margin: 6px 0 10px; }
.cl-dbar i { display: block; height: 100%; background: #fff; border-radius: 6px; transition: width .5s ease; }
.cl-enc { font-size: 12.5px; color: rgba(255,255,255,.92); line-height: 1.5; margin-bottom: 12px; }
.cl-chap { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none;
  padding: 7px 0; cursor: pointer; text-align: left; }
.cl-chap + .cl-chap { border-top: 1px solid rgba(255,255,255,.16); }
.cl-chn { font-size: 12.5px; color: #fff; flex: 0 0 108px; }
.cl-chbar { flex: 1; height: 6px; border-radius: 5px; background: rgba(255,255,255,.22); overflow: hidden; }
.cl-chbar i { display: block; height: 100%; background: #fff; }
.cl-chp { font-size: 11px; color: rgba(255,255,255,.72); flex: 0 0 34px; text-align: right; }
.cl-chp.done { color: #fff; font-weight: 700; }
.cl-keep { display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.2);
  font-size: 13px; font-weight: 600; color: #fff; }

/* Help & advice (support blue) */
.cl-advice { background: var(--support-light, #EDF2FF); border: 1px solid #d9e1fb; border-radius: 14px;
  padding: 13px; margin-bottom: 9px; }
.cl-advice .cl-at { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600;
  color: var(--support-dark, #2346C0); margin-bottom: 3px; }
.cl-advice .cl-at svg { stroke: var(--support, #3B5BDB); fill: none; stroke-width: 1.9; }
.cl-advice .cl-ab { font-size: 12.5px; color: #3a4aa0; line-height: 1.5; }
.cl-lrow { display: flex; align-items: center; gap: 10px; width: 100%; background: #fff;
  border: 1px solid var(--border, #E0E0E0); border-radius: 12px; padding: 11px; margin-bottom: 8px;
  cursor: pointer; text-align: left; }
.cl-lbadge { font-size: 9px; font-weight: 700; color: #fff; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }
.cl-lrt { font-size: 12.5px; color: var(--black, #1A1A1A); }
.cl-lrow .cl-chev { margin-left: auto; color: var(--grey-300, #ccc); font-size: 18px; }
.cl-helpbtn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--support, #3B5BDB); color: #fff; font-weight: 600; font-size: 14px;
  padding: 13px; border-radius: 13px; border: none; cursor: pointer; }
.cl-helpbtn:active { background: var(--support-dark, #2346C0); }
.cl-helpbtn svg { stroke: #fff; fill: none; stroke-width: 1.9; }

/* Referral invite card (NOT in the nav) */
.cl-invite { display: flex; align-items: center; gap: 13px; width: 100%; background: var(--support-light, #EDF2FF);
  border: 1.5px dashed var(--support-mid, #91A7FF); border-radius: 14px; padding: 13px; margin-bottom: 9px;
  cursor: pointer; text-align: left; }
.cl-invite .cl-doorico { color: var(--support, #3B5BDB); }
.cl-invite .cl-go { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--support, #3B5BDB); }

/* Me menu — support-blue Help row + deferred Estate row */
.cl-door-blue .cl-doorico { background: var(--support-light, #EDF2FF); color: var(--support, #3B5BDB); }
.cl-door-blue b { color: var(--support-dark, #2346C0); }
.cl-door-soon { opacity: .9; }
.cl-door-soon .cl-doorico { background: #FAECE7; color: #B4441A; }
.cl-soonpill { margin-left: auto; font-size: 10px; font-weight: 700; color: #993C1D;
  background: #FAECE7; padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
