:root {
    --primary-color: #3a7ca5;
    --secondary-color: #2f6690;
    --accent-color: #16425b;
    --text-color: #333;
    --light-gray: #f5f5f5;
    --medium-gray: #e0e0e0;
    --dark-gray: #666;
    --white: #fff;
    --green: #28a745;
    --red: #dc3545;
    --yellow: #ffc107;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-gray);
    min-height: 100vh;
}

/* Header */
.header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header h1 { font-size: 1.5rem; font-weight: 700; }
.header h1 a { color: var(--white); text-decoration: none; cursor: pointer; }
.version-floater {
    position: absolute;
    top: calc(100% + 4px);
    left: 2rem;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    animation: floaterFadeIn 0.15s ease;
}
@keyframes floaterFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* margin-left: auto pins actions to the right when .user-name is max-width capped on narrow screens */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
    margin-left: auto;
}
.header .user-name {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.9;
    cursor: pointer;
    white-space: nowrap;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    text-align: center;
}
.header .user-name:hover { opacity: 1; }
.header-icon-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.25);
    color: var(--white);
    font-size: 1.28rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.header-icon-btn:hover {
    background: rgba(255,255,255,0.4);
}

/* Avatars */
.header-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.5);
    margin-right: 0.65rem;
    cursor: pointer;
    flex-shrink: 0;
}
.group-avatar-wrap {
    position: relative;
    display: inline-block;
    cursor: default;
    margin-bottom: 0.3rem;
}
.group-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.15);
}
.group-avatar-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.1);
}
.group-header-avatar-wrap {
    margin-right: 0;
    margin-bottom: 0;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
    flex-shrink: 0;
}
.group-header-avatar-wrap .group-avatar,
.group-header-avatar-wrap .group-avatar-placeholder {
    width: 56px;
    height: 56px;
}
.group-header-avatar-wrap:hover {
    transform: scale(1.03);
}
.group-header-avatar-wrap.group-logo-disabled {
    cursor: not-allowed;
    opacity: 0.7;
}
.group-header-avatar-wrap.group-logo-disabled:hover {
    transform: none;
}
.group-header-avatar-wrap.updating {
    opacity: 0.6;
    pointer-events: none;
}
.group-header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
}
.group-header-center .balance-amount {
    margin: 0;
}
.chat-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.chat-avatar-placeholder {
    background: var(--medium-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--dark-gray);
}
.chat-msg-row {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary-color); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--accent-color); }
.btn-secondary { background: var(--medium-gray); color: var(--text-color); }
.btn-secondary:hover:not(:disabled) { background: #ccc; }
.btn-success { background: var(--green); color: var(--white); }
.btn-success:hover:not(:disabled) { background: #218838; }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #c82333; }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}
.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: var(--white);
}

/* Main content */
.main-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    padding-bottom: 90px;
    min-height: calc(100vh - 60px);
}
.screen-version {
    margin-top: 1.25rem;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: rgba(22, 66, 91, 0.45);
    text-align: left;
    user-select: text;
}
.screen-version-overlay {
    position: absolute;
    left: 1rem;
    bottom: 0.85rem;
    margin-top: 0;
    color: rgba(255, 255, 255, 0.42);
    pointer-events: none;
}

/* Groups screen */
.group-card {
    background: var(--white);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.group-card-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.group-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.group-card .group-card-name { font-weight: 600; font-size: 1rem; }
.group-card .group-card-meta { font-size: 0.85rem; color: var(--dark-gray); }
.group-card .group-card-status {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.5rem;
    background: var(--yellow);
    color: #333;
}
.group-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.btn-leave-group {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--dark-gray);
    background: transparent;
    color: var(--dark-gray);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-leave-group:hover {
    background: var(--red, #e74c3c);
    border-color: var(--red, #e74c3c);
    color: var(--white);
}
.group-card .group-card-arrow {
    font-size: 1.2rem;
    color: var(--dark-gray);
}
.group-card-logo,
.group-card-logo-placeholder {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
}
.group-card-logo {
    object-fit: cover;
    border: 2px solid var(--medium-gray);
    background: var(--light-gray);
}
.group-card-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light-gray);
    border: 2px solid var(--medium-gray);
    color: var(--dark-gray);
    font-size: 1.05rem;
}

/* Clickable group name header */
.group-name-link {
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.group-name-link:hover { opacity: 0.8; }

/* Auth screen */
.auth-container {
    max-width: 400px;
    margin: 3rem auto;
    background: var(--white);
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.auth-container h2 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}
.auth-container .subtitle {
    text-align: center;
    color: var(--dark-gray);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}
.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--medium-gray);
}
.auth-tab {
    flex: 1;
    padding: 0.7rem;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--dark-gray);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}
