@import url('branding.css');

:root {
    /* ─── ACTIVE THEME (default = child; .role-parent overrides) ── */
    --primary:              var(--child-primary);
    --primary-dark:         var(--child-primary-dark);
    --primary-soft:         var(--child-primary-soft);
    --nav-bg:               var(--child-nav-bg);
    --nav-active:           var(--child-nav-active);
    --on-nav:               var(--child-on-nav);
}

body.role-parent {
    --primary:              var(--parent-primary);
    --primary-dark:         var(--parent-primary-dark);
    --primary-soft:         var(--parent-primary-soft);
    --nav-bg:               var(--parent-nav-bg);
    --nav-active:           var(--parent-nav-active);
    --on-nav:               var(--parent-on-nav);
}


@media (display-mode: standalone) {
  :root {
    --safe-bottom: 0px;
    --safe-top: 30px;
  }
}

/* ═══════════════════════════════════════════════════════════
   Add these rules ANYWHERE in app.css (e.g. at the bottom).
   They make sure success-state UI uses green regardless of
   which app is active, even when --primary is the accent color.
   ═══════════════════════════════════════════════════════════ */

/* Toggle ON — always green in both apps */
.toggle-switch.on {
    background: var(--success) !important;
}

/* Unread badge — uses app accent (yellow for kids, orange for parent) */
.conv-unread-badge,
.nav-badge {
    background: var(--primary);
    color: #FFFFFF;
}

/* Send button + send icon — uses app accent */
.send-btn,
.compose-send {
    background: var(--primary);
    color: #FFFFFF;
}

/* Top nav — uses --on-nav for legibility on the colored bar */
.top-bar {
    background: var(--nav-bg);
    color: var(--on-nav);
}
.top-bar h1, .top-bar .top-action-btn { color: var(--on-nav); }

/* Bottom nav active tab indicator */
.nav-item.active .nav-icon,
.nav-item.active .nav-label {
    color: var(--nav-active);
}




/* ─── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    /* Driven by initKeyboardWatcher in app.js: --visible-height is the
       visualViewport height in px, which on iOS shrinks correctly when
       the keyboard opens (unlike 100dvh, which iOS leaves at full
       screen). The 100dvh fallback covers first-paint before JS runs
       and browsers without visualViewport. */
    height: var(--visible-height, 100dvh);
    overflow: hidden;
    /* Disable native pull-to-refresh; we implement a scoped version
       on the top bar in app.js. */
    overscroll-behavior: none;
    background: var(--nav-bg);
    color: var(--text-primary);
    font-family: var(--font-book);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}
html:has(body.role-parent) {
    background: var(--parent-nav-bg);
}

/* Body is a vertical flex shell: top-bar | screen-container | bottom-nav.
   This is the keystone fix for the mobile-keyboard layout problem.
   Previously the three shell elements were position:fixed and anchored
   to the layout viewport — on iOS the layout viewport stays full-screen
   when the keyboard opens, so fixed elements floated behind the keyboard.
   With a flex shell, when --visible-height shrinks, top-bar stays at
   the top, screen-container shrinks (flex:1), bottom-nav stays anchored
   at the bottom. The compose bar — already an in-flow flex child of
   #screen-conversation — rides up with screen-container to sit just
   above the keyboard. */
body {
    display: flex;
    flex-direction: column;
}

/* When the on-screen keyboard is open (detected via visualViewport in
   app.js), hide the bottom nav so it doesn't take up space we now want
   for the compose bar. */
body.kb-open #bottom-nav { display: none; }
body.kb-open .toast,
body.kb-open .update-banner { bottom: 14px; }



button { background: none; border: none; cursor: pointer; font-family: inherit; }
textarea, input { font-family: inherit; }
a { color: inherit; text-decoration: none; }


/* ─── TOP BAR ────────────────────────────────────────────── */
/* Flex child of body. Was position:fixed — see the body flex shell
   comment above for why. */
#top-bar {
    flex: 0 0 auto;
    height: var(--top-bar-height);
    margin-top: var(--safe-top); 
    background: var(--nav-bg);
    z-index: 100;
    transition: background 0.3s ease;
}
.top-bar-container {
    height:100%;
    width:100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 16px;
    padding-right: 12px; 
}

