:root {
    color-scheme: dark;
    --bg: #0d0f17;
    --surface: #1d1f2d;
    --surface-raised: #242636;
    --field: #141621;
    --border: #373a4b;
    --border-strong: #595d74;
    --text: #eef0f6;
    --muted: #9a9eae;
    --dim: #666a7a;
    --purple: #aa80ff;
    --purple-hover: #bd9cff;
    --blue: #7ea7ff;
    --rose: #f08b91;
    --gold: #f4bd4f;
    --green: #73d6a2;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
    font: inherit;
    letter-spacing: 0;
}

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

.login-page {
    display: grid;
    place-items: center;
    padding: 32px 20px;
}

.login-shell {
    width: min(100%, 440px);
}

.login-panel {
    position: relative;
    overflow: hidden;
    padding: 42px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.login-panel::before {
    position: absolute;
    inset: 0 0 auto;
    height: 2px;
    background: linear-gradient(90deg, var(--blue), var(--purple), var(--rose), var(--gold));
    content: "";
}

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    margin-bottom: 24px;
    place-items: center;
    color: #161821;
    background: var(--purple);
    border-radius: 8px;
}

.brand-mark svg {
    width: 21px;
    height: 21px;
}

.gradient-title {
    display: inline-block;
    margin: 0;
    color: transparent;
    background: linear-gradient(94deg, var(--blue) 0%, var(--purple) 38%, var(--rose) 72%, var(--gold) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    font-weight: 600;
    letter-spacing: 0;
}

.login-panel h1 {
    font-size: 30px;
    line-height: 1.2;
}

.login-kicker {
    margin: 8px 0 30px;
    color: var(--muted);
    font-size: 14px;
}

.login-form {
    display: grid;
    gap: 20px;
}

.register-shell {
    width: min(100%, 480px);
}

.register-shell .login-panel {
    padding-top: 36px;
    padding-bottom: 36px;
}

.register-shell .brand-mark {
    margin-bottom: 18px;
}

.register-shell .login-kicker {
    margin-bottom: 24px;
}

.register-shell .login-form {
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.input-wrap {
    position: relative;
    display: block;
}

.input-wrap > svg {
    position: absolute;
    top: 50%;
    left: 15px;
    width: 18px;
    height: 18px;
    color: var(--dim);
    pointer-events: none;
    transform: translateY(-50%);
}

.input-wrap input {
    width: 100%;
    height: 50px;
    padding: 0 16px 0 45px;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-wrap input::placeholder,
textarea::placeholder {
    color: var(--dim);
}

.input-wrap input:focus,
textarea:focus {
    background: #171925;
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(170, 128, 255, 0.12);
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 18px;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
}

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

.button:focus-visible,
.icon-button:focus-visible,
.support-link:focus-visible {
    outline: 2px solid var(--purple);
    outline-offset: 3px;
}

.button-primary {
    color: #151720;
    background: var(--purple);
}

.button-primary:hover {
    background: var(--purple-hover);
}

.button-secondary {
    background: rgba(255, 255, 255, 0.015);
    border-color: var(--border);
}

.button-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-strong);
}

.button-block {
    width: 100%;
    margin-top: 6px;
}

.auth-switch {
    margin-top: 12px;
}

.verify-slider {
    --verify-progress: 48px;
    position: relative;
    height: 48px;
    overflow: hidden;
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: 8px;
    user-select: none;
}

.verify-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--verify-progress);
    background: rgba(170, 128, 255, 0.14);
    transition: background 160ms ease;
}

