:root {
    --bg-main: #030816;
    --bg-soft: #071024;
    --bg-card: rgba(15, 23, 42, 0.62);

    --border-soft: rgba(148, 163, 184, 0.16);
    --border-blue: rgba(96, 165, 250, 0.24);

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --text-soft: #CBD5E1;

    --blue: #2563EB;
    --blue-light: #60A5FA;
    --violet: #5B21B6;
    --violet-light: #8B5CF6;

    --danger: #EF4444;

    --layout-max-width: 1120px;
    --layout-gutter: 24px;
}

body {
    font-family: 'EB Garamond', sans-serif;
    margin: 0;
    min-height: 100vh;
    background:
            radial-gradient(circle at 70% 20%, rgba(124, 58, 237, 0.18), transparent 32%),
            radial-gradient(circle at 25% 10%, rgba(37, 99, 235, 0.16), transparent 28%),
            linear-gradient(180deg, #030816 0%, #050A18 45%, #020617 100%);
    color: var(--text-main);
}

.layout-container {
    width: min(calc(100% - (var(--layout-gutter) * 2)), var(--layout-max-width));
    margin: 0 auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    min-height: 42px;
    padding: 0 14px;

    border-radius: 5px;
    font-size: 17px;
    font-weight: 400;
    line-height: 1;

    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;

    transition:
            transform 180ms ease,
            box-shadow 180ms ease,
            border-color 180ms ease,
            background 180ms ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.app-modal .btn:disabled {
    cursor: wait;
    opacity: 0.68;
    transform: none;
}

.btn-primary {
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
    background: linear-gradient(135deg, var(--blue), var(--violet));
    box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.12) inset,
            0 18px 42px rgba(37, 99, 235, 0.28),
            0 0 32px rgba(91, 33, 182, 0.24);
}

.btn-primary:hover {
    box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.18) inset,
            0 22px 52px rgba(37, 99, 235, 0.36),
            0 0 42px rgba(91, 33, 182, 0.34);
}

.btn-secondary {
    color: var(--text-soft);
    background: rgba(15, 23, 42, 0.46);
    border-color: var(--border-soft);
    backdrop-filter: blur(18px);
}

.btn-secondary:hover {
    color: white;
    border-color: var(--border-blue);
    background: rgba(15, 23, 42, 0.72);
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(10px);
}

.app-modal.hidden {
    display: none;
}

#errorModal {
    z-index: 80;
}

body #error-modal-container {
    position: relative;
    z-index: 90;
}

.app-modal-dialog {
    width: min(100%, 440px);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 6px;
    background: rgba(7, 16, 36, 0.96);
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
}

.app-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 20px 0;
}

.app-modal-title {
    margin: 0;
    color: #f8f5ee;
    font-size: 22px;
    line-height: 1;
    font-weight: 400;
}

.app-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.48);
    color: rgba(203, 213, 225, 0.82);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.app-modal-close:hover {
    border-color: rgba(96, 165, 250, 0.24);
    background: rgba(15, 23, 42, 0.72);
    color: #f8f5ee;
}

.app-modal-close:focus-visible {
    outline: none;
    border-color: rgba(96, 165, 250, 0.42);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.24);
}

.app-modal-close span {
    font-size: 22px;
    line-height: 1;
}

.app-modal-body {
    display: grid;
    gap: 18px;
    padding: 20px;
}

.app-modal-stack {
    display: grid;
    gap: 8px;
}

.app-modal-copy {
    margin: 0;
    color: #f8f5ee;
    font-family: 'Roboto Flex', sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

.app-modal-copy.is-muted {
    color: rgba(203, 213, 225, 0.68);
}

.app-modal-field {
    display: grid;
    gap: 8px;
}

.app-modal-field-label {
    color: rgba(203, 213, 225, 0.82);
    font-family: 'Roboto Flex', sans-serif;
    font-size: 14px;
    line-height: 1;
}

.app-modal-field-input {
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 5px;
    background: rgba(7, 16, 36, 0.72);
    color: #f8f5ee;
    font-family: 'Roboto Flex', sans-serif;
    font-size: 15px;
}

.app-modal-field-input:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.42);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.24);
}