#app-wordmark {
    font-family: var(--font-heavy);
    font-size: 20px;
    color: #ffffff;
    letter-spacing: -0.5px;
}

#screen-title {
    font-family: var(--font-semi);
    font-size: 15px;
    color: rgba(255,255,255,0.7);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

#top-bar-center {
    display: none;
}

#top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
#top-bar-right #top-action-btn,
#top-bar-right #user-avatar {
    display: none;
}


.icon-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.8);
    font-size: 20px;
    transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }

/* User avatar chip in top bar */
.avatar-chip {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-semi);
    font-size: 12px;
    color: #fff;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    transition: border-color 0.2s;
}
.avatar-chip:hover { border-color: rgba(255,255,255,0.5); }
.avatar-chip.small { width: 28px; height: 28px; font-size: 20px; border-width: 1.5px; }


/* ─── SCREEN CONTAINER ───────────────────────────────────── */
/* Flex:1 child of body — fills space between top-bar and bottom-nav.
   When the keyboard opens and body height shrinks, this shrinks too. */
#screen-container {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: var(--bg);
}

.screen {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.screen.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

/* Conversation slide-in from right */
.slide-screen {
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.slide-screen.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
}

.screen-inner {
    padding: 12px 0 16px;
    padding: 0;
    min-height: 100%;
}


/* ─── BOTTOM NAVIGATION ──────────────────────────────────── */
/* Flex child of body. Was position:fixed — see body flex shell comment. */
#bottom-nav {
    flex: 0 0 auto;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--nav-bg);
    display: flex;
    align-items: flex-start;
    padding-top: 8px;
    z-index: 100;
    transition: background 0.3s ease;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0px;
    padding: 4px 0;
    color: rgba(255,255,255,0.6);
    font-family: var(--font-semi);
    font-size: 10px;
    letter-spacing: 0.01em;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.role-child .nav-item {
    color: rgba(255,255,255);
}
.nav-item:hover { color: rgba(255,255,255,0.85); }
.nav-item.active {
    color: var(--nav-active);
}

.nav-icon-wrap {
    position: relative;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.nav-label {
    font-size: 12px;
}

.nav-badge {
    position: absolute;
    top: -4px; right: -6px;
    min-width: 20px; height: 20px;
    background: var(--danger);
    color: #fff;
    font-family: var(--font-semi);
    font-size: 12px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    border: 1.5px solid var(--nav-bg);
}

/* Role-based badge variants.
   Owner: numeric count (default — uses the rule above as-is).
   Adult: red dot, no text. Smaller pill, font-size:0 hides any
     stray text content (JS sets it to '').
   Kid: shows the literal word "NEW". Wider pill, smaller font so
     it fits without breaking the bottom-nav alignment. */
body.role-parent:not(.role-owner) .nav-badge {
    min-width: 12px;
    height: 12px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    top: -2px; right: -4px;
}
body.role-child .nav-badge {
    min-width: 0;
    height: 16px;
    font-size: 9px;
    letter-spacing: 0.4px;
    padding: 0 5px;
    border-radius: 8px;
}

/* Role visibility */
body.role-child  .parent-nav { display: none; }
body.role-parent .child-nav  { display: none; }
body.role-parent .parent-nav { display: flex; }

/* Owner-only nav items (Family, Activity) — hidden for adults.
   Adults are role-parent for branding/theming but lack role-owner.
   Without this rule adults would see owner-management tabs they
   can't actually access. */
body.role-parent:not(.role-owner) .owner-only-nav { display: none; }


/* ─── CONVERSATION LIST (Chats + Groups tabs) ────────────── */
.conversation-list { padding: 0 0 8px; }

.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item:first-child { border-top: 1px solid var(--border); }

.conv-avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-semi);
    font-size: 25px;
    color: var(--primary-dark);
    flex-shrink: 0;
}
.conv-avatar.group-avatar { border-radius: var(--radius-sm); }

