:root {
    color-scheme: dark;
    --system-page: #0b1020;
    --system-surface: #121a33;
    --system-surface-raised: #1e293b;
    --system-border: #334155;
    --system-text: #e2e8f0;
    --system-muted: #94a3b8;
    --system-accent: #3b82f6;
    --system-accent-hover: #2563eb;
    --system-success: #22c55e;
    --system-danger: #ef4444;
    --system-shadow: 0 18px 48px rgba(2, 6, 23, 0.38);
}

html[data-theme="light"] {
    color-scheme: light;
    --system-page: #f3f5f8;
    --system-surface: #ffffff;
    --system-surface-raised: #f8fafc;
    --system-border: #dbe1e8;
    --system-text: #1f2937;
    --system-muted: #64748b;
    --system-accent: #2563eb;
    --system-accent-hover: #1d4ed8;
    --system-success: #16a34a;
    --system-danger: #dc2626;
    --system-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

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

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

body.system-page {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background-color: var(--system-page);
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.035) 1px, transparent 1px);
    background-size: 28px 28px;
    color: var(--system-text);
    font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0;
}

html[data-theme="light"] body.system-page {
    background-color: var(--system-page) !important;
    background-image:
        linear-gradient(rgba(37, 99, 235, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 99, 235, 0.03) 1px, transparent 1px) !important;
    color: var(--system-text) !important;
}

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

a {
    color: inherit;
    text-decoration: none;
}

.system-header {
    height: 56px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--system-border);
    background: color-mix(in srgb, var(--system-surface) 92%, transparent);
    box-shadow: 0 1px 10px rgba(2, 6, 23, 0.08);
}

