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

body,
html.theme_dark body.bg_light {
    --text-color: #000;
    --second-text-color: #7d7f81;
    --accent-btn-color: #2481cc;
    --accent-color-hover: #1a8ad5;
    --body-bg: #fff;
    --box-bg: #fff;
    --box-bg-blured: rgba(255, 255, 255, .84);
    --tme-logo-color: #363b40;
    --accent-link-color: #2481cc;
    --proxy-btn-color: #4CAF50;
    --proxy-btn-hover: #43A047
}

html.theme_dark body,
html body.bg_dark {
    --text-color: #fff;
    --accent-btn-color: #1c93e3;
    --accent-color-hover: #1a8ad5;
    --body-bg: #000;
    --box-bg: #1e1e1e;
    --box-bg-blured: rgba(34, 34, 34, .84);
    --tme-logo-color: #fff;
    --accent-link-color: #3ca1eb;
    --proxy-btn-color: #388E3C;
    --proxy-btn-hover: #2E7D32
}

/* Фон на html + прозрачный body: слой z-index:-1 не уходит «под» непрозрачный фон body */
html {
    min-height: 100%;
    background: #fff
}

html.theme_dark {
    background: #000
}

body {
    font-family: Roboto, sans-serif;
    min-height: 100%;
    background: transparent;
    color: var(--text-color);
    -webkit-font-smoothing: antialiased
}

a {
    text-decoration: none
}

.no_transition,
.no_transition * {
    transition: none !important
}

.tgme_background_wrap {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    z-index: 0;
    pointer-events: none
}

.tgme_background {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block
}

/* Светлая тема: градиент на весь экран + паттерн отдельным слоем сверху */
html:not(.theme_dark) .tgme_background {
    opacity: 1
}

.tgme_background_pattern {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    opacity: .4;
    background-image: url(./pattern.svg);
    background-size: 420px auto;
    background-repeat: repeat;
    background-position: 0 0;
    pointer-events: none
}

/*
 * Тёмная тема (как tgsw): фон страницы чёрный (#000 на html),
 * слой с «плиткой» паттерна скрыт — градиент рисуется только на canvas
 * и обрезается маской из того же pattern.svg (цвет только по линиям).
 */
html.theme_dark .tgme_background_pattern {
    display: none
}

/* Маска паттерна делается в wallpaper.js (destination-in), не через CSS */
html.theme_dark .tgme_background {
    opacity: .4
}

.tgme_head_wrap {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 54px;
    padding: 10px 16px;
    box-shadow: 0 2px 4px #0000001a;
    background: var(--box-bg-blured);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    z-index: 10
}

.tgme_head {
    display: flex;
    justify-content: space-between;
    align-items: center
}

.tgme_head_brand,
.tgme_logo {
    display: inline-block;
    vertical-align: top
}

a.tgme_head_right_btn {
    display: inline-block;
    font-size: 14px;
    line-height: 17px;
    font-weight: 700;
    -webkit-font-smoothing: antialiased;
    text-transform: uppercase;
    color: #fff;
    background: var(--accent-btn-color);
    padding: 9px 16px;
    height: 34px;
    border-radius: 17px;
    text-align: center;
    transition: all .15s ease .15s
}

a.tgme_head_right_btn:hover,
a.tgme_head_right_btn:active {
    text-decoration: none;
    color: #fff;
    background: var(--accent-color-hover)
}

.tgme_page_wrap {
    position: relative;
    z-index: 1;
    font-family: Roboto, sans-serif;
    color: var(--text-color)
}

.tgme_body_wrap {
    padding: 70px 16px 40px
}

.tgme_page {
    position: relative;
    margin: 16px auto;
    padding: 32px 0;
    max-width: 400px;
    background: var(--box-bg);
    box-shadow: 0 2px 4px #0000001a;
    border-radius: 16px;
    transition: all .15s ease .15s
}

.tgme_page a {
    color: var(--accent-link-color)
}