.conv-info { flex: 1; min-width: 0; }
.conv-name {
    font-family: var(--font-semi);
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-preview.unread { color: var(--text-primary); font-family: var(--font-medium); }
.conv-preview.virtual { color: var(--text-tertiary); font-style: italic; }
.conv-item.virtual .conv-avatar { opacity: 0.85; }

/* Muted rows: dimmed when shown, never selected by native long-press */
.conv-item { user-select: none; -webkit-user-select: none; }
.conv-item.muted { opacity: 0.65; }
.conv-item.muted .conv-name { font-family: var(--font-medium); }

.conv-time-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.conv-mute-icon {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1;
}

/* Action menu inside a bottom-sheet (mute / unmute / future actions) */
.action-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0 16px;
}
.action-menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-2);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-medium);
    font-size: 15px;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s;
}
.action-menu-btn:hover,
.action-menu-btn:active { background: var(--border); }
.action-menu-btn i {
    font-size: 18px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    flex-shrink: 0;
}
.conv-time {
    font-size: 11px;
    color: var(--text-tertiary);
}
.conv-unread-badge {
    min-width: 20px; height: 20px;
    background: var(--primary);
    color: #fff;
    font-family: var(--font-semi);
    font-size: 11px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
}


/* ─── CONVERSATION VIEW ──────────────────────────────────── */
.convo-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.back-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    color: var(--primary);
    margin-left: -6px;
    transition: background 0.15s;
}
.back-btn:hover { background: var(--primary-soft); }

.convo-header-info {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 1;
}
.convo-name {
    font-family: var(--font-semi);
    font-size: 15px;
    color: var(--text-primary);
}
.convo-status { font-size: 12px; color: var(--text-secondary); }

/* Conversation screen lays out as: header (auto) | messages (scroll) | compose (auto) */
#screen-conversation {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#screen-conversation .convo-header { flex: 0 0 auto; }
#screen-conversation .message-list { flex: 1 1 auto; min-height: 0; }
#screen-conversation .compose-bar  { flex: 0 0 auto; }

.message-list {
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.message-row {
    display: flex;
    align-items: flex-end;
    gap: 7px;
}
.message-row.outgoing { flex-direction: row-reverse; }

.message-sender-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-semi);
    font-size: 20px;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-bottom: 2px;
}

.bubble {
    max-width: 100%;
    padding: 9px 13px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.45;
    overflow-wrap: break-word;
}
@media (min-width: 768px) {
    .bubble { max-width: 480px; }
}
.bubble.incoming {
    background: var(--surface);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.bubble.outgoing {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.bubble-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 3px;
    padding: 0 4px;
}
.message-row.outgoing .bubble-time { text-align: right; }

/* Sender name above incoming bubbles in groups (and both sides in
   read-only Activity view). Small and muted; aligned with bubble. */
.bubble-sender-name {
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 0 6px;
    margin-bottom: 3px;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.message-row.outgoing .bubble-sender-name { text-align: right; }

.bubble-read {
    font-size: 10px;
    color: var(--text-tertiary);
}
.bubble-read.seen { color: var(--primary); }

/* Compose bar — now an in-flow flex child of #screen-conversation,
   not position:fixed, so it sits flush against the bottom nav and
   doesn't get hijacked by the transformed .slide-screen ancestor. */
.compose-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.compose-bar.hidden { display: none; }

.message-input {
    flex: 1;
    min-height: 38px;
    max-height: 120px;
    padding: 9px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 15px;
    color: var(--text-primary);
    resize: none;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}
.message-input:focus { border-color: var(--primary); }
.message-input::placeholder { color: var(--text-tertiary); }

.send-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 17px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
    opacity: 0.4;
}
.send-btn:not(:disabled) { opacity: 1; }
.send-btn:not(:disabled):active { transform: scale(0.92); }
.send-btn:disabled { cursor: not-allowed; }


/* ─── ME / PROFILE SCREEN ────────────────────────────────── */
.profile-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 20px 20px;
    gap: 10px;
}

.profile-avatar-large {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-bold);
    font-size: 28px;
    color: var(--primary-dark);
    border: 3px solid var(--primary);
}

.profile-name {
    font-family: var(--font-semi);
    font-size: 20px;
    color: var(--text-primary);
}

.emoji-picker-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    width: 100%;
}

/* ─── PROFILE AVATAR EDIT BADGE ─────────────────────────── */
.profile-avatar-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.profile-avatar-edit-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    pointer-events: none; /* avatar's onclick handles the tap */
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}