.system-header-inner {
    width: min(1120px, calc(100% - 32px));
    height: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.system-header-login {
    min-height: 36px;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--system-accent);
    border-radius: 8px;
    background: var(--system-accent);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.system-header-login:hover {
    border-color: var(--system-accent-hover);
    background: var(--system-accent-hover);
    transform: translateY(-1px);
}

.system-header-login:focus-visible {
    outline: 2px solid var(--system-accent);
    outline-offset: 2px;
}

.system-brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.system-brand img {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    object-fit: contain;
}

.system-brand strong {
    overflow: hidden;
    color: var(--system-text);
    font-size: 17px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.system-brand span {
    color: var(--system-muted);
    font-size: 13px;
    white-space: nowrap;
}

.system-main {
    width: min(1120px, calc(100% - 32px));
    min-height: calc(100vh - 56px);
    min-height: calc(100dvh - 56px);
    margin: 0 auto;
    padding: 32px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.system-panel {
    width: min(720px, 100%);
    border: 1px solid var(--system-border);
    border-radius: 8px;
    background: var(--system-surface);
    box-shadow: var(--system-shadow);
}

.system-panel-wide {
    width: min(860px, 100%);
}

.system-panel-body {
    padding: 40px;
}

.system-eyebrow {
    margin: 0 0 8px;
    color: var(--system-accent);
    font-size: 13px;
    font-weight: 700;
}

.system-title {
    margin: 0;
    color: var(--system-text);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.25;
}

.system-description {
    margin: 12px 0 0;
    color: var(--system-muted);
    font-size: 15px;
    line-height: 1.75;
}

.system-actions {
    margin-top: 28px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.system-actions-centered {
    justify-content: center;
}

.system-button {
    min-width: 112px;
    min-height: 42px;
    padding: 9px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--system-border);
    border-radius: 8px;
    background: var(--system-surface-raised);
    color: var(--system-text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.system-button:hover {
    border-color: var(--system-accent);
    transform: translateY(-1px);
}

.system-button:focus-visible,
.system-input:focus-visible {
    outline: 2px solid var(--system-accent);
    outline-offset: 2px;
}

.system-button-primary {
    border-color: var(--system-accent);
    background: var(--system-accent);
    color: #ffffff;
}

.system-button-primary:hover {
    border-color: var(--system-accent-hover);
    background: var(--system-accent-hover);
}

.system-modal-open {
    overflow: hidden;
}

.login-modal[hidden] {
    display: none;
}

.login-modal {
    position: fixed;
    z-index: 20;
    /* Chromium 86 ignores the inset shorthand. Keep the dialog in the viewport. */
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-modal-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border: 0;
    padding: 0;
    background: rgba(15, 23, 42, 0.64);
    cursor: pointer;
}

.login-modal-panel {
    position: relative;
    z-index: 1;
    width: min(860px, 100%);
    height: min(700px, calc(100vh - 48px));
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--system-border);
    border-radius: 16px;
    background: var(--system-surface);
    box-shadow: 0 28px 80px rgba(2, 6, 23, 0.42);
}

.login-modal-brand {
    min-width: 0;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #2563eb 0%, #4f8df5 100%);
    color: #ffffff;
    text-align: center;
}

.login-modal-brand img {
    width: 58px;
    height: 58px;
    margin-bottom: 18px;
    object-fit: contain;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
}

.login-modal-brand-kicker {
    margin: 0 0 18px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.28em;
}

.login-modal-brand strong {
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(25px, 3vw, 42px);
    font-weight: 800;
    letter-spacing: 0.12em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.login-modal-brand span {
    margin-top: 8px;
    font-size: clamp(16px, 2vw, 24px);
    letter-spacing: 0.28em;
}

.login-modal-brand p:last-child {
    margin: 26px 0 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
}

.login-modal-content {
    position: relative;
    min-width: 0;
    min-height: 0;
    background: var(--system-surface);
}

.login-modal-close {
    position: absolute;
    z-index: 2;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--system-border);
    border-radius: 8px;
    background: transparent;
    color: var(--system-muted);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.login-modal-close:hover,
.login-modal-close:focus-visible {
    border-color: #60a5fa;
    background: rgba(96, 165, 250, 0.14);
    color: var(--system-accent);
}

.login-modal-close:focus-visible,
.login-modal-backdrop:focus-visible {
    outline: 2px solid var(--system-accent);
    outline-offset: 2px;
}

.login-modal-panel iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
    background: var(--system-surface);
}

.system-button-muted {
    color: var(--system-muted);
}

.welcome-layout {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.welcome-mark,
.result-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--system-accent);
}

.welcome-mark {
    width: 72px;
    height: 72px;
    font-size: 30px;
}

.result-layout {
    text-align: center;
}

.result-mark {
    width: 72px;
    height: 72px;
    margin: 0 auto 22px;
    font-size: 32px;
}

.result-mark-success {
    border-color: color-mix(in srgb, var(--system-success) 40%, transparent);
    background: color-mix(in srgb, var(--system-success) 13%, transparent);
    color: var(--system-success);
}

.result-mark-danger {
    border-color: color-mix(in srgb, var(--system-danger) 40%, transparent);
    background: color-mix(in srgb, var(--system-danger) 13%, transparent);
    color: var(--system-danger);
}

.result-message {
    max-width: 560px;
    margin: 12px auto 0;
    color: var(--system-muted);
    line-height: 1.75;
    overflow-wrap: anywhere;
}

.result-countdown {
    min-height: 42px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    color: var(--system-muted);
    font-size: 13px;
}

.result-countdown b {
    min-width: 2ch;
    color: var(--system-text);
    font-size: 14px;
}

.not-found-layout {
    display: grid;
    grid-template-columns: minmax(220px, 330px) minmax(0, 1fr);
    align-items: center;
    gap: 36px;
}

.not-found-visual {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
}

.install-panel-header {
    padding: 28px 32px 22px;
    border-bottom: 1px solid var(--system-border);
}

.install-steps {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.install-step {
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--system-muted);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.install-step::before,
.install-step::after {
    content: "";
    position: absolute;
    top: 15px;
    width: 50%;
    height: 1px;
    background: var(--system-border);
}

.install-step::before {
    left: 0;
}

.install-step::after {
    right: 0;
}

.install-step:first-child::before,
.install-step:last-child::after {
    display: none;
}

.install-step-number {
    position: relative;
    z-index: 1;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--system-border);
    border-radius: 50%;
    background: var(--system-surface);
    color: var(--system-muted);
}

.install-step.is-active,
.install-step.is-complete {
    color: var(--system-text);
}

.install-step.is-active .install-step-number,
.install-step.is-complete .install-step-number {
    border-color: var(--system-accent);
    background: var(--system-accent);
    color: #ffffff;
}

.install-step.is-complete::before,
.install-step.is-complete::after,
.install-step.is-active::before {
    background: var(--system-accent);
}

.install-panel-body {
    padding: 30px 32px 32px;
}

.install-stage {
    display: none;
}

.install-stage.is-active {
    display: block;
}

.install-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.install-field {
    min-width: 0;
}

.install-field-wide {
    grid-column: 1 / -1;
}

.install-label {
    margin-bottom: 7px;
    display: block;
    color: var(--system-text);
    font-size: 13px;
    font-weight: 700;
}

.system-input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--system-border);
    border-radius: 8px;
    background: var(--system-surface-raised);
    color: var(--system-text);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.system-input:focus {
    border-color: var(--system-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.system-input::placeholder {
    color: var(--system-muted);
}

.install-actions {
    margin-top: 26px;
    padding-top: 22px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--system-border);
}

.install-summary {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
    border-top: 1px solid var(--system-border);
}

.install-summary-row {
    min-width: 0;
    padding: 13px 0;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 12px;
    border-bottom: 1px solid var(--system-border);
}

.install-summary dt {
    color: var(--system-muted);
}

.install-summary dd {
    min-width: 0;
    margin: 0;
    color: var(--system-text);
    font-weight: 700;
    overflow-wrap: anywhere;
}

@media (max-width: 720px) {
    .login-modal-panel {
        grid-template-columns: 1fr;
    }

    .login-modal-brand {
        display: none;
    }

    .system-header-inner,
    .system-main {
        width: min(100% - 24px, 1120px);
    }

    .system-brand span {
        display: none;
    }

    .system-main {
        padding: 20px 0;
        align-items: flex-start;
    }

    .system-panel-body,
    .install-panel-body {
        padding: 26px 20px;
    }

    .install-panel-header {
        padding: 24px 20px 20px;
    }

    .system-title {
        font-size: 23px;
    }

    .welcome-layout,
    .not-found-layout {
        grid-template-columns: 1fr;
        gap: 22px;
        text-align: center;
    }

    .welcome-mark {
        margin: 0 auto;
    }

    .not-found-visual {
        max-height: 210px;
    }

    .system-actions {
        justify-content: center;
    }

    .install-grid,
    .install-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .system-actions,
    .install-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .system-button,
    .result-countdown {
        width: 100%;
    }

    .system-header-login {
        padding-right: 11px;
        padding-left: 11px;
    }

    .login-modal {
        padding: 10px;
    }

    .login-modal-panel {
        height: calc(100vh - 20px);
        border-radius: 12px;
        grid-template-columns: 1fr;
    }

    .login-modal-brand {
        display: none;
    }

    .install-step {
        font-size: 12px;
    }

    .install-summary-row {
        grid-template-columns: 82px minmax(0, 1fr);
    }
}

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