/* Finnische mobile component library (f-*). Dark fintech, no neon, no scanlines.
 * Scoped to #mobile-app so the desktop admin shell keeps its own styling.
 */

/* ---------- Shell visibility ----------
 * The desktop admin shell relies on Tailwind utilities (hidden / lg:flex / lg:hidden),
 * but Tailwind is only loaded at >=1024px. These rules make the two shells toggle
 * correctly regardless of Tailwind, so the mobile shell never leaks desktop markup.
 */
#desktop-version { display: none; }
#mobile-version { display: block; }
@media (min-width: 1024px) {
    #desktop-version { display: flex; }
    #mobile-version { display: none; }
}

/* ---------- App scaffold ---------- */
#mobile-app {
    --_f-ink: var(--text);
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
}
#mobile-app *,
#mobile-app *::before,
#mobile-app *::after {
    box-sizing: border-box;
}
#mobile-app button,
#mobile-app input,
#mobile-app textarea,
#mobile-app select {
    font-family: inherit;
    font-size: inherit;
}
#mobile-app input,
#mobile-app textarea,
#mobile-app select {
    color: inherit;
}
#mobile-app button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
#mobile-app svg { flex-shrink: 0; }

.f-app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.f-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    animation: f-fade 0.25s ease;
}
.f-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--pad) var(--pad) calc(var(--tabbar-h) + var(--safe-bottom) + var(--pad));
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}
.f-content > .f-stack { gap: var(--gap); }
.f-stack { display: flex; flex-direction: column; gap: 12px; }
/* Row lists have no gap, so each .f-row's bottom border reads as a list divider. */
.f-list { display: flex; flex-direction: column; }
.f-list > .f-btn { margin-top: 12px; }

@keyframes f-fade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}
@keyframes f-rise {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: none; }
}
@keyframes f-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* ---------- Header ---------- */
.f-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--header-h);
    padding: calc(8px + var(--safe-top)) 12px 8px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border);
}
.f-header__title {
    flex: 1;
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.01em;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.f-header__side {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 44px;
    justify-content: flex-end;
}
.f-header__side--left { justify-content: flex-start; }
.f-icon-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--text-2);
    border-radius: var(--radius-inner);
}
.f-icon-btn:active { background: var(--surface-3); color: var(--text); }
.f-icon-btn svg { width: 22px; height: 22px; }

/* ---------- Tabbar ---------- */
.f-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    display: flex;
    align-items: center;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 3px 4px calc(3px + var(--safe-bottom));
}
.f-tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    padding: 2px 2px;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: var(--radius-inner);
}
.f-tabbar__item svg { width: 20px; height: 20px; }
.f-tabbar__item.is-active { color: var(--text); }
.f-tabbar__item:active { background: var(--surface-3); }

/* ---------- Cards ---------- */
.f-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 18px;
    box-shadow: var(--shadow-card);
}
.f-card--hero { padding: 20px; }
.f-card--flush { padding: 0; overflow: hidden; }
.f-card--tint {
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

/* ---------- Section labels ---------- */
.f-section-label {
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-2);
    margin: 0 0 10px;
}
.f-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.f-section-head .f-section-label { margin: 0; }