.role-child  .child-only.emoji-picker-row {
    display: none;
}
.emoji-btn {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 2px solid transparent;
    transition: border-color 0.15s, background 0.15s;
    padding: 0;
}
.emoji-btn.active {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* Settings list */
.settings-list { padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.settings-group {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-label {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-label i { color: var(--primary); font-size: 16px; }
.settings-value {
    font-family: var(--font-semi);
    font-size: 14px;
    color: var(--text-primary);
}

.settings-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 13px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
    text-align: left;
}
.settings-btn:last-child { border-bottom: none; }
.settings-btn:hover { background: var(--surface-2); }
.settings-btn i:first-child { color: var(--primary); font-size: 16px; }
.settings-btn.danger { color: var(--danger); }
.settings-btn.danger i:first-child { color: var(--danger); }
.settings-chevron { margin-left: auto; font-size: 14px; color: var(--text-tertiary); }

.parent-notice {
    margin: 16px 16px 0;
    padding: 10px 14px;
    background: var(--primary-soft);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 7px;
    text-align: center;
    justify-content: center;
}


/* ─── FAMILY SCREEN (parent) ─────────────────────────────── */
.section-block {
    margin-bottom: 4px;
}
.section-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 7px;
}
.section-block-title {
    font-family: var(--font-semi);
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.section-block-action {
    font-family: var(--font-semi);
    font-size: 13px;
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}
.section-block-action:hover { background: var(--primary-soft); }

.member-list {
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.member-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
}
.member-row:last-child { border-bottom: none; }
.member-row:hover { background: var(--surface-2); }

.member-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-semi);
    font-size: 20px;
    color: var(--primary-dark);
    flex-shrink: 0;
}
.member-avatar.square { border-radius: var(--radius-sm); }

.member-info { flex: 1; min-width: 0; }
.member-name {
    font-family: var(--font-semi);
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 1px;
}
.member-sub {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-tag {
    font-family: var(--font-semi);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}
.role-tag.owner   { background: #EEEDFE; color: #3C3489; }
.role-tag.adult   { background: #E1F5EE; color: #085041; }
.role-tag.child   { background: #E6F1FB; color: #185FA5; }
.role-tag.pending { background: #FAEEDA; color: #854F0B; }
.role-tag.connected { background: #EAF3DE; color: #3B6D11; }
.role-tag.shared  { background: #EEEDFE; color: #534AB7; }

.member-chevron { font-size: 16px; color: var(--text-tertiary); flex-shrink: 0; }

.empty-state-inline {
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Toggle switch */
.toggle-switch {
    width: 44px; height: 26px;
    border-radius: 13px;
    background: var(--border-strong);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.toggle-switch.on { background: var(--primary); }
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on::after { transform: translateX(18px); }

/* Locked toggle — used for own-family owners on contact lists.
   Visually rendered as on, with a subdued opacity and a lock cursor.
   The knob carries a small lock glyph. */
.toggle-switch.locked {
    cursor: not-allowed;
    opacity: 0.7;
}
.toggle-switch.locked::after {
    background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%23555' d='M8 1a3 3 0 0 0-3 3v2H4a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1h-1V4a3 3 0 0 0-3-3zm0 1.5A1.5 1.5 0 0 1 9.5 4v2h-3V4A1.5 1.5 0 0 1 8 2.5z'/></svg>") center/12px 12px no-repeat;
}


/* ─── ACTIVITY SCREEN (parent) ───────────────────────────── */
.activity-filter-bar {
    padding: 10px 14px;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border);
}
.activity-filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
    font-family: var(--font-medium);
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.filter-chip.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.activity-list { padding-bottom: 16px; }

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
}
.activity-item.unread {
    background-color: var(--warning-soft);
}
.activity-item:first-child { border-top: 1px solid var(--border); }
.activity-item:hover { background: var(--surface-2); }

.activity-child-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-semi);
    font-size: 12px;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.activity-info { flex: 1; min-width: 0; }
.activity-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}
.activity-convo {
    font-family: var(--font-semi);
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.activity-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.activity-time {
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    margin-top: 2px;
}

/* Read-only banner inside conversation view for parents */
.read-only-bar {
    background: #FAEEDA;
    border-top: 1px solid #EF9F27;
    padding: 9px 16px;
    font-size: 12px;
    color: #633806;
    text-align: center;
    font-family: var(--font-medium);
}


/* ─── EMPTY STATES ───────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 32px;
    gap: 10px;
    text-align: center;
}
.empty-icon {
    font-size: 48px;
    color: var(--text-tertiary);
    opacity: 0.5;
}
.empty-title {
    font-family: var(--font-semi);
    font-size: 17px;
    color: var(--text-secondary);
}
.empty-sub {
    font-size: 14px;
    color: var(--text-tertiary);
    max-width: 240px;
    line-height: 1.5;
}


/* ─── LOCKSCREEN ─────────────────────────────────────────── */
.lockscreen {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: var(--nav-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}
.lockscreen-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
}
.lockscreen-icon {
    font-size: 64px;
    color: var(--primary);
    opacity: 0.8;
}
.lockscreen-title {
    font-family: var(--font-bold);
    font-size: 26px;
    color: #fff;
}
.lockscreen-sub {
    font-size: 16px;
    color: rgba(255,255,255,0.6);
    line-height: 1.6;
}
.lockscreen-time {
    font-family: var(--font-thin);
    font-size: 14px;
    color: rgba(255,255,255,0.4);
    margin-top: 8px;
}

/* ─── APP LOCK OVERLAY (adults/owners) ───────────────────── */
.app-lock-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--nav-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    animation: app-lock-fade 0.2s ease;
}
@keyframes app-lock-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.app-lock-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    width: 100%;
    max-width: 320px;
    text-align: center;
}
.app-lock-icon {
    font-size: 56px;
    color: var(--parent-primary);
    opacity: 0.85;
    margin: 0 auto;
}
.app-lock-title {
    font-family: var(--font-semi);
    font-size: 22px;
    color: #fff;
    margin-bottom: 2px;
}
.app-lock-sub {
    font-size: 14px;
    color: rgba(255,255,255,0.55);
    margin-bottom: 14px;
}
.app-lock-pin-input {
    padding: 14px 18px;
    border-radius: 12px;
    border: 1.5px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-family: var(--font-semi);
    font-size: 22px;
    letter-spacing: 8px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}
.app-lock-pin-input:focus { border-color: var(--parent-primary); }
.app-lock-error {
    font-size: 13px;
    color: #F09595;
    margin: -4px 0 4px;
}
.app-lock-btn {
    padding: 12px;
    border-radius: 12px;
    background: var(--parent-primary);
    color: #fff;
    font-family: var(--font-semi);
    font-size: 15px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.app-lock-btn:hover { background: var(--parent-primary-dark); }
.app-lock-btn.ghost {
    background: transparent;
    color: rgba(255,255,255,0.55);
    border: 1px solid rgba(255,255,255,0.15);
}
.app-lock-btn.ghost:hover { background: rgba(255,255,255,0.05); }

/* ─── SHARED-WITH-ME LIST + CHILD PICKER ─────────────────── */
.shared-list {
    padding: 0;
}
.shared-summary {
    padding: 12px 16px;
    border-bottom: 1px dashed var(--border);
}
.shared-summary-title {
    font-family: var(--font-semi);
    font-size: 14px;
    color: var(--text-primary);
}
.shared-summary-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.shared-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
}
.shared-row:hover { background: var(--surface-2); }
.shared-row:last-child { border-bottom: none; }
.shared-row .member-avatar { width: 32px; height: 32px; font-size: 12px; flex-shrink: 0; }
.shared-row-info { flex: 1; min-width: 0; }
.shared-row-name {
    font-family: var(--font-medium);
    font-size: 14px;
    color: var(--text-primary);
}
.shared-row-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
}
.shared-row-sub.added { color: var(--teal); }
.shared-row .chevron {
    font-size: 14px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.shared-show-more {
    text-align: center;
    padding: 10px;
    font-size: 13px;
    font-family: var(--font-medium);
    color: var(--parent-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.shared-show-more:hover { background: var(--surface-2); }

/* Child picker sheet header (avatar + name) */
.child-picker-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}
.child-picker-header .family-detail-avatar {
    width: 38px; height: 38px;
    font-size: 20px;
}


/* ─── TOAST ──────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 14px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: #fff;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 20px;
    z-index: 500;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    pointer-events: none;
    animation: toast-in 0.2s ease;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── UPDATE BANNER (SW skip-waiting prompt) ─────────────── */
.update-banner {
    position: fixed;
    left: 50%;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 14px);
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--text-primary);
    color: #fff;
    font-size: 13px;
    padding: 10px 12px 10px 18px;
    border-radius: 24px;
    z-index: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    animation: toast-in 0.2s ease;
    max-width: calc(100vw - 32px);
}
.update-banner-text {
    font-family: 'axiformamedium', sans-serif;
    white-space: nowrap;
}
.update-banner-btn {
    background: #fff;
    color: var(--text-primary);
    border: 0;
    border-radius: 16px;
    padding: 6px 14px;
    font-family: 'axiformasemibold', sans-serif;
    font-size: 13px;
    cursor: pointer;
}
.update-banner-btn:disabled {
    opacity: 0.6;
    cursor: default;
}


/* ─── LOADING SKELETON ───────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
}
@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}


/* ─── FAMILY SCREEN — extended ───────────────────────────── */

/* "add row" links at bottom of each section */
.family-add-row {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 11px 16px;
    font-size: 14px;
    color: var(--parent-primary);
    font-family: var(--font-medium);
    background: var(--surface);
    border-top: 1px solid var(--border);
    transition: background 0.12s;
    text-align: left;
}
.family-add-row:hover { background: var(--parent-primary-soft); }
.family-add-row i { font-size: 17px; }

/* Detail screen avatar (smaller than conv avatar, used in slide headers) */
.family-detail-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-semi);
    font-size: 20px;
    color: var(--primary-dark);
    flex-shrink: 0;
}
.family-detail-avatar.square { border-radius: var(--radius-sm); }

/* Child stats bar */
.child-stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.child-stat {
    background: var(--surface);
    padding: 10px 8px;
    text-align: center;
}
.child-stat-value {
    font-family: var(--font-semi);
    font-size: 14px;
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}
.child-stat-label {
    font-size: 10px;
    color: var(--text-tertiary);
    line-height: 1.2;
}

/* Child detail tab strip — sits below stats bar, above tab panels */
.child-tab-strip,
.detail-tab-strip {
    display: flex;
    gap: 6px;
    padding: 10px 16px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2;
}
.child-tab-strip::-webkit-scrollbar,
.detail-tab-strip::-webkit-scrollbar { display: none; }

.child-tab-btn,
.detail-tab-btn {
    font-family: var(--font-medium);
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    cursor: pointer;
}
.child-tab-btn:hover,
.detail-tab-btn:hover { background: var(--surface-2); }
.child-tab-btn.active,
.detail-tab-btn.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
}

/* Tab panels — only the active one is visible */
.child-tab,
.detail-tab { display: none; }
.child-tab.active,
.detail-tab.active { display: block; }

/* Member row toggle column */
.member-toggle-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}
.member-toggle-label {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* Number input for daily limit */
.family-number-input {
    width: 70px;
    padding: 6px 10px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font-semi);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--surface-2);
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}
.family-number-input:focus { border-color: var(--parent-primary); }

