* {
    box-sizing: border-box;
}

:root {
    --app-height: 100dvh;
    --visual-safe-top: 0px;
    --visual-safe-right: 0px;
    --visual-safe-bottom: 0px;
    --visual-safe-left: 0px;
    --safe-top-offset: max(env(safe-area-inset-top, 0px), var(--visual-safe-top));
    --safe-right-offset: max(env(safe-area-inset-right, 0px), var(--visual-safe-right));
    --safe-bottom-offset: max(env(safe-area-inset-bottom, 0px), var(--visual-safe-bottom));
    --safe-left-offset: max(env(safe-area-inset-left, 0px), var(--visual-safe-left));
    --font-family-base: "Microsoft YaHei", sans-serif;
    --color-text-primary: #fff;
    --color-text-secondary: rgba(255, 255, 255, 0.68);
    --color-text-tertiary: rgba(255, 255, 255, 0.5);
    --color-text-quaternary: rgba(255, 255, 255, 0.45);
    --accent-primary: #4caf50;
    --accent-primary-strong: rgba(76, 175, 80, 0.6);
    --accent-primary-soft: rgba(76, 175, 80, 0.2);
    --accent-warning: #ffb300;
    --accent-danger: #ff6b6b;
    --app-shell-background:
        radial-gradient(circle at top, rgba(52, 72, 108, 0.45), transparent 40%),
        linear-gradient(180deg, #0b1020 0%, #090b12 100%);
    --panel-surface: rgba(14, 18, 28, 0.9);
    --panel-border: 1px solid rgba(255, 255, 255, 0.1);
    --panel-shadow: 0 22px 50px rgba(0, 0, 0, 0.35);
    --panel-muted-text: rgba(255, 255, 255, 0.65);
    --back-button-surface: rgba(10, 14, 24, 0.8);
    --back-button-border: rgba(255, 255, 255, 0.12);
    --back-button-hover-surface: rgba(122, 162, 255, 0.16);
    --back-button-hover-border: rgba(122, 162, 255, 0.35);
    --feature-surface: rgba(20, 20, 20, 0.95);
    --feature-border: 1px solid rgba(255, 255, 255, 0.1);
    --feature-shadow: 0 22px 50px rgba(0, 0, 0, 0.35);
    --close-button-surface: rgba(255, 255, 255, 0.05);
    --close-button-border: rgba(255, 255, 255, 0.1);
    --close-button-color: #888;
    --close-button-hover-surface: rgba(255, 77, 79, 0.2);
    --close-button-hover-border: rgba(255, 77, 79, 0.3);
    --close-button-hover-color: #ff4d4f;
    color-scheme: dark;
}

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

#root,
#app-shell,
#page-chat {
    width: 100%;
    min-height: 100%;
    background: var(--viewport-background, var(--app-shell-background));
    background-color: #090b12;
}

html {
    background: var(--viewport-background, var(--app-shell-background));
    background-color: #090b12;
    min-height: 100dvh;
}

body {
    font-family: var(--font-family-base);
    color: var(--color-text-primary);
    background: var(--viewport-background, var(--app-shell-background));
    position: relative;
    height: max(var(--app-height), 100dvh);
    min-height: max(var(--app-height), 100dvh);
    width: 100%;
}

#app-shell {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    overflow: hidden;
    background: var(--viewport-background, var(--app-shell-background));
    height: max(var(--app-height), 100dvh);
    min-height: 100dvh;
}

#main-pages {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.main-page {
    position: absolute;
    inset: 0;
    display: none;
}

.main-page.active {
    display: block;
}

.panel-page.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.panel-card {
    width: min(560px, 100%);
    border-radius: 28px;
    border: var(--panel-border);
    background: var(--panel-surface);
    box-shadow: var(--panel-shadow);
    padding: 32px 28px;
    text-align: center;
}

.panel-card h2 {
    margin: 8px 0 10px;
    font-size: 28px;
}

.panel-card p {
    margin: 0;
    color: var(--panel-muted-text);
    line-height: 1.7;
}

.subpage-back-btn {
    appearance: none;
    border: 1px solid var(--back-button-border);
    background: var(--back-button-surface);
    color: var(--color-text-primary);
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.22s ease;
}

.subpage-back-btn:hover {
    background: var(--back-button-hover-surface);
    border-color: var(--back-button-hover-border);
}

.chat-back-btn {
    position: absolute;
    top: 48px;
    left: 16px;
    z-index: 1200;
}

.inline-back-btn {
    align-self: flex-start;
    margin-bottom: 18px;
}

.feature-panel {
    width: min(960px, 100%);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-modal-content {
    width: min(920px, 100%);
    max-width: 920px;
    height: min(100%, 780px);
    box-shadow: var(--feature-shadow);
}

.modal-content {
    background: var(--feature-surface);
    width: 90%;
    max-width: 500px;
    height: 70vh;
    border: var(--feature-border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.close-btn {
    background: var(--close-button-surface);
    border: 1px solid var(--close-button-border);
    color: var(--close-button-color);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    padding-bottom: 2px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: var(--close-button-hover-surface);
    color: var(--close-button-hover-color);
    border-color: var(--close-button-hover-border);
    transform: rotate(90deg);
}

.hidden {
    display: none !important;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7);
    }
    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(244, 67, 54, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0);
    }
}

@keyframes status-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@media (max-width: 700px) {
    body {
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    .panel-page.active {
        padding: 16px;
    }

    .panel-card {
        padding: 24px 20px;
        border-radius: 22px;
    }

    .feature-panel {
        width: 100%;
    }

    .feature-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 22px;
    }

    .chat-back-btn {
        top: 42px;
        left: 12px;
        padding: 9px 12px;
    }
}
