/* Final phone ownership for BIC-QA. Loaded after all theme styles. */
@media (max-width: 640px) {
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

    .sidebar-toggle-btn,
    .container.sidebar-open .sidebar-toggle-btn,
    .container.sidebar-open.sidebar-collapsed .sidebar-toggle-btn {
        top: calc(10px + env(safe-area-inset-top)) !important;
        left: 10px !important;
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
        padding: 0 !important;
        border-radius: 13px !important;
    }

    .container.sidebar-open > .sidebar,
    .container.sidebar-open.sidebar-collapsed > .sidebar,
    .container > .sidebar.is-open,
    .sidebar.is-open,
    .sidebar.is-collapsed.is-open {
        width: min(86vw, 324px) !important;
        min-width: min(86vw, 324px) !important;
        max-width: min(86vw, 324px) !important;
        transform: translateX(0) !important;
        padding: env(safe-area-inset-top) 10px calc(10px + env(safe-area-inset-bottom)) !important;
        border-radius: 0 20px 20px 0 !important;
        box-shadow: 18px 0 44px rgba(27, 36, 58, .16) !important;
    }

    .container.sidebar-open .sidebar-toggle-btn { left: min(calc(86vw - 54px), 270px) !important; }
    .sidebar .logo-section { min-height: 76px !important; padding: 12px 52px 10px 14px !important; }
    .sidebar .logo-section img { width: min(190px, 72%) !important; max-height: 52px !important; object-fit: contain; }
    .sidebar .sidebar-history-panel { gap: 8px !important; padding: 6px 4px !important; }
    .sidebar .sidebar-history-header { min-height: 28px !important; padding: 0 4px !important; }
    .sidebar .sidebar-history-list { gap: 4px !important; padding: 2px 0 !important; overflow-y: auto !important; }
    .sidebar .sidebar-history-item { border-radius: 11px !important; }
    .sidebar .sidebar-history-open { min-height: 44px !important; padding: 10px 38px 10px 12px !important; border-radius: 11px !important; }
    .sidebar .sidebar-history-menu-toggle { right: 1px !important; width: 40px !important; height: 40px !important; }
    .sidebar .quick-actions-sidebar { gap: 6px !important; padding: 8px 4px 4px !important; }
    .sidebar .sidebar-action-btn { min-height: 44px !important; padding: 9px 12px !important; border-radius: 11px !important; }

    .content-area > .token-registration-banner {
        min-height: 72px !important;
        height: 72px !important;
        flex-basis: 72px !important;
        gap: 8px !important;
        padding: 8px 40px 8px 62px !important;
    }

    .content-area > .token-registration-banner .token-banner-mobile-copy {
        font-size: 11px !important;
        line-height: 15px !important;
    }

    .content-area > .token-registration-banner .token-banner-cta {
        min-width: 0 !important;
        height: 40px !important;
        padding: 0 10px !important;
        font-size: 11px !important;
        border-radius: 11px !important;
    }

    .content-area > .token-registration-banner .token-banner-close {
        right: 5px !important;
        width: 36px !important;
        height: 44px !important;
    }

    .content-area .selector-row {
        min-height: 44px !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        padding: 0 14px 0 62px !important;
        margin: 8px 0 0 !important;
    }
    .content-area .selector-right,
    .content-area .language-switcher { flex: 0 0 auto !important; width: auto !important; margin: 0 !important; }
    .content-area .language-select {
        width: 128px !important;
        min-width: 0 !important;
        max-width: 128px !important;
        height: 44px !important;
        padding: 8px 32px 8px 12px !important;
        border-radius: 11px !important;
        font-size: 14px !important;
    }

    .content-area.no-result .input-center-wrapper { justify-content: flex-start !important; padding-top: clamp(38px, 7vh, 58px) !important; }
    .content-area.no-result .input-header { margin: 0 0 20px !important; padding: 0 !important; }
    .content-area.no-result .input-title { font-size: 26px !important; line-height: 32px !important; }
    .content-area.no-result .input-subtitle { margin-top: 3px !important; font-size: 12px !important; line-height: 18px !important; }
    .content-area .input-container {
        width: calc(100% - 24px) !important;
        min-height: 0 !important;
        padding: 10px !important;
        border-radius: 17px !important;
    }
    .content-area .question-input {
        min-height: 64px !important;
        height: 64px !important;
        padding: 8px 10px !important;
        font-size: 16px !important;
        line-height: 24px !important;
    }
    .content-area .composer-attachment-list:empty { display: none !important; }
    .content-area .composer-toolbar {
        min-height: 50px !important;
        height: 50px !important;
        flex-flow: row nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 8px 2px 0 !important;
    }
    .content-area .composer-toolbar-primary,
    .content-area .composer-toolbar-actions { width: auto !important; min-width: 0 !important; }
    .content-area.has-result .input-center-wrapper { margin-bottom: max(10px, env(safe-area-inset-bottom)) !important; }
    .content-area.has-result .question-input { min-height: 64px !important; height: 64px !important; }

    .content-area .footer {
        padding: 11px 18px calc(11px + env(safe-area-inset-bottom)) !important;
        font-size: 12px !important;
        line-height: 1.55 !important;
    }

    /* Phone auth: a compact, content-sized sheet with one clear action row. */
    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) {
        align-items: flex-end !important;
        padding: 8px 10px max(10px, env(safe-area-inset-bottom)) !important;
        background: rgba(27, 36, 58, .5) !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-dialog {
        width: 100% !important;
        max-width: 400px !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: calc(100dvh - 18px - env(safe-area-inset-bottom)) !important;
        padding-bottom: 0 !important;
        border-radius: 24px !important;
        box-shadow: 0 -2px 8px rgba(24, 33, 55, .06), 0 24px 64px rgba(24, 33, 55, .24) !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-dialog > .dialog-header {
        min-height: 68px !important;
        padding: 12px 54px 8px 66px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-dialog > .dialog-header h3 {
        min-height: 29px !important;
        font-size: 20px !important;
        line-height: 25px !important;
        letter-spacing: -.02em !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-dialog > .dialog-header h3::before {
        left: -48px !important;
        width: 40px !important;
        height: 40px !important;
        border-radius: 12px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-dialog > .dialog-header h3::after {
        bottom: -13px !important;
        font-size: 10px !important;
        line-height: 15px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-dialog > .dialog-header .close-btn {
        top: 10px !important;
        right: 10px !important;
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
        font-size: 22px !important;
        border-radius: 12px !important;
        touch-action: manipulation;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-form,
    .bicbot-login-overlay[data-mode="login"]:not(.bicbot-cancel-account-overlay) .bicbot-login-form {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        margin: 0 !important;
        padding: 6px 14px 12px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-auth-method-tabs {
        min-height: 48px !important;
        padding: 3px !important;
        border-radius: 12px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-auth-method-tab {
        min-height: 42px !important;
        font-size: 14px !important;
        border-radius: 10px !important;
        touch-action: manipulation;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-field {
        gap: 4px !important;
        font-size: 13px !important;
        line-height: 17px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-field input,
    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-code-btn {
        height: 46px !important;
        min-height: 46px !important;
        border-radius: 11px !important;
        font-size: 16px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-code-row {
        grid-template-columns: minmax(0, 1fr) 110px !important;
        gap: 8px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-code-btn {
        width: 110px !important;
        padding: 0 8px !important;
        font-size: 13px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-legal-consent,
    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-remember-me {
        min-height: 30px !important;
        margin: 0 !important;
        font-size: 12px !important;
        line-height: 18px !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-assist:has(.bicbot-register-prompt[style*="display: none"] + .bicbot-forgot-btn[style*="display: none"]) {
        display: none !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-actions {
        min-height: 48px !important;
        display: grid !important;
        grid-template-columns: minmax(96px, .8fr) minmax(0, 1.4fr) !important;
        flex-direction: initial !important;
        gap: 8px !important;
        margin: 2px 0 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
    }

    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-actions .bicbot-secondary-btn,
    .bicbot-login-overlay:not(.bicbot-cancel-account-overlay) .bicbot-login-actions .bicbot-primary-btn {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 48px !important;
        height: 48px !important;
        border-radius: 12px !important;
        font-size: 15px !important;
        touch-action: manipulation;
    }

    .profile-center-dialog { align-items: flex-end !important; padding: 0 !important; }
    .profile-center-dialog .profile-center-container {
        width: 100% !important;
        height: min(88dvh, 660px) !important;
        max-height: min(88dvh, 660px) !important;
        border-radius: 22px 22px 0 0 !important;
    }
    .profile-center-dialog .profile-center-header { min-height: 64px !important; padding: 10px 16px !important; }
    .profile-center-dialog .profile-center-header h3 { font-size: 21px !important; line-height: 26px !important; }
    .profile-center-dialog .profile-center-close,
    .profile-center-dialog .profile-center-header .close-btn {
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
        border-radius: 12px !important;
    }
    .profile-center-dialog .profile-center-tabs { min-height: 52px !important; gap: 4px !important; padding: 6px 10px !important; }
    .profile-center-dialog .profile-tab-btn { min-height: 40px !important; padding: 7px 9px !important; font-size: 12px !important; }
    .profile-center-dialog .profile-center-content {
        height: calc(min(88dvh, 660px) - 116px) !important;
        padding: 14px 12px calc(18px + env(safe-area-inset-bottom)) !important;
    }
    .profile-center-dialog .profile-token-hero { min-height: 112px !important; padding: 16px !important; gap: 10px !important; border-radius: 16px !important; }
    .profile-center-dialog .profile-token-section { margin-top: 12px !important; padding: 14px !important; border-radius: 16px !important; }
    .profile-center-dialog .profile-token-section .profile-section-heading { margin-bottom: 12px !important; }
    .profile-center-dialog .profile-token-range-tabs { position: static !important; width: 100% !important; margin: 0 0 8px !important; }
    .profile-center-dialog .profile-token-range-btn { flex: 1 1 0 !important; min-width: 0 !important; min-height: 38px !important; }
    .profile-center-dialog .profile-token-chart-shell { padding-top: 8px !important; border-radius: 12px !important; }
    .profile-center-dialog .profile-token-chart-shell .profile-token-chart { min-height: 142px !important; height: 142px !important; padding: 12px 8px 8px !important; }
    .profile-center-dialog .profile-token-chart-stats {
        min-height: 62px !important;
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 8px !important;
        padding: 10px !important;
        overflow: visible !important;
    }
    .profile-center-dialog .profile-token-chart-stats span { font-size: 9px !important; white-space: nowrap; }
    .profile-center-dialog .profile-token-chart-stats strong { font-size: 13px !important; }
}