/* ---------- Numbers ---------- */
.f-num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.f-num--xl { font-size: var(--f-num-xl); line-height: 1.05; }
.f-num--lg { font-size: var(--f-num-lg); line-height: 1.1; }
.f-num--md { font-size: var(--f-num-md); }
.f-num-alt { font-family: var(--font-mono); font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.f-num-exact { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }

/* ---------- Stat grid ---------- */
.f-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.f-stat {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 12px;
    min-width: 0;
}
.f-stat__icon { color: var(--text-3); margin-bottom: 8px; }
.f-stat__icon svg { width: 18px; height: 18px; }
.f-stat__value { font-family: var(--font-mono); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.f-stat__label { font-size: 11px; color: var(--text-3); margin-top: 2px; letter-spacing: 0.02em; }

/* ---------- Segmented control ---------- */
.f-segmented {
    display: flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 3px;
    gap: 2px;
}
.f-segmented__btn {
    flex: 1;
    min-height: 36px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.f-segmented__btn.is-active { background: var(--surface-3); color: var(--text); }
.f-segmented__btn:active { background: var(--surface-3); }

/* ---------- Buttons ---------- */
.f-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 20px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 650;
    color: var(--text);
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease, opacity 0.15s ease;
}
.f-btn:active { transform: scale(0.98); }
.f-btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.f-btn--primary { background: var(--text); color: #0A0A0B; }
.f-btn--primary:active { background: #E6E6E6; }
.f-btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.f-btn--ghost:active { background: var(--surface-3); color: var(--text); }
.f-btn--danger { background: transparent; border-color: color-mix(in srgb, var(--neg) 45%, transparent); color: var(--neg); }
.f-btn--danger:active { background: color-mix(in srgb, var(--neg) 12%, transparent); }
.f-btn--block { width: 100%; }
.f-btn svg { width: 20px; height: 20px; }

/* ---------- Inputs ---------- */
.f-input {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 0 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
}
.f-input:focus-within { border-color: var(--border-strong); background: var(--surface-3); }
.f-input svg { width: 20px; height: 20px; color: var(--text-3); flex-shrink: 0; }
.f-input input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    height: 50px;
    font-size: 16px;
}
.f-input input::placeholder { color: var(--text-3); }
.f-field { display: flex; flex-direction: column; gap: 6px; }
.f-field__label { font-size: 12px; color: var(--text-2); }

/* ---------- Rows / list ---------- */
.f-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    min-height: 44px;
    /* Reset native <button> chrome: account rows are buttons, and the default
     * 2px outset border otherwise shows as a light bevel/glow on 3 sides. */
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-align: left;
    background: transparent;
    width: 100%;
    color: var(--text);
}
.f-row:last-child { border-bottom: 0; }
.f-row:active { opacity: 0.7; }
.f-row__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.f-row__title {
    display: block;
    font-weight: 600;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.f-row__sub {
    display: block;
    font-size: 12.5px;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.f-row__value {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    max-width: 45%;
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
}

.f-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--text-2);
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
}
.f-row .f-avatar { width: 36px; height: 36px; }
.f-avatar__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.f-avatar svg { width: 20px; height: 20px; }
.f-avatar--accent { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: #9db6ff; }

/* ---------- Chips & badges ---------- */
.f-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: var(--surface-3);
    color: var(--text-2);
    white-space: nowrap;
}
.f-chip--pos { background: color-mix(in srgb, var(--pos) 16%, transparent); color: var(--pos); }
.f-chip--neg { background: color-mix(in srgb, var(--neg) 16%, transparent); color: var(--neg); }
.f-chip--accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: #9db6ff; }
.f-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.04em;
    background: var(--surface-3);
    color: var(--text-2);
    text-transform: uppercase;
}
.f-badge--brand { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.f-badge--accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: #9db6ff; }

/* ---------- Divider ---------- */
.f-divider { height: 1px; background: var(--border); border: 0; margin: 4px 0; }

/* ---------- Empty / skeleton / toast ---------- */
.f-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-3);
}
.f-empty__icon { width: 44px; height: 44px; color: var(--text-3); }
.f-empty__icon svg { width: 44px; height: 44px; }
.f-skeleton {
    border-radius: var(--radius-inner);
    background: var(--surface-2);
    position: relative;
    overflow: hidden;
}
.f-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: f-shimmer 1.4s infinite;
}
@keyframes f-shimmer { 100% { transform: translateX(100%); } }

.f-toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-inner);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    font-size: 14px;
    animation: f-fade 0.2s ease;
}
.f-toast--error { border-color: color-mix(in srgb, var(--neg) 40%, transparent); }
.f-toast--error .f-toast__dot { background: var(--neg); }
.f-toast__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex-shrink: 0; }