.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.invite-sponsor-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.invite-sponsor-message {
    min-width: 0;
}
.invite-sponsor-name {
    white-space: nowrap;
    margin-right: 0.2rem;
}
.invite-sponsor-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(22, 66, 91, 0.2);
    flex-shrink: 0;
}
.invite-sponsor-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--white);
    background: var(--primary-color);
}
.invite-sponsor-subtext {
    margin-top: 0.7rem;
}
.invite-sponsor-note {
    margin-top: 0.35rem;
    color: var(--dark-gray);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--accent-color);
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--medium-gray);
    border-radius: 6px;
    font-family: inherit;
    font-size: 16px; /* prevents iOS auto-zoom on focus */
    transition: var(--transition);
}
.form-group input[type="checkbox"] {
    width: auto;
    padding: 0;
    border: revert;
    border-radius: revert;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 124, 165, 0.15);
}
.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}
.form-actions .btn { flex: 1; }

/* Cards */
.card {
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card h3 {
    font-size: 1.1rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-gray);
}

/* Balance display */
.balance-card {
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: var(--white);
}
.balance-card h3 { color: rgba(255,255,255,0.8); border-bottom-color: rgba(255,255,255,0.2); }
.balance-amount {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}
.balance-currency { font-size: 0.9rem; opacity: 0.8; }

/* Tab bar â€” segmented pill track */
.tab-bar {
    display: flex;
    margin-bottom: 0.5rem;
    padding: 4px;
    background: var(--medium-gray);
    border-radius: 12px;
    box-shadow: var(--shadow);
    gap: 4px;
}
.tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    min-height: 44px;
    background: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dark-gray);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}