.app-modal-field-input::placeholder {
    color: rgba(148, 163, 184, 0.72);
}

.captcha-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.captcha-image {
    display: block;
    max-width: calc(100% - 54px);
    height: auto;
    border-radius: 5px;
}

.captcha-refresh-button {
    display: inline-flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.48);
    color: rgba(203, 213, 225, 0.82);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.captcha-refresh-button:hover {
    border-color: rgba(96, 165, 250, 0.24);
    background: rgba(15, 23, 42, 0.72);
    color: #f8f5ee;
}

.captcha-refresh-button:focus-visible {
    outline: none;
    border-color: rgba(96, 165, 250, 0.42);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.24);
}

.captcha-refresh-button:disabled {
    cursor: wait;
    opacity: 0.5;
}

.captcha-refresh-button span {
    font-size: 26px;
    line-height: 1;
}

.app-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.app-modal-actions .btn {
    min-width: 120px;
}

.app-modal-submit {
    width: 100%;
}

.app-modal-primary-actions {
    display: grid;
    gap: 10px;
}

.app-modal-text-action {
    justify-self: center;
    padding: 0;
    border: 0;
    border-bottom: 1px solid transparent;
    background: none;
    color: rgba(148, 163, 184, 0.82);
    font-family: 'Roboto Flex', sans-serif;
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.app-modal-text-action:hover {
    border-bottom-color: rgba(203, 213, 225, 0.42);
    color: rgba(203, 213, 225, 0.96);
}

.app-modal-text-action:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.42);
    outline-offset: 4px;
    border-radius: 2px;
}

.app-modal-text-action:disabled {
    cursor: default;
    opacity: 0.5;
}

.app-modal-text-action-muted {
    color: rgba(148, 163, 184, 0.68);
}

.app-modal-code-input {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.28em;
}

.app-modal-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 5px;
    background: rgba(22, 101, 52, 0.12);
    color: rgba(220, 252, 231, 0.9);
    font-family: 'Roboto Flex', sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

.app-modal-notice.hidden {
    display: none;
}

.app-modal-notice p {
    margin: 0;
}

.app-modal-notice-icon {
    color: #86efac;
    font-weight: 700;
}

.app-modal-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.app-modal-tab {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.48);
    color: rgba(203, 213, 225, 0.72);
    font-family: 'Roboto Flex', sans-serif;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.app-modal-tab:hover {
    color: #f8f5ee;
    border-color: rgba(96, 165, 250, 0.24);
    background: rgba(15, 23, 42, 0.72);
}

.app-modal-tab.is-active {
    color: #f8f5ee;
    border-color: rgba(255, 255, 255, 0.5);
    background: linear-gradient(135deg, var(--blue), var(--violet));
    box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.12) inset,
            0 18px 42px rgba(37, 99, 235, 0.28),
            0 0 32px rgba(91, 33, 182, 0.24);
}

.app-modal-form {
    display: grid;
    gap: 18px;
}

.app-modal-message {
    margin: 0;
    color: #f8f5ee;
    font-family: 'Roboto Flex', sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

.app-modal .hidden {
    display: none;
}

@media (max-width: 640px) {
    :root {
        --layout-gutter: 12px;
    }

    .app-modal {
        padding: 12px;
    }

    .app-modal-head,
    .app-modal-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .app-modal-actions {
        flex-direction: column-reverse;
    }

    .app-modal-actions .btn {
        width: 100%;
    }
}

.app-modal-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(148, 163, 184, 0.66);
    font-family: 'Roboto Flex', sans-serif;
    font-size: 13px;
}

.app-modal-divider::before,
.app-modal-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(148, 163, 184, 0.16);
}

.app-modal-telegram img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.app-modal-legal {
    margin: -4px 0 0;
    color: rgba(148, 163, 184, 0.72);
    font-family: 'Roboto Flex', sans-serif;
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.app-modal-legal a {
    color: rgba(203, 213, 225, 0.9);
    text-decoration: underline;
    text-decoration-color: rgba(148, 163, 184, 0.42);
    text-underline-offset: 2px;
}

.app-modal-legal a:hover {
    color: #f8f5ee;
    text-decoration-color: rgba(203, 213, 225, 0.8);
}
