/* ═══════════════════════════════════════════════
   FORESTORERS — RESTORATION JOURNAL
   css/style.css
═══════════════════════════════════════════════ */
*{box-sizing:border-box;margin:0;padding:0}
/* Light is the default theme; dark is opt-in via data-theme="dark" on <html>,
   set before paint by the head bootstrap script (Settings > Appearance). */
:root{
  color-scheme:light;
  --bg:#f4f6fa;
  --surface:#ffffff;
  --surface2:#f0f2f7;
  --surface3:#e6e9f0;
  --border:rgba(0,0,0,.08);
  --border2:rgba(0,0,0,.13);
  --text:#0f1117;
  --muted:#4a5568;
  --muted2:#6b7794;
  --accent:#2563eb;
  --accent-hover:#1d4ed8;
  --accent2:rgba(37,99,235,.09);
  --green:#16a34a;
  --greenl:rgba(22,163,74,.1);
  --greenb:rgba(22,163,74,.35);
  --red:#dc2626;
  --redl:rgba(220,38,38,.1);
  --redb:rgba(220,38,38,.35);
  --amber:#b45309;
  --amberl:rgba(180,83,9,.1);
  --amberb:rgba(180,83,9,.35);
  --purple:#7c3aed;
  --mono:'DM Mono','Fira Mono','Consolas',monospace;
  --sans:'DM Sans',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  --sidebar:228px;
  --header:48px;
  --shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.05);
  --shadow-lg:0 4px 24px rgba(0,0,0,.12),0 1px 4px rgba(0,0,0,.07);
}
[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0e1211;
  --surface:#151a18;
  --surface2:#1c2220;
  --surface3:#242b28;
  --border:rgba(255,255,255,.07);
  --border2:rgba(255,255,255,.12);
  --text:#e6eae8;
  --muted:#9db0a8;
  --muted2:#6f8078;
  --accent:#3b82f6;
  --accent-hover:#60a5fa;
  --accent2:rgba(59,130,246,.14);
  --green:#22c55e;
  --greenl:rgba(34,197,94,.12);
  --greenb:rgba(34,197,94,.4);
  --red:#ef4444;
  --redl:rgba(239,68,68,.12);
  --redb:rgba(239,68,68,.4);
  --amber:#f59e0b;
  --amberl:rgba(245,158,11,.12);
  --amberb:rgba(245,158,11,.4);
  --purple:#8b5cf6;
  --shadow:0 1px 3px rgba(0,0,0,.35),0 1px 2px rgba(0,0,0,.25);
  --shadow-lg:0 4px 24px rgba(0,0,0,.5),0 1px 4px rgba(0,0,0,.35);
}
html,body{height:100%;background:var(--bg)}
body{font-family:var(--sans);color:var(--text);font-size:15px;overflow:hidden;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}

/* ── APP SHELL ── */
.app{display:flex;flex-direction:column;height:100vh;height:100dvh;overflow:hidden;background:var(--surface);padding-top:env(safe-area-inset-top,0px)}
.main{flex:1;overflow-y:auto;overflow-x:hidden;padding:1.25rem}
.page{display:none;animation:fadein .15s ease}
.page.active{display:block}
@keyframes fadein{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}
.page-hdr{margin-bottom:1rem;display:flex;align-items:center;gap:12px}
.page-hdr h1{font-family:var(--mono);font-size:18px;font-weight:500;flex:1;color:var(--text)}
.input{width:100%;font-family:var(--sans);font-size:13px;padding:8px 11px;border:1px solid var(--border2);border-radius:8px;background:var(--surface2);color:var(--text);outline:none;transition:border-color .12s,box-shadow .12s}
.input:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent2)}

