/* ═══════════════════════════════════════════════════════════
   LOGIN — aibar.world app look
   Mirrors the design tokens from app/assets/app.css so the login
   page reads as part of the same product (dark purple/gold theme,
   Space Grotesk). Keep these in sync with app.css :root.
   ═══════════════════════════════════════════════════════════ */
:root {
    --bg: #0d0a1e;
    --surface: #16112e;
    --surface-2: #1e1640;
    --purple: #6c3eb0;
    --purple-lite: #9b5de5;
    --purple-glow: rgba(155, 93, 229, 0.35);
    --gold: #c8842a;
    --gold-lite: #f4a742;
    --gold-glow: rgba(244, 167, 66, 0.35);
    --green: #2ecc71;
    --red: #e74c3c;
    --text: #f0eafa;
    --text-muted: #c9bde0;
    --card-bg: rgba(22, 17, 46, 0.92);
    --border: rgba(155, 93, 229, 0.25);
    --border-gold: rgba(244, 167, 66, 0.30);
    --radius-sm: 8px;
    --radius: 16px;
    --radius-lg: 24px;
}

/* Type roles — same idea as poster/app: layout classes do not set color. */
.pa-head {
    color: var(--text-muted);
}
.pa-sub {
    color: var(--text);
    font-weight: 450;
    line-height: 1.45;
}

/* ── Page shell ─────────────────────────────────────────────── */
body {
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(108, 62, 176, 0.28), transparent 60%),
        radial-gradient(900px 500px at 100% 110%, rgba(244, 167, 66, 0.10), transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

/* ── Login card ─────────────────────────────────────────────── */
.login-container {
    position: relative;
    max-width: min(92vw, 420px);
    width: 100%;
    margin: 2rem auto;
    padding: clamp(1.25rem, 5vw, 2rem);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.02) inset,
        0 0 90px rgba(108, 62, 176, 0.18);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-container:hover {
    transform: translateY(-2px);
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.6),
        0 0 110px rgba(108, 62, 176, 0.24);
}

/* ── Header ─────────────────────────────────────────────────── */
.login-header {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-logo-link {
    display: inline-block;
    line-height: 0;
}

.login-logo {
    width: clamp(64px, 16vw, 104px);
    height: clamp(64px, 16vw, 104px);
    margin-bottom: 0.5rem;
    object-fit: contain;
    transition: transform 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 4px 14px rgba(155, 93, 229, 0.45));
}

.login-logo-link:hover .login-logo {
    transform: scale(1.05);
    filter: drop-shadow(0 6px 20px rgba(155, 93, 229, 0.6));
}

/* Tiny social caption links under the logo (Telegram channel + Instagram) */
.login-social-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 1rem;
    margin-bottom: 1.25rem;
}

.login-channel-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.login-channel-link:hover {
    color: var(--purple-lite);
}

.login-channel-icon {
    width: 15px;
    height: 15px;
}