/* ---------- Bottom sheet ---------- */
.f-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-end;
    animation: f-fade 0.2s ease;
}
.f-sheet {
    width: 100%;
    max-height: 86dvh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    padding: 8px 18px calc(20px + var(--safe-bottom));
    animation: f-rise 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.f-sheet__grip { width: 40px; height: 4px; border-radius: 0; background: var(--border-strong); margin: 8px auto 12px; }
.f-sheet__title { font-size: 18px; font-weight: 650; margin: 4px 0 14px; }

/* ---------- Simple bar chart (SVG-driven) ---------- */
.f-bar-chart { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding-top: 8px; }
.f-bar-chart__bar {
    flex: 1;
    min-width: 4px;
    border-radius: 0;
    background: var(--accent);
    opacity: 0.85;
}
.f-bar-chart__bar.is-dim { background: var(--surface-3); }
.f-bar-chart__bar--neg { background: var(--neg); }

/* ---------- Heatmap ---------- */
.f-heatmap { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; }
.f-heatmap__cell { aspect-ratio: 1; border-radius: 0; background: var(--surface-2); }
.f-heatmap__cell[data-lvl="1"] { background: color-mix(in srgb, var(--accent) 25%, var(--surface-2)); }
.f-heatmap__cell[data-lvl="2"] { background: color-mix(in srgb, var(--accent) 50%, var(--surface-2)); }
.f-heatmap__cell[data-lvl="3"] { background: color-mix(in srgb, var(--accent) 80%, var(--surface-2)); }
.f-heatmap__cell[data-lvl="4"] { background: var(--accent); }

/* ---------- Sparkline ---------- */
.f-sparkline { display: block; width: 100%; height: 40px; }

/* ---------- Onboarding ---------- */
.f-onboard {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: safe center;
    gap: 18px;
    padding: calc(24px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
}
.f-onboard__title { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.12; }
.f-onboard__title .f-num { letter-spacing: 0; }
.f-onboard__sub { color: var(--text-2); font-size: 15px; }
.f-onboard__brand { color: var(--text-2); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 650; }
.f-onboard__divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-3);
    font-size: 12px;
}
.f-onboard__divider::before,
.f-onboard__divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.f-onboard__error {
    padding: 10px 14px;
    border: 1px solid color-mix(in srgb, var(--neg) 45%, transparent);
    background: color-mix(in srgb, var(--neg) 10%, transparent);
    color: var(--neg);
    border-radius: var(--radius-inner);
    font-size: 13px;
}
.f-onboard__hint {
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    font-size: 13px;
    color: var(--text-2);
}
.f-code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 12px 14px;
    font-size: 14px;
    color: var(--brand);
    word-break: break-all;
    user-select: all;
    -webkit-user-select: all;
}
.f-progress {
    height: 3px;
    background: var(--surface-2);
    border-radius: 0;
    overflow: hidden;
}
.f-progress > span { display: block; height: 100%; background: var(--accent); border-radius: 0; transition: width 0.3s ease; }
.f-steps { font-size: 12px; color: var(--text-3); font-weight: 600; }

/* ---------- Chat (restyled from existing chat.js DOM) ---------- */
#mobile-app .chat-shell {
    height: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
#mobile-app .chat-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
#mobile-app .chat-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}
#mobile-app .chat-header-title { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); font-size: 14px; font-weight: 650; letter-spacing: 0; }
#mobile-app .chat-header-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#mobile-app .chat-header-dot { color: var(--brand); font-size: 10px; flex-shrink: 0; }
#mobile-app .chat-status { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 11px; flex-shrink: 0; }
#mobile-app .chat-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: none; flex-shrink: 0; }
#mobile-app .chat-status-dot.connecting,
#mobile-app .chat-status-dot.reconnecting { background: #facc15; }
#mobile-app .chat-status-dot.offline { background: var(--neg); }
#mobile-app .chat-channel-segmented { min-height: 0; }
#mobile-app .chat-channel-segmented .f-segmented__btn { min-height: 30px; font-size: 11px; }
#mobile-app .chat-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
#mobile-app #chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
}
#mobile-app #chat-messages::-webkit-scrollbar { width: 0; }
#mobile-app .chat-scroll-new {
    position: absolute;
    right: 14px;
    bottom: 12px;
    z-index: 2;
    min-height: 40px;
    min-width: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}