.tab-btn:hover { color: var(--primary-color); background: rgba(255,255,255,0.5); }
.tab-btn.active {
    color: var(--primary-color);
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.tab-btn .tab-icon { font-size: 1.1rem; }

/* Tab content card */
.tab-content-card {
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Group info bar (used inside money tab) */
.group-info-bar {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.info-item {
    background: var(--light-gray);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    text-align: center;
    min-width: 120px;
}
.info-item .info-label { font-size: 0.75rem; color: var(--dark-gray); text-transform: uppercase; letter-spacing: 0.05em; }
.info-item .info-value { font-size: 1.2rem; font-weight: 700; color: var(--accent-color); }
.info-item .info-my-vote { font-size: 0.75rem; color: var(--primary-color); font-weight: 600; margin-top: 2px; }
.info-item .info-vote-link {
    font-size: 0.7rem; color: var(--accent-color); cursor: pointer;
    margin-top: 3px; text-decoration: underline; font-weight: 600;
}
.info-item .info-vote-link:hover { color: var(--primary-color); }

/* Transaction list */
.tx-list { list-style: none; }
.tx-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--light-gray);
}
.tx-item:last-child { border-bottom: none; }
.tx-info .tx-parties { font-weight: 500; font-size: 0.9rem; }
.tx-info .tx-memo { font-size: 0.8rem; color: var(--dark-gray); }
.tx-info .tx-date { font-size: 0.75rem; color: var(--dark-gray); }
.tx-amount { font-weight: 700; font-size: 0.95rem; }
.tx-amount.sent { color: var(--red); }
.tx-amount.received { color: var(--green); }

/* Members list */
.member-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--light-gray);
}
.member-item:last-child { border-bottom: none; }
.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.6rem;
    flex-shrink: 0;
}
.member-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--medium-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dark-gray);
    margin-right: 0.6rem;
    flex-shrink: 0;
}
.member-name { font-weight: 500; }
.member-status {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}
.member-status.active { background: #d4edda; color: #155724; }
.member-status.pending { background: #fff3cd; color: #856404; }
.member-sponsor { font-size: 0.8rem; color: var(--dark-gray); font-style: italic; margin-left: auto; }

/* Modal overlay (above contact list and meet overlay so dialogs are visible) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}
.modal {
    background: var(--white);
    border-radius: 8px;
    padding: 2rem;
    width: 90%;
    min-width: 280px;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal.modal-wide { max-width: 650px; }
.modal h3 {
    color: var(--accent-color);
    margin-bottom: 1.5rem;
}
.pref-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.pref-modal-header h3 {
    margin-bottom: 0;
}
.pref-logout-btn {
    flex-shrink: 0;
    border-width: 1px;
    color: var(--dark-gray);
    border-color: var(--dark-gray);
    padding: 0.3rem 0.6rem;
}
.pref-profile-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}
.pref-photo-preview {
    width: 80px;
    height: 80px;
    cursor: pointer;
    flex-shrink: 0;
}
.pref-display-name-group {
    margin-bottom: 0;
    flex: 1;
}
.pref-help-text {
    font-size: 0.8rem;
    color: var(--dark-gray);
    margin-top: 0.2rem;
}
.pref-display-name-group .pref-help-text {
    margin-top: 0.3rem;
    margin-bottom: 0;
}
.pref-contact-field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.pref-contact-field label {
    flex: 0 0 3.5rem;
    margin: 0;
    white-space: nowrap;
}
.pref-contact-field input {
    text-align: right;
}
.pref-contact-hint {
    text-align: right;
    margin-bottom: 0.2rem;
}
.pref-sponsor-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--light-gray);
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
    margin-bottom: 1rem;
}
.pref-sponsor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--medium-gray);
    color: var(--dark-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
}
.pref-sponsor-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.pref-sponsor-label {
    font-size: 0.75rem;
    color: var(--dark-gray);
}
.pref-sponsor-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-color);
}
.pref-divider {
    margin: 1rem 0;
    border: none;
    border-top: 1px solid var(--light-gray);
}
.pref-section-title {
    font-size: 0.95rem;
    color: var(--accent-color);
    margin-bottom: 0.6rem;
}
.pref-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.pref-push-hint {
    margin-top: -0.4rem;
}

/* Notification toast */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    color: var(--white);
    font-weight: 500;
    font-size: 0.9rem;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
    max-width: 350px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--primary-color); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Install hint floater */
.install-hint-floater {
    position: fixed;
    top: 0.9rem;
    right: 0.9rem;
    width: min(360px, calc(100vw - 1.8rem));
    background: rgba(22, 66, 91, 0.96);
    color: var(--white);
    border-radius: 14px;
    padding: 0.9rem 2rem 0.9rem 0.95rem;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
    z-index: 9000;
    animation: installHintIn 0.2s ease-out;
}
.install-hint-floater::before {
    content: '';
    position: absolute;
    top: -10px;
    right: 1.5rem;
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 10px solid rgba(22, 66, 91, 0.96);
}
.install-hint-message {
    font-size: 0.88rem;
    line-height: 1.35;
    font-weight: 500;
}
.install-hint-close {
    position: absolute;
    top: 0.38rem;
    right: 0.38rem;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--white);
    background: rgba(255, 255, 255, 0.15);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.install-hint-close:hover {
    background: rgba(255, 255, 255, 0.28);
}
@keyframes installHintIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    min-height: 300px;
    min-width: 0;
    /* height set dynamically by JS to fill remaining viewport */
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* avoid wide map tiles widening layout */
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0.5rem;
    gap: 0.4rem;
    min-width: 0;
}
.chat-load-more {
    text-align: center;
    padding: 0.5rem;
}
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    min-width: 0; /* allow bubble to shrink below wide map content (narrow viewports) */
    align-self: flex-start;
}
.chat-msg-mine {
    align-self: flex-end;
}
.chat-msg-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 0.1rem;
    padding-left: 0.4rem;
}
.chat-msg-mine .chat-msg-sender {
    display: none;
}
.chat-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
    background: var(--medium-gray);
    color: var(--text-color);
    border-bottom-left-radius: 0.25rem;
    min-width: 0; /* contain wide children (e.g. Leaflet) inside bubble */
}
.chat-bubble.chat-bubble-location {
    overflow: hidden; /* clip map tiles to rounded bubble */
}
.chat-msg-mine .chat-bubble {
    background: #007aff;
    color: #fff;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 0.25rem;
}
.chat-msg-time {
    font-size: 0.65rem;
    color: var(--dark-gray);
    margin-top: 0.15rem;
    padding: 0 0.4rem;
}
.chat-msg-mine .chat-msg-time {
    text-align: right;
}
.chat-input-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 0 0;
    border-top: 1px solid var(--medium-gray);
    margin-top: auto;
    min-width: 0; /* prevent flex row from overflowing tab card */
    align-items: center;
}
.chat-input-bar input {
    flex: 1;
    min-width: 0; /* critical: input shrinks so Send stays in frame */
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--medium-gray);
    border-radius: 6px;
    font-family: inherit;
    font-size: 16px; /* prevents iOS zoom */
}
.chat-input-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 124, 165, 0.15);
}

