* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #000;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
}

#app {
    width: 100%;
    height: 100vh;
    max-width: 430px;
    margin: 0 auto;
    position: relative;
    background: #000;
    overflow: hidden;
}

.hidden { display: none !important; }

/* 通用占位图 */
.ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
    padding: 12px;
    letter-spacing: .5px;
}
.ph.small { font-size: 12px; min-height: 90px; border-radius: 10px; }

/* ===================== 顶部导航（抖音当前样式） ===================== */
.top-bar {
    position: fixed;
    top: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 430px;
    z-index: 200;
    padding: 10px 12px 6px;
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, transparent 100%);
}
.top-left { flex: 0 0 auto; padding-left: 4px; }
.hamburger {
    color: #fff; font-size: 22px; cursor: pointer;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}
.top-tabs {
    display: flex; gap: 18px; align-items: center;
    flex: 1; justify-content: center;
}
.tab {
    color: rgba(255,255,255,0.65);
    font-size: 15px; font-weight: 500;
    cursor: pointer; position: relative; padding-bottom: 2px;
    white-space: nowrap;
}
.tab.active { color: #fff; font-weight: 700; }
.tab.active::after {
    content: ''; position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%);
    width: 20px; height: 2.5px; border-radius: 2px; background: #fff;
}
.tab-dot { position: relative; }
.tab-dot .dot {
    position: absolute; top: -2px; right: -8px;
    width: 6px; height: 6px; border-radius: 50%; background: #fe2c55;
}
.top-right { flex: 0 0 auto; padding-right: 4px; }
.search-icon {
    color: #fff; font-size: 19px; cursor: pointer;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}

/* ===================== Feed 流 ===================== */
.feed-container {
    width: 100%; height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}
.feed-container::-webkit-scrollbar { display: none; }

.feed-item {
    width: 100%; height: 100vh;
    position: relative;
    scroll-snap-align: start;
    background: #111;
    overflow: hidden;
}
.feed-media {
    position: absolute; inset: 0;
    z-index: 1;
    cursor: pointer;
}
.feed-media img, .feed-media video, .feed-poster {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.feed-poster { position: relative; }
.play-badge {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 26px;
    opacity: 0; transition: opacity .2s;
}
.feed-item.paused .play-badge { opacity: 1; }

/* 移步赴景入口胶囊（左上角，仅暂停时出现）—— 对齐抖音搜索胶囊 */
.search-pill {
    position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 30;
    display: none;
    align-items: center; gap: 5px;
    height: 28px; padding: 0 10px 0 8px;
    border-radius: 14px;
    background: rgba(0,0,0,0.32);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    transition: background .15s;
}
.feed-item.paused .search-pill { display: flex; }
.search-pill:active { background: rgba(0,0,0,0.5); }

/* 左侧扫描图标（对齐截图 ⊞ 样式） */
.search-pill-icon {
    width: 13px; height: 13px;
    flex-shrink: 0;
    color: rgba(255,255,255,0.9);
}

/* 中间文字 */
.search-pill-text {
    color: #fff; font-size: 12.5px; font-weight: 600;
    white-space: nowrap;
}

/* 最右侧小圆点 ● */
.search-pill-dot {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: rgba(255,255,255,0.7);
    flex-shrink: 0;
}

/* 左下信息区（抖音当前样式） */
.feed-info {
    position: absolute;
    bottom: 72px; left: 14px; right: 80px;
    z-index: 10;
}
.danmaku-tag {
    display: inline-block;
    color: rgba(255,255,255,0.85);
    font-size: 13px; font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: 1px;
}
.author-name {
    color: #fff; font-size: 16px; font-weight: 700;
    display: inline-block; margin-bottom: 4px;
}
.video-desc {
    color: rgba(255,255,255,0.92); font-size: 14px; line-height: 1.5; margin-bottom: 6px;
}
.video-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { color: rgba(255,255,255,0.75); font-size: 13px; }

/* 音乐进度条 */
.music-bar {
    display: flex; align-items: center; gap: 6px;
    margin-top: 10px; padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.music-disc {
    width: 24px; height: 24px; border-radius: 50%;
    background: linear-gradient(135deg, #333, #111);
    border: 2px solid rgba(255,255,255,0.25);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: rgba(255,255,255,0.6);
}
.music-info { flex: 1; overflow: hidden; }
.music-title {
    color: rgba(255,255,255,0.8); font-size: 13px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-progress {
    height: 2px; background: rgba(255,255,255,0.2); border-radius: 1px;
    margin-top: 4px; position: relative; overflow: hidden;
}
.music-progress::after {
    content: ''; position: absolute; left: 0; top: 0; height: 100%;
    width: 35%; background: rgba(255,255,255,0.6); border-radius: 1px;
}

/* 右侧操作栏（抖音当前样式） */
.action-bar {
    position: absolute;
    right: 6px; top: 28%; z-index: 100;
    display: flex; flex-direction: column; gap: 18px; align-items: center;
}

/* 操作图标 + 数字 */
.action-item { display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.action-icon {
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s;
}
.action-icon:active { transform: scale(1.15); }
.action-icon svg { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.action-text { color: #fff; font-size: 11.5px; font-weight: 500; text-shadow: 0 1px 3px rgba(0,0,0,.6); }

/* 点赞后爱心变红实心 */
.action-item.like.liked .action-icon svg { stroke: #fe2c55; fill: #fe2c55; }

/* ===================== 暂停浮窗（极简胶囊式） ===================== */
.float-window {
    position: fixed;
    left: 50%; transform: translateX(-50%);
    bottom: 76px; z-index: 150;
    width: calc(100% - 32px); max-width: 398px;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    animation: floatUp .25s ease;
}
@keyframes floatUp { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translateX(-50%); } }

.float-dot {
    flex: 0 0 auto;
    width: 10px; height: 10px; border-radius: 50%;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

.float-pill {
    flex: 1;
    display: flex; align-items: center; gap: 6px;
    height: 38px; padding: 0 14px 0 10px;
    border-radius: 19px;
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.2);
    cursor: pointer;
    transition: background .15s;
}
.float-pill:active { background: rgba(255,255,255,0.28); }
.float-icon { font-size: 17px; line-height: 1; }
.float-text {
    color: #fff; font-size: 14px; font-weight: 600;
    letter-spacing: .3px; flex: 1;
}
.float-arrow {
    color: rgba(255,255,255,0.7); font-size: 18px; font-weight: 700;
}

/* ===================== 全屏覆盖（选形象 / 结果页） ===================== */
.screen {
    position: fixed; inset: 0; z-index: 300;
    width: 100%; max-width: 430px; margin: 0 auto;
    background: #0e0e10;
    display: flex; flex-direction: column;
    overflow: hidden;
}
/* 选形象屏：纯黑相机取景器 */
#avatarScreen { background: #000; }

.screen-header {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    background: #161618;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.back-btn {
    width: 32px; height: 32px; border: none; background: transparent;
    color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
}
.screen-title { color: #fff; font-size: 17px; font-weight: 700; }

/* ===================== 选形象屏（相机取景器风格） ===================== */

/* 顶部栏 */
.cam-top {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; align-items: center; z-index: 10;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
}
.cam-close {
    width: 36px; height: 36px; border: none; background: transparent;
    color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
.cam-close:active { background: rgba(255,255,255,0.15); }
.cam-title-bar {
    flex: 1; text-align: center;
}
.cam-scene-name {
    color: rgba(255,255,255,0.6); font-size: 14px;
    background: rgba(255,255,255,0.12);
    padding: 4px 14px; border-radius: 20px;
}

/* 右侧工具栏 */
.cam-sidebar {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 18px; z-index: 10;
}
.cam-tool {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(0,0,0,0.35);
    color: #fff; font-size: 17px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.08);
}
.cam-tool:active { background: rgba(255,255,255,0.2); }

/* 取景区域 */
.cam-viewfinder {
    position: absolute; top: 60px; left: 0; right: 70px; bottom: 140px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.cam-preview-img {
    max-width: 100%; max-height: 100%; object-fit: contain;
    border-radius: 8px;
}
.cam-placeholder {
    text-align: center; color: rgba(255,255,255,0.3);
}
.cam-placeholder-icon { font-size: 48px; margin-bottom: 10px; }
.cam-placeholder-text { font-size: 14px; }

/* 底部操作栏 */
.cam-bottom {
    position: absolute; bottom: 0; left: 0; right: 0;
    display: flex; align-items: flex-end; justify-content: space-between;
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
    z-index: 10;
}
.cam-bottom-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    cursor: pointer;
}
.cam-thumb-wrap {
    width: 52px; height: 52px; border-radius: 12px; overflow: hidden;
    border: 2px solid rgba(255,255,255,0.25);
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.08);
}
.cam-thumb { width: 100%; height: 100%; object-fit: cover; }
.cam-thumb-empty {
    color: rgba(255,255,255,0.5); font-size: 22px; line-height: 1;
}
.cam-label { color: #fff; font-size: 11px; }

/* 大白圆圈快门按钮（确认/生成） */
.cam-shutter-wrap {
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 4px;
}
.cam-shutter {
    width: 68px; height: 68px; border-radius: 50%;
    border: 3px solid #fff; background: transparent;
    cursor: pointer; position: relative;
    transition: transform 0.1s, background 0.15s;
}
.cam-shutter:not(:disabled):active { transform: scale(0.92); }
.cam-shutter:not(:disabled) { box-shadow: 0 0 0 rgba(255,255,255,0.3); }
.cam-shutter:not(:disabled)::after {
    content: ''; position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 54px; height: 54px; border-radius: 50%;
    background: #fff;
    transition: background 0.15s;
}
.cam-shutter:not(:disabled):active::after { background: #e0e0e0; }
.cam-shutter:disabled {
    border-color: rgba(255,255,255,0.25);
    cursor: not-allowed;
}
.cam-shutter:disabled::after { background: rgba(255,255,255,0.15); }

/* 相册按钮可点 */
.cam-album-btn { cursor: pointer; }
.cam-album-btn:active .cam-thumb-empty { opacity: 0.7; }

/* 形象库面板（从底部滑出） */
.cam-panel {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: #111; border-radius: 20px 20px 0 0;
    z-index: 20; max-height: 55vh; overflow-y: auto;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    animation: camPanelUp 0.25s ease-out;
}
@keyframes camPanelUp {
    from { transform: translateY(100%); } to { transform: translateY(0); }
}
.cam-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
    color: #fff; font-size: 16px; font-weight: 600;
}
.cam-panel-close {
    border: none; background: transparent; color: rgba(255,255,255,0.6);
    font-size: 18px; cursor: pointer; padding: 4px;
}
.cam-panel-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.cam-panel-cell {
    cursor: pointer; text-align: center;
}
.cam-panel-cell img {
    width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px;
    border: 2px solid transparent; transition: border-color 0.15s;
}
.cam-panel-cell.selected img { border-color: #fe2c55; }
.cam-cell-ph {
    aspect-ratio: 1; border-radius: 12px;
    background: #222; display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.5); font-size: 13px;
}
.cam-cell-name {
    display: block; color: rgba(255,255,255,0.7); font-size: 12px; margin-top: 6px;
}

.screen-footer { flex: 0 0 auto; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: #161618; }
.confirm-btn {
    width: 100%; height: 48px; border: none; border-radius: 24px;
    background: linear-gradient(135deg, #fe2c55 0%, #ff6034 100%);
    color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
}
.confirm-btn:disabled { background: #3a3a3d; color: rgba(255,255,255,0.4); }
.confirm-btn:not(:disabled):active { opacity: .85; }

/* ===================== 结果页 ===================== */
.result-header { justify-content: space-between; }
.result-tabs { display: flex; gap: 20px; margin: 0 auto; }
.rtab {
    color: rgba(255,255,255,0.55); font-size: 16px; font-weight: 600;
    padding-bottom: 4px; cursor: pointer;
}
.rtab.active { color: #fff; border-bottom: 2px solid #fe2c55; }

.result-body { flex: 1; overflow-y: auto; padding: 16px; }
.result-photo {
    width: 100%; height: 360px; border-radius: 14px; overflow: hidden; margin-bottom: 16px;
    background: #1c1c1f;
}
.result-photo.small-ph { height: 220px; }
.result-card {
    background: #1c1c1f; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px;
}
.result-card h3 { color: #fff; font-size: 15px; margin-bottom: 8px; }
.result-card p { color: rgba(255,255,255,0.82); font-size: 14px; line-height: 1.6; }
.result-card .muted { color: rgba(255,255,255,0.55); font-size: 13px; margin-top: 6px; }
.result-card.praise {
    background: linear-gradient(135deg, rgba(254,44,85,0.18), rgba(255,96,52,0.18));
    border: 1px solid rgba(254,44,85,0.3);
}
.result-card.praise p { color: #ffd9e1; font-style: italic; }

.buy-all-btn {
    width: 100%; height: 50px; border: none; border-radius: 25px;
    background: linear-gradient(135deg, #fe2c55 0%, #ff6034 100%);
    color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; margin-bottom: 16px;
}
.buy-all-btn:active { opacity: .85; }

/* 视频信息流 */
.video-feed { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.video-feed::-webkit-scrollbar { display: none; }
.vf-card { flex: 0 0 140px; }
.vf-card .ph { height: 90px; border-radius: 10px; }
.vf-title { color: #fff; font-size: 13px; margin-top: 6px; line-height: 1.3; }
.vf-views { color: rgba(255,255,255,0.5); font-size: 11px; margin-top: 2px; }

/* 商品列表 */
.product-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.product-row {
    display: flex; align-items: center; gap: 12px;
    background: #1c1c1f; border-radius: 14px; padding: 12px;
}
.product-img { width: 72px; height: 72px; border-radius: 10px; overflow: hidden; flex: 0 0 auto; background: #26262a; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-info { flex: 1; }
.product-name { color: #fff; font-size: 14px; margin-bottom: 6px; }
.product-price { color: #fe2c55; font-size: 16px; font-weight: 700; }
.add-cart {
    flex: 0 0 auto; height: 34px; padding: 0 14px;
    border: 1px solid #fe2c55; border-radius: 17px;
    background: transparent; color: #fe2c55; font-size: 13px; font-weight: 600; cursor: pointer;
}
.add-cart:active { background: rgba(254,44,85,0.12); }

.change-style-btn {
    width: 100%; height: 50px; border: none; border-radius: 25px;
    background: #2a2a2e; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.change-style-btn:active { background: #34343a; }

/* ===================== 底部导航 ===================== */
.bottom-bar {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 430px; z-index: 250;
    display: flex; justify-content: space-around; align-items: center;
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    background: rgba(0,0,0,0.94); backdrop-filter: blur(10px);
    border-top: 0.5px solid rgba(255,255,255,0.06);
}
.nav-item {
    color: rgba(255,255,255,0.5); font-size: 11px;
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    cursor: pointer; flex: 1;
}
.nav-item.active { color: #fff; }
.nav-sub { font-size: 10px; opacity: 0.6; }
.add-btn {
    width: 40px; height: 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px; font-weight: 600; position: relative;
}
.add-btn::before, .add-btn::after {
    content: ''; position: absolute; width: 36px; height: 28px;
    border-radius: 8px; background: inherit; z-index: -1;
}
.add-btn::before { left: -4px; background: #ff0050; opacity: .6; }
.add-btn::after { right: -4px; background: #00f2ea; opacity: .6; }

/* ===================== Toast ===================== */
.toast {
    position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%);
    z-index: 500;
    background: rgba(0,0,0,0.85); color: #fff;
    padding: 10px 18px; border-radius: 20px; font-size: 14px;
    max-width: 80%;
}

/* ===================== 生成写真加载遮罩 ===================== */
.gen-loading {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0,0,0,0.78);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px;
}
.gen-spinner {
    width: 42px; height: 42px; border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #fe2c55;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gen-text { color: #fff; font-size: 15px; }

/* 生成失败详情卡片 */
.gen-error-box {
    width: 84%; max-width: 360px;
    background: #1c1c1e; border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px; padding: 20px 18px;
    display: flex; flex-direction: column; gap: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.gen-error-title { color: #ff5b6e; font-size: 16px; font-weight: 600; }
.gen-error-msg {
    color: #e6e6e6; font-size: 13px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
    max-height: 50vh; overflow-y: auto;
    background: rgba(255,255,255,0.04); border-radius: 8px; padding: 10px 12px;
}
.gen-error-close {
    align-self: flex-end;
    background: #fe2c55; color: #fff; border: none;
    border-radius: 20px; padding: 9px 22px; font-size: 14px; cursor: pointer;
}
.gen-error-close:active { opacity: 0.85; }