/* Action bar below settings section */
.family-action-bar {
    padding: 10px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.family-save-btn {
    width: 100%;
    padding: 11px;
    border-radius: var(--radius-md);
    background: var(--parent-primary);
    color: #fff;
    font-family: var(--font-semi);
    font-size: 15px;
    transition: background 0.2s, transform 0.1s;
}
.family-save-btn:hover  { background: var(--parent-primary-dark); }
.family-save-btn:active { transform: scale(0.98); }
.family-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Family invite box (inside connection detail) */
.family-invite-box {
    margin: 0 16px 4px;
    background: var(--child-primary-soft);
    border: 1px solid rgba(108,99,255,0.2);
    border-radius: var(--radius-md);
    padding: 14px;
}
.family-invite-title {
    font-family: var(--font-semi);
    font-size: 14px;
    color: #3C3489;
    margin-bottom: 2px;
}
.family-invite-sub {
    font-size: 12px;
    color: #534AB7;
    margin-bottom: 10px;
}
.family-invite-link-wrap { margin-bottom: 10px; }
.family-invite-link-input {
    width: 100%;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid rgba(108,99,255,0.3);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: monospace;
    color: #534AB7;
    word-break: break-all;
    margin-bottom: 8px;
    outline: none;
}
.family-invite-btns { display: flex; gap: 8px; }
.family-invite-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: #534AB7;
    color: #fff;
    font-family: var(--font-medium);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.15s;
}
.family-invite-btn:hover { background: #3C3489; }
.family-invite-btn.ghost {
    background: transparent;
    color: #534AB7;
    border: 1px solid #534AB7;
}
.family-invite-btn.ghost:hover { background: rgba(83,74,183,0.08); }
.family-invite-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 8px;
    padding: 6px 8px;
    background: #FCEBEB;
    border-radius: var(--radius-sm);
}