/* Map location button in chat input bar */
.chat-map-btn {
    background: none;
    border: 1px solid var(--medium-gray);
    border-radius: 6px;
    padding: 0.45rem 0.5rem;
    cursor: pointer;
    color: var(--dark-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s, border-color 0.2s;
}
.chat-map-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Map picker overlay */
.map-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}
.map-picker-modal {
    background: var(--white);
    border-radius: 12px;
    width: 92%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}
.map-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--light-gray);
}
.map-picker-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--accent-color);
}
.map-picker-radius {
    font-size: 0.85rem;
    color: var(--dark-gray);
    font-weight: 500;
}
.map-picker-map {
    width: 100%;
    height: 350px;
}
.map-picker-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--light-gray);
    justify-content: flex-end;
}

/* Inline location preview in chat bubbles */
.chat-location-wrap {
    max-width: 100%;
    min-width: 0;
}
.chat-location-preview {
    width: 100%;
    max-width: 250px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}
.chat-location-preview .leaflet-container {
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px;
}
/* Static preview: let taps reach the clickable wrapper to open the system Maps app */
.chat-location-clickable .chat-location-preview .leaflet-container {
    pointer-events: none;
}
.chat-location-clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(58, 124, 165, 0.25);
}
.chat-location-clickable:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
.chat-location-label {
    font-size: 0.8rem;
    margin-top: 0.35rem;
    opacity: 0.85;
}
.chat-msg-mine .chat-location-label {
    color: rgba(255, 255, 255, 0.85);
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content { padding: 1rem; padding-bottom: 80px; }
    .balance-amount { font-size: 2rem; }
    .tab-btn { font-size: 0.8rem; padding: 0.6rem 0.5rem; min-height: 44px; }
    .install-hint-floater {
        top: 0.65rem;
        right: 0.65rem;
    }
}

