* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6c5ce7;
    --primary-dark: #5a4bd1;
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --success: #00d2d3;
    --danger: #ff6b6b;
    --warning: #feca57;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

/* ========== 启动画面 ========== */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

.logo-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
}

.logo-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    border-right-color: var(--success);
    animation: spin 1.5s linear infinite;
}

.logo-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(108, 92, 231, 0.5);
}

.app-name {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.loading-bar {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 3px;
    animation: loadProgress 2s ease-in-out forwards;
}

/* ========== 主容器 ========== */
#app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
    position: relative;
}

#app-container.visible {
    opacity: 1;
}

/* ========== 顶部状态栏 ========== */
#status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    padding-top: calc(8px + var(--safe-top));
    background: var(--bg-card);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 44px;
    flex-shrink: 0;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-center {
    flex: 1;
    text-align: center;
}

.app-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(0, 210, 211, 0.5);
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(255, 107, 107, 0.5);
}

.status-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.status-btn:active {
    transform: scale(0.9);
}

/* ========== iframe主体 ========== */
#main-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: #fff;
}

/* ========== 错误页面 ========== */
#error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#error-overlay.hidden {
    display: none;
}

.error-content {
    text-align: center;
    padding: 32px;
}

.error-content h2 {
    margin: 20px 0 8px;
    font-size: 20px;
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.retry-btn {
    padding: 12px 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.6);
}

.retry-btn:active {
    transform: translateY(0);
}

/* ========== 底部导航 ========== */
#bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 6px 0;
    padding-bottom: calc(6px + var(--safe-bottom));
    background: var(--bg-card);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item:active {
    transform: scale(0.92);
}

/* ========== 动画 ========== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loadProgress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* ========== 全屏模式 ========== */
body.fullscreen #status-bar,
body.fullscreen #bottom-nav {
    display: none;
}

body.fullscreen #main-frame {
    height: 100vh;
}

/* ========== 响应式 ========== */
@media (min-width: 768px) {
    #bottom-nav {
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }
}
