/* ========== Reset & Base ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
}

body {
    width: 100%;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f6f6f6;
    overflow: hidden;
}

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

img {
    display: block;
    max-width: 100%;
}

ul,
li {
    list-style: none;
}

/* ========== App Shell ========== */
#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    background: #f6f6f6;
    position: relative;
    /* iOS 书签封装：顶部避开状态栏 */
    /* padding-top: constant(safe-area-inset-top); */
    padding-top: env(safe-area-inset-top);


}

/* ========== Header ========== */
.app-header {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

/* ========== Content Area ========== */
.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.tab-page {
    display: none;
    min-height: 100%;
    padding: 12px;
    animation: fadeIn 0.25s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ========== Bottom Tab Bar ========== */
.tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 56px;
    background: #fff;
    border-top: 1px solid #e8e8e8;
    flex-shrink: 0;
    z-index: 100;
    /* iOS 全屏模式：白色背景延伸覆盖 Home Indicator 区域 */
    box-sizing: content-box;
    padding-bottom: env(safe-area-inset-bottom);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    cursor: pointer;
    transition: none;
    color: #999;
    position: relative;
}

/* ✅ 激活字体不变 */
.tab-item.active {
    color: #999;
}
.tab-item .tab-icon {
    width: 26px;
    height: 26px;
    margin-bottom: 1px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-item.active .tab-icon::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 50%;
    top: 76%;
    transform: translate(-50%, -50%);
    background: var(--tab-active-bg) center / contain no-repeat;
    z-index: 0;
}

/* 图标在遮罩上面 */
.tab-icon-svg {
    display: inline-block !important;
    width: 24px !important;
    height: 24px !important;
    position: relative;
    z-index: 1;
    background-color: transparent !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    -webkit-mask: none !important;
    mask: none !important;
}

/* 文字 */
.tab-item .tab-label {
    font-size: 10px;
    line-height: 1;
    color: #999;
}
.tab-item[data-tab="audio"] .tab-label{
    display:inline-block;
    width:36px;
    height:14px;
    font-size:0;
    line-height:0;
    background:var(--tab-audio-label) center / contain no-repeat;
}
/* ========== Section Styles ========== */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    padding: 12px 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title .more {
    font-size: 12px;
    color: #999;
    font-weight: 400;
}

/* ========== Card Grid ========== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.card-grid.col-2 {
    grid-template-columns: repeat(2, 1fr);
}

.card-item {
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.card-item .card-cover {
    width: 100%;
    aspect-ratio: 3/4;
    background: #eee;
    position: relative;
    overflow: hidden;
}

.card-item .card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-item .card-cover .tag {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(102, 126, 234, 0.85);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
}

.card-item .card-title {
    padding: 6px;
    font-size: 12px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Video Card (horizontal) ========== */
.video-card {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.video-card .video-cover {
    width: 140px;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    background: #eee;
    flex-shrink: 0;
    position: relative;
}

.video-card .video-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-card .video-cover .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-card .video-cover .play-icon::after {
    content: '';
    border-style: solid;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #fff;
    margin-left: 2px;
}

.video-card .video-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.video-card .video-info .title {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    /* -webkit-line-clamp: 2; */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-card .video-info .meta {
    font-size: 11px;
    color: #999;
}

/* ========== Swiper / Banner ========== */
.banner-wrap {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/7;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

/* ========== Douyin (Short Video) Feed ========== */
.douyin-feed {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.douyin-item {
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    background: #000;
    aspect-ratio: 9/14;
}

.douyin-item .douyin-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.douyin-item .douyin-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 8px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
}

.douyin-item .douyin-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.douyin-item .douyin-play::after {
    content: '';
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent #fff;
    margin-left: 3px;
}

/* ========== User / Profile Page ========== */
.user-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 4px;
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-name {
    font-size: 18px;
    font-weight: 600;
}

.user-desc {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.menu-list {
    margin-top: 10px;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 4px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #333;
}

.menu-item .menu-icon {
    margin-right: 10px;
    color: #667eea;
}

.menu-item .menu-left {
    display: flex;
    align-items: center;
}

.menu-item .arrow {
    color: #ccc;
    font-size: 14px;
}

/* ========== Audio Comic ========== */
.audio-list .audio-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.audio-item .audio-cover {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
    flex-shrink: 0;
}

.audio-item .audio-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.audio-item .audio-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.audio-item .audio-info .title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-item .audio-info .desc {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.audio-item .audio-info .episodes {
    font-size: 11px;
    color: #667eea;
    margin-top: 6px;
}

/* ========== Placeholder ========== */
.placeholder-cover {
    background: linear-gradient(135deg, #e0e0e0, #c0c0c0);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 12px;
}

/* ========== Image Loading Placeholder ========== */
.gg-loading {
    position: relative;
    background: #f3f3f3;
}

/* 不要隐藏 img，否则 loading.png 也会被隐藏 */
.gg-loading img {
    visibility: visible !important;
}

/* 不再用转圈，直接显示 loading.png */
.gg-loading::after {
    display: none !important;
}

/* 普通图片兜底状态 */
img.img-loading-fallback,
img.img-load-error {
    background: #f3f3f3;
    object-fit: cover;
}
@keyframes ggSpin {
    to { transform: rotate(360deg); }
}

/* ========== Scrollbar ========== */
.app-content::-webkit-scrollbar {
    width: 0;
    display: none;
}

/* ========== Loading Mask ========== */
.td-loading-mask {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.td-loading-mask.show {
    display: flex;
}

.td-loading-box {
    background: rgba(0, 0, 0, 0.75);
    border-radius: 12px;
    padding: 20px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.td-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tdSpin 0.7s linear infinite;
}

@keyframes tdSpin {
    to {
        transform: rotate(360deg);
    }
}

.td-loading-text {
    color: #fff;
    font-size: 13px;
}

/* ========== Alert Dialog ========== */
.td-alert-mask {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10001;
    justify-content: center;
    align-items: center;
}

.td-alert-mask.show {
    display: flex;
}

.td-alert-box {
    width: 280px;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    text-align: center;
}

.td-alert-body {
    padding: 24px 20px 16px;
    font-size: 15px;
    color: #333;
    line-height: 1.5;
    word-break: break-word;
}

.td-alert-btns {
    display: flex;
    border-top: 1px solid #e8e8e8;
}

.td-alert-btns .td-alert-btn {
    flex: 1;
    padding: 12px 0;
    font-size: 16px;
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.td-alert-btns .td-alert-btn:active {
    background: #f5f5f5;
}

.td-alert-btns .td-alert-btn.cancel {
    color: #999;
    border-right: 1px solid #e8e8e8;
}

.td-alert-btns .td-alert-btn.confirm {
    color: #667eea;
    font-weight: 600;
}

/* ========== Toast ========== */
.td-toast {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 80%;
    text-align: center;
    pointer-events: none;
}

.td-toast.show {
    opacity: 1;
}

/* ========== 跨文档导航过渡（App 级流程页滑动）==========
   渐进增强：仅支持 View Transitions 的内核生效（Chrome/Android WebView 126+、
   Safari 18+），不支持的内核自动降级为原来的瞬间跳转，不影响任何现有逻辑。
   作用对象：goPage/goBack 触发的整页(同源)跳转；底部 tab 的 SPA 切换不受影响。 */
@view-transition {
    navigation: auto;
}

/* 新页面：从右滑入（前进“入栈”手感）*/
::view-transition-new(root) {
    animation: vt-page-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* 旧页面：轻微左移 + 淡出 */
::view-transition-old(root) {
    animation: vt-page-out 0.24s ease both;
}

@keyframes vt-page-in {
    from { transform: translateX(100%); opacity: 0.65; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes vt-page-out {
    from { transform: translateX(0);     opacity: 1; }
    to   { transform: translateX(-16%);  opacity: 0; }
}

/* 尊重系统“减弱动态效果”设置：关闭滑动，仅做快速淡入 */
@media (prefers-reduced-motion: reduce) {
    ::view-transition-new(root),
    ::view-transition-old(root) {
        animation: vt-fade 0.12s ease both;
    }
    @keyframes vt-fade {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
}