#mobile-app .chat-scroll-new.show { display: inline-flex; align-items: center; gap: 5px; }

#mobile-app .chat-message { display: flex; width: 100%; }
#mobile-app .chat-message--own { justify-content: flex-end; }
#mobile-app .chat-message--other,
#mobile-app .chat-message--system-user { justify-content: flex-start; }
#mobile-app .chat-message--grouped { margin-top: -4px; }
#mobile-app .chat-message--grouped .chat-message-head { display: none; }
#mobile-app .chat-message.is-reply-target .chat-bubble { border-color: var(--accent); }
#mobile-app .chat-bubble {
    width: fit-content;
    max-width: min(78%, 520px);
    padding: 8px 10px 7px;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--surface);
    color: var(--text);
}
#mobile-app .chat-message--other .chat-bubble { border-radius: 0; background: var(--surface); }
#mobile-app .chat-message--system-user .chat-bubble { border-radius: 0; background: #12141a; border-color: #2a2e3a; }
#mobile-app .chat-message--own .chat-bubble { border-radius: 0; background: var(--surface-3); border-color: var(--border-strong); }
#mobile-app .chat-message-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
#mobile-app .chat-message--own .chat-message-head { justify-content: flex-end; }
#mobile-app .chat-username { font-size: 12px; font-weight: 700; color: var(--text-2); }
#mobile-app .chat-message--system-user .chat-username { color: #c9b86a; }
#mobile-app .chat-time { font-size: 11px; color: var(--text-3); }
#mobile-app .chat-text { font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
#mobile-app .reply-quote-button {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    padding: 8px 10px;
    text-align: left;
    border: 0;
    border-left: 2px solid var(--accent);
    border-radius: 0;
    background: var(--surface-2);
}
#mobile-app .reply-quote-author { font-size: 11px; font-weight: 700; color: var(--accent); }
#mobile-app .reply-quote-text { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mobile-app .reply-button {
    display: none;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    padding: 3px 0;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 11px;
}
#mobile-app .chat-message.is-reply-target .reply-button { display: inline-flex; }
#mobile-app .reply-button:active { color: var(--text-2); }
#mobile-app .chat-system-notice {
    align-self: center;
    max-width: 90%;
    margin: 4px 0;
    padding: 4px 12px;
    color: var(--text-3);
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
}
#mobile-app .chat-composer {
    padding: 10px 12px calc(10px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
}
#mobile-app .chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
#mobile-app #chat-input {
    flex: 1;
    min-width: 0;
    min-height: 46px;
    max-height: 130px;
    resize: none;
    padding: 12px 14px;
    color: var(--text);
    outline: none;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--surface-2);
    font-size: 15px;
    line-height: 1.4;
}
#mobile-app #chat-input:focus { border-color: var(--border-strong); }
#mobile-app #chat-input::placeholder { color: var(--text-3); }
#mobile-app .chat-send-button {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 0;
    background: var(--text);
    color: #0A0A0B;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}
#mobile-app .chat-send-button:active { background: #E6E6E6; }
#mobile-app .chat-send-button:disabled { opacity: 0.4; }
#mobile-app .chat-send-button.is-offline { filter: none; opacity: 0.4; }
#mobile-app #reply-preview { margin-bottom: 8px; }
#mobile-app .reply-preview-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 11px;
    border-left: 3px solid var(--accent);
    border-radius: 0;
    background: var(--surface-2);
}
#mobile-app .reply-preview-title { font-size: 11px; font-weight: 700; color: var(--accent); }
#mobile-app .reply-preview-text { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mobile-app .reply-cancel-button { width: 36px; height: 36px; border: 0; border-radius: 0; background: transparent; color: var(--text-3); font-size: 20px; line-height: 1; }

/* Chat mode: content takes full height, tabbar hidden */
#mobile-app .f-content.chat-mode { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
#mobile-app .f-content.chat-mode .chat-shell { flex: 1; }