/* ─── BOTTOM SHEETS ──────────────────────────────────────── */
.sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    animation: fade-in 0.2s ease;
}
.bottom-sheet {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 12px 20px calc(20px + var(--safe-bottom));
    z-index: 201;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
    animation: sheet-up 0.28s cubic-bezier(0.4,0,0.2,1);
}
.bottom-sheet.open,
.bottom-sheet.open + .sheet-backdrop,  /* can't do prev sibling, use JS */
.sheet-backdrop.open {
    display: block;
}
/* JS adds .open to both sheet and backdrop */

@keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.sheet-handle {
    width: 36px; height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    margin: 0 auto 18px;
}
.sheet-title {
    font-family: var(--font-semi);
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.sheet-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}
.sheet-error {
    background: #FCEBEB;
    border: 1px solid #F09595;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    color: #A32D2D;
    margin-bottom: 12px;
}
.sheet-field { margin-bottom: 12px; }
.sheet-label {
    display: block;
    font-size: 12px;
    font-family: var(--font-medium);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 5px;
}
.sheet-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-family: var(--font-book);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--surface-2);
    outline: none;
    transition: border-color 0.2s;
}
.sheet-input:focus { border-color: var(--parent-primary); }
.sheet-btn {
    width: 100%;
    padding: 13px;
    border-radius: var(--radius-md);
    background: var(--parent-primary);
    color: #fff;
    font-family: var(--font-semi);
    font-size: 16px;
    margin-top: 8px;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}
