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

:root {
    color-scheme: light;
    --color-bg-page: #fafafa;
    --color-surface: #ffffff;
    --color-surface-hover: #f5f5f5;
    --color-text: #202020;
    --color-text-secondary: #666666;
    --color-text-tertiary: #686868;
    --color-border: #e7e7e7;
    --color-border-hover: #d8d8d8;
    --color-action-primary: #1f1f1f;
    --color-action-primary-hover: #333333;
    --color-focus: #2767d8;
    --color-brand: #6657f5;
    --color-success: #237a46;
    --color-success-soft: rgba(35, 122, 70, 0.1);
    --color-error: #c93636;
    --color-error-soft: rgba(201, 54, 54, 0.08);
    /* Compatibility aliases used by the existing legal pages. */
    --accent-400: #7b70f7;
    --accent-500: var(--color-brand);
    --accent-600: #5948e8;
    --accent-glow: rgba(102, 87, 245, 0.14);
    --bg-card: var(--color-surface);
    --border: var(--color-border);
    --border-hover: var(--color-border-hover);
    --glass-bg: var(--color-surface);
    --glass-border: var(--color-border);
    --label: var(--color-text);
    --label-secondary: var(--color-text-secondary);
    --label-tertiary: var(--color-text-tertiary);
    --radius-xl: var(--radius-control);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.05), 0 12px 36px rgba(0, 0, 0, 0.08);
    --shadow-control: 0 1px 1px rgba(0, 0, 0, 0.025), 0 1px 2px rgba(0, 0, 0, 0.025);
    --radius-card: 14px;
    --radius-control: 10px;
}

html, body {
    min-height: 100%;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--color-bg-page);
    color: var(--color-text);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, select {
    font: inherit;
}

button, a, input, select {
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

.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;
}

.page-tools {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 10;
}

.language-switcher {
    position: relative;
}

.language-button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--color-text-secondary);
    background: transparent;
    cursor: pointer;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.language-button:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
    border-color: var(--color-border);
}

.language-chevron {
    color: var(--color-text-tertiary);
}

.language-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 150px;
    padding: 5px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

.language-menu button {
    width: 100%;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 9px;
    border: 0;
    border-radius: 7px;
    color: var(--color-text);
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.language-menu button:hover {
    background: var(--color-surface-hover);
}

.language-check {
    color: var(--color-brand);
    visibility: hidden;
}

.language-menu button[aria-checked="true"] .language-check {
    visibility: visible;
}

.container {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 72px 24px 40px;
}

.card {
    width: 100%;
    max-width: 420px;
    padding: 36px 32px 28px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

/* Legacy legal pages share this stylesheet; keep their glass class structural
   and opaque so dense legal text remains readable. */
.glass {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 28px;
    text-align: center;
}

.app-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 14px;
    border-radius: 11px;
    box-shadow: var(--shadow-control);
}

.logo-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    border: 1px solid var(--color-border);
    border-radius: 11px;
    color: var(--color-text);
    background: var(--color-surface-active);
}

h1 {
    margin: 0;
    color: var(--color-text);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.25;
}

.subtitle {
    margin: 7px 0 0;
    color: var(--color-text-secondary);
    font-size: 13px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    margin-bottom: 24px;
    padding: 3px;
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
}

.auth-tab {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--color-text-secondary);
    background: transparent;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.auth-tab:hover:not(.active) {
    color: var(--color-text);
}

.auth-tab.active {
    color: var(--color-text);
    background: var(--color-surface);
    border-color: rgba(0, 0, 0, 0.045);
    box-shadow: var(--shadow-control);
}

.form-area {
    margin: 0;
}

.field-group {
    margin-bottom: 16px;
}

.field-group > label {
    display: block;
    margin-bottom: 7px;
    color: var(--color-text);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
}

input, select {
    height: 44px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    color: var(--color-text);
    background: var(--color-surface);
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input {
    width: 100%;
    padding: 10px 13px;
}

input::placeholder {
    color: #929292;
}

input:hover, select:hover {
    border-color: var(--color-border-hover);
}

input:focus, select:focus {
    border-color: var(--color-focus);
    box-shadow: 0 0 0 3px rgba(39, 103, 216, 0.14);
}

.phone-row, .code-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.country-control {
    position: relative;
    flex: 0 0 88px;
}

.country-select {
    width: 100%;
    padding: 10px 29px 10px 12px;
    appearance: none;
    cursor: pointer;
}

.select-chevron {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.password-control {
    position: relative;
}

.password-control input {
    padding-right: 44px;
}

.toggle-password {
    position: absolute;
    top: 50%;
    right: 7px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    padding: 0;
    border: 0;
    border-radius: 7px;
    color: var(--color-text-tertiary);
    background: transparent;
    cursor: pointer;
}

.toggle-password:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

.button {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

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

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-primary {
    color: #ffffff;
    background: var(--color-action-primary);
}

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

.button-secondary {
    color: var(--color-text);
    background: var(--color-surface);
    border-color: var(--color-border);
}

.button-secondary:hover:not(:disabled) {
    background: var(--color-surface-hover);
    border-color: var(--color-border-hover);
}

.send-code-button {
    flex: 0 0 auto;
    width: auto;
    min-width: 104px;
    white-space: nowrap;
    font-size: 13px;
}

.error-message {
    margin: -2px 0 14px;
    padding: 9px 11px;
    color: var(--color-error);
    background: var(--color-error-soft);
    border: 1px solid rgba(201, 54, 54, 0.16);
    border-radius: 8px;
    font-size: 13px;
    text-align: left;
}

.inline-error {
    margin: 7px 0 0;
}

.password-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 7px;
}

.hint-item {
    color: var(--color-text-tertiary);
    font-size: 12px;
}

.hint-item::before {
    display: inline-block;
    width: 14px;
}

.hint-fail::before {
    content: "○";
}

.hint-pass {
    color: var(--color-success);
}

.hint-pass::before {
    content: "✓";
}

.legal-copy {
    margin: 18px 0 0;
    color: var(--color-text-tertiary);
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
}

.legal-copy a {
    color: var(--color-text-secondary);
    text-decoration: underline;
    text-decoration-color: #c7c7c7;
    text-underline-offset: 2px;
}

.legal-copy a:hover {
    color: var(--color-text);
}

.success-card {
    padding-top: 40px;
    text-align: center;
}

.success-mark {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    border-radius: 50%;
    color: var(--color-success);
    background: var(--color-success-soft);
}

.success-copy {
    margin: 10px auto 0;
    max-width: 320px;
    color: var(--color-text-secondary);
}

.success-card > .button {
    margin-top: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    padding: 13px;
    background: var(--color-bg-page);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    text-align: left;
}

.avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 50%;
    object-fit: cover;
}

.user-detail {
    min-width: 0;
}

.user-detail h2 {
    margin: 0;
    overflow: hidden;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-name {
    margin: 2px 0 0;
    overflow: hidden;
    color: var(--color-text-secondary);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

button:focus-visible, a:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

@media (max-width: 520px) {
    .page-tools {
        position: absolute;
        top: 12px;
        right: 14px;
    }

    .container {
        align-items: flex-start;
        padding: 64px 0 0;
    }

    .card {
        max-width: none;
        min-height: calc(100svh - 64px);
        padding: 28px 22px 24px;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 14px 14px 0 0;
        box-shadow: none;
    }

    .logo-area {
        margin-bottom: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