@media (max-width: 480px) {
    /* Header */
    .header { padding: 0.7rem 0.8rem; }
    .header h1 { font-size: 1.25rem; }
    .header .user-name {
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Tab bar: icon-only pills */
    .tab-btn .tab-label { display: none; }
    .tab-btn .tab-icon { font-size: 1.4rem; }
    .tab-btn { padding: 0.7rem 0.5rem; min-height: 44px; }

    /* Group info bar */
    .group-info-bar { gap: 0.5rem; }
    .info-item { min-width: 0; flex: 1 1 30%; padding: 0.6rem 0.5rem; }
    .info-item .info-value { font-size: 1rem; }

    /* Balance card */
    .balance-amount { font-size: 1.5rem !important; }
    .balance-card { padding: 1rem !important; }

    /* Modals */
    .modal { width: 95%; min-width: 0; padding: 1.2rem; }
    .modal.modal-wide { max-width: 95vw; }
    .pref-profile-row { align-items: flex-start; }
    .pref-modal-header { align-items: center; }
    .pref-logout-btn { padding: 0.25rem 0.5rem; }

    /* Form action buttons */
    .form-actions { flex-wrap: wrap; }
    .form-actions .btn { min-width: 0; }

    /* Stats grid */
    .stats-grid { gap: 0.5rem; }

    /* Activity log */
    .activity-item { gap: 0.4rem; font-size: 0.8rem; }
    .activity-time { min-width: 60px; font-size: 0.7rem; }

    /* Toasts */
    .toast { right: 0.5rem; left: 0.5rem; max-width: none; }
    .install-hint-floater {
        top: 0.45rem;
        right: 0.5rem;
        width: calc(100vw - 1rem);
        border-radius: 12px;
        padding: 0.8rem 1.9rem 0.8rem 0.85rem;
    }
    .install-hint-floater::before {
        right: 1.2rem;
    }

    /* Cards and tab content */
    .card { padding: 1rem; }
    .tab-content-card { padding: 1rem; }
    .auth-container { padding: 1.5rem; margin: 1.5rem auto; }

    /* Contacts inline */
    .contacts-search-wrap { padding: 0 0 0.5rem; }
    .contact-row-header { padding: 0.7rem 0.8rem; }
}

@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr; }
    .info-item { flex: 1 1 100%; }
}

/* Chat input: keep Send + map icon inside card on narrow phones (e.g. iPhone SE) */
@media (max-width: 420px) {
    .chat-input-bar {
        gap: 0.35rem;
    }
    .chat-input-bar .btn-primary {
        padding: 0.5rem 0.65rem;
        font-size: 0.8rem;
        flex-shrink: 0;
    }
    .chat-map-btn {
        padding: 0.4rem 0.45rem;
    }
}