.login-title {
    font-size: clamp(1.5rem, 4vw, 1.85rem);
    margin-bottom: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.login-title a {
    color: var(--gold-lite);
    text-decoration: none;
    transition: color 0.3s ease;
}

.login-title a:hover {
    color: var(--gold);
}

.login-subtitle {
    font-size: clamp(0.875rem, 3vw, 1rem);
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

/* ── Register mode (login.php?mode=register) ──────────────────── */
.login-benefits {
    list-style: none;
    margin: 0 auto 1.5rem;
    padding: 0;
    max-width: 360px;
    display: grid;
    gap: 0.5rem;
    text-align: start;
}

.login-benefits li {
    position: relative;
    padding-inline-start: 1.75rem;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.login-benefits li::before {
    content: '✓';
    position: absolute;
    inset-inline-start: 0;
    top: 0.1em;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--purple), var(--purple-lite));
}

.login-register-note {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Establishment badge ────────────────────────────────────── */
.establishment-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(145deg, rgba(30, 22, 64, 0.9), rgba(22, 17, 46, 0.9));
    padding: clamp(0.5rem, 2vw, 0.7rem) clamp(1rem, 3vw, 1.25rem);
    border-radius: 999px;
    margin-bottom: clamp(1.5rem, 4vw, 2rem);
    border: 1px solid var(--border-gold);
    transition: all 0.3s ease;
    max-width: 92%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.establishment-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(244, 167, 66, 0.18);
}

.establishment-icon {
    display: flex;
    align-items: center;
    margin-right: 0.6rem;
    color: var(--gold-lite);
}

.establishment-icon i {
    font-size: 1.5rem;
    line-height: 1;
    filter: drop-shadow(0 1px 4px rgba(244, 167, 66, 0.45));
}

.establishment-badge:hover .establishment-icon i {
    transform: scale(1.1);
    transition: transform 0.3s ease;
}

.establishment-name {
    font-size: clamp(1rem, 3vw, 1.1rem);
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
}

.establishment-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    text-align: start;
}

.establishment-slug {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted, rgba(240, 234, 250, 0.65));
    text-transform: none;
    letter-spacing: 0.01em;
    word-break: break-all;
}