/* ── HEADER ── */
.safe-area-top{display:none}
.hdr{height:var(--header);background:var(--surface);border-bottom:1px solid var(--border);display:flex;align-items:center;padding:0 18px;gap:14px;flex-shrink:0;position:relative;z-index:20}
.hdr-status{display:flex;align-items:center;gap:8px;margin-left:auto}
/* Buddies nav button in header */
.hdr-buddies-btn{display:flex;align-items:center;gap:5px;padding:5px 9px;border-radius:6px;border:1px solid var(--border2);background:none;cursor:pointer;font-family:var(--mono);font-size:12px;font-weight:500;color:var(--muted2);transition:all .15s;white-space:nowrap}
.hdr-buddies-btn:hover{background:var(--surface2);color:var(--text)}
.hdr-buddies-dot{width:6px;height:6px;border-radius:50%;background:var(--muted2);flex-shrink:0;transition:background .3s}
body:not(.p2p-offline) .hdr-buddies-dot{background:var(--accent)}
body:not(.p2p-offline) .hdr-buddies-btn{color:var(--text);border-color:var(--border2)}
body.p2p-offline .hdr-buddies-label{display:none}
body.p2p-offline .hdr-buddies-btn{opacity:.4;border-color:transparent}
.hamburger{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border:none;background:transparent;cursor:pointer;border-radius:6px;color:var(--muted);font-size:17px;padding:0;flex-shrink:0;transition:background .12s}
.hamburger:hover{background:var(--surface2);color:var(--text)}
header{height:calc(var(--header) + env(safe-area-inset-top,0px));background:var(--surface);border-bottom:1px solid var(--border);display:flex;align-items:center;padding:env(safe-area-inset-top,0px) 18px 0;gap:14px;flex-shrink:0;position:relative;z-index:20}
.logo{font-family:var(--mono);font-size:14px;font-weight:500;letter-spacing:-.01em;display:flex;align-items:center;gap:8px;color:var(--text)}
.logo-mark{width:24px;height:24px;background:var(--accent);border-radius:5px;display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:13px;color:#fff}
.logo-sub{font-size:11px;color:var(--muted);font-family:var(--mono)}
.menu-btn{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border:none;background:transparent;cursor:pointer;border-radius:6px;color:var(--muted);font-size:17px;padding:0;flex-shrink:0;transition:background .12s;margin-right:4px}
.menu-btn:hover{background:var(--surface2);color:var(--text)}
.menu-btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* Peer status */
.peer-status{font-family:var(--mono);font-size:10px;color:var(--muted2);display:flex;align-items:center;gap:6px;flex-shrink:0}
.peer-dot{width:7px;height:7px;border-radius:50%;background:var(--muted2);transition:background .3s}
/* Status dots: glowy box-shadow halos read as "real-time AI dashboard."
   Flat indicator pucks read as "appliance status light" -- which is what these
   actually are. Same colors, no Tron bloom. */
.peer-dot.ready{background:var(--green)}
.sig-dot{width:4px;height:4px;border-radius:50%;background:var(--muted2);flex-shrink:0;transition:background .3s;opacity:.4}
.sig-dot.on{background:#3b82f6;opacity:.85}
/* ── New header dots ── */
.hdr-dots{display:flex;align-items:center;gap:12px;padding:6px 16px;background:var(--surface2);border:1px solid var(--border2);border-radius:20px;flex-shrink:0;cursor:pointer;font:inherit;transition:background .2s,border-color .2s}
.hdr-dots.has-notif{background:rgba(59,130,246,.14);border-color:rgba(59,130,246,.4)}
.hdr-dot{width:12px;height:12px;min-width:12px;min-height:12px;max-width:12px;max-height:12px;border-radius:50%;background:#3a3a3a;display:block;flex-shrink:0;flex-grow:0;transition:background .3s;cursor:default;line-height:0}
.hdr-dot.on{background:#22c55e}
.hdr-dot.ready{background:#22c55e}
.hdr-dot.public-only{background:#3b82f6}
.hdr-dot.public-off{background:#111;box-shadow:none}
.hdr-dot-btn{background:none;border:none;cursor:pointer;padding:0;display:flex;align-items:center;justify-content:center;line-height:0;position:relative;width:12px;height:12px;min-width:12px;min-height:12px;max-width:12px;max-height:12px;flex-shrink:0;flex-grow:0;overflow:visible;box-sizing:border-box}
.hdr-dot-label{font-family:var(--mono);font-size:9px;color:var(--muted);letter-spacing:.02em;white-space:nowrap;line-height:1;position:absolute;top:-9px;left:50%;transform:translateX(-50%);pointer-events:none}
.hdr-status-wrap{display:flex;flex-direction:row;flex-wrap:nowrap;align-items:center;gap:6px;position:relative;flex-shrink:0}
.hdr-count-badge{position:absolute;top:-4px;right:-4px;background:var(--accent);color:#fff;border-radius:8px;font-family:var(--mono);font-size:8px;font-weight:700;min-width:14px;height:14px;display:flex;align-items:center;justify-content:center;padding:0 3px;pointer-events:none;line-height:1}
/* Pending-buddy-request orb -- top-left of the buddy button so it doesn't fight
   the count chips on the right. Solid green = "you have a request waiting." */
.hdr-req-dot{position:absolute;top:-3px;left:-3px;width:10px;height:10px;border-radius:50%;background:var(--green);border:2px solid var(--surface);pointer-events:none}

/* Compact toggle row for header dropdowns. Replaces the big 3-button bank
   when a single on/off switch is all you need (e.g. inside the 👥 or 📱
   dropdowns). Pattern: small dot + label + state chip in a tappable row. */
.dd-toggle-row{display:flex;align-items:center;gap:10px;width:100%;padding:10px 14px;background:none;border:none;border-bottom:1px solid var(--border2);cursor:pointer;font-family:inherit;text-align:left;color:var(--text);transition:background .12s}
.dd-toggle-row:hover{background:var(--surface2)}
.dd-toggle-row .dd-toggle-dot{width:10px;height:10px;border-radius:50%;background:var(--muted2);flex-shrink:0;transition:background .15s}
.dd-toggle-row.on .dd-toggle-dot{background:var(--green)}
.dd-toggle-row .dd-toggle-label{flex:1;font-size:12px;font-weight:500;color:var(--text)}
.dd-toggle-row .dd-toggle-state{font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.06em;padding:2px 8px;border-radius:10px;background:var(--surface3);color:var(--muted2);text-transform:uppercase;flex-shrink:0}
.dd-toggle-row.on .dd-toggle-state{background:rgba(34,197,94,.15);color:var(--green)}
.dd-toggle-row.disabled{opacity:.5;cursor:not-allowed}
.dd-toggle-row.disabled:hover{background:none}

/* Inline collapsible help chip used to replace chunky explanatory paragraphs.
   Pattern: short statement + a "?" chip next to it that expands the full
   explanation underneath. Works on touch + desktop, no JS required. */
details.help-tip{margin:0 0 14px 22px}
details.help-tip > summary{list-style:none;cursor:pointer;display:inline-flex;align-items:center;gap:5px;padding:1px 8px;border:1px solid var(--border2);border-radius:10px;background:var(--surface);font-family:var(--mono);font-size:10px;color:var(--muted2);transition:background .12s,color .12s,border-color .12s;user-select:none;-webkit-tap-highlight-color:transparent}
details.help-tip > summary::-webkit-details-marker{display:none}
details.help-tip > summary:hover{color:var(--text);border-color:var(--accent2);background:var(--accent2)}
details.help-tip[open] > summary{color:var(--accent);border-color:var(--accent);background:var(--accent2)}
details.help-tip > .help-tip-body{font-size:11px;color:var(--muted2);line-height:1.5;margin-top:6px;padding:8px 10px;background:var(--surface2);border:1px solid var(--border2);border-radius:5px}
.hdr-lock-btn{width:34px;height:34px;border-radius:7px;background:var(--surface2);border:1px solid var(--border2);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:15px;padding:0;flex-shrink:0;color:var(--muted);transition:background .15s}
.hdr-lock-btn:hover{background:var(--surface);color:var(--text)}
/* ── Sync ripple animation ── */
/* Ripple still telegraphs the sync, just without the heavy bloom + thick ring. */
@keyframes hdrDotRipple{0%{transform:scale(1);opacity:.6}100%{transform:scale(2.2);opacity:0}}
.hdr-dot.sync-pulse{background:#4ade80!important;transition:none}
.hdr-dot-ripple{position:absolute;border-radius:50%;border:1px solid #4ade80;pointer-events:none;animation:hdrDotRipple .85s ease-out forwards}
.hdr-dot.sync-warn-pulse{background:#f97316!important;transition:none}
.hdr-dot-ripple-warn{position:absolute;border-radius:50%;border:1px solid #f97316;pointer-events:none;animation:hdrDotRipple 1.1s ease-out forwards}
/* ── NOTIFICATIONS ── */
/* Brightness flicker reads as "new thing" without the AI-dashboard glow ring. */
@keyframes notifPulse{0%,100%{background:#f59e0b}50%{background:#fbbf24}}
.hdr-dot.notif-unread{background:#f59e0b}
.hdr-dot.notif-pulse{animation:notifPulse .9s ease-out forwards}
.notif-item{display:flex;align-items:flex-start;gap:8px;padding:9px 12px;border-bottom:1px solid var(--border2)}
.notif-item:last-child{border-bottom:none}
.notif-icon{font-size:14px;flex-shrink:0;margin-top:1px}
.notif-body{flex:1;min-width:0}
.notif-title{font-size:12px;font-weight:500;color:var(--text);line-height:1.35}
.notif-desc{font-size:11px;color:var(--muted);margin-top:2px;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.notif-time{font-family:var(--mono);font-size:10px;color:var(--muted2);margin-top:3px}
.notif-del{background:none;border:none;cursor:pointer;font-size:11px;color:var(--muted2);padding:2px 4px;flex-shrink:0;line-height:1;border-radius:3px;transition:color .12s}
.notif-del:hover{color:var(--danger,#ef4444)}
/* ── CHAT MODAL ── */
.chat-modal-box{display:flex;flex-direction:column;max-height:min(72dvh,calc(100svh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px) - 2rem));width:100%;max-width:460px}
.chat-modal-msgs{flex:1;overflow-y:auto;padding:12px 16px;display:flex;flex-direction:column;gap:8px;min-height:160px}
.chat-modal-msg{max-width:78%;padding:8px 12px;border-radius:12px;font-size:13px;line-height:1.45;word-break:break-word}
.chat-modal-msg.out{align-self:flex-end;background:var(--accent);color:#fff;border-bottom-right-radius:3px}
.chat-modal-msg.in{align-self:flex-start;background:var(--surface2);color:var(--text);border-bottom-left-radius:3px}
.chat-modal-msg-meta{font-size:10px;opacity:.6;margin-top:3px;text-align:right}
.chat-modal-footer{display:flex;gap:8px;padding:10px 14px;border-top:1px solid var(--border2);flex-shrink:0}
.chat-modal-input{flex:1;background:var(--surface2);border:1px solid var(--border2);border-radius:8px;padding:8px 12px;font-size:13px;color:var(--text);outline:none}
.chat-modal-input:focus{border-color:var(--accent)}
.chat-modal-send{background:var(--accent);border:none;border-radius:8px;cursor:pointer;font-size:16px;padding:8px 14px;color:#fff;flex-shrink:0}
/* ── BUDDY CHAT ── */
.chat-panel{background:var(--surface);border:1px solid var(--border2);border-radius:12px;margin:12px 0;display:flex;flex-direction:column;overflow:hidden}
.chat-header{display:flex;align-items:center;gap:8px;padding:10px 14px;border-bottom:1px solid var(--border2);background:var(--surface2)}
.chat-avatar{font-size:22px;line-height:1;flex-shrink:0}
.chat-title{font-size:14px;font-weight:600;color:var(--text);flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-close{margin-left:auto;flex-shrink:0;color:var(--muted);font-size:13px}
.chat-messages{flex:1;overflow-y:auto;padding:12px 14px;display:flex;flex-direction:column;gap:6px;min-height:180px;max-height:380px}
.chat-empty{color:var(--muted2);font-size:13px;text-align:center;padding:24px 0;font-family:var(--mono)}
.chat-msg{display:flex;flex-direction:column;max-width:80%}
.chat-msg.out{align-self:flex-end;align-items:flex-end}
.chat-msg.in{align-self:flex-start;align-items:flex-start}
.chat-bubble{padding:8px 12px;border-radius:14px;font-size:14px;line-height:1.5;color:var(--text);white-space:pre-wrap;word-break:break-word}
.chat-msg.out .chat-bubble{background:var(--green);color:#fff;border-bottom-right-radius:4px}
.chat-msg.in .chat-bubble{background:var(--surface3);border-bottom-left-radius:4px}
.chat-time{font-size:10px;color:var(--muted2);font-family:var(--mono);margin-top:2px;padding:0 4px}
.chat-status{margin-left:5px;font-size:11px;vertical-align:middle}
.chat-status.delivered{color:rgba(255,255,255,.8)}
.chat-status.pending{color:rgba(255,255,255,.5)}
.chat-status.failed{color:#f97316;font-weight:700}
.chat-compose{display:flex;gap:8px;padding:10px 14px;border-top:1px solid var(--border2);align-items:flex-end}
.chat-input{flex:1;background:var(--surface2);border:1px solid var(--border2);border-radius:10px;padding:8px 12px;font-size:14px;color:var(--text);resize:none;font-family:inherit;line-height:1.4}
.chat-input:focus{outline:none;border-color:var(--green)}
.chat-send{flex-shrink:0;align-self:flex-end}
.chat-footer{font-size:10px;font-family:var(--mono);color:var(--muted2);text-align:center;padding:4px 14px 8px;opacity:.7}
/* Unread badge on contact-item-name */
.chat-unread{display:inline-block;background:var(--green);color:#fff;font-size:10px;font-family:var(--mono);font-weight:700;border-radius:8px;padding:1px 5px;margin-left:5px;vertical-align:middle;line-height:1.4}

/* ── BUDDY LIVE TIMER BADGE ── */
.buddy-timer-badge{margin-top:5px;font-size:13px;line-height:1;animation:buddyTimerPulse 2.5s ease-in-out infinite}
.buddy-timer-badge.tug{filter:drop-shadow(0 0 3px rgba(34,197,94,.7))}
.buddy-timer-badge.ret{filter:drop-shadow(0 0 3px rgba(96,165,250,.7))}
@keyframes buddyTimerPulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.65;transform:scale(.88)}}
.tug-pulse{animation:buddyTimerPulse 2.5s ease-in-out infinite;display:inline-block}
.ret-pulse{animation:buddyTimerPulse 2.5s ease-in-out infinite;display:inline-block}

/* ── SIDEBAR ── */
.sidebar{position:fixed;top:calc(var(--header) + env(safe-area-inset-top,0px));left:0;bottom:0;width:var(--sidebar);background:var(--surface);border-right:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden;transform:translateX(-100%);transition:transform .22s cubic-bezier(.4,0,.2,1);z-index:200}
.sidebar.open{transform:translateX(0);box-shadow:4px 0 24px rgba(0,0,0,.18)}
.sidebar-backdrop{display:none;position:fixed;inset:0;top:calc(var(--header) + env(safe-area-inset-top,0px));background:rgba(0,0,0,.5);z-index:199;backdrop-filter:blur(2px)}
.sidebar.open~.sidebar-backdrop{display:block}
.sb-inner{display:flex;flex-direction:column;height:100%;overflow-y:auto}
/* Tighter sections: less vertical padding, lighter dividers, more compact headers
   so the menu doesn't feel like it's shouting. Tap targets on nav-items unchanged. */
.sb-section{padding:6px 0}
.sb-section + .sb-section{border-top:1px solid var(--border2)}
.sb-section-hdr{font-family:var(--mono);font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted2);padding:6px 14px 4px;cursor:pointer;user-select:none}
.sb-section-hdr:hover{color:var(--muted)}
.sb-items{display:flex;flex-direction:column;padding:0 8px;gap:1px}
.nav-item{display:flex;align-items:center;gap:8px;padding:8px 11px;border-radius:8px;cursor:pointer;font-family:var(--mono);font-size:13px;font-weight:500;color:var(--muted);transition:background .12s,color .12s;border:1px solid transparent;background:none;text-align:left;width:100%}
.nav-item:hover{background:var(--surface2);color:var(--text)}
/* Active state: stronger background + heavier weight. No left-edge accent bar
   -- that "tab" indicator is a common AI dashboard cliche; a darker tint reads
   as "selected" without the Linear-style notch. */
.nav-item.active{background:var(--surface3);color:var(--text);font-weight:600}
.sb-scroll{flex:1;overflow-y:auto}
.sb-backdrop{display:none;position:fixed;inset:0;top:calc(var(--header) + env(safe-area-inset-top,0px));background:rgba(0,0,0,.5);z-index:199;backdrop-filter:blur(2px)}
.sb-backdrop.open{display:block}
.sb-label{font-family:var(--mono);font-size:10px;font-weight:500;letter-spacing:.1em;color:var(--muted2);text-transform:uppercase;margin-bottom:8px}
.sb-nav-item{display:flex;align-items:center;gap:8px;padding:6px 9px;border-radius:5px;cursor:pointer;font-family:var(--mono);font-size:13px;font-weight:500;color:var(--muted);transition:background .12s,color .12s;margin-bottom:2px;border:1px solid transparent}
.sb-nav-item:hover{background:var(--surface2);color:var(--text)}
.sb-nav-item.active{background:var(--surface3);color:var(--text);font-weight:600}
.sb-nav-icon{width:16px;text-align:center;font-size:11px;flex-shrink:0}
.sb-nav-label{flex:1}
.sb-badge{font-family:var(--mono);font-size:11px;background:var(--surface3);color:var(--muted);padding:1px 6px;border-radius:10px}
.sb-btn{font-family:var(--mono);font-size:12px;font-weight:500;letter-spacing:.03em;padding:7px 11px;border-radius:5px;border:1px solid var(--border2);background:var(--surface2);color:var(--text);cursor:pointer;transition:all .14s;text-align:center;width:100%;display:block;margin-bottom:4px}
.sb-btn:hover{border-color:var(--muted2);background:var(--surface3)}
.sb-info{font-family:var(--mono);font-size:11px;color:var(--muted2);line-height:2}
.sb-acc{border-bottom:1px solid var(--border)}
.sb-acc-hdr{display:flex;align-items:center;justify-content:space-between;padding:9px 14px;cursor:pointer;font-family:var(--mono);font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);user-select:none;transition:background .1s}
.sb-acc-hdr:hover{background:var(--surface2)}
.sb-acc-caret{font-size:8px;transition:transform .15s;color:var(--muted2)}
.sb-acc.open .sb-acc-caret{transform:rotate(180deg)}
.sb-acc-body{display:none;padding:0 0 10px}
.sb-acc.open .sb-acc-body{display:block}
.sb-legal{padding:10px 12px;border-top:1px solid var(--border);margin-top:auto;font-family:var(--mono);font-size:10px;color:var(--muted2);line-height:1.9}
.sb-legal a{color:var(--muted);text-decoration:none}
.sb-legal a:hover{color:var(--text);text-decoration:underline}

/* ── MAIN AREA ── */
.main-area{flex:1;display:flex;flex-direction:column;min-width:0;overflow:hidden}
.page-wrap{flex:1;overflow-y:auto;overflow-x:hidden}
.main-footer{padding:8px 18px;border-top:1px solid var(--border);font-family:var(--mono);font-size:11px;color:var(--muted2);display:flex;align-items:center;gap:14px;flex-shrink:0;flex-wrap:wrap}
.main-footer a{color:var(--muted);text-decoration:none}.main-footer a:hover{color:var(--text)}
.main-footer-sep{opacity:.3}

/* ── PANELS ── */
.panel{background:var(--surface);border:1px solid var(--border);border-radius:12px;overflow:hidden;box-shadow:var(--shadow)}
.ph{padding:10px 14px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:8px;background:var(--surface2)}
.ph h2{font-family:var(--mono);font-size:14px;font-weight:600;letter-spacing:.04em;color:var(--text)}
.pb{padding:14px}
.panel.collapsed .pb{display:none}
.panel.collapsed .ph{border-bottom:none}
.hdr-dropdown{position:fixed!important;top:calc(var(--header) + env(safe-area-inset-top,0px))!important;left:50%!important;transform:translateX(-50%)!important;min-width:280px!important;max-width:92vw!important;max-height:75vh!important;overflow-y:auto!important;z-index:1100!important;border-radius:12px!important}
#dropdown-backdrop{display:none;position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:1099;backdrop-filter:blur(2px)}

/* ── BUTTONS ── */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;font-family:var(--mono);font-size:13px;font-weight:500;letter-spacing:.02em;padding:8px 14px;border-radius:8px;border:1px solid transparent;cursor:pointer;transition:background .12s,border-color .12s,color .12s,transform .08s;white-space:nowrap;-webkit-tap-highlight-color:transparent}
.btn:active{transform:scale(.97)}
.btn-primary{background:var(--accent);color:#fff;border-color:var(--accent)}.btn-primary:hover{background:var(--accent-hover);border-color:var(--accent-hover)}
.btn-secondary{background:var(--accent2);color:var(--accent);border-color:var(--accent)}.btn-secondary:hover{border-color:var(--accent-hover);color:var(--accent-hover)}
.btn-danger{background:transparent;color:var(--red);border-color:rgba(239,68,68,.35)}.btn-danger:hover{background:var(--redl);border-color:var(--red)}
.btn-ghost{background:var(--surface2);color:var(--muted);border-color:var(--border2)}.btn-ghost:hover{border-color:var(--muted2);color:var(--text);background:var(--surface3)}
.btn-green{background:var(--green);color:#fff;border-color:var(--green)}.btn-green:hover{background:#15803d}
.btn-green:disabled,.btn-primary:disabled{background:var(--muted2);border-color:var(--muted2);cursor:not-allowed;opacity:.5}
.btn-sm{padding:6px 12px;font-size:13px}
.kot-btn{transition:background .15s,color .15s}
.kot-btn.kot-active{background:var(--green);color:#fff;border-color:var(--green)}
.btn-icon{padding:6px 8px;background:none;border:none;cursor:pointer;color:var(--muted2);transition:color .12s;font-size:15px;border-radius:4px}
.btn-icon:hover{color:var(--red);background:var(--redl)}

/* ── FORMS ── */
.fg{margin-bottom:12px}
label{display:block;font-family:var(--mono);font-size:12px;font-weight:500;color:var(--muted);margin-bottom:4px;text-transform:uppercase;letter-spacing:.06em}
input[type=text],input[type=number],input[type=date],textarea,select{width:100%;font-family:var(--sans);font-size:13px;padding:8px 11px;border:1px solid var(--border2);border-radius:8px;background:var(--surface2);color:var(--text);outline:none;transition:border-color .12s,box-shadow .12s}
input:focus,textarea:focus,select:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent2)}
textarea{resize:vertical;min-height:70px}
select{appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23505a6e'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 9px center;padding-right:28px}
input[type=file]{display:none}
input[type=range]{-webkit-appearance:none;width:100%;height:2px;background:var(--surface3);border-radius:1px;outline:none}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:13px;height:13px;border-radius:50%;background:var(--accent);cursor:pointer;box-shadow:0 1px 3px rgba(0,0,0,.4)}
input[type=checkbox]{accent-color:var(--accent)}
.range-row{display:flex;gap:6px;align-items:center}.range-row input[type=range]{flex:1}.range-row span{font-size:11px;color:var(--muted2);font-family:var(--mono);min-width:36px;text-align:right}
.opt-grid{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}
.opt-item{display:flex;align-items:center;gap:5px;padding:4px 9px;border:1px solid var(--border2);border-radius:4px;cursor:pointer;background:var(--surface2);font-size:13px;transition:all .1s}
.opt-item:has(input:checked){border-color:var(--accent);background:var(--accent2)}
.opt-item input{accent-color:var(--accent);cursor:pointer;width:auto}

/* Metric row (range + value) */
.metric-row{display:flex;gap:8px;align-items:center;margin-top:2px}
.metric-row input[type=range]{flex:1}
.metric-row .metric-val{font-family:var(--mono);font-size:12px;font-weight:500;min-width:40px;text-align:right;color:var(--text)}

/* ── LAYOUT HELPERS ── */
.flex{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.ml{margin-left:auto}
hr{border:none;border-top:1px solid var(--border);margin:12px 0}
.two-col{display:grid;grid-template-columns:240px 1fr;gap:1rem;align-items:start}
.empty{text-align:center;padding:2.5rem 1rem;color:var(--muted2)}
.empty .icon{font-size:2rem;margin-bottom:10px;color:var(--muted2);opacity:.7}
.empty p{font-family:var(--sans);font-size:13px;line-height:1.6;color:var(--muted);max-width:36ch;margin:0 auto}

/* ── LIST ITEMS ── */
.li{padding:9px 12px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:6px;cursor:pointer;transition:background .1s}
.li:last-child{border-bottom:none}
.li:hover{background:var(--surface2)}
.li.sel{background:var(--accent2);border-left:2px solid var(--accent);padding-left:10px}
.li-name{font-size:13px;font-weight:500;flex:1}
.li-meta{font-family:var(--mono);font-size:11px;color:var(--muted2);margin-top:1px}

/* ── Dashboard profile avatar column ── */
.profile-avatar-col{flex-shrink:0;width:74px;display:flex;flex-direction:column;align-items:center;text-align:center;border-right:1px solid var(--border2);padding:10px 4px}
@media(min-width:641px){.profile-avatar-col{width:110px}}
/* When the latest-photo setting is on and a photo is being rendered, give the
   column ~100px of extra room so the 3:4 photo can grow without crowding the
   right-hand sparkline + badges. */
.profile-avatar-col.has-photo{width:124px}
@media(min-width:641px){.profile-avatar-col.has-photo{width:210px}}

/* ── STAT CARDS (dashboard) ── */
.stats-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:10px;margin-bottom:1.5rem}
.stat-card{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:16px 18px;display:flex;flex-direction:column;gap:4px;box-shadow:var(--shadow)}
.stat-card .label{font-family:var(--mono);font-size:11px;color:var(--muted2);text-transform:uppercase;letter-spacing:.08em}
.stat-card .value{font-size:26px;font-weight:300;color:var(--text);line-height:1}
.stat-card .value.accent{color:var(--accent)}
.stat-card .value.green{color:var(--green)}
.stat-card .sub{font-size:12px;color:var(--muted);font-family:var(--mono)}
.stat-card.border-accent{border-left:3px solid var(--accent)}
.stat-card.border-green{border-left:3px solid var(--green)}
.stat-card.border-amber{border-left:3px solid var(--amber)}
/* Legacy stat classes */
.stat-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(148px,1fr));gap:10px;margin-bottom:1rem}
.stat{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:14px 16px;box-shadow:var(--shadow)}
.stat-val{font-family:var(--mono);font-size:26px;font-weight:300;line-height:1;letter-spacing:-.02em}
.stat-lbl{font-family:var(--mono);font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-top:3px}
.stat.accent{border-left:3px solid var(--accent)}.stat.flag{border-left:3px solid var(--red)}
.stat.good{border-left:3px solid var(--green)}.stat.warn{border-left:3px solid var(--amber)}

/* ── ACTIVITY FEED ── */
.feed-item{display:flex;align-items:flex-start;gap:12px;padding:12px 16px;border-bottom:1px solid var(--border);cursor:pointer;transition:background .15s}
.feed-item:hover{background:var(--surface3)}
.feed-item:last-child{border-bottom:none}
.feed-item .feed-thumb{width:40px;height:53px;border-radius:5px;object-fit:cover;flex-shrink:0;border:1px solid var(--border2)}
.feed-item .feed-no-thumb{width:40px;height:53px;border-radius:5px;background:var(--surface2);border:1px solid var(--border2);flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:10px;color:var(--muted2);font-family:var(--mono)}
.feed-item .feed-meta{flex:1;min-width:0}
.feed-item .feed-date{font-family:var(--mono);font-size:12px;color:var(--muted2)}
.feed-item .feed-author{font-weight:600;font-size:13px;margin-bottom:3px}
.feed-item .feed-chips{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}
.feed-chip{font-family:var(--mono);font-size:12px;padding:3px 9px;border-radius:4px;background:var(--surface2);border:1px solid var(--border2);color:var(--muted)}
.feed-note{font-size:12px;color:var(--muted);margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:380px}

/* ── CI BADGE ── */
.ci-badge{font-family:var(--mono);font-size:13px;font-weight:600;padding:3px 9px;border-radius:4px;flex-shrink:0;display:inline-block;background:var(--accent2);color:var(--accent);border:1px solid rgba(59,130,246,.3)}

/* ── CI SELECTOR BUTTONS ── */
.ci-selector{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}
.ci-btn{width:34px;height:34px;border-radius:6px;font-family:var(--mono);font-size:13px;font-weight:600;border:2px solid var(--border2);background:var(--surface2);color:var(--muted);cursor:pointer;transition:all .12s}
.ci-btn:hover{border-color:var(--accent);color:var(--accent)}
.ci-btn.active{border-color:var(--accent);background:var(--accent2);color:var(--accent)}
.ci-label-desc{font-family:var(--mono);font-size:11px;color:var(--muted);margin-top:4px;padding:5px 8px;background:var(--surface3);border-radius:4px;border:1px solid var(--border2)}

/* ── DEVICE CHIP (journal form) ── */
.device-chip{font-family:var(--mono);font-size:12px;padding:4px 11px;border-radius:4px;border:1px solid var(--border2);background:var(--surface2);color:var(--muted);cursor:pointer;transition:all .12s;white-space:nowrap}
.device-chip:hover{border-color:var(--accent);color:var(--accent)}
.device-chip.active{background:var(--accent2);border-color:var(--accent);color:var(--accent)}
.device-chips-row{display:flex;flex-wrap:wrap;gap:5px;margin-bottom:6px}

/* ── JOURNAL LAYOUT ── */
#page-journal .page-hdr{margin-bottom:.5rem}
.journal-split{display:flex;height:calc(100vh - var(--header) - env(safe-area-inset-top,0px) - 3.5rem);gap:0;overflow:hidden;margin:0 -1.25rem -1.25rem}
.journal-list-pane{width:280px;flex-shrink:0;border-right:1px solid var(--border);background:var(--surface);display:flex;flex-direction:column;overflow:hidden}
.journal-detail-pane{flex:1;overflow-y:auto;background:var(--bg)}
.journal-list-top{padding:8px;border-bottom:1px solid var(--border);flex-shrink:0}
.journal-list-scroll{flex:1;overflow-y:auto}
/* ── Journal accordion (entries + buddy notes) ── */
#jl-entries-panel{flex:1;min-height:0;overflow:hidden;position:relative}
#jl-entries-panel:not([open]){flex:0 0 auto}
#jl-entries-panel > summary{display:none}
/* position:absolute bypasses the <details> shadow DOM auto-height wrapper that breaks height:100% */
#jl-entries-panel > .jl-acc-body{position:absolute;inset:0;display:flex;flex-direction:column;overflow:hidden}
#jl-entries-panel > .jl-acc-body > .journal-list-scroll{flex:1;overflow-y:auto;min-height:0}
#buddy-notes-panel{flex-shrink:0;border-top:1px solid var(--border);overflow:hidden}
.jl-acc-summary{
  cursor:pointer;list-style:none;
  padding:0 18px;
  height:52px;
  font-family:var(--mono);font-size:13px;font-weight:600;color:var(--text);
  text-transform:uppercase;letter-spacing:.06em;
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  user-select:none;background:var(--surface2);
  border-bottom:1px solid var(--border);
  -webkit-tap-highlight-color:transparent;
}
.jl-acc-summary::-webkit-details-marker{display:none}
.jl-acc-summary::after{content:'▸';transition:transform .15s;display:inline-block;flex-shrink:0;font-size:10px}
details[open] > .jl-acc-summary::after{transform:rotate(90deg)}
#buddy-notes-panel[open] > #buddy-notes-content{max-height:220px;overflow-y:auto}
/* Legacy journal-main (used in some code paths) */
.journal-layout{display:flex;height:calc(100vh - var(--header) - env(safe-area-inset-top,0px));gap:0;overflow:hidden;margin:-1.25rem}
.journal-list{width:280px;flex-shrink:0;border-right:1px solid var(--border);background:var(--surface);display:flex;flex-direction:column;overflow:hidden}
.journal-main{flex:1;overflow-y:auto;background:var(--bg)}
.journal-main-inner{padding:1.25rem}

/* ── THUMBNAIL HOVER ── */
.thumb-hover{cursor:pointer;transition:outline .1s}
.thumb-hover:hover{outline:2px solid var(--accent);outline-offset:2px}

/* ── ENTRY ITEM (journal list) ── */
.entry-item{padding:9px 12px;border-bottom:1px solid var(--border);cursor:pointer;transition:background .1s;display:flex;align-items:center;gap:8px}
.entry-item:last-child{border-bottom:none}
.entry-item:hover{background:var(--surface2)}
.entry-item.sel{background:var(--accent2);border-left:3px solid var(--accent);padding-left:9px}
.entry-item-thumb{width:28px;height:38px;border-radius:4px;object-fit:cover;background:var(--surface2);flex-shrink:0;border:1px solid var(--border2)}
.entry-item-thumb.placeholder{height:38px;background:var(--surface3)}
.entry-item-body{flex:1;min-width:0}
.entry-item-date{font-family:var(--mono);font-size:13px;font-weight:500;color:var(--text)}
.entry-item-meta{font-family:var(--mono);font-size:11px;color:var(--muted2);margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:flex;align-items:center;gap:4px;flex-wrap:wrap}

/* ── ENTRY PERSON HEADER ── */
.entry-person-hdr{padding:7px 12px 5px;font-family:var(--mono);font-size:12px;font-weight:700;letter-spacing:.05em;color:var(--text);background:var(--bg);border-bottom:1px solid var(--border);border-top:2px solid var(--accent);position:sticky;top:0;z-index:2}
.entry-person-hdr.buddy{border-top-color:var(--muted2);color:var(--muted)}

/* ── ENTRY GROUP HEADER ── */
.entry-group-hdr{padding:5px 12px 4px;font-family:var(--mono);font-size:11px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:var(--muted2);background:var(--surface2);border-bottom:1px solid var(--border);position:sticky;top:24px;z-index:1}

/* ── ENTRY FORM SECTIONS ── */
.form-section{margin-bottom:1.25rem}
.form-section-title{font-family:var(--mono);font-size:11px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);padding:0 0 6px;border-bottom:1px solid var(--border);margin-bottom:12px;display:flex;align-items:center;gap:6px}
.entry-actions{display:flex;gap:6px;align-items:center;margin-bottom:1rem;flex-wrap:wrap}

/* ── PHOTO GRID ── */
.photo-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.photo-slot{border:1px dashed var(--border2);border-radius:7px;overflow:hidden;background:var(--surface2);transition:border-color .15s}
.photo-slot.has-img{border-style:solid;border-color:var(--border2)}
.photo-slot-img{width:100%;max-height:320px;object-fit:contain;display:block;cursor:pointer;background:var(--surface3)}
/* Sizing guide overlay -- semi-transparent icon to help align the photo's
   subject to the suggested proportion. Pointer-events:none so it never
   blocks taps on the photo itself (which opens the lightbox). */
.photo-slot-img-wrap .photo-sizing-guide{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;pointer-events:none;opacity:.38;mix-blend-mode:multiply}
.photo-slot-placeholder{width:100%;aspect-ratio:3/4;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;color:var(--muted2);font-family:var(--mono);font-size:11px}
.photo-slot-actions{display:flex;gap:4px;padding:5px 6px;background:var(--surface);border-top:1px solid var(--border);flex-wrap:wrap}
.photo-slot-label{font-family:var(--mono);font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted2);padding:4px 6px 0}

/* ── DEVICE GRID (legacy checkboxes) ── */
.device-grid{display:flex;flex-wrap:wrap;gap:4px}
.device-item{display:flex;align-items:center;gap:5px;padding:4px 9px;border:1px solid var(--border2);border-radius:4px;cursor:pointer;background:var(--surface2);font-family:var(--mono);font-size:10px;transition:all .1s;color:var(--muted)}
.device-item:has(input:checked){border-color:var(--accent);background:var(--accent2);color:var(--accent)}
.device-item input{accent-color:var(--accent);cursor:pointer;width:auto}

/* ── CONTACTS PAGE ── */
.p2p-warn{background:rgba(245,158,11,.08);border:1px solid rgba(245,158,11,.2);border-radius:8px;padding:12px 16px;margin-bottom:1rem;font-size:13px;color:var(--amber);line-height:1.6}
.p2p-warn strong{color:var(--amber)}
.contact-item{display:flex;align-items:center;gap:10px;padding:10px 14px;border-bottom:1px solid var(--border);background:var(--surface)}
.contact-item:last-child{border-bottom:none}
.contact-item-info{flex:1;min-width:0}
.contact-item-name{font-size:13px;font-weight:500}
.contact-item-meta{font-family:var(--mono);font-size:11px;color:var(--muted2);margin-top:2px}
.online-dot{width:8px;height:8px;border-radius:50%;background:var(--muted2);flex-shrink:0;transition:background .3s}
.online-dot.online{background:var(--green)}
.online-dot.idle{background:#f97316}
.share-code{font-family:var(--mono);font-size:11px;background:var(--surface2);border:1px solid var(--border2);border-radius:5px;padding:8px 12px;word-break:break-all;color:var(--text);line-height:1.7;user-select:all}
.contact-journal-banner{background:var(--surface3);border-bottom:1px solid var(--border);padding:10px 14px;font-family:var(--mono);font-size:10px;display:flex;align-items:center;gap:8px;color:var(--text)}

/* ── COMPARE PAGE ── */
.cmp-ctrl{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:10px 12px;background:var(--surface);border:1px solid var(--border);border-radius:10px;margin-bottom:1rem}
.cmp-ctrl select{max-width:260px;font-family:var(--mono);font-size:11px}
.vs{font-family:var(--mono);font-size:10px;color:var(--muted2);flex-shrink:0}
.cmp-grid{display:grid;grid-template-columns:1fr 1fr!important;gap:8px}
.cmp-img-wrap{position:relative;background:var(--surface3);border-radius:6px;overflow:hidden;line-height:0;cursor:crosshair}
.cmp-img-wrap img{display:block;width:100%;max-height:440px;object-fit:contain}

/* Compare loupe */
#loupe-cmp{position:fixed;pointer-events:none;z-index:900;display:none;border-radius:8px;overflow:hidden;box-shadow:0 0 0 2px rgba(255,255,255,.15),var(--shadow-lg);flex-direction:column}
#loupe-cmp.show{display:flex}
.lc-panes{display:flex;flex:1;overflow:hidden}
.lc-pane{flex:1;position:relative;overflow:hidden}
.lc-pane canvas{position:absolute;top:0;left:0}
.lc-div{width:2px;background:#60a5fa;flex-shrink:0}
.lc-foot{display:flex;background:rgba(0,0,0,.75);border-top:1px solid rgba(255,255,255,.07);flex-shrink:0}
.lc-foot-item{flex:1;padding:4px 8px;font-family:var(--mono);font-size:9px;color:rgba(255,255,255,.5);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lc-foot-item+.lc-foot-item{border-left:1px solid rgba(255,255,255,.1)}

/* ── TIMELINE PAGE ── */
.tl-controls{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:10px 12px;background:var(--surface);border:1px solid var(--border);border-radius:10px;margin-bottom:1rem}
.tl-chart-wrap{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:16px;margin-bottom:1rem;overflow:hidden;box-shadow:var(--shadow)}
.tl-chart-title{font-family:var(--mono);font-size:10px;font-weight:500;color:var(--muted);margin-bottom:10px;text-transform:uppercase;letter-spacing:.06em}
.tl-chart-svg{width:100%;display:block;overflow:visible}
.tl-entry-row{display:flex;align-items:center;gap:10px;padding:8px 12px;border-bottom:1px solid var(--border);cursor:pointer;transition:background .1s}
.tl-entry-row:last-child{border-bottom:none}
.tl-entry-row:hover{background:var(--surface2)}
.tl-entry-date{font-family:var(--mono);font-size:12px;font-weight:500;min-width:90px}
.tl-entry-stats{display:flex;gap:8px;flex-wrap:wrap;flex:1}
.tl-entry-stat{font-family:var(--mono);font-size:12px;color:var(--muted2)}
.tl-entry-stat strong{color:var(--text)}

/* ── MODALS ── */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.55);backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);z-index:400;display:none;align-items:center;justify-content:center;padding:max(1rem,env(safe-area-inset-top)) 1rem max(1rem,env(safe-area-inset-bottom))}
.modal-overlay.open{display:flex}
.modal-box{background:var(--surface);border-radius:14px;padding:0;max-width:500px;width:100%;box-shadow:var(--shadow-lg);overflow:hidden;border:1px solid var(--border2)}
.modal-hdr{padding:14px 18px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:8px;background:var(--surface2);font-family:var(--mono);font-size:13px;font-weight:600;color:var(--text)}
.modal-hdr button{margin-left:auto;background:none;border:none;cursor:pointer;font-size:18px;color:var(--muted);line-height:1;padding:6px 8px;border-radius:4px;transition:color .12s}
.modal-hdr button:hover{color:var(--text)}
.modal-body{padding:18px}
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:16px}
/* Generic modal-bg (for confirm etc.) */
.modal-bg{position:fixed;inset:0;background:rgba(0,0,0,.55);backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);z-index:450;display:none;align-items:center;justify-content:center;padding:1rem}
.modal-bg.open{display:flex}
.modal{background:var(--surface);border-radius:14px;padding:24px;max-width:480px;width:100%;box-shadow:var(--shadow-lg);border:1px solid var(--border2)}
.modal h2,.modal h3{font-family:var(--mono);font-size:13px;font-weight:500;margin-bottom:8px;color:var(--text)}
.modal p{font-size:13px;color:var(--muted);line-height:1.7;margin-bottom:10px}
.modal ul{font-size:13px;color:var(--muted);line-height:1.9;padding-left:18px;margin-bottom:10px}
.modal ol{font-size:13px;color:var(--muted);line-height:1.9;padding-left:18px;margin-bottom:10px}

/* confirmModal must sit above all other modal-overlays (same z-index, DOM order wins otherwise) */
#confirmModal{z-index:500}

/* ── Sidebar doc links ── */
.sb-doc-links{margin-top:auto;padding:10px 10px 12px;border-top:1px solid var(--border);display:grid;grid-template-columns:1fr 1fr;gap:4px}
.sb-doc-btn{font-family:var(--mono);font-size:11px;font-weight:500;color:var(--muted);background:var(--surface2);border:1px solid var(--border2);cursor:pointer;padding:7px 4px;border-radius:6px;transition:color .12s,background .12s;text-align:center;width:100%}
.sb-doc-btn:hover{color:var(--text);background:var(--surface3);border-color:var(--border)}

/* ── Doc modals (Help, TOS, Privacy, Legal) ── */
.doc-modal-box{max-width:580px!important}
.doc-modal-body{padding:20px 22px;max-height:72vh;overflow-y:auto;display:flex;flex-direction:column;gap:0}
.doc-modal-body h2{font-family:var(--mono);font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--text);margin:18px 0 6px}
.doc-modal-body h2:first-child{margin-top:0}
.doc-modal-body p{font-size:13px;color:var(--muted);line-height:1.75;margin:0 0 8px}
.doc-modal-body ul{font-size:13px;color:var(--muted);line-height:1.75;padding-left:18px;margin:0 0 8px}
.doc-modal-body code{font-family:var(--mono);font-size:11px;background:var(--surface2);padding:1px 5px;border-radius:3px;border:1px solid var(--border2)}

/* ── TOS MODAL ── */
#tosModal .modal-box{max-width:560px}
.tos-body{padding:18px;max-height:60vh;overflow-y:auto}
.tos-body ol{padding-left:20px}
.tos-body li{font-size:13px;color:var(--muted);line-height:1.8;margin-bottom:8px}
.tos-footer{padding:14px 18px;border-top:1px solid var(--border);display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.tos-check-label{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:500;cursor:pointer;flex:1;color:var(--text)}
.tos-check-label input{accent-color:var(--accent);width:16px;height:16px}

/* ── LIGHTBOX ── */
.lightbox{display:none;position:fixed;inset:0;background:rgba(0,0,0,.88);z-index:1000;align-items:center;justify-content:center}
.lightbox.open{display:flex}
.lightbox img{max-width:92vw;max-height:92vh;object-fit:contain;border-radius:5px}
img{-webkit-user-drag:none;user-select:none;draggable:false}
.lb-close{position:absolute;top:1rem;right:1.4rem;color:#fff;font-size:1.7rem;cursor:pointer;background:none;border:none;z-index:1}

/* ── TOAST ── */
/* Clip wrapper: fixed at header bottom, clips toast while it slides from above */
#toast-clip{position:fixed;top:calc(var(--header) + env(safe-area-inset-top,0px));left:0;right:0;z-index:500;pointer-events:none;display:flex;justify-content:center;clip-path:inset(0 0 -80px 0)}
.toast{position:relative;transform:translateY(-100%);background:var(--surface3);color:var(--text);border:1px solid var(--border2);padding:10px 18px;border-radius:0 0 12px 12px;font-family:var(--mono);font-size:12px;opacity:0;transition:opacity .22s,transform .22s;pointer-events:none;box-shadow:var(--shadow-lg);max-width:360px;white-space:normal;word-break:break-word;text-align:center;line-height:1.6}
.toast.show{transform:translateY(0);opacity:1}
.toast.err{background:rgba(239,68,68,.15);border-color:rgba(239,68,68,.35);color:var(--red)}


/* ── SCROLLBAR ── */
::-webkit-scrollbar{width:4px;height:4px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border2);border-radius:2px}

/* ── WEBCAM MODAL ── */
#webcamModal .modal-box{max-width:640px}

/* ── OOR / DIFF BADGES ── */
.oor-badge{display:inline-flex;align-items:center;font-family:var(--mono);font-size:10px;font-weight:600;padding:2px 7px;border-radius:3px;background:rgba(239,68,68,.12);color:var(--red);border:1px solid rgba(239,68,68,.3)}

/* ── DIFF HIGHLIGHT (compare) ── */
.diff-hl{outline:2px solid rgba(239,68,68,.4);outline-offset:2px;border-radius:3px}

/* ── RV CHIP (contact entry view) ── */
.rv-chip{font-family:var(--mono);font-size:11px;padding:3px 8px;border-radius:4px;background:var(--accent2);border:1px solid rgba(59,130,246,.3);color:var(--accent)}

/* ── DETAILS / SUMMARY ── */
details>summary{list-style:none;cursor:pointer;outline:none}
details>summary::-webkit-details-marker{display:none}
.hidden{display:none!important}

/* ── NOTES BLOCK ── */
.notes-block{background:var(--surface2);border:1px solid var(--border2);border-radius:5px;padding:10px 12px;font-size:13px;line-height:1.6;white-space:pre-wrap;color:var(--text)}

@media (max-width:768px){
  header{padding:0 10px}
  .logo-sub{display:none}
  .photo-grid{grid-template-columns:repeat(2,1fr)}
  .journal-list-pane{width:220px}
  .journal-list{width:220px}
  .cmp-grid{grid-template-columns:1fr 1fr}
  .stats-grid{grid-template-columns:repeat(auto-fill,minmax(130px,1fr))}
  .two-col{grid-template-columns:1fr}
}
@media (max-width:500px){
  /* Legacy */
  .journal-layout{flex-direction:column}
  .journal-list{width:100%;height:220px;border-right:none;border-bottom:1px solid var(--border)}
  .stats-grid{grid-template-columns:1fr 1fr}
}

@media (max-width:640px){
  /* ── Journal mobile: simple stacked layout, no overflow:hidden ancestors ── */
  .journal-split{
    display:block;
    height:auto;
    overflow:visible;
    margin:0 -1.25rem;
  }
  /* List pane: normal flow at top, no positioning tricks */
  .journal-split .journal-list-pane{
    display:block;
    position:static;
    width:100%;
    overflow:visible;
    border-right:none;
    border-bottom:1px solid var(--border);
  }
  /* Detail pane: normal flow below */
  .journal-split .journal-detail-pane{
    display:block;
    position:static;
    overflow-y:visible;
    height:auto;
    padding:1rem 1.25rem 2rem;
  }
  /* Entries accordion */
  #jl-entries-panel{flex:none;min-height:unset;overflow:visible;position:static}
  #jl-entries-panel > summary{display:flex}
  #jl-entries-panel > .jl-acc-body{display:block;overflow:visible;height:auto;position:static}
  /* THE scroll container — no overflow:hidden anywhere above it in the chain */
  #jl-entries-panel > .jl-acc-body > .journal-list-scroll{
    height:45vh;
    overflow-y:scroll;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior:contain;
  }
  #buddy-notes-panel > #buddy-notes-content{height:auto;overflow:visible}
  .journal-detail-back{display:none!important}

  /* Prevent iOS auto-zoom on input focus (must be ≥ 16px) */
  input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]),
  select,textarea{font-size:max(16px,1em)!important}

  /* Body text minimum */
  body{font-size:16px}
  .page-hdr h1{font-size:20px}

  /* Touch active feedback */
  .btn:active{transform:scale(.97);opacity:.82}
  .btn{-webkit-tap-highlight-color:transparent}
  .entry-item:active,.li:active,.tl-entry-row:active,.feed-item:active{background:var(--surface2)}
  .nav-item:active,.sb-nav-item:active{background:var(--surface2)}
  .ci-btn:active{border-color:var(--accent);color:var(--accent)}
  .device-chip:active,.opt-item:active{border-color:var(--accent)}

  /* Range thumb — larger for touch */
  input[type=range]::-webkit-slider-thumb{width:20px;height:20px}

  /* Modals: limit height, allow scroll */
  .modal-box{max-height:min(92dvh,calc(100svh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px) - 2rem));overflow-y:auto}
  .modal-body{padding:14px}

  /* Stat grids */
  .stats-grid,.stat-grid{grid-template-columns:1fr 1fr}

  /* Sidebar full width on narrow phones */
  .sidebar{width:min(300px,85vw)}

  /* Compact header on mobile: hide logo text, tighten spacing */
  .logo{display:none}
  .hdr,header{
    gap:8px;
    padding-left:max(8px,env(safe-area-inset-left,8px));
    padding-right:max(8px,env(safe-area-inset-right,8px));
  }

  /* Bottom nav covers Buddies navigation — hide header button on mobile */
  #hdrBuddiesBtn{display:none}

  /* Keep kill switch but hide text label on very narrow screens */
  @media (max-width:390px){
    #killSwitchLabel{display:none}
    .kill-switch-btn{padding:6px}
  }
}

/* ── No-hover device: remove sticky hover states ── */
@media (hover:none){
  .li:hover,.entry-item:hover,.feed-item:hover,.tl-entry-row:hover{background:inherit}
  .nav-item:hover,.sb-nav-item:hover{background:inherit;color:var(--muted)}
  .sb-section-hdr:hover{color:var(--muted2)}
  .sb-acc-hdr:hover{background:inherit}
  .btn-ghost:hover{background:var(--surface2);color:var(--muted);border-color:var(--border2)}
  .btn-primary:hover{background:var(--accent);border-color:var(--accent)}
  .btn-secondary:hover{background:var(--accent2)}
  .btn-danger:hover{background:transparent;border-color:rgba(239,68,68,.35)}
  .btn-green:hover{background:var(--green)}
  .hamburger:hover,.menu-btn:hover{background:transparent;color:var(--muted)}
  .thumb-hover:hover{outline:none}
  .ci-btn:hover{border-color:var(--border2);color:var(--muted)}
  .device-chip:hover{border-color:var(--border2);color:var(--muted)}
  .sb-btn:hover{border-color:var(--border2);background:var(--surface2)}
  .sb-legal a:hover{color:var(--muted);text-decoration:none}
  .main-footer a:hover{color:var(--muted)}
}

/* ── Kill switch button ── */
.kill-switch-btn{display:flex;align-items:center;gap:5px;padding:4px 8px;border-radius:6px;border:1px solid var(--border2);background:none;cursor:pointer;font-family:var(--mono);font-size:11px;color:var(--muted2);transition:all .15s;-webkit-tap-highlight-color:transparent;min-height:30px}
.kill-switch-dot{width:7px;height:7px;border-radius:50%;background:var(--muted2);flex-shrink:0;transition:background .3s}
body:not(.p2p-offline) .kill-switch-dot{background:var(--green)}
body:not(.p2p-offline) .kill-switch-btn{color:var(--text);border-color:var(--greenb)}
.kill-switch-btn:hover{background:var(--surface2)}

/* ── Bottom nav (mobile only) ── */
.bottom-nav{display:none}
@media (max-width:640px){
  /* In-flow flex child of .app (which is height:100dvh), so it always sits flush
     with the bottom of the visible dynamic viewport. position:fixed here left a
     gap on phones whose fixed-viewport bottom differs from the dvh bottom. */
  .bottom-nav{
    display:flex;flex-shrink:0;
    height:calc(56px + env(safe-area-inset-bottom,0px));
    padding-bottom:env(safe-area-inset-bottom,0px);
    background:var(--surface);border-top:1px solid var(--border);
    z-index:100;box-shadow:0 -1px 12px rgba(0,0,0,.08)
  }
  .bottom-nav-item{
    flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
    gap:3px;border:none;background:none;cursor:pointer;color:var(--muted2);
    font-family:var(--mono);font-size:10px;font-weight:500;letter-spacing:.04em;
    text-transform:uppercase;padding:8px 4px;min-height:44px;
    -webkit-tap-highlight-color:transparent;transition:color .12s;
  }
  .bottom-nav-item.active{color:var(--accent)}
  .bottom-nav-item:active{color:var(--accent);transform:scale(.93)}
  .bottom-nav-icon{font-size:19px;line-height:1}
  /* Bottom nav is now an in-flow flex sibling, so .main no longer needs to
     reserve space for a fixed overlay; normal padding is enough. */
  .main{padding-bottom:1.25rem}
}

/* ── Hide images privacy mode ── */
body.blur-images img,body.blur-images canvas.photo-canvas{visibility:hidden}
#blurImagesBtn.active{color:var(--accent);background:var(--accent2)}

/* ── Profile edit responsive grid ── */
.prof-edit-grid{grid-template-columns:repeat(auto-fill,minmax(180px,1fr))}
@media (max-width:460px){.prof-edit-grid{grid-template-columns:1fr}}

/* ── Encryption setup overlay (first-run) ── */
.enc-setup-overlay{position:fixed;inset:0;z-index:100000;background:var(--surface);display:none;align-items:center;justify-content:center;padding:24px}
.enc-setup-overlay.active{display:flex}
.enc-setup-box{width:100%;max-width:360px;background:var(--surface2);border:1px solid var(--border2);border-radius:16px;padding:32px 28px;text-align:center}
.enc-setup-icon{font-size:44px;line-height:1;margin-bottom:12px}
.enc-setup-title{font-family:var(--sans);font-size:18px;font-weight:600;color:var(--text);margin:0 0 8px}
.enc-setup-sub{font-size:13px;color:var(--muted);line-height:1.6;margin:0 0 20px}
.enc-setup-field{margin-bottom:10px}
.enc-setup-field input{width:100%;box-sizing:border-box;background:var(--surface);border:1px solid var(--border2);border-radius:8px;padding:10px 14px;font-family:var(--mono);font-size:13px;color:var(--text);outline:none}
.enc-setup-field input:focus{border-color:var(--accent)}
.enc-setup-strength{display:flex;align-items:center;gap:8px;margin:-2px 0 10px}
.enc-str-track{flex:1;height:4px;background:var(--border);border-radius:2px;overflow:hidden}
.enc-str-fill{height:100%;width:0;border-radius:2px;transition:width .2s,background .2s}
.enc-setup-strength span{font-family:var(--mono);font-size:10px;color:var(--muted2);min-width:38px;text-align:right}
.enc-setup-check-row{display:flex;align-items:flex-start;gap:8px;text-align:left;font-size:12px;color:var(--muted);line-height:1.5;margin-bottom:12px;cursor:pointer}
.enc-setup-check-row input{flex-shrink:0;margin-top:2px;accent-color:var(--accent)}
.enc-setup-err{font-family:var(--mono);font-size:11px;color:var(--red);margin:0 0 10px;min-height:16px}
.enc-setup-submit{width:100%}
.enc-setup-skip{display:block;margin-top:12px;font-family:var(--mono);font-size:11px;color:var(--muted2);background:none;border:none;cursor:pointer;text-decoration:underline}

/* ── Buddy Network — Presence toggle ── */
.presence-toggle{display:flex;gap:4px;padding:8px 12px;border-top:1px solid var(--border2)}
.presence-btn{flex:1;padding:5px 4px;border-radius:5px;border:1px solid var(--border2);background:none;cursor:pointer;font-family:var(--mono);font-size:10px;font-weight:500;color:var(--muted2);transition:all .12s;text-align:center}
.presence-btn.active-offline{background:var(--surface3);border-color:var(--border2);color:var(--text)}
.presence-btn.active-private{background:#172554;border-color:#1d4ed8;color:#93c5fd}
.presence-btn.active-public{background:#052e16;border-color:#166534;color:#86efac}

/* ── Network / Buddies / Public toggle buttons ── */
.net-toggles{display:flex;gap:6px;padding:8px 14px 6px}
.net-toggle-btn{flex:1;display:flex;flex-direction:column;align-items:center;gap:5px;padding:10px 4px 8px;background:var(--surface2);border:1px solid var(--amberb,#92400e);border-radius:8px;cursor:pointer;transition:background .15s,border-color .2s,box-shadow .2s;-webkit-tap-highlight-color:transparent;box-shadow:0 0 0 0 transparent}
.net-toggle-btn:hover{background:var(--surface3,#222)}
.net-toggle-btn.active{background:rgba(34,197,94,.08);border-color:rgba(34,197,94,.4);box-shadow:none}
.net-toggle-dot{width:11px;height:11px;border-radius:50%;background:var(--amber,#f59e0b);flex-shrink:0;transition:background .2s}
.net-toggle-dot.on{background:#22c55e}
.net-toggle-label{font-family:var(--mono);font-size:10px;color:var(--amber,#f59e0b);text-transform:uppercase;letter-spacing:.05em;font-weight:600}
.net-toggle-btn.active .net-toggle-label{color:#22c55e}
.net-toggle-state{font-family:var(--mono);font-size:9px;letter-spacing:.04em;font-weight:500;color:var(--amber,#f59e0b);margin-top:-2px}
.net-toggle-btn.active .net-toggle-state{color:rgba(34,197,94,.8)}
.net-status-line{padding:2px 14px 8px;font-size:11px;color:var(--muted2);line-height:1.5;min-height:1.5em}
.net-status-line.offline{color:var(--amber,#f59e0b)}
.net-status-line.online{color:#22c55e}

/* ── Buddy Network — Restorers Online emoji buttons ── */
.restorer-item{position:relative;display:inline-flex}
.restorer-emoji-btn{width:36px;height:36px;border-radius:50%;border:1px solid var(--border2);background:var(--surface2);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:20px;transition:background .12s}
.restorer-emoji-btn:hover{background:var(--surface3)}
.restorer-block-btn{position:absolute;top:-3px;right:-3px;width:14px;height:14px;border-radius:50%;border:none;background:var(--red,#ef4444);color:#fff;cursor:pointer;font-size:7px;line-height:14px;padding:0;text-align:center;opacity:0;transition:opacity .12s;z-index:1}
.restorer-item:hover .restorer-block-btn{opacity:1}
@keyframes highlightFlash{0%{box-shadow:0 0 0 3px var(--green);background:rgba(34,197,94,.15)}100%{box-shadow:none;background:transparent}}
.highlight-flash{animation:highlightFlash 1.8s ease-out forwards}
.welcome-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:16px}
.welcome-action-wrap{position:relative}
.welcome-action-btn{display:flex;flex-direction:column;align-items:flex-start;gap:4px;padding:12px 14px;padding-right:26px;background:var(--surface2);border:1px solid var(--border2);border-radius:8px;cursor:pointer;text-align:left;transition:border-color .15s,background .15s;font-family:inherit;width:100%}
.welcome-action-btn:hover{border-color:var(--accent);background:var(--surface3)}
.welcome-action-btn .wa-icon{font-size:20px;line-height:1}
.welcome-action-btn .wa-title{font-size:12px;font-weight:600;color:var(--text)}
.welcome-action-btn .wa-sub{font-size:10px;color:var(--muted2);line-height:1.4;font-family:var(--mono)}
.wa-dismiss{position:absolute;top:4px;right:4px;width:24px;height:24px;border:none;background:none;color:var(--muted2);font-size:15px;line-height:1;cursor:pointer;border-radius:4px;display:flex;align-items:center;justify-content:center;padding:0;transition:color .12s,background .12s;z-index:1}
.wa-dismiss:hover{color:var(--text);background:var(--surface3)}

/* ── Timer hero buttons ── */
.timer-hero{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:0 0 1.25rem;background:none}
.timer-hero-btn{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;padding:26px 16px;cursor:pointer;transition:background .18s,box-shadow .18s,transform .12s;-webkit-tap-highlight-color:transparent;border:none;outline:none;min-height:104px;user-select:none;border-radius:16px;box-shadow:var(--shadow)}
.timer-hero-btn:active{transform:scale(.98)}
.timer-hero-btn.tug{background:#166534;color:#bbf7d0}
.timer-hero-btn.tug:hover{background:#15803d}
.timer-hero-btn.tug.active{background:#22c55e;color:#052e16;animation:timerPulseGreen 2s ease-in-out infinite}
.timer-hero-btn.ret{background:#1e40af;color:#bfdbfe}
.timer-hero-btn.ret:hover{background:#1d4ed8}
.timer-hero-btn.ret.active{background:#3b82f6;color:#eff6ff;animation:timerPulseBlue 2s ease-in-out infinite}
.timer-hero-label{font-family:var(--mono);font-size:15px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}
.timer-hero-sub{font-family:var(--mono);font-size:11px;opacity:.75}
.timer-hero-btn.active .timer-hero-sub{font-size:20px;font-weight:700;opacity:1;letter-spacing:.02em}
@keyframes timerPulseGreen{0%,100%{box-shadow:inset 0 0 0 0 rgba(0,0,0,0)}50%{box-shadow:inset 0 -6px 24px rgba(0,0,0,.2)}}
@keyframes timerPulseBlue{0%,100%{box-shadow:inset 0 0 0 0 rgba(0,0,0,0)}50%{box-shadow:inset 0 -6px 24px rgba(0,0,0,.2)}}
@keyframes timerPulse{0%,100%{border-color:#22c55e;box-shadow:0 0 0 0 rgba(34,197,94,.3)}50%{border-color:#4ade80;box-shadow:0 0 8px 2px rgba(34,197,94,.15)}}
/* Timer — adopted (running on your other device, recent) */
.timer-hero-btn.tug.adopted{background:#14532d;color:#86efac;animation:timerPulseGreen 3s ease-in-out infinite;opacity:.88}
.timer-hero-btn.tug.adopted:hover{background:#166534}
.timer-hero-btn.ret.adopted{background:#1e3a8a;color:#93c5fd;animation:timerPulseBlue 3s ease-in-out infinite;opacity:.88}
.timer-hero-btn.ret.adopted:hover{background:#1e40af}
/* Timer — stale (>12h from another device) */
.timer-hero-btn.tug.stale{background:#78350f;color:#fde68a}
.timer-hero-btn.ret.stale{background:#78350f;color:#fde68a}
.timer-device-row{display:grid;grid-template-columns:1fr 1fr;gap:3px;margin-bottom:1rem}
.timer-device-col{display:flex;flex-wrap:wrap;gap:4px;padding:6px 8px;justify-content:center;min-height:28px}
.tdev-chip{font-family:var(--mono);font-size:11px;padding:3px 8px;border-radius:12px;cursor:pointer;border:1px solid var(--border2);background:var(--surface2);color:var(--muted);transition:background .15s,color .15s;white-space:nowrap;user-select:none}
.tdev-chip:hover{border-color:var(--border3,#cbd5e1);color:var(--text)}
.tdev-chip.tug-sel{background:#166534;border-color:#16a34a;color:#bbf7d0;font-weight:600}
.tdev-chip.ret-sel{background:#1e40af;border-color:#2563eb;color:#bfdbfe;font-weight:600}
/* Live-update flash when remote activity arrives */
@keyframes timerLiveFlash{0%{box-shadow:none}30%{box-shadow:0 0 0 3px rgba(34,197,94,.55),inset 0 0 20px rgba(34,197,94,.08)}100%{box-shadow:none}}
.timer-hero.live-update{animation:timerLiveFlash .75s ease-out}
/* Adopted / stale info bars */
.timer-sync-bar{font-family:var(--mono);font-size:10px;text-align:center;padding:4px 12px 10px;margin-top:-4px}
.timer-sync-bar.adopted{color:#60a5fa}
.timer-sync-bar.stale{background:rgba(120,53,15,.18);border-radius:6px;color:#fbbf24;padding:10px 16px 12px;margin:0 0 12px}
.timer-sessions{margin-top:10px;border-top:1px solid var(--border);padding-top:8px}
.timer-sessions-hdr{font-family:var(--mono);font-size:10px;color:var(--muted2);cursor:pointer;padding:4px 0;text-transform:uppercase;letter-spacing:.05em;list-style:none}
.timer-sessions-hdr::-webkit-details-marker{display:none}
.timer-sessions-list{display:flex;flex-direction:column;gap:1px}
.timer-session-row{display:flex;align-items:center;gap:8px;padding:5px 4px;font-family:var(--mono);font-size:11px;color:var(--muted);border-bottom:1px solid var(--border)}
.timer-session-row.editing{flex-direction:column;align-items:stretch;padding:8px 4px}
.timer-session-icon{font-size:14px;flex-shrink:0}
.timer-session-date{color:var(--muted2);white-space:nowrap}
.timer-session-dur{color:var(--text);font-weight:600;white-space:nowrap}
.timer-session-note{color:var(--muted2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:120px}
.timer-session-actions{margin-left:auto;display:flex;gap:2px;opacity:.4;transition:opacity .12s}
.timer-session-row:hover .timer-session-actions{opacity:1}
.timer-session-edit-fields{display:flex;flex-direction:column;gap:2px;width:100%}

/* ── Storage / private-mode warning banner ── */
.storage-warn-bar{display:flex;align-items:flex-start;gap:12px;background:var(--amberl);border:1px solid var(--amberb);border-radius:8px;padding:12px 14px;margin-bottom:1rem;font-size:13px;line-height:1.45}
.storage-warn-icon{font-size:18px;flex-shrink:0;margin-top:1px}
.storage-warn-body{flex:1;min-width:0}
.storage-warn-title{font-weight:600;color:var(--amber);margin-bottom:2px}
.storage-warn-private{display:none;margin-top:6px;padding:6px 10px;background:rgba(180,83,9,.13);border-radius:5px;font-size:12px;color:var(--amber);font-weight:500}
.storage-warn-private.visible{display:block}
.storage-warn-dismiss{flex-shrink:0;align-self:center;background:none;border:1px solid var(--amberb);border-radius:5px;color:var(--amber);font-size:12px;padding:4px 10px;cursor:pointer;white-space:nowrap;font-family:var(--sans)}
.storage-warn-dismiss:hover{background:var(--amberb)}

/* ── GALLERY ── */
.gal-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-bottom:1rem}
.gal-card{background:var(--surface);border:1px solid var(--border);border-radius:10px;overflow:hidden;cursor:pointer;transition:box-shadow .15s;user-select:none;box-shadow:var(--shadow)}
.gal-card:hover{box-shadow:var(--shadow-lg)}
.gal-card-cover{aspect-ratio:3/4;overflow:hidden;background:var(--surface2);border-radius:10px 10px 0 0}
.gal-card-body{padding:10px 12px 12px}
.gal-card-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gal-card-meta{font-size:11px;color:var(--muted2);margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gal-photo-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-bottom:1rem}
.gal-item{position:relative;break-inside:avoid}
.gal-photo-grid .gal-item canvas{aspect-ratio:1;object-fit:cover;width:100%;display:block;border-radius:4px;cursor:pointer}
.gal-item-title{font-size:11px;color:var(--muted);margin-top:4px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gal-item-note{font-size:11px;color:var(--muted2);margin-top:2px;text-align:center;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.gal-item-remove{position:absolute;top:4px;right:4px;background:rgba(0,0,0,.55);color:#fff;border:none;border-radius:50%;width:22px;height:22px;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s}
.gal-item:hover .gal-item-remove{opacity:1}
.gal-note-badge{position:absolute;top:4px;left:4px;background:var(--amber,#f59e0b);color:#fff;border-radius:10px;padding:2px 6px;font-size:10px;font-weight:700;line-height:1.4;pointer-events:none}
.gal-buddy-note{background:var(--surface2);border:1px solid var(--border2);border-radius:6px;padding:8px 10px;margin-bottom:6px}
.gal-buddy-note-author{font-family:var(--mono);font-size:11px;font-weight:600;color:var(--muted);margin-bottom:3px}
.gal-buddy-note-text{font-size:13px;color:var(--text);line-height:1.5;white-space:pre-wrap;word-break:break-word}
@media(max-width:600px){.gal-grid{grid-template-columns:repeat(2,1fr)}.gal-photo-grid{grid-template-columns:repeat(3,1fr)}}

/* ── Comment cards (shared between journal + gallery) ── */
.comment-card{background:var(--surface2);border:1px solid var(--border2);border-radius:6px;padding:10px 12px;margin-bottom:8px}
.comment-card-author{font-family:var(--mono);font-size:11px;font-weight:600;color:var(--muted);margin-bottom:3px;display:flex;align-items:baseline;gap:6px}
.comment-card-author .comment-ts{font-weight:400;color:var(--muted2)}
.comment-card-body{font-size:13px;color:var(--text);line-height:1.5;white-space:pre-wrap;word-break:break-word}
.comment-card-edited{font-family:var(--mono);font-size:10px;color:var(--muted2);margin-top:4px}

/* ── Data Analytics Page ── */
.data-span-bar{display:flex;flex-direction:column;gap:8px;padding:0 0 16px}
.data-span-types{display:flex;gap:6px;flex-wrap:wrap}
.data-span-btn{font-family:var(--mono);font-size:12px;padding:6px 12px;border-radius:6px;border:1px solid var(--border2);background:var(--surface);color:var(--muted);cursor:pointer;transition:background .12s,color .12s,border-color .12s}
.data-span-btn:hover{background:var(--surface2);color:var(--text)}
.data-span-btn.active{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}
.data-span-nav{display:flex;align-items:center;gap:6px}
.data-span-period{font-family:var(--mono);font-size:11px;color:var(--muted);min-width:160px;text-align:center;white-space:nowrap}
.data-span-nav-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;background:var(--surface);border:1px solid var(--border2);border-radius:5px;color:var(--text);font-size:18px;cursor:pointer;padding:0;flex-shrink:0}
.data-span-nav-btn:hover:not(:disabled){background:var(--surface2)}
.data-span-nav-btn.disabled,.data-span-nav-btn:disabled{opacity:.3;cursor:default}
.data-stats-row{display:grid;grid-template-columns:repeat(auto-fill,minmax(110px,1fr));gap:10px;margin-bottom:16px}
.data-stat-card{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:12px 14px;box-shadow:var(--shadow)}
.data-stat-val{font-family:var(--mono);font-size:20px;font-weight:600;color:var(--text);line-height:1.2}
.data-stat-label{font-size:11px;color:var(--muted);margin-top:3px}
.data-stat-sub{font-family:var(--mono);font-size:10px;color:var(--muted2);margin-top:2px}
.data-card{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:16px;margin-bottom:14px;box-shadow:var(--shadow)}
.data-2col>.data-card{margin-bottom:0}
.data-card-title{font-family:var(--mono);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--muted2);margin-bottom:12px}
.data-2col{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-bottom:14px}
@media(max-width:540px){.data-2col{grid-template-columns:1fr}}
.data-legend-row{display:flex;align-items:center;flex-wrap:wrap;gap:6px;font-size:11px;color:var(--muted);margin-bottom:10px}
.data-ldot{display:inline-block;width:9px;height:9px;border-radius:50%;flex-shrink:0;vertical-align:middle}

/* ── Responsive helpers ─────────────────────────────────────────────────── */
.show-mobile{display:none}
@media(max-width:600px){.hide-mobile{display:none!important}.show-mobile{display:inline!important}}

/* ── Activity feed ──────────────────────────────────────────────────────── */
#page-activity .page-hdr{max-width:min(33vw,520px);margin:0 auto}
.af-container{max-width:min(33vw,520px);margin:0 auto}
@media(max-width:900px){#page-activity .page-hdr,.af-container{max-width:100%}}
#activity-feed{display:flex;flex-direction:column;gap:0}
.af-card{background:var(--surface);border:1px solid var(--border);border-radius:10px;margin:0 0 14px;overflow:hidden;box-shadow:var(--shadow)}
.af-header{display:flex;align-items:center;gap:10px;padding:12px 14px;background:var(--surface2);border-bottom:1px solid var(--border)}
.af-avatar{font-size:20px;line-height:1;flex-shrink:0;width:34px;height:34px;display:flex;align-items:center;justify-content:center;background:var(--surface);border-radius:50%;border:1px solid var(--border2)}
.af-name{font-size:13px;font-weight:600;color:var(--text)}
.af-label{font-size:11px;color:var(--muted2);font-family:var(--mono)}
.af-time{font-family:var(--mono);font-size:10px;color:var(--muted2);margin-left:auto;flex-shrink:0}
.af-photo{padding:0;border-bottom:1px solid var(--border)}
.af-photo img,.af-photo canvas{width:100%;max-height:50vh;object-fit:contain;display:block;background:var(--surface3)}
.af-metrics{padding:8px 14px 0;font-family:var(--mono);font-size:12px;color:var(--muted)}
.af-note{padding:8px 14px 0;font-size:13px;color:var(--text);white-space:pre-wrap;line-height:1.5}
.af-actions{display:flex;align-items:center;gap:10px;padding:10px 14px 6px}
.af-comments{padding:0 14px 10px;border-top:1px solid var(--border);margin-top:6px;padding-top:8px}
.af-comment{font-size:12px;color:var(--text);margin-bottom:5px;line-height:1.4}
.af-comment-author{font-weight:600;margin-right:4px}
.af-comment-ts{font-family:var(--mono);font-size:10px;color:var(--muted2);margin-left:6px}
.af-comment-form{display:flex;align-items:flex-start;gap:6px;padding:6px 14px 12px}
.af-filter-chip{display:inline-flex;align-items:center;gap:5px;padding:4px 10px;border-radius:16px;border:1px solid var(--border2);background:var(--surface2);color:var(--muted);font-family:var(--mono);font-size:11px;cursor:pointer;transition:all .15s;white-space:nowrap}
.af-filter-chip:hover{border-color:var(--accent);color:var(--text)}
.af-filter-chip.active{background:var(--accent2);border-color:var(--accent);color:var(--accent);font-weight:600}
.af-comment-input{flex:1;font-size:13px;font-family:var(--sans);padding:7px 10px;border-radius:5px;border:1px solid var(--border2);background:var(--surface2);color:var(--text);resize:none;min-height:30px;box-sizing:border-box;transition:border-color .12s}
.af-comment-input:focus{border-color:var(--accent)}

/* ── Messenger (full-page chat) ─────────────────────────────────────────── */
.msgr{display:flex;height:calc(100vh - var(--header) - env(safe-area-inset-top,0px));margin:-1.25rem;overflow:hidden}
.msgr-list-pane{width:290px;flex-shrink:0;order:2;border-left:1px solid var(--border);display:flex;flex-direction:column;background:var(--surface);min-height:0}
.msgr-list-hdr{font-family:var(--mono);font-size:13px;font-weight:600;padding:14px 16px 10px;border-bottom:1px solid var(--border2);color:var(--text)}
.msgr-list{flex:1;overflow-y:auto;min-height:0}
.msgr-list-empty{padding:24px 18px;font-size:13px;color:var(--muted);display:flex;flex-direction:column;gap:8px;align-items:flex-start}
.msgr-convo{display:flex;gap:10px;width:100%;padding:11px 14px;background:none;border:none;border-bottom:1px solid var(--border2);cursor:pointer;text-align:left;font-family:inherit;color:var(--text);transition:background .12s;align-items:center}
.msgr-convo:hover{background:var(--surface2)}
.msgr-convo.active{background:var(--surface2)}
.msgr-convo-avatar{font-size:22px;line-height:1;position:relative;flex-shrink:0}
.msgr-convo-dot{position:absolute;right:-3px;bottom:-3px;width:9px;height:9px;border-radius:50%;background:#555;border:2px solid var(--surface)}
.msgr-convo-dot.on{background:var(--green)}
.msgr-convo-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.msgr-convo-top{display:flex;align-items:baseline;gap:8px}
.msgr-convo-name{flex:1;font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.msgr-convo-time{font-family:var(--mono);font-size:10px;color:var(--muted2);flex-shrink:0}
.msgr-convo-bottom{display:flex;align-items:center;gap:8px}
.msgr-convo-preview{flex:1;font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.msgr-convo-unread{background:var(--green);color:#fff;font-size:10px;font-family:var(--mono);font-weight:700;border-radius:9px;padding:1px 6px;flex-shrink:0}
.msgr-thread-pane{flex:1;min-width:0;display:flex;flex-direction:column}
.msgr-thread-pane .empty{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--muted2)}
#msgr-thread{display:flex;flex-direction:column;flex:1;min-height:0}
.msgr-thread-hdr{display:flex;align-items:center;gap:10px;padding:10px 16px;border-bottom:1px solid var(--border);background:var(--surface);flex-shrink:0}
.msgr-back{display:none;background:none;border:none;color:var(--text);font-size:18px;cursor:pointer;padding:4px 8px;margin-left:-8px}
.msgr-hdr-avatar{font-size:22px;line-height:1}
.msgr-hdr-names{flex:1;min-width:0}
#msgrName{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#msgrStatus{font-family:var(--mono);font-size:10px;color:var(--muted2)}
.msgr-msgs{flex:1;overflow-y:auto;padding:14px 18px;display:flex;flex-direction:column;gap:8px;min-height:0}
#msgrPhotoPicker{flex:1;overflow-y:auto;padding:10px;min-height:0;border-bottom:1px solid var(--border2)}
.msgr-footer{display:flex;gap:8px;padding:10px 14px;border-top:1px solid var(--border);background:var(--surface);flex-shrink:0}
@media (max-width:640px){
  .msgr{position:fixed;left:0;right:0;top:calc(var(--header) + env(safe-area-inset-top,0px));bottom:calc(56px + env(safe-area-inset-bottom,0px));height:auto;margin:0}
  .msgr-list-pane{width:100%;border-right:none}
  .msgr-thread-pane{display:none}
  .msgr.thread-open .msgr-list-pane{display:none}
  .msgr.thread-open .msgr-thread-pane{display:flex}
  .msgr-back{display:block}
}

/* ── Dashboard logs cluster (sessions / weekly log / daily tracker) ─────── */
.dash-logs{display:flex;flex-direction:column;gap:8px;margin:1.25rem 0 1.5rem}
.dash-logs .panel{margin-bottom:0}
.dash-logs summary h2{font-size:13px;font-weight:500;color:var(--muted)}
.dash-logs details[open] summary h2{color:var(--text)}
.dash-logs .timer-sessions-hdr{font-size:13px;font-weight:500;color:var(--muted)}

/* ── Icon system (inline SVG sprite, stroke icons) ──────────────────────── */
.icon{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;display:inline-block;vertical-align:middle;pointer-events:none}
.bottom-nav-icon .icon{width:22px;height:22px;stroke-width:1.8}
.hdr-lock-btn .icon{width:16px;height:16px}
.chat-modal-send .icon{width:16px;height:16px}

/* ── Accessibility floor ────────────────────────────────────────────────── */
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
  html{scroll-behavior:auto}
}

/* ── Dark-theme visibility tweaks ───────────────────────────────────────── */
[data-theme="dark"] .hdr-dot.public-off{background:#39423e}

/* ── Mobile app feel: iOS-zoom-proof inputs + comfortable touch targets ─── */
@media (max-width:640px){
  .input,.chat-modal-input,input[type=text],input[type=number],input[type=date],textarea,select{font-size:16px}
  .btn{min-height:42px}
  .btn-sm{min-height:38px}
  .nav-item{min-height:44px}
  .msgr-convo{min-height:56px}
}

/* ── CI illustrated reference modal ─────────────────────────────────────── */
.ciref-box{max-width:720px;display:flex;flex-direction:column;max-height:calc(100svh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px) - 2rem)}
.ciref-hint{font-family:var(--mono);font-size:11px;color:var(--muted2);padding:10px 16px 0;line-height:1.5}
.ciref-body{overflow-y:auto;padding:14px;display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px;min-height:0}
.ciref-card{background:var(--surface);border:1px solid var(--border2);border-radius:10px;overflow:hidden;cursor:pointer;text-align:left;padding:0;transition:border-color .12s,transform .08s;font-family:inherit;color:var(--text);-webkit-tap-highlight-color:transparent}
.ciref-card:hover{border-color:var(--accent)}
.ciref-card:active{transform:scale(.98)}
.ciref-card.current{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent2)}
.ciref-card img{display:block;width:100%;aspect-ratio:3/4;object-fit:contain;background:#fff}
.ciref-card-label{font-family:var(--mono);font-size:12px;font-weight:600;color:var(--accent);padding:8px 10px 2px}
.ciref-card-desc{font-size:11px;color:var(--muted);line-height:1.5;padding:0 10px 10px}
.ciref-open-btn{background:none;border:none;padding:0;margin-top:5px;font-family:var(--mono);font-size:11px;color:var(--accent);cursor:pointer;text-decoration:underline;text-underline-offset:2px}
.ciref-open-btn:hover{color:var(--accent-hover)}
@media (max-width:520px){.ciref-body{grid-template-columns:repeat(2,1fr)}}

/* ── Chats unread badges (sidebar + bottom nav) ─────────────────────────── */
.nav-unread{margin-left:auto;background:var(--green);color:#fff;font-family:var(--mono);font-size:10px;font-weight:700;border-radius:9px;padding:1px 6px;line-height:1.4}
.bn-unread{position:absolute;top:-5px;right:-9px;background:var(--green);color:#fff;font-family:var(--mono);font-size:9px;font-weight:700;border-radius:8px;min-width:14px;height:14px;display:flex;align-items:center;justify-content:center;padding:0 3px;line-height:1}

/* ── Messenger thread header: tappable identity opens the profile popup ─── */
.msgr-hdr-id{display:flex;align-items:center;gap:10px;flex:1;min-width:0;background:none;border:none;cursor:pointer;text-align:left;padding:4px 8px;margin:-4px -8px;border-radius:8px;font-family:inherit;color:var(--text);-webkit-tap-highlight-color:transparent}
.msgr-hdr-id:hover{background:var(--surface2)}
.msgr-hdr-id .msgr-hdr-names{display:flex;flex-direction:column;min-width:0}

/* ── Storage health banner (js/storagehealth.js) ────────────────────────── */
.shb{display:flex;align-items:flex-start;gap:10px;border-radius:10px;padding:11px 14px;margin-bottom:1rem;font-size:13px;line-height:1.55}
.shb-warn{background:var(--amberl);border:1px solid var(--amberb);color:var(--text)}
.shb-danger{background:var(--redl);border:1px solid var(--redb);color:var(--text)}
.shb-text{flex:1;min-width:0}
.shb-close{background:none;border:none;cursor:pointer;color:var(--muted2);font-size:17px;line-height:1;padding:2px 6px;flex-shrink:0;border-radius:4px}
.shb-close:hover{color:var(--text)}

/* ── Buddy cards (refreshed) ─────────────────────────────────────────────── */
.buddy-empty{grid-column:1/-1;display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center;padding:2rem 1.5rem;color:var(--muted)}
.buddy-empty p{max-width:36ch;font-size:13px;line-height:1.6;margin:0}
.buddy-card{display:flex;flex-direction:column;gap:8px;padding:12px;background:var(--surface);border:1px solid var(--border);border-radius:12px;cursor:pointer;box-shadow:var(--shadow);transition:border-color .12s,transform .08s}
.buddy-card:hover{border-color:var(--border2)}
.buddy-card:active{transform:scale(.995)}
.buddy-card.mutual{border-color:color-mix(in srgb, var(--purple) 45%, transparent);background:color-mix(in srgb, var(--purple) 5%, var(--surface))}
.bc-head{display:flex;align-items:center;gap:10px}
.bc-avatar{position:relative;width:38px;height:38px;border-radius:50%;background:var(--surface2);border:1px solid var(--border2);display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:21px;line-height:1}
.bc-dot{position:absolute;bottom:-1px;right:-1px;width:11px;height:11px;border-radius:50%;background:var(--muted2);border:2px solid var(--surface)}
.bc-dot.online{background:var(--green)}
.bc-dot.idle{background:#f97316}
.buddy-card.mutual .bc-dot{border-color:color-mix(in srgb, var(--purple) 5%, var(--surface))}
.bc-id{min-width:0;flex:1}
.bc-name{font-weight:600;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bc-status{display:flex;align-items:center;gap:5px;font-family:var(--mono);font-size:11px;color:var(--muted2);margin-top:1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bc-ci{padding:1px 6px;border-radius:4px;background:var(--surface2);border:1px solid var(--border2);font-size:10px;color:var(--muted);flex-shrink:0}
.bc-fp{font-family:var(--mono);font-size:9px;color:var(--muted2);letter-spacing:.06em;margin-top:2px}
.bc-tags{font-size:10px;color:var(--muted2);text-align:center}
.bc-actions{display:flex;gap:4px}
.bc-btn{flex:1;display:flex;align-items:center;justify-content:center;padding:7px 0;background:var(--surface2);border:1px solid var(--border2);border-radius:8px;cursor:pointer;color:var(--muted);transition:background .12s,color .12s,border-color .12s;-webkit-tap-highlight-color:transparent}
.bc-btn:hover{background:var(--surface3);color:var(--text)}
.bc-btn .icon{width:16px;height:16px}
.bc-trust.trusting{color:var(--accent);border-color:color-mix(in srgb, var(--accent) 45%, transparent)}
.bc-trust.trusted{color:var(--purple);border-color:color-mix(in srgb, var(--purple) 45%, transparent)}
.bc-remove:hover{color:var(--red);border-color:var(--redb);background:var(--redl)}
@media (max-width:640px){ .bc-btn{padding:9px 0} .bc-btn .icon{width:18px;height:18px} }