/* Constitution / Diff styles */
.constitution-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.8;
    white-space: pre-wrap;
    padding: 1rem;
    background: var(--light-gray);
    border-radius: 6px;
    border: 1px solid var(--medium-gray);
}
.constitution-text .tag {
    background: #e3f0f8;
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.3rem;
}
.diff-display {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.8;
    white-space: pre-wrap;
    padding: 1rem;
    background: var(--light-gray);
    border-radius: 6px;
    border: 1px solid var(--medium-gray);
}
.diff-display ins {
    background: #d4edda;
    color: #155724;
    text-decoration: none;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
}
.diff-display del {
    background: #f8d7da;
    color: #721c24;
    text-decoration: line-through;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
}
.amendment-card {
    border: 1px solid var(--medium-gray);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--white);
}
.amendment-card.voting { border-left: 4px solid var(--primary-color); }
.amendment-card.passed { border-left: 4px solid var(--green); }
.amendment-card.failed { border-left: 4px solid var(--red); }
.amendment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.amendment-title { font-weight: 600; font-size: 0.95rem; }
.amendment-meta { font-size: 0.8rem; color: var(--dark-gray); }
.amendment-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}
.amendment-status.voting { background: #cce5ff; color: #004085; }
.amendment-status.passed { background: #d4edda; color: #155724; }
.amendment-status.failed { background: #f8d7da; color: #721c24; }
.vote-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}
.vote-bar-track {
    flex: 1;
    height: 8px;
    background: var(--medium-gray);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
.vote-bar-fill {
    height: 100%;
    background: var(--green);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.vote-bar-threshold {
    position: absolute;
    top: -3px;
    height: 14px;
    width: 2px;
    background: var(--red);
}

/* Activity log */
.activity-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--light-gray);
    font-size: 0.85rem;
    align-items: baseline;
}
.activity-item:last-child { border-bottom: none; }
.activity-time {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--dark-gray);
    min-width: 70px;
}
.activity-summary { color: var(--text-color); }
.activity-item.highlight {
    animation: activityHighlight 2s ease-out;
}
@keyframes activityHighlight {
    from { background-color: #e3f0f8; }
    to { background-color: transparent; }
}

.hidden { display: none !important; }

/* Meet / QR contact exchange overlay */
.meet-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.meet-overlay .meet-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 3001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.meet-overlay .meet-close:hover {
    background: rgba(255,255,255,0.35);
}
.meet-qr-section {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem 1rem;
}
.meet-qr-box {
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    display: inline-block;
}
.meet-camera-section {
    flex: 1 1 auto;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.meet-camera-section video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.meet-camera-section .meet-scan-hint {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    background: rgba(0,0,0,0.5);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    white-space: nowrap;
}
.meet-success {
    color: #4cff88;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    padding: 1rem;
}
.meet-copy-btn {
    margin-top: 0.6rem;
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}
.meet-copy-btn:hover { background: rgba(255,255,255,0.35); }

/* Full-screen flash overlay for successful handshake */
.handshake-flash {
    position: fixed;
    inset: 0;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
}
.handshake-flash.active {
    animation: handshakeFlash 0.6s ease-in-out;
}
@keyframes handshakeFlash {
    0%   { opacity: 1; background: #3a7ca5; }
    16%  { opacity: 1; background: #d0d0d0; }
    33%  { opacity: 1; background: #3a7ca5; }
    50%  { opacity: 1; background: #d0d0d0; }
    66%  { opacity: 1; background: #3a7ca5; }
    83%  { opacity: 1; background: #d0d0d0; }
    100% { opacity: 0; background: #d0d0d0; }
}

/* Inline contacts search */
.contacts-search-wrap {
    position: relative;
    padding: 0 0 0.75rem;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}
.contacts-search-icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-65%);
    color: var(--dark-gray);
    font-size: 1.27rem;
    pointer-events: none;
}
.contacts-search-input {
    width: 100%;
    padding: 0.65rem 2.65rem 0.65rem 2.25rem;
    border: 1px solid var(--medium-gray);
    border-radius: 8px;
    font-family: inherit;
    font-size: 16px;
    background: #edf1f4;
    color: var(--text-color);
}
.contacts-search-clear {
    position: absolute;
    right: 0.45rem;
    top: 50%;
    transform: translateY(-65%);
    border: none;
    background: transparent;
    color: var(--dark-gray);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    display: none;
}
.contacts-search-clear:hover {
    background: rgba(0, 0, 0, 0.08);
}
.contacts-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 124, 165, 0.15);
}
.contacts-list-wrap {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}
.contact-row {
    background: var(--white);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: var(--transition);
}
.contact-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.contact-row-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
}
.contact-row-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.contact-row-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--medium-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--dark-gray);
    flex-shrink: 0;
}
.contact-row-name {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
}
.contact-row-name-top {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    width: 100%;
}
.contact-row-known-duration {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--dark-gray);
    opacity: 0.7;
    line-height: 1.2;
    white-space: nowrap;
}
.contact-row-name-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.contact-row-shared-icons {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    margin-left: 0.3rem;
    color: var(--dark-gray);
}
.contact-row-shared-icon {
    font-size: 0.39rem;
    line-height: 1;
    filter: grayscale(100%);
    opacity: 0.7;
}
.contact-row-shared-icon-email {
    font-size: 0.78rem;
}
.contact-row-lastseen { font-size: 0.78rem; color: var(--dark-gray); white-space: nowrap; }
.contact-row-chevron { font-size: 0.9rem; color: var(--dark-gray); transition: transform 0.2s; }
.contact-row.expanded .contact-row-chevron { transform: rotate(90deg); }
.contact-detail {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--light-gray);
    display: none;
}
.contact-row.expanded .contact-detail { display: block; }
.contact-detail-line { padding: 0.4rem 0; font-size: 0.9rem; color: var(--dark-gray); }
.contact-detail-line a { color: var(--primary-color); text-decoration: none; }
.contact-action-icon {
    margin-left: 0.5rem;
    font-size: 1.1rem;
    vertical-align: middle;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.contact-action-icon:hover { opacity: 1; }
.contact-detail-muted { font-style: italic; }
.contact-detail-media-row {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.75rem;
}
.contact-detail-top-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.contact-detail-profile-media {
    flex-shrink: 0;
    width: 90px;
    height: 90px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--medium-gray);
    display: flex;
    align-items: center;
    justify-content: center;
}
.contact-detail-top-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 90px;
    height: 90px;
}
.contact-detail-top-actions .btn {
    flex: 1;
    width: 100%;
    text-align: center;
    padding: 0;
}
.contact-detail-profile-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.contact-detail-profile-placeholder {
    font-size: 2rem;
    color: var(--dark-gray);
}
/* ---- Met on date field ---- */
.contact-detail-met-on {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0;
    border-top: 1px solid var(--light-gray);
    margin-top: 0.6rem;
}
.contact-detail-met-on-label {
    font-size: 0.85rem;
    color: var(--dark-gray);
    font-weight: 500;
    white-space: nowrap;
}
.contact-detail-met-on-value {
    display: inline-flex;
    align-items: center;
}
.contact-detail-met-on-display {
    font-size: 0.85rem;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
    pointer-events: none;
}
.contact-detail-met-on-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.001;
    border: none;
    background: transparent;
    color: transparent;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

