:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-primary-subtle: #eff6ff;
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-border: #e5e7eb;
    --color-border-focus: #2563eb;
    --color-background: #f8fafc;
    --color-card: #ffffff;
    --color-success: #047857;
    --color-success-bg: #ecfdf5;
    --color-warning: #92400e;
    --color-warning-bg: #fffbeb;
    --color-error: #b91c1c;
    --color-error-bg: #fef2f2;
    --font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.2);
    --radius-md: 12px;
    --radius-lg: 16px;
    --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-background);
    background-image:
        radial-gradient(ellipse at top, var(--color-primary-subtle) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(37, 99, 235, 0.05) 0%, transparent 40%);
    -webkit-font-smoothing: antialiased;
}

.page-wrapper {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1.5rem;
    animation: fadeIn 0.5s var(--ease-out);
}

.card {
    width: 100%;
    max-width: 420px;
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem 1.5rem;
    animation: slideUp 0.6s var(--ease-out);
}


.language-picker {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.language-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    min-height: 48px;
    padding: 0.5rem;
    background: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.language-option:hover {
    background: var(--color-primary-subtle);
}

.language-option[aria-pressed="true"] {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.language-option:focus-visible {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-focus);
}

.language-flag {
    display: block;
    width: 30px;
    height: 22px;
}

.icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 1.5rem;
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
}

.icon {
    width: 28px;
    height: 28px;
    color: var(--color-primary);
}

.text {
    text-align: center;
    font-size: clamp(1rem, 4.5vw, 1.25rem);
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 1.75rem;
}

.input-wrapper {
    margin-bottom: 1.25rem;
}

.input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.phone-input-row {
    display: flex;
    gap: 0.5rem;
}

.country-trigger,
#phone {
    height: 56px;
    font-family: var(--font-family);
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.country-trigger {
    width: 116px;
    flex: 0 0 116px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0 0.625rem;
    cursor: pointer;
}

.country-trigger-region {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
}

.country-trigger-code {
    font-size: 1.0625rem;
    font-weight: 600;
}

.country-trigger:disabled {
    cursor: wait;
    opacity: 0.7;
}

#phone {
    min-width: 0;
    flex: 1 1 auto;
    padding: 0 0.875rem;
    letter-spacing: 0.04em;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
}

#phone::placeholder {
    color: var(--color-text-muted);
    font-weight: 400;
}

.country-trigger:focus-visible,
#phone:focus {
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-focus);
}

.input-hint,
.input-error {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    line-height: 1.4;
}

.input-hint {
    color: var(--color-text-secondary);
}

.input-error {
    color: var(--color-error);
    font-weight: 500;
}

.button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    height: 56px;
    padding: 0 1.5rem;
    font-family: var(--font-family);
    font-size: 1.0625rem;
    font-weight: 600;
    color: white;
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s var(--ease-out), transform 0.15s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.button:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.button:focus-visible {
    box-shadow: var(--shadow-focus);
}

.button:active:not(:disabled) {
    transform: scale(0.98);
}

.button:disabled {
    cursor: wait;
    opacity: 0.75;
}

.button-icon {
    width: 20px;
    height: 20px;
}

.button-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.button.is-loading .button-icon {
    display: none;
}

.button.is-loading .button-spinner {
    display: inline-block;
}

.status-message {
    margin-top: 1rem;
    padding: 0.75rem 0.875rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}

.status-message.success {
    color: var(--color-success);
    background: var(--color-success-bg);
}

.status-message.warning {
    color: var(--color-warning);
    background: var(--color-warning-bg);
}

.status-message.error {
    color: var(--color-error);
    background: var(--color-error-bg);
}


.country-dialog {
    width: 100%;
    max-width: 480px;
    max-height: min(82dvh, 720px);
    margin: auto 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
}

.country-dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
}

.country-sheet {
    display: flex;
    flex-direction: column;
    max-height: min(82dvh, 720px);
    background: var(--color-card);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 32px rgba(15, 23, 42, 0.18);
    overflow: hidden;
    animation: countrySheetIn 0.25s var(--ease-out);
}

.country-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem 0.75rem;
}

.country-sheet-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.country-close {
    min-width: 48px;
    min-height: 48px;
    padding: 0 0.5rem;
    font: inherit;
    font-weight: 600;
    color: var(--color-primary);
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.country-close:focus-visible,
.country-search:focus,
.country-option:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.country-search-wrapper {
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.country-search {
    width: 100%;
    height: 52px;
    padding: 0 1rem;
    font: inherit;
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-background);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    appearance: none;
}

.country-search::placeholder {
    color: var(--color-text-secondary);
}

.country-results {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
}

.country-section {
    padding-top: 1rem;
}

.country-section[hidden] {
    display: none;
}

.country-section-title {
    margin-bottom: 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.country-popular {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.country-list {
    border-top: 1px solid var(--color-border);
}

.country-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    min-height: 52px;
    padding: 0.75rem 0.875rem;
    font: inherit;
    font-size: 1rem;
    text-align: left;
    color: var(--color-text);
    background: var(--color-card);
    border: 0;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    cursor: pointer;
}

.country-popular .country-option {
    min-height: 56px;
    gap: 0.5rem;
    padding: 0.625rem;
    font-size: 0.95rem;
    background: var(--color-primary-subtle);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
}

.country-option:active,
.country-option[aria-current="true"] {
    background: var(--color-primary-light);
}

.country-option-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.country-option-code {
    flex: 0 0 auto;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.country-empty {
    padding: 2rem 0;
    text-align: center;
    color: var(--color-text-secondary);
}

@keyframes countrySheetIn {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 600px) {
    .country-dialog {
        margin: auto;
    }

    .country-sheet {
        border-radius: 20px;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 360px) {
    .content { padding: 1rem; }
    .card { padding: 1.5rem 1rem; }
    .country-trigger { width: 104px; flex-basis: 104px; padding: 0 0.4rem; }
    #phone { padding: 0 0.5rem; font-size: 1rem; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .content { padding: 1rem; }
    .card { padding: 1.25rem; }
    .icon-wrapper { width: 44px; height: 44px; margin-bottom: 1rem; }
    .icon { width: 22px; height: 22px; }
    .text { font-size: 0.9375rem; margin-bottom: 1rem; }
    .input-wrapper { margin-bottom: 0.75rem; }
    .country-trigger, #phone, .button { height: 48px; }
}

@media (min-width: 400px) {
    .card { padding: 2.5rem 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
