:root {
    color-scheme: light;
    --color-primary: #5b35f5;
    --color-primary-dark: #4320d9;
    --color-primary-soft: #f0edff;
    --color-secondary: #825ffb;
    --color-success: #16a963;
    --color-danger: #e5484d;
    --color-warning: #f59e0b;
    --color-text: #101638;
    --color-muted: #687295;
    --color-subtle: #929ab5;
    --color-border: #dfe3ef;
    --color-surface: #ffffff;
    --color-surface-soft: #f7f7fc;
    --color-page: #f3f2fb;
    --gradient-primary: linear-gradient(105deg, #4820ee 0%, #6d35ff 58%, #5423ec 100%);
    --shadow-sm: 0 3px 12px rgba(37, 28, 85, 0.06);
    --shadow-md: 0 16px 44px rgba(43, 34, 97, 0.11);
    --shadow-primary: 0 12px 25px rgba(91, 53, 245, 0.22);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: 180ms ease;
    --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --color-primary: #8265ff;
    --color-primary-dark: #9b85ff;
    --color-primary-soft: #292248;
    --color-text: #f3f1ff;
    --color-muted: #a9aec6;
    --color-subtle: #858ba5;
    --color-border: #343950;
    --color-surface: #191c2c;
    --color-surface-soft: #222538;
    --color-page: #11131f;
    --shadow-sm: 0 3px 12px rgba(0, 0, 0, 0.18);
    --shadow-md: 0 16px 44px rgba(0, 0, 0, 0.28);
}

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

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--color-page);
    color: var(--color-text);
    font-family: var(--font-sans);
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
    color: inherit;
    font: inherit;
}

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

button {
    border: 0;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition), opacity var(--transition);
}

a:hover {
    color: var(--color-primary-dark);
}

:focus-visible {
    outline: 3px solid rgba(91, 53, 245, 0.24);
    outline-offset: 2px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    color: var(--color-text);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.brand:hover {
    color: var(--color-text);
}

.brand-mark {
    display: inline-grid;
    width: 52px;
    height: 52px;
    place-items: center;
    border-radius: 12px;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-primary);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
}

.button {
    position: relative;
    display: inline-flex;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 24px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: var(--color-surface-soft);
    cursor: pointer;
    font-weight: 700;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition), border-color var(--transition);
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:active:not(:disabled) {
    transform: translateY(0);
}

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

.button-primary {
    background: var(--gradient-primary);
    box-shadow: 0 8px 20px rgba(82, 39, 239, 0.19);
    color: #fff;
}

.button-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-primary);
}

.button-block {
    width: 100%;
}

.button-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.38);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

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

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

.toast-region {
    position: fixed;
    z-index: 1000;
    right: 24px;
    bottom: 24px;
    display: grid;
    width: min(390px, calc(100vw - 32px));
    gap: 12px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px 17px;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    color: var(--color-text);
    font-size: 0.92rem;
    pointer-events: auto;
    animation: toast-in 220ms ease both;
}

.toast::before {
    content: "✓";
    display: grid;
    flex: 0 0 22px;
    height: 22px;
    place-items: center;
    border-radius: 50%;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 0.75rem;
    font-weight: 900;
}

.toast.is-error {
    border-left-color: var(--color-danger);
}

.toast.is-error::before {
    content: "!";
    background: rgba(229, 72, 77, 0.12);
    color: var(--color-danger);
}

.toast.is-leaving {
    animation: toast-out 180ms ease both;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(8px); }
}

.protected-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 32px;
    background:
        radial-gradient(circle at 10% 10%, rgba(128, 98, 255, 0.13), transparent 34%),
        var(--color-page);
}

.protected-card {
    width: min(680px, 100%);
    padding: clamp(28px, 6vw, 64px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.protected-card .brand {
    margin-bottom: 36px;
}

.protected-card h1 {
    margin: 0 0 12px;
    font-size: clamp(1.75rem, 5vw, 2.6rem);
    letter-spacing: -0.04em;
}

.protected-card p {
    margin: 0 auto 28px;
    color: var(--color-muted);
}

.protected-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}