/* ---- Image lightbox ---- */
.img-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.img-lightbox.active {
    opacity: 1;
    pointer-events: all;
}
.img-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.img-lightbox-close:hover { background: rgba(255,255,255,0.3); }
.img-lightbox-img {
    max-width: min(90vw, 560px);
    max-height: 70vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    display: block;
}
.img-lightbox-caption {
    margin-top: 0.85rem;
    text-align: center;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    line-height: 1.55;
}

/* ---- Selfies horizontal strip ---- */
.contact-detail-selfies-section {
    margin-top: 0.9rem;
}
.selfies-strip-container {
    overflow: hidden;
}
.selfies-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.4rem;
    /* hide scrollbar but keep scroll */
    scrollbar-width: none;
}
.selfies-strip::-webkit-scrollbar { display: none; }
.selfie-tile {
    flex: 0 0 110px;
    scroll-snap-align: start;
    border-radius: 10px;
    overflow: hidden;
    background: var(--medium-gray);
    display: flex;
    flex-direction: column;
}
.selfie-tile img {
    width: 110px;
    height: 110px;
    object-fit: cover;
    display: block;
}
.selfie-caption {
    padding: 3px 5px 4px;
    font-size: 0.67rem;
    color: var(--dark-gray);
    line-height: 1.3;
    background: var(--light-gray, #f5f5f5);
}
.selfie-caption-location {
    font-size: 0.62rem;
    opacity: 0.75;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.selfie-tile-add {
    cursor: pointer;
    align-items: center;
    justify-content: center;
    height: 110px;
    border: 2px dashed var(--dark-gray);
    background: transparent;
    opacity: 0.55;
    transition: opacity 0.15s;
}
.selfie-tile-add:hover, .selfie-tile-add:active { opacity: 0.85; }
.selfie-tile-add-icon { font-size: 1.8rem; }
/* ---- New-contact fullscreen selfie overlay ---- */
.new-contact-selfie-overlay {
    position: fixed;
    inset: 0;
    z-index: 9900;
    background: #000;
    display: flex;
    align-items: stretch;
}
.new-contact-selfie-overlay.hidden { display: none; }
.new-contact-selfie-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.new-contact-selfie-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
    background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, transparent 100%);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
}
.new-contact-selfie-skip {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
    right: 1rem;
    background: rgba(0,0,0,0.45);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.new-contact-selfie-capture {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 2rem);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 50%;
    width: 4.5rem;
    height: 4.5rem;
    font-size: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.new-contact-selfie-capture:active { transform: translateX(-50%) scale(0.93); }
/* Hide small avatar in header when row is expanded */
.contact-row.expanded .contact-row-avatar,
.contact-row.expanded .contact-row-avatar-placeholder { display: none; }

.contact-detail-actions {
    margin-top: 0.9rem;
    display: flex;
    gap: 0.6rem;
}
.contact-detail-actions .btn {
    margin-right: 0;
    flex: 1;
}
.contact-detail-actions .btn-share-with-contact,
.contact-detail-actions .btn-vouch-with-contact {
    padding: 0.6rem 0.7rem;
}
.btn-vouch-with-contact {
    background: var(--primary-color);
    color: var(--white);
}
.btn-vouch-with-contact:hover:not(:disabled) { background: var(--accent-color); }
.contact-shared-details {
    margin-top: 0.9rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    background: var(--light-gray);
}
.contact-shared-trust {
    margin-top: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    background: var(--light-gray);
}
.contact-shared-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--dark-gray);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.contact-shared-trust .contact-detail-line { margin-top: 0.2rem; }
.contact-shared-key {
    font-weight: 600;
    color: var(--dark-gray);
}
.header-heart-btn { color: #ff4d6d !important; font-size: 1.32rem !important; }

/* Family tree in contact details */
.family-tree { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--light-gray); }
.family-tree-title { font-size: 0.8rem; font-weight: 600; color: var(--dark-gray); margin-bottom: 0.5rem; }
.family-tree-loading { font-size: 0.8rem; color: var(--dark-gray); }
.family-tree-diagram {
    display: flex;
    flex-direction: column;
    gap: 0;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
}
.ft-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ft-node {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    background: var(--light-gray);
    margin: 2px 0;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    font-size: 0.75rem;
}
.ft-node.ft-lca {
    background: var(--primary-color);
    color: var(--white);
    font-weight: 600;
}
.ft-node.ft-you {
    border: 2px solid var(--primary-color);
    font-weight: 600;
}
.ft-node.ft-them {
    border: 2px solid #d63384;
    font-weight: 600;
}
.ft-connector { width: 2px; height: 10px; background: var(--medium-gray); }
.ft-junction {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ft-junction-bar {
    height: 2px;
    background: var(--medium-gray);
    align-self: stretch;
    margin: 0 50%;
}
.ft-branches {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}
.ft-branches.ft-single-right,
.ft-branches.ft-single-left {
    width: 100%;
    max-width: 230px;
    justify-content: space-between;
}
.ft-branch-empty {
    min-width: 100px;
}
.ft-split-bar {
    display: flex;
    width: 100%;
    max-width: 210px;
}
.ft-split-bar div {
    flex: 1;
    height: 2px;
    background: var(--medium-gray);
}
.ft-branch-connector {
    width: 2px;
    height: 10px;
    background: var(--medium-gray);
}
.ft-top-bar {
    display: flex;
    align-items: flex-end;
}
.ft-top-bar-line {
    height: 2px;
    background: var(--medium-gray);
    flex: 1;
}
.ft-top-bar-stem {
    width: 2px;
    height: 10px;
    background: var(--medium-gray);
}
/* Bottom bar */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    height: 64px;
}
.bottom-bar-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--dark-gray);
    padding: 0.5rem 0;
    height: 100%;
    transition: color 0.2s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.bottom-bar-btn.active {
    color: var(--primary-color);
}
.bottom-bar-btn:hover {
    color: var(--primary-color);
}
.bottom-bar-icon {
    width: 24px;
    height: 24px;
}
.bottom-bar-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.bottom-bar-btn-center {
    flex: none;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: var(--white);
    margin-top: -35px;
    box-shadow: 0 4px 14px rgba(58, 124, 165, 0.4);
    padding: 0;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.bottom-bar-btn-center:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 18px rgba(58, 124, 165, 0.5);
    color: var(--white);
}
.bottom-bar-btn-center:active {
    transform: scale(0.96);
}
.bottom-bar-handshake {
    font-size: 2rem;
    line-height: 1;
}

/* Profile screen (inline) */
#profileScreen .card {
    margin-top: 0;
}
.profile-screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.profile-screen-header h2 {
    color: var(--accent-color);
    margin: 0;
}

.choice-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.choice-item {
    display: flex;
}
.choice-button {
    width: 100%;
    justify-content: center;
}
