:root {
    --bar: #29394f;
    --bar-deep: #213148;
    --paper: #f2f4f6;
    --white: #fff;
    --muted: #9eacbd;
    --gold: #e5c98f;
    --sans: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

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

body {
    overflow: hidden;
    background: var(--paper);
    font-family: var(--sans);
}

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

.preview-header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    min-height: 60px;
    padding: 0 24px;
    color: var(--white);
    background: var(--bar);
}

.preview-back {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
}

.preview-back > span:first-child {
    width: 8px;
    height: 8px;
    border-bottom: 1px solid currentColor;
    border-left: 1px solid currentColor;
    transform: rotate(45deg);
}

.preview-back:hover {
    color: var(--gold);
}

.preview-category {
    display: inline-flex;
    align-items: center;
    height: 25px;
    max-width: 140px;
    margin-left: 18px;
    padding: 0 10px;
    overflow: hidden;
    color: var(--gold);
    background: rgba(229, 201, 143, 0.08);
    border: 1px solid rgba(229, 201, 143, 0.28);
    border-radius: 5px;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-switcher {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: 16px;
}

.device-switcher button {
    display: grid;
    width: 27px;
    height: 30px;
    padding: 0;
    color: rgba(255, 255, 255, 0.48);
    background: transparent;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    place-items: center;
}

.device-switcher button:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
}

.device-switcher button.is-active {
    color: var(--gold);
}

.device-switcher svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.25;
}

.preview-stage {
    display: flex;
    justify-content: center;
    width: 100%;
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    overflow: hidden;
    background: #e9edf1;
}

.preview-device {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--white);
    transition: width 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.preview-frame-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    background: var(--white);
}

.preview-frame {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--white);
    border: 0;
}

.preview-loader {
    position: absolute;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #8490a3;
    background: #f8f9fa;
    inset: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.preview-loader span {
    width: 27px;
    height: 27px;
    border: 2px solid #dbe0e8;
    border-top-color: var(--bar);
    border-radius: 50%;
    animation: preview-spin 0.8s linear infinite;
}

.preview-loader small {
    font-size: 10px;
    letter-spacing: 0.08em;
}

.preview-loader.is-hidden {
    visibility: hidden;
    opacity: 0;
}

.preview-stage[data-device="tablet"] .preview-device {
    width: min(820px, 100%);
    box-shadow: 0 0 0 1px rgba(31, 46, 68, 0.08), 0 16px 45px rgba(31, 46, 68, 0.1);
}

.preview-stage[data-device="mobile"] .preview-device {
    width: min(390px, 100%);
    box-shadow: 0 0 0 1px rgba(31, 46, 68, 0.08), 0 16px 45px rgba(31, 46, 68, 0.1);
}

.preview-stage[data-device="tablet"],
.preview-stage[data-device="mobile"] {
    background: #dfe4e9;
}

.preview-error {
    display: grid;
    min-height: calc(100vh - 60px);
    min-height: calc(100dvh - 60px);
    padding: 30px;
    color: var(--bar-deep);
    text-align: center;
    background: var(--paper);
    place-content: center;
}

.preview-error span {
    color: #7c899b;
    font-size: 9px;
    letter-spacing: 0.2em;
}

.preview-error h1 {
    margin: 18px 0 28px;
    font-family: Georgia, "Songti SC", serif;
    font-size: clamp(28px, 5vw, 54px);
    font-weight: 500;
}

.preview-error a {
    justify-self: center;
    padding: 11px 18px;
    color: var(--white);
    background: var(--bar);
    border-radius: 4px;
    font-size: 12px;
}

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

@media (max-width: 760px) {
    .preview-header {
        min-height: 56px;
        padding: 0 14px;
    }

    .preview-back {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .preview-category {
        flex: 0 1 auto;
        max-width: 92px;
        margin-left: 8px;
        padding: 0 7px;
        font-size: 10px;
    }

    .device-switcher {
        flex: 0 0 auto;
        margin-left: 12px;
    }

    .device-switcher button {
        width: 25px;
    }

    .preview-stage {
        height: calc(100vh - 56px);
        height: calc(100dvh - 56px);
    }

    .preview-device {
        width: 100%;
        box-shadow: none;
    }
}