.verify-text {
    position: absolute;
    inset: 0 52px;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

.verify-handle {
    position: absolute;
    top: 3px;
    left: 3px;
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    color: var(--text);
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    cursor: grab;
    touch-action: none;
    transition: background 160ms ease, border-color 160ms ease;
    will-change: transform;
}

.verify-handle:active {
    cursor: grabbing;
}

.verify-handle svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.verify-slider.is-loading .verify-handle,
.verify-slider.is-verified .verify-handle {
    color: #151720;
    background: var(--green);
    border-color: var(--green);
}

.verify-slider.is-loading .verify-handle svg {
    animation: spin 0.9s linear infinite;
}

.verify-slider.is-verified .verify-fill {
    background: rgba(115, 214, 162, 0.18);
}

.verify-slider.is-verified .verify-text {
    color: var(--green);
}

.verify-slider.is-error {
    border-color: rgba(240, 139, 145, 0.5);
}

.verify-slider.is-disabled {
    opacity: 0.55;
}

.button:disabled {
    color: var(--dim);
    background: #272936;
    border-color: transparent;
    cursor: wait;
    transform: none;
}

.button.is-loading svg {
    animation: spin 0.9s linear infinite;
}

.support-link {
    display: flex;
    width: fit-content;
    align-items: center;
    gap: 7px;
    margin: 30px auto 0;
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
}

.support-link:hover {
    color: var(--blue);
}

.support-link svg {
    width: 16px;
    height: 16px;
}

.app-shell {
    width: min(100% - 40px, 960px);
    margin: 0 auto;
    padding: 56px 0 34px;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.app-header h1 {
    font-size: 34px;
    line-height: 1.2;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--dim);
    font-family: Consolas, monospace;
    font-size: 11px;
    font-weight: 700;
}

.account-cluster {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.account-name,
.points {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    gap: 8px;
    padding: 0 13px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}

.account-name svg,
.points svg {
    width: 16px;
    height: 16px;
}

.points {
    color: #d1bbff;
    background: rgba(170, 128, 255, 0.08);
    border-color: rgba(170, 128, 255, 0.2);
}

.workbench {
    position: relative;
    padding: 30px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.section-heading,
.section-heading > div,
.modal-header {
    display: flex;
    align-items: center;
}

.section-heading {
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.section-heading > div {
    gap: 12px;
}

.section-icon {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    place-items: center;
    color: var(--purple-hover);
    background: rgba(170, 128, 255, 0.1);
    border: 1px solid rgba(170, 128, 255, 0.16);
    border-radius: 8px;
}

.section-icon svg {
    width: 18px;
    height: 18px;
}

.section-heading h2,
.modal-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 650;
    line-height: 1.25;
}

.section-heading p {
    margin: 3px 0 0;
    color: var(--dim);
    font-size: 12px;
}

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.status-dot > span {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(115, 214, 162, 0.09);
}

.status-dot.is-offline > span {
    background: var(--rose);
    box-shadow: 0 0 0 4px rgba(240, 139, 145, 0.09);
}

textarea {
    display: block;
    width: 100%;
    min-height: 230px;
    padding: 19px;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    resize: vertical;
    line-height: 1.65;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    padding-right: 50px;
}

.logout-form {
    position: absolute;
    right: 30px;
    bottom: 30px;
    margin: 0;
}

.icon-button {
    display: inline-grid;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-strong);
}

.icon-button.danger {
    color: var(--rose);
    border-color: rgba(240, 139, 145, 0.25);
}

.icon-button.danger:hover {
    background: rgba(240, 139, 145, 0.08);
    border-color: var(--rose);
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid;
    border-radius: 8px;
    line-height: 1.45;
}

.login-panel .notice {
    margin: 0 0 20px;
}

.notice svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin-top: 1px;
}

.notice-error {
    color: #f5a5aa;
    background: rgba(240, 139, 145, 0.07);
    border-color: rgba(240, 139, 145, 0.22);
}

.notice-success {
    color: #91e4b8;
    background: rgba(115, 214, 162, 0.07);
    border-color: rgba(115, 214, 162, 0.2);
}

.history-section {
    margin-top: 28px;
    padding: 28px 30px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.history-heading-row {
    margin-bottom: 14px;
}

.history-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.history-list li {
    display: grid;
    grid-template-columns: minmax(130px, 180px) 1fr;
    gap: 18px;
    padding: 15px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    line-height: 1.55;
}

.history-list time {
    color: var(--dim);
    font-family: Consolas, monospace;
    font-size: 12px;
}

.history-list span {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--muted);
}

.empty-state {
    display: grid;
    min-height: 150px;
    place-items: center;
    align-content: center;
    gap: 12px;
    color: var(--dim);
}

.empty-state svg {
    width: 30px;
    height: 30px;
}

.empty-state strong {
    font-size: 13px;
    font-weight: 500;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 28px;
    color: var(--dim);
    font-family: Consolas, monospace;
    font-size: 11px;
}

.app-footer a {
    color: var(--blue);
    text-decoration: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    padding: 20px;
    place-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 180ms ease, visibility 180ms ease;
}

.modal.is-open {
    visibility: visible;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 7, 11, 0.76);
    backdrop-filter: blur(10px);
}

.modal-box {
    position: relative;
    width: min(100%, 430px);
    padding: 26px;
    background: var(--surface-raised);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow: var(--shadow);
    transform: translateY(8px);
    transition: transform 180ms ease;
}

.modal.is-open .modal-box {
    transform: translateY(0);
}

.modal-header {
    gap: 12px;
    margin-bottom: 24px;
}

.modal-header h2 {
    flex: 1;
}

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

.modal-open {
    overflow: hidden;
}

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

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

@media (max-width: 700px) {
    .app-shell {
        width: min(100% - 24px, 960px);
        padding-top: 28px;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-header h1 {
        font-size: 29px;
    }

    .account-cluster {
        width: 100%;
        justify-content: flex-start;
    }

    .workbench {
        padding: 22px;
    }

    .action-bar {
        display: grid;
        grid-template-columns: 1fr;
        padding: 0;
    }

    .button {
        width: 100%;
    }

    .logout-form {
        position: static;
        margin-top: 10px;
    }

    .logout-form .icon-button {
        width: 100%;
    }

    .history-section {
        padding: 24px 8px;
    }

    .history-list li {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

@media (max-width: 460px) {
    .login-page {
        align-items: start;
        padding: 14px;
    }

    .login-panel {
        padding: 28px 22px;
    }

    .account-cluster {
        flex-direction: column;
        align-items: stretch;
    }

    .account-name,
    .points {
        justify-content: center;
    }

    .section-heading {
        align-items: flex-start;
    }

    .status-dot {
        padding-top: 10px;
    }

    textarea {
        min-height: 210px;
    }

    .modal-box {
        padding: 22px;
    }
}

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