/* ======================================
   全局移动端适配基础样式
   ====================================== */

/* === 浮动返回按钮（替代页头） === */
.page-back-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border: none;
    border-radius: 20px;
    background: rgba(10, 5, 2, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #f0d68a;
    font-size: 0.82rem;
    font-family: 'Noto Serif SC', 'PingFang SC', serif;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

@supports (padding: env(safe-area-inset-top)) {
    .page-back-btn {
        top: calc(12px + env(safe-area-inset-top));
    }
}

.page-back-btn:active {
    background: rgba(212, 168, 83, 0.2);
}

/* === 触控优化 === */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* 防止 iOS 双击缩放 */
button, a, input, select, textarea {
    touch-action: manipulation;
}

/* === 安全区域适配（刘海屏/药丸屏） === */
@supports (padding: env(safe-area-inset-top)) {
    body.has-header .site-header {
        padding-top: env(safe-area-inset-top);
    }

    body.has-header {
        padding-top: calc(48px + env(safe-area-inset-top));
    }

    #controls {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* === 滚动优化 === */
body, .script-preview, .records-list {
    -webkit-overflow-scrolling: touch;
}

/* === 移动端全局样式覆盖 (≤ 480px) === */
@media (max-width: 480px) {

    /* 按钮/链接最小点击区域 44px */
    button, .btn-gold, .btn-secondary, .btn-primary, .btn-outline,
    .header-btn, .record-btn, a.btn-gold, a.btn-secondary {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 输入框增大触控区 */
    input[type="text"], input[type="tel"], input[type="password"],
    textarea, select {
        font-size: 16px !important; /* 防止 iOS 自动缩放 */
        min-height: 44px;
    }

    /* 弹窗移动端适配 */
    .modal-content {
        width: 94% !important;
        max-width: none !important;
        padding: 24px 18px !important;
        border-radius: 14px !important;
        max-height: 85vh;
        overflow-y: auto;
    }

    .modal-content h2 {
        font-size: 1.5rem;
    }

    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }

    .modal-actions button,
    .modal-actions .btn-gold,
    .modal-actions .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    /* Toast 在移动端更宽 */
    #toast-container {
        width: 90% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

/* === 极小屏幕 (≤ 360px) === */
@media (max-width: 360px) {
    html {
        font-size: 14px;
    }
}

/* ======================================
   全局底部 Tab 栏
   ====================================== */

:root {
    --tab-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 所有页面给底部留出 Tab 栏空间 */
body {
    padding-bottom: calc(var(--tab-height) + var(--safe-bottom));
}

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tab-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: rgba(10, 5, 2, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(212, 168, 83, 0.12);
    z-index: 100;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: var(--tab-height);
    background: none;
    border: none;
    cursor: pointer;
    color: #a89080;
    font-family: inherit;
    font-size: 0.65rem;
    transition: color 0.2s;
    touch-action: manipulation;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn.active {
    color: #d4a853;
}

.tab-btn .tab-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.tab-btn .tab-label {
    line-height: 1;
    letter-spacing: 0.05em;
}

/* 中间创建按钮 — 突出样式 */
.tab-btn-create .tab-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #d4a853, #a07830);
    border-radius: 12px;
    font-size: 1.3rem;
    color: #1a0f0a;
    margin-top: -14px;
    box-shadow: 0 4px 16px rgba(212, 168, 83, 0.3);
}

/* ======================================
   Tab 栏内嵌列表视图（播放页用）
   ====================================== */

.tab-list-overlay {
    position: fixed;
    inset: 0;
    bottom: calc(var(--tab-height) + var(--safe-bottom));
    background: #0a0505;
    z-index: 90;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: tabListSlideUp 0.25s ease-out;
}

.tab-list-overlay.visible {
    display: flex;
}

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

.tab-list-header {
    padding: 16px 16px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(212, 168, 83, 0.1);
    flex-shrink: 0;
}

.tab-list-title {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.3rem;
    color: #d4a853;
}

.tab-list-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tab-list-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(30, 20, 15, 0.7);
    border: 1px solid rgba(212, 168, 83, 0.1);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.tab-list-card:active {
    background: rgba(212, 168, 83, 0.12);
    border-color: rgba(212, 168, 83, 0.3);
}

.tab-list-cover {
    width: 80px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    background: #1a120e;
    flex-shrink: 0;
}

.tab-list-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.tab-list-name {
    font-size: 0.95rem;
    color: #f0d68a;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-list-desc {
    font-size: 0.78rem;
    color: #a89080;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.tab-list-empty,
.tab-list-loading {
    text-align: center;
    padding: 40px 20px;
    color: #a89080;
    font-size: 0.9rem;
}