.establishment-badge--claim {
    border-radius: 18px;
    align-items: flex-start;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.establishment-badge--claim .establishment-icon {
    margin-top: 0.1rem;
}

/* ── Actions ────────────────────────────────────────────────── */
.login-actions {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Method toggle (Register / Login) */
.login-method-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.14);
    border: 1px solid var(--border);
    transition: 0.4s;
    border-radius: 999px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 3px;
    background-color: #fff;
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

input:checked + .toggle-slider {
    background: linear-gradient(145deg, var(--purple-lite), var(--purple));
    border-color: transparent;
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Username input */
.username-input-container {
    display: none;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.username-input-container.active {
    display: flex;
}

.username-input {
    width: min(92%, 320px);
    padding: 0.8rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.username-input:focus {
    border-color: var(--purple-lite);
    box-shadow: 0 0 0 3px var(--purple-glow);
    outline: none;
}

.username-input::placeholder {
    color: var(--text-muted);
}

/* Language switcher — compact pill pinned to the top-(end) corner of the card.
   Mirrors the app's .settings-select look (dark field, custom caret, focus glow)
   so the login page reads as part of the same product. Applies instantly on
   change (reload with ?lang) — no separate Save step needed pre-auth. */
.login-lang {
    position: absolute;
    inset-block-start: clamp(0.6rem, 3vw, 0.9rem);
    inset-inline-end: clamp(0.6rem, 3vw, 0.9rem);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding-inline-start: 0.55rem;
    background: rgba(30, 22, 64, 0.72);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.login-lang:hover { border-color: var(--border-gold); }
.login-lang-icon { font-size: 0.85rem; line-height: 1; opacity: 0.9; }
.login-lang-select {
    -webkit-appearance: none;
    appearance: none;
    /* Native dropdown popup follows the select's color scheme; without this the area
       not covered by the dark <option>s renders white (the select itself is transparent). */
    color-scheme: dark;
    background-color: transparent;
    color: var(--text);
    border: 0;
    border-radius: 999px;
    margin: 0;
    padding: 0.32rem 1.7rem 0.32rem 0.3rem;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='7' viewBox='0 0 12 7' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239b5de5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
}
.login-lang-select:focus { outline: none; box-shadow: 0 0 0 3px var(--purple-glow); border-radius: 999px; }
.login-lang-select option { background: #1a0f28; color: #fff; }

/* RTL (Hebrew): flip the caret to the start side. */
[dir="rtl"] .login-lang-select {
    padding: 0.32rem 0.3rem 0.32rem 1.7rem;
    background-position: left 0.55rem center;
}

/* 18+ notice (alcohol-serving bars only) */
.login-age-notice {
    margin: 0.9rem 0 0;
    font-size: 0.72rem;
    line-height: 1.45;
    text-align: center;
    color: var(--text-muted);
    opacity: 0.9;
}
.login-age-notice a { color: var(--purple-lite); text-decoration: underline; white-space: nowrap; }

/* "Need help?" pill - mirrors .ob-help in onboarding.php so the two pages read as
   one product. Not position:fixed like that one: here it stays inline under the age
   notice rather than floating in the corner. Logical properties / flex gap keep it
   RTL-safe. */
.login-help { text-align: center; margin-top: 14px; }
.login-help a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, .1);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 999px;
    padding: .42rem .85rem;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
/* Bootstrap restyles a:hover, so colour and underline are pinned explicitly. */
.login-help a:hover,
.login-help a:focus {
    color: var(--text);
    text-decoration: none;
    border-color: var(--border-gold);
}
.login-help-icon { font-size: .9rem; line-height: 1; }

/* Quick-fill clear (✕) sits inside the username field */
.username-field { position: relative; width: 100%; display: flex; }
.username-field .username-input { width: 100%; padding-right: 2.6rem; box-sizing: border-box; }
.username-clear {
    position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
    width: 1.7rem; height: 1.7rem; padding: 0; border: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface); color: var(--text-muted);
    font-size: 0.8rem; line-height: 1; cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}
.username-clear:hover { color: var(--text); background: var(--border); }
.username-clear[hidden] { display: none; }

/* ── Primary buttons ────────────────────────────────────────── */
.login-btn {
    padding: clamp(0.8rem, 2vw, 1rem) clamp(1.5rem, 3vw, 2rem);
    font-size: clamp(0.9rem, 3vw, 1rem);
    font-weight: 700;
    width: min(92%, 320px);
    margin: 0 auto;
    border-radius: 14px;
    border: none;
    color: var(--text);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Top-light shimmer — same "3D block face" as app .btn */
.login-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(175deg,
            rgba(255, 255, 255, 0.18) 0%,
            rgba(255, 255, 255, 0.04) 45%,
            rgba(0, 0, 0, 0.08) 100%);
    pointer-events: none;
}

.login-btn > * {
    position: relative;
    z-index: 1;
}

.login-btn i {
    font-size: 1.4rem;
    line-height: 1;
}

.login-btn:not(:disabled):hover {
    transform: translateY(-2px);
}

.login-btn:active:not(:disabled) {
    transform: translateY(1px);
}

/* Telegram CTA — amethyst gradient (mirrors app .btn-create) */
.telegram-btn {
    background: linear-gradient(160deg, #7c3aed 0%, #4c1d95 50%, #1e1040 100%);
    box-shadow:
        0 8px 24px rgba(124, 58, 237, 0.45),
        0 2px 6px rgba(30, 16, 64, 0.55),
        inset 0 1px 0 rgba(196, 181, 253, 0.28),
        inset 0 -2px 0 rgba(0, 0, 0, 0.35);
    color: #fff;
}

.telegram-btn:hover {
    color: #fff;
    box-shadow:
        0 12px 30px rgba(124, 58, 237, 0.55),
        0 2px 6px rgba(30, 16, 64, 0.55),
        inset 0 1px 0 rgba(196, 181, 253, 0.3);
}

.telegram-btn i {
    color: #fff;
}

/* ── Sign in with Google ────────────────────────────────────────
   Per Google branding guidelines the button must stay light:
   https://developers.google.com/identity/branding-guidelines */
.gsi-signin-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

.gsi-signin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
    width: min(100%, 320px);
    min-height: 42px;
    padding: 0 12px;
    margin: 0;
    border: 1px solid #747775;
    border-radius: 8px;
    background-color: #fff;
    color: #1f1f1f;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: 0.25px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.gsi-signin-btn:hover {
    background-color: #f7f8f8;
    border-color: #747775;
    color: #1f1f1f;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

.gsi-signin-btn:focus {
    outline: none;
}

.gsi-signin-btn:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.gsi-signin-btn:active {
    background-color: #ececec;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3);
}

.gsi-signin-btn--disabled,
.gsi-signin-btn--disabled:hover,
.gsi-signin-btn--disabled:active {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}

.gsi-signin-btn__icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #fff;
}

.gsi-signin-btn__logo {
    display: block;
    width: 20px;
    height: 20px;
}

.gsi-signin-btn__text {
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A subtle "or" divider between Google and Telegram */
.gsi-signin-wrap + .login-actions::before,
.login-divider {
    content: attr(data-label);
}

/* ── Alerts (login errors) ──────────────────────────────────── */
.alert.alert-warning {
    background: rgba(244, 167, 66, 0.12);
    border: 1px solid var(--border-gold);
    color: var(--gold-lite);
    border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════════════════════
   MODALS (Bootstrap) — dark surface
   ═══════════════════════════════════════════════════════════ */
.modal-content {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin: 1rem;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-dialog {
    margin: 0.5rem;
    max-width: min(95vw, 500px);
}

.modal-dialog-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    margin: 0 auto;
}

@media (min-width: 576px) {
    .modal-dialog-centered {
        min-height: calc(100% - 3.5rem);
    }
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: clamp(1rem, 3vw, 1.25rem);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
}

.modal-title i {
    color: var(--gold-lite);
}

.modal-header .btn-close {
    filter: invert(1) grayscale(1) brightness(1.6);
    opacity: 0.7;
    /* Bootstrap's physical margin-left:auto leaves the X next to the title in RTL; use logical margins. */
    margin-inline: auto calc(-0.5 * var(--bs-modal-header-padding-x, 1rem));
}

.modal-body {
    padding: clamp(1rem, 3vw, 1.5rem);
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: clamp(1rem, 3vw, 1.25rem);
}

/* Modal action buttons (Bootstrap .btn-primary / .btn-secondary) */
.modal-footer .btn-primary {
    background: linear-gradient(145deg, var(--purple-lite), var(--purple));
    border: none;
    font-weight: 600;
}

.modal-footer .btn-primary:hover {
    filter: brightness(1.08);
}

.modal-footer .btn-secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

/* Telegram "open" action buttons inside modals */
.telegram-action-btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-outline-primary.telegram-action-btn {
    color: var(--purple-lite);
    border-color: var(--purple-lite);
}

.btn-outline-primary.telegram-action-btn:hover {
    background: var(--purple);
    border-color: var(--purple);
    color: #fff;
}

.btn-outline-secondary.telegram-action-btn {
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-outline-secondary.telegram-action-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* ── Instruction steps ──────────────────────────────────────── */
.instruction-step {
    display: flex;
    align-items: flex-start;
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.instruction-step:hover {
    transform: translateX(4px);
    border-color: var(--purple-lite);
}

.step-number {
    width: clamp(26px, 6vw, 30px);
    height: clamp(26px, 6vw, 30px);
    background: linear-gradient(145deg, var(--purple-lite), var(--purple));
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 1rem;
    flex-shrink: 0;
    font-size: clamp(0.875rem, 3vw, 1rem);
    box-shadow: 0 2px 10px var(--purple-glow);
}

.step-content {
    text-align: left;
    flex: 1;
}

.step-content h6 {
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: 700;
    font-size: clamp(0.875rem, 3vw, 1rem);
}

.step-content p {
    color: var(--text-muted);
    margin-bottom: 0;
    font-size: clamp(0.875rem, 3vw, 1rem);
    line-height: 1.5;
}

.step-content code {
    background: rgba(155, 93, 229, 0.16);
    color: var(--purple-lite);
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
}

/* ── Code input ─────────────────────────────────────────────── */
.code-input-container {
    margin-top: 1rem;
}

.code-input,
.form-control.code-input {
    text-align: center;
    letter-spacing: 0.5rem;
    font-size: clamp(1rem, 4vw, 1.25rem);
    padding: clamp(0.75rem, 2vw, 1rem);
    border-radius: var(--radius-sm);
    margin: 0 auto;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.modal-username .code-input {
    width: min(100%, 200px);
}

.modal-telegram .code-input {
    width: 100%;
    letter-spacing: 0.25rem;
    font-size: 14px;
}

.code-input:focus,
.form-control.code-input:focus {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--purple-lite);
    box-shadow: 0 0 0 3px var(--purple-glow);
    outline: none;
}

.code-input::placeholder {
    color: var(--text-muted);
}

.error-message {
    color: var(--red);
    font-size: clamp(0.75rem, 2.5vw, 0.875rem);
    margin-top: 0.5rem;
    display: none;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ═══════════════════════════════════════════════════════════
   Telegram modal — username / register-via-bot modes
   ═══════════════════════════════════════════════════════════ */
#registrationModal .login-method-toggle {
    margin-bottom: 1.25rem;
}

#registrationModal .tg-mode {
    display: none;
}

#registrationModal.mode-username .tg-mode-username {
    display: block;
}

#registrationModal.mode-register .tg-mode-register {
    display: block;
}

/* The username field is always visible within its (mode-gated) panel */
#registrationModal .username-input-container {
    display: flex;
    margin-bottom: 0;
}

.tg-mode-username .username-input {
    width: 100%;
}

#registrationModal #sendCodeBtn {
    width: 100%;
    margin-top: 0.85rem;
}

.tg-mode-hint {
    display: block;
    color: var(--text-muted);
    font-size: clamp(0.85rem, 3vw, 0.95rem);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.tg-send-status {
    font-size: 0.85rem;
    margin-top: 0.6rem;
    min-height: 1.1em;
    line-height: 1.4;
}

.tg-send-status.success { color: var(--green); }
.tg-send-status.error   { color: var(--red); }
.tg-send-status.loading { color: var(--text-muted); }

.code-entry {
    margin-top: 1.25rem;
}

.tg-code-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
    font-size: clamp(0.85rem, 3vw, 0.95rem);
}

/* ── Telegram inline links ──────────────────────────────────── */
.telegram-link {
    color: var(--purple-lite);
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    font-size: clamp(0.875rem, 3vw, 1rem);
    transition: all 0.3s ease;
    padding: 0.15rem 0.3rem;
    border-radius: 6px;
}

.telegram-link:hover {
    background: rgba(155, 93, 229, 0.16);
    color: var(--purple-lite);
    text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════
   Minimal Telegram window (custom popup shell)
   ═══════════════════════════════════════════════════════════ */
.telegram-window {
    position: fixed;
    inset: auto 1rem 1rem auto;
    width: min(92vw, 360px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    z-index: 1080;
    overflow: hidden;
}

.telegram-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.telegram-window-title {
    display: flex;
    align-items: center;
    font-weight: 700;
    color: var(--text);
}

.telegram-window-title img,
.telegram-action-btn img {
    width: 20px;
    height: 20px;
}

.telegram-window-header .close-btn {
    color: var(--text-muted);
}

.telegram-window-body {
    padding: 1rem;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 576px) {
    .login-container {
        margin: 1rem auto;
        border-radius: var(--radius);
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    /* Telegram modal on phones: one margin (not dialog + content), tighter spacing,
       16px fields (no iOS zoom), full-width footer buttons with Verify as the main action. */
    #registrationModal .modal-dialog {
        margin: 0.75rem;
        max-width: none;
    }

    #registrationModal .modal-content {
        margin: 0;
    }

    #registrationModal .modal-header,
    #registrationModal .modal-body {
        padding: 0.9rem 1rem;
    }

    #registrationModal .modal-title {
        font-size: 1.05rem;
    }

    #registrationModal .login-method-toggle {
        margin-bottom: 0.9rem;
    }

    #registrationModal .username-input,
    #registrationModal .code-input {
        min-height: 3rem;
        font-size: 1rem;
    }

    #registrationModal .code-entry {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
    }

    #registrationModal .code-input-container {
        margin-top: 0.5rem;
    }

    #registrationModal.modal-username .code-input,
    #registrationModal .code-input {
        width: 100%;
    }

    #registrationModal .modal-footer {
        flex-wrap: nowrap;
        gap: 0.6rem;
        padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    }

    #registrationModal .modal-footer .btn {
        flex: 1 1 0;
        min-height: 2.9rem;
        margin: 0;
    }

    #registrationModal .modal-footer .btn-primary {
        flex: 2 1 0;
    }
}