.verified-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    padding: 1px;
    text-indent: -10em;
    overflow: hidden;
    background: url(data:image/svg+xml,%3Csvg%20fill%3D%22none%22%20height%3D%2226%22%20viewBox%3D%220%200%2026%2026%22%20width%3D%2226%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22m6%206h12v12h-12z%22%20fill%3D%22%23fff%22%2F%3E%3Cpath%20clip-rule%3D%22evenodd%22%20d%3D%22m14.38%201.51%201.82%201.82c.37.37.86.57%201.38.57h2.57c1.01%200%201.85.77%201.94%201.76l.01.19v2.57c0%20.52.21%201.01.57%201.38l1.82%201.82c.71.71.76%201.84.13%202.61l-.13.15-1.82%201.82c-.37.37-.57.86-.57%201.38v2.57c0%201.01-.77%201.85-1.76%201.94l-.19.01h-2.57c-.52%200-1.01.21-1.38.57l-1.82%201.82c-.71.71-1.84.76-2.61.13l-.15-.13-1.82-1.82c-.37-.37-.86-.57-1.38-.57h-2.57c-1.01%200-1.85-.77-1.94-1.76l-.01-.19v-2.57c0-.52-.21-1.01-.57-1.38l-1.82-1.82c-.71-.71-.76-1.84-.13-2.61l.13-.15%201.82-1.82c.37-.37.57-.86.57-1.38v-2.57c0-1.08.87-1.95%201.95-1.95h2.57c.52%200%201.01-.21%201.38-.57l1.82-1.82c.76-.76%202-.76%202.76%200zm3.2%208.05c-.43-.34-1.03-.31-1.42.06l-.1.11-4.45%205.56-1.75-1.75-.11-.1c-.42-.32-1.03-.29-1.42.1s-.42.99-.1%201.42l.1.11%202.6%202.6.11.1c.42.32%201.02.29%201.4-.08l.1-.11%205.2-6.5.08-.12c.27-.46.17-1.05-.25-1.4z%22%20fill%3D%22%231c93e3%22%20fill-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E) no-repeat 0 0;
    background-size: 100%;
    vertical-align: -4px;

    font-style: normal;
}

.tgme_page_photo {
    text-align: center;
    padding-bottom: 16px
}

.tgme_page_photo_image {
    width: 122px;
    height: 122px;
    border-radius: 61px
}

.tgme_page_title {
    font-size: 26px;
    line-height: 32px;
    font-weight: 700;
    text-align: center;
    max-width: 340px;
    padding: 0 10px;
    margin: 0 auto;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis
}

.tgme_page_extra {
    font-size: 15px;
    line-height: 18px;
    text-align: center;
    padding: 6px 16px 0;
    color: var(--second-text-color)
}

.tgme_page_description {
    font-size: 16px;
    line-height: 25px;
    text-align: center;
    margin: 10px 16px 0;
    padding: 0;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis
}

.tgme_page_action {
    text-align: center;
    margin-top: 24px;
    line-height: 0
}

a.tgme_action_button_new {
    font-size: 14px;
    line-height: 17px;
    font-weight: 700;
    -webkit-font-smoothing: antialiased;
    color: #fff;
    background-color: var(--accent-btn-color);
    border-radius: 22px;
    overflow: hidden;
    display: inline-block;
    padding: 13px 24px;
    height: 42px;
    text-transform: uppercase;
    vertical-align: top
}

a.tgme_action_button_new:hover,
a.tgme_action_button_new:active {
    color: #fff;
    background-color: var(--accent-color-hover);
    text-decoration: none
}

a.tgme_action_button_new.shine {
    background-image: linear-gradient(270deg, #64b5ef00 48.44%, #64b5ef 75.52%, #64b5ef00);
    background-repeat: no-repeat;
    animation: bg-move linear 5s infinite
}

@keyframes bg-move {
    0% {
        background-position: -500px 0
    }

    to {
        background-position: 1000px 0
    }
}

.tgme_proxy_button {
    font-size: 14px;
    line-height: 17px;
    font-weight: 700;
    -webkit-font-smoothing: antialiased;
    color: #fff;
    background-color: var(--proxy-btn-color);
    border-radius: 22px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 24px;
    height: 42px;
    text-transform: uppercase;
    vertical-align: top;
    margin-top: 10px;
    background-image: linear-gradient(270deg, #4caf5000 48.44%, #81c78499 75.52%, #4caf5000);
    background-repeat: no-repeat;
    animation: bg-move linear 5s infinite
}

button.tgme_proxy_button {
    border: none;
    cursor: pointer;
    font-family: Roboto, sans-serif
}

.tgme_proxy_button:hover,
.tgme_proxy_button:active {
    color: #fff;
    background-color: var(--proxy-btn-hover);
    text-decoration: none
}

.tgme_proxy_button_icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    flex-shrink: 0
}

.tgme_page_additional {
    font-size: 14px;
    line-height: 23px;
    text-align: center;
    margin: 32px 16px 0;
    color: gray
}

.tgme_page_additional strong {
    -webkit-font-smoothing: antialiased
}

.tgme_page_icon {
    text-align: center;
    margin-bottom: 20px
}

.tgme_page_context_link_wrap {
    text-align: center;
    margin-top: 18px
}

.tgme_page_context_link {
    font-size: 12px;
    color: var(--second-text-color)
}

.tgme_page_context_link:hover {
    text-decoration: underline
}

.tgme_username_link {
    color: var(--accent-link-color)
}

@media(max-width:768px) {
    .tgme_page_photo_image {
        width: 110px;
        height: 110px;
        border-radius: 55px
    }

    .tgme_page {
        margin-top: 0
    }
}

@keyframes tgme_overlay_in {
    0% {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

@keyframes tgme_overlay_out {
    0% {
        opacity: 1
    }

    to {
        opacity: 0
    }
}

@keyframes tgme_modal_in {
    0% {
        opacity: 0;
        transform: scale(.95)
    }

    to {
        opacity: 1;
        transform: scale(1)
    }
}

@keyframes tgme_modal_out {
    0% {
        opacity: 1;
        transform: scale(1)
    }

    to {
        opacity: 0;
        transform: scale(.95)
    }
}

@keyframes tgme_sheet_in {
    0% {
        transform: translateY(100%)
    }

    to {
        transform: translateY(0)
    }
}

@keyframes tgme_sheet_out {
    0% {
        transform: translateY(0)
    }

    to {
        transform: translateY(100%)
    }
}

.tgme_instruction_overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: #00000080;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    animation: tgme_overlay_in .15s ease-out
}

.tgme_instruction_overlay--closing {
    animation: tgme_overlay_out .12s ease-in forwards
}

.tgme_instruction_modal {
    background: var(--box-bg);
    border-radius: 16px;
    padding: 28px 24px;
    width: 100%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 4px 24px #0003;
    animation: tgme_modal_in .15s ease-out
}

.tgme_instruction_overlay--closing .tgme_instruction_modal {
    animation: tgme_modal_out .12s ease-in forwards
}

.tgme_instruction_handle {
    display: none
}

.tgme_instruction_close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--second-text-color);
    transition: background .15s
}

