:root {
    --limao-tg-safe-top: 0px;
    --limao-tg-safe-right: 0px;
    --limao-tg-safe-bottom: 0px;
    --limao-tg-safe-left: 0px;
    --limao-tg-content-safe-top: 0px;
    --limao-tg-content-safe-right: 0px;
    --limao-tg-content-safe-bottom: 0px;
    --limao-tg-content-safe-left: 0px;
}

html.telegram-mini-app,
html.telegram-mini-app body {
    min-height: var(--tg-viewport-stable-height, 100dvh);
    overscroll-behavior-y: none;
}

html.telegram-mini-app body {
    padding-right: max(env(safe-area-inset-right), var(--limao-tg-content-safe-right));
    padding-bottom: max(env(safe-area-inset-bottom), var(--limao-tg-content-safe-bottom));
    padding-left: max(env(safe-area-inset-left), var(--limao-tg-content-safe-left));
}

html.telegram-mini-app .header {
    padding-top: max(env(safe-area-inset-top), var(--limao-tg-content-safe-top));
}

html.telegram-mini-app .chat-input-area {
    padding-bottom: calc(12px + max(env(safe-area-inset-bottom), var(--limao-tg-content-safe-bottom))) !important;
}

html.telegram-mini-app .mobile-section-bar,
html.telegram-mini-app .payment-modal-footer,
html.telegram-mini-app .account-toast,
html.telegram-mini-app .notification-toast {
    margin-bottom: max(env(safe-area-inset-bottom), var(--limao-tg-content-safe-bottom));
}

html.telegram-mini-app [data-telegram-hidden="true"],
html.telegram-mini-app .logout-btn,
html.telegram-mini-app [data-action="logout"] {
    display: none !important;
}

html.telegram-mini-app .telegram-payment-note {
    display: block !important;
}

.telegram-only {
    display: none !important;
}

html.telegram-mini-app .telegram-only {
    display: initial !important;
}

.telegram-auth-error {
    position: fixed;
    z-index: 10000;
    right: 16px;
    bottom: calc(16px + max(env(safe-area-inset-bottom), var(--limao-tg-content-safe-bottom)));
    left: 16px;
    max-width: 520px;
    margin: 0 auto;
    padding: 14px 15px;
    border: 1px solid #ddb4ad;
    border-radius: 14px;
    background: #fff5f2;
    box-shadow: 0 18px 48px rgba(65, 35, 28, 0.2);
    color: #7e342b;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
}

.telegram-auth-error strong,
.telegram-auth-error span {
    min-width: 0;
}

.telegram-auth-error strong {
    font-size: 14px;
}

.telegram-auth-error span {
    grid-column: 1;
    color: #9b5148;
    font-size: 12px;
}

.telegram-auth-error button {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid #8f4137;
    border-radius: 9px;
    background: #8f4137;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
}

@media (prefers-color-scheme: dark) {
    .telegram-auth-error {
        border-color: #70443e;
        background: #352421;
        color: #ffd9d3;
    }

    .telegram-auth-error span {
        color: #e9aaa1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .telegram-auth-error * {
        transition: none !important;
    }
}