.sheet-btn:hover  { background: var(--parent-primary-dark); }
.sheet-btn:active { transform: scale(0.98); }
.sheet-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.sheet-btn.ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border-strong);
}
.sheet-btn.ghost:hover { background: var(--surface-2); }
.sheet-link-wrap {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 4px;
}
.sheet-link-input {
    width: 100%;
    font-size: 13px;
    font-family: monospace;
    color: var(--parent-primary);
    background: transparent;
    border: none;
    outline: none;
    margin-bottom: 8px;
    word-break: break-all;
}
.sheet-link-copy-btn {
    font-family: var(--font-medium);
    font-size: 13px;
    color: var(--parent-primary);
    padding: 4px 0;
}

/* ─── SCROLLBAR ──────────────────────────────────────────── */
.screen::-webkit-scrollbar { width: 3px; }
.screen::-webkit-scrollbar-track { background: transparent; }
.screen::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }


/* Time input for sleep settings */
.family-time-input {
    padding: 6px 10px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font-semi);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface-2);
    outline: none;
    transition: border-color 0.2s;
    width: 120px;
}
.family-time-input:focus { border-color: var(--parent-primary); }

/* Group rename button inline in section header */
.section-block-rename {
    background: none;
    border: none;
    font-size: 13px;
    color: var(--parent-primary);
    font-family: var(--font-medium);
    cursor: pointer;
    padding: 2px 0;
}
.section-block-rename:hover { text-decoration: underline; }

