/* ========== 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: #E3E3E5;
    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: #E3E3E5;
    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: color 0.2s;
    color: #999;
    position: relative;
}

.tab-item.active {
    color: #667eea;
}

.tab-item .tab-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

.tab-icon-svg {
    display: block;
    width: 24px;
    height: 24px;
    background-color: currentColor;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.tab-item .tab-label {
    font-size: 10px;
    line-height: 1;
}

/* ========== 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: #e8e8e8;
}

/* 加载中隐藏 img，避免显示损坏图标 */
.gg-loading img {
    visibility: hidden;
}

.gg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid #d0d0d0;
    border-top-color: #999;
    border-radius: 50%;
    animation: ggSpin 0.7s linear infinite;
}

@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;
}