/* ---------- Chat: author avatars, attachments, reactions ---------- */
#mobile-app .chat-message { align-items: flex-start; gap: 8px; }
#mobile-app .chat-message--own { gap: 0; }
#mobile-app .chat-avatar,
#mobile-app .chat-avatar--grouped {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--text-2);
    font-weight: 700;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    border: 0;
    padding: 0;
}
#mobile-app .chat-avatar--grouped { visibility: hidden; }
#mobile-app .chat-avatar__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#mobile-app .chat-header-avatar {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--text-2);
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
}
#mobile-app .chat-header-avatar .chat-avatar__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#mobile-app .chat-attachment { margin-top: 8px; border: 1px solid var(--border); background: var(--surface-2); max-width: 100%; overflow: hidden; cursor: pointer; }
#mobile-app .chat-attachment__thumb { display: block; max-width: 240px; width: auto; height: auto; }
#mobile-app .chat-attachment-loading {
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-3);
    border: 1px dashed var(--border-strong);
    background: var(--surface-2);
}
#mobile-app .chat-reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
#mobile-app .chat-reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    cursor: pointer;
}
#mobile-app .chat-reaction.is-mine {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
    color: var(--text);
}
#mobile-app .chat-reaction-count { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
#mobile-app .chat-link { color: var(--accent); text-decoration: underline; word-break: break-all; }
#mobile-app .chat-photo-btn {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
}
#mobile-app .chat-photo-btn svg { width: 20px; height: 20px; }
#mobile-app .chat-photo-btn:active { background: var(--surface-3); color: var(--text); }
#mobile-app #attachment-preview { margin-bottom: 8px; }
#mobile-app .attachment-preview {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}
#mobile-app .attachment-preview__img { width: 64px; height: 64px; object-fit: cover; }
#mobile-app .attachment-preview__loading { padding: 10px; font-size: 12px; color: var(--text-3); }
#mobile-app .attachment-preview__remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

/* ---------- Overlays appended to <body> (lightbox / actions / profile) ---------- */
.chat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-lightbox__img { max-width: 100%; max-height: 100%; object-fit: contain; }
.chat-lightbox__close {
    position: absolute;
    top: calc(12px + var(--safe-top));
    right: 12px;
    width: 44px;
    height: 44px;
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
.chat-sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.chat-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}
.chat-action-btn:active { background: var(--surface-3); }
.chat-sheet-emojis { display: flex; gap: 8px; }
.chat-action-btn--emoji { flex: 1; justify-content: center; font-size: 22px; }
.chat-profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.chat-profile-avatar {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--text-2);
    font-weight: 700;
    font-size: 24px;
    overflow: hidden;
}
.chat-profile-meta { min-width: 0; }
.chat-profile-name { font-weight: 700; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-profile-username { color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Admin compact block ---------- */
.f-admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.f-admin-row:last-child { border-bottom: 0; }

/* ---------- Responsive: phone sizes ---------- */
@media (max-width: 360px) {
    #mobile-app { font-size: 14px; }
    .f-content { padding: 12px 12px calc(var(--tabbar-h) + var(--safe-bottom) + 12px); gap: 12px; }
    .f-card { padding: 14px; }
    .f-card--hero { padding: 16px 14px; }
    .f-section-head { padding-left: 14px !important; padding-right: 14px !important; }
    .f-stack { gap: 10px; }
    .f-stat { padding: 10px; }
    .f-stat__value { font-size: 15px; }
    .f-heatmap { gap: 2px; }
    .f-tabbar__item { font-size: 8px; }
}
@media (max-height: 700px) {
    .f-card--hero { padding: 14px 16px; }
    .f-bar-chart { height: 84px; }
    .f-stat-grid { gap: 8px; }
    .f-stat { padding: 10px; }
    .f-onboard { gap: 14px; }
    .f-onboard__title { font-size: 26px; }
}
@media (min-width: 430px) {
    #mobile-app { font-size: 16px; }
    .f-card { padding: 20px; }
    .f-row__title { font-size: 16px; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
    #mobile-app * { animation: none !important; transition: none !important; }
}

/* Desktop-only cyber chrome must not leak into the mobile shell. */
@media (max-width: 1023px) {
    .scanline { display: none; }
    .auth-overlay { display: none; }
    #universal-modal { display: none !important; }
}