/* child-only / parent-only visibility helpers */
.role-child  .child-only  { display: block; }
.role-child  .parent-only { display: none;  }
.role-parent .parent-only { display: block; }
.role-parent .child-only  { display: none;  }
/* ─── CONTACT GROUP HEADERS (child whitelist sections) ─────── */
.contact-group-header {
    padding: 12px 16px 6px;
    font-size: 11px;
    font-family: var(--font-medium);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.contact-group-header:first-child {
    border-top: none;
}

/* ─── AVATAR PICKER (drop: display names + avatars) ────────── */
.avatar-picker .sheet-title { margin-bottom: 8px; }
#avatar-picker-grid {
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 12px;
}
.avatar-pick-category {
    margin-bottom: 14px;
}
.avatar-pick-cat-title {
    font-size: 11px;
    font-family: var(--font-medium);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 4px 6px;
}
.avatar-pick-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.avatar-pick-cell {
    background: var(--surface-2, #f3f3f8);
    border: 2px solid transparent;
    border-radius: 12px;
    aspect-ratio: 1;
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.08s, border-color 0.12s;
    padding: 0;
}
.avatar-pick-cell:active { transform: scale(0.92); }
.avatar-pick-cell.selected {
    border-color: var(--brand, #6C63FF);
    background: var(--surface-3, #ebebf3);
}

/* Tappable avatar affordance — subtle ring on hover/focus */
.profile-avatar-large.tappable,
.family-detail-avatar.tappable {
    cursor: pointer;
    transition: transform 0.1s;
}
.profile-avatar-large.tappable:active,
.family-detail-avatar.tappable:active {
    transform: scale(0.95);
}

/* ─── EMERGENCY CONTACT — LOCKSCREEN HELP BUTTON ────────── */
.lockscreen-help-btn {
    margin-top: 24px;
    padding: 12px 24px;
    background: rgba(255,255,255,0.12);
    border: 1.5px solid rgba(255,255,255,0.3);
    color: #fff;
    border-radius: var(--radius-md);
    font-family: var(--font-semi);
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.lockscreen-help-btn:hover  { background: rgba(255,255,255,0.2); }
.lockscreen-help-btn:active { transform: scale(0.97); }
.lockscreen-help-btn i      { font-size: 18px; }

/* ─── EMERGENCY CONTACT — TRAY OWNER ROWS ───────────────── */
.help-mode-owner-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}
.help-mode-owner-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-md);
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    font-size: 15px;
    color: var(--text-primary);
}
.help-mode-owner-row:hover  { background: var(--surface-2); }
.help-mode-owner-row:active { transform: scale(0.99); }
.help-mode-owner-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.help-mode-owner-name {
    flex: 1;
    font-family: var(--font-semi);
}
.help-mode-owner-row i.las {
    color: var(--text-secondary);
    font-size: 16px;
}

/* ─── EMERGENCY CONTACT — HELP MODE TRAY (over lockscreen) ─
   The owner picker tray opens FROM the lockscreen, so its z-index
   must clear the lockscreen (z 999). Default .bottom-sheet /
   .sheet-backdrop sit at z 200/201 — that's correct for normal
   in-app sheets, but would be hidden behind the lockscreen here.
   Scope the bump to these specific IDs so other sheets are unaffected. */
#help-mode-backdrop { z-index: 1050; }
#help-mode-tray     { z-index: 1051; }

/* ─── EMERGENCY CONTACT — HELP MODE CONVERSATION OVERLAY ── */
.help-mode-conv {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--surface);
    z-index: 1100;          /* above lockscreen (z 999) and sheets (z 200) */
    flex-direction: column;
    height: 100dvh;
}
.help-mode-conv.visible { display: flex; }

.help-mode-topbar {
    flex-shrink: 0;
    background: var(--danger);
    color: #fff;
    padding: 12px 12px calc(12px) 12px;
    padding-top: calc(12px + env(safe-area-inset-top, 0));
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.help-mode-back {
    background: transparent;
    color: #fff;
    border: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
}
.help-mode-back:active { background: rgba(255,255,255,0.15); }
.help-mode-title-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.help-mode-title-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.85;
    font-family: var(--font-semi);
}
.help-mode-title-name {
    font-family: var(--font-semi);
    font-size: 17px;
}

.help-mode-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface-2);
}
.help-mode-loading {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 32px 16px;
}
.help-msg {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.help-msg.in {
    align-self: flex-start;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-bottom-left-radius: 4px;
}
.help-msg.out {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.help-msg.failed { opacity: 0.5; }

.help-mode-compose {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border-strong);
}
.help-mode-compose textarea {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.4;
    background: var(--surface-2);
    color: var(--text-primary);
}
.help-mode-compose textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.help-mode-compose button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 18px;
    transition: background 0.15s, opacity 0.15s;
}
.help-mode-compose button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