@media (max-width: 768px) {
    .login-btn {
        width: 100%;
    }

    .code-input {
        width: 100%;
    }
}

/* Small phones (iPhone SE / mini, 360px Androids): tighter card and type */
@media (max-width: 380px) {
    .container {
        padding: 0.5rem;
    }

    .login-container {
        margin: 0.5rem auto;
        padding: 1.1rem 0.9rem;
    }

    .login-title {
        font-size: 1.3rem;
    }

    /* The language pill sits top-right; keep the logo below it. */
    .login-header {
        padding-top: 2.25rem;
    }

    .login-social-links {
        gap: 0.25rem 0.75rem;
        margin-bottom: 0.9rem;
    }

    .login-channel-link {
        font-size: 0.74rem;
    }

    .login-benefits li {
        font-size: 0.86rem;
    }
}

/* Tablets and up: a roomier card and wider buttons */
@media (min-width: 768px) {
    .login-container {
        max-width: 480px;
        padding: 2.25rem 2.5rem;
    }

    .login-btn,
    .gsi-signin-btn {
        width: min(100%, 340px);
    }
}

/* Register on wide screens: the reasons on one side, the sign-up on the other */
@media (min-width: 992px) {
    .login-container--register {
        max-width: 900px;
        display: grid;
        grid-template-columns: 1.1fr 1fr;
        column-gap: 2.5rem;
        align-items: center;
        text-align: start;
    }

    .login-container--register .login-header {
        align-items: flex-start;
        margin-bottom: 0;
        padding-inline-end: 2.5rem;
        border-inline-end: 1px solid var(--border);
    }

    .login-container--register .login-social-links {
        justify-content: flex-start;
    }

    .login-container--register .login-subtitle {
        padding: 0;
    }

    .login-container--register .login-benefits {
        margin: 0;
        max-width: none;
    }

    .login-container--register .login-main {
        text-align: center;
    }
}

/* Large desktops: bigger type and buttons */
@media (min-width: 1200px) {
    .login-container {
        max-width: 540px;
        padding: 2.75rem 3rem;
    }

    .login-container--register {
        max-width: 1000px;
    }

    .login-title {
        font-size: 2.1rem;
    }

    .login-subtitle,
    .login-benefits li {
        font-size: 1.05rem;
    }

    .login-btn,
    .gsi-signin-btn {
        width: min(100%, 360px);
        min-height: 48px;
        font-size: 1.05rem;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .login-container {
        margin: 1rem auto;
        padding: 1rem;
    }

    /* Short landscape screens: compact the modal instead of adding an inner scrollbar;
       the page-level .modal scroller handles any overflow. */
    #registrationModal .modal-header,
    #registrationModal .modal-body,
    #registrationModal .modal-footer {
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
    }

    #registrationModal .login-method-toggle,
    #registrationModal .code-entry {
        margin-top: 0;
        margin-bottom: 0.6rem;
    }
}

/* Dark, slim scrollbar for the modal scroller (the default light one clashes with the dark theme) */
.modal {
    scrollbar-width: thin;
    scrollbar-color: var(--purple) transparent;
}