.tgme_instruction_close:hover {
    background: #80808026
}

.tgme_instruction_close svg {
    width: 18px;
    height: 18px
}

.tgme_instruction_title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-color);
    text-align: center;
    margin: 0 0 8px
}

.tgme_instruction_desc {
    font-size: 14px;
    line-height: 1.5;
    color: var(--second-text-color);
    text-align: center;
    margin: 0 0 24px
}

.tgme_instruction_timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin-bottom: 20px
}

.tgme_instruction_privacy {
    font-size: 11px;
    line-height: 1.45;
    font-weight: 400;
    letter-spacing: .02em;
    text-align: center;
    margin: 0 0 18px;
    color: rgba(255, 255, 255, .38)
}

html:not(.theme_dark) body .tgme_instruction_privacy {
    color: rgba(0, 0, 0, .42)
}

.tgme_instruction_step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    position: relative
}

.tgme_instruction_step:first-child {
    padding-bottom: 20px
}

.tgme_instruction_step_icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative
}

.tgme_instruction_step_icon svg {
    width: 20px;
    height: 20px
}

.tgme_instruction_step:first-child .tgme_instruction_step_icon {
    background: var(--proxy-btn-color)
}

.tgme_instruction_step:first-child:after {
    content: "";
    position: absolute;
    top: 40px;
    left: 20px;
    transform: translate(-50%);
    width: 2px;
    bottom: 0;
    background: var(--second-text-color);
    opacity: .3
}

.tgme_instruction_step:last-child .tgme_instruction_step_icon {
    background: var(--accent-btn-color)
}

.tgme_instruction_step .tgme_instruction_step_icon.tgme_instruction_step_icon--resolve {
    background: var(--accent-btn-color)
}

.tgme_instruction_step .tgme_instruction_step_icon.tgme_instruction_step_icon--proxy {
    background: var(--proxy-btn-color)
}

.tgme_instruction_step_content {
    flex: 1;
    min-width: 0;
    padding-top: 2px
}

.tgme_instruction_step_title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 4px
}

.tgme_instruction_step_subtitle {
    font-size: 13px;
    line-height: 1.45;
    color: var(--second-text-color);
    margin: 0
}

.tgme_instruction_actions {
    display: flex;
    flex-direction: column;
    gap: 10px
}

.tgme_instruction_actions a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 44px;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    color: #fff;
    -webkit-font-smoothing: antialiased
}

.tgme_instruction_actions a:hover {
    text-decoration: none;
    color: #fff
}

.tgme_instruction_action_proxy {
    background-color: var(--proxy-btn-color)
}

.tgme_instruction_action_proxy:hover {
    background-color: var(--proxy-btn-hover)
}

.tgme_instruction_action_resolve {
    background-color: var(--accent-btn-color)
}

.tgme_instruction_action_resolve:hover {
    background-color: var(--accent-color-hover)
}

@media(max-width:768px) {
    .tgme_instruction_overlay {
        align-items: flex-end;
        padding: 0
    }

    .tgme_instruction_modal {
        border-radius: 16px 16px 0 0;
        max-width: none;
        padding-bottom: calc(28px + env(safe-area-inset-bottom));
        animation: tgme_sheet_in .2s ease-out;
        transition: transform .15s ease-out
    }

    .tgme_instruction_overlay--closing .tgme_instruction_modal {
        animation: tgme_sheet_out .15s ease-in forwards
    }

    .tgme_instruction_handle {
        display: block;
        width: 36px;
        height: 4px;
        background: var(--second-text-color);
        opacity: .3;
        border-radius: 2px;
        margin: 0 auto 16px
    }
}

#instructionOverlay[hidden] {
    display: none !important
}