/* 抖音风格 - 剪映视频下载 */

:root {
    --bg: #0d0d0d;
    --card: #1a1a1a;
    --surface: #2a2a2a;
    --accent: #fe2c55;
    --accent-dim: rgba(254,44,85,0.12);
    --text: #f5f5f5;
    --text-dim: #999999;
    --text-weak: #666666;
    --border: #333333;
    --success: #25d366;
    --radius: 10px;
    --top-h: 50px;
    --btm-h: 56px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ====== 顶部栏 ====== */
.top-bar {
    height: var(--top-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(13,13,13,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}

.top-bar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.top-bar-tag {
    font-size: .7rem;
    color: var(--accent);
    text-decoration: none;
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 3px 10px;
    margin-left: 8px;
    white-space: nowrap;
}

.top-bar-btn {
    width: 34px; height: 34px;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}

.top-bar-btn:hover { background: var(--surface); }

.top-bar-btn svg { color: var(--text); }

.top-back {
    width: 34px; height: 34px;
    display: flex;
    align-items: center; justify-content: center;
    color: var(--text);
    text-decoration: none;
    border-radius: 50%;
}

.top-back:hover { background: var(--surface); }

.top-bar-spacer { width: 34px; }

/* ====== 输入面板 ====== */
.input-panel {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: rgba(26,26,26,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 30;
    transform: translateY(-100%);
    transition: transform .25s ease;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    border-radius: 0 0 16px 16px;
    max-height: 70vh;
    overflow-y: auto;
}

.input-panel.show { transform: translateY(0); }

.input-panel-inner {
    padding: 20px 16px;
    padding-top: calc(var(--top-h) + 12px);
}

.input-panel textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #111;
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    resize: vertical;
    line-height: 1.5;
}

.input-panel textarea:focus { outline: none; border-color: var(--accent); }

.input-panel textarea::placeholder { color: var(--text-weak); }

.input-panel-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.btn-accent {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
    font-family: inherit;
}

.btn-accent:active { opacity: .8; }

.btn-accent.full { width: 100%; flex: none; margin-top: 6px; }

.btn-ghost {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: .9rem;
    cursor: pointer;
    font-family: inherit;
}

.btn-ghost:active { opacity: .7; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 25;
}

.overlay.show { display: block; }

/* 链接提取结果 */
.link-result { margin-top: 12px; }

.link-result .result-header {
    font-size: .8rem;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.link-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #111;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
}

.link-item .link-url {
    flex: 1;
    font-size: .78rem;
    word-break: break-all;
    color: var(--accent);
}

.link-item .btn-submit {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.link-item .btn-submit:active { opacity: .7; }

.link-item .btn-submit.done {
    background: var(--success);
    opacity: .8;
}

/* ====== 视频信息流 ====== */
.feed {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    padding-bottom: calc(var(--btm-h) + 12px);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.feed-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
    font-size: .88rem;
}

/* 视频列表项 - 卡片式 */
.video-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    margin: 0 12px 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .15s, background .15s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.video-item:active { border-color: var(--accent); background: var(--surface); }

.video-item-thumb {
    width: 90px; height: 60px;
    background: var(--surface);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.video-item-cover {
    width: 100%; height: 100%;
    object-fit: cover; position: absolute;
    top: 0; left: 0;
}

.video-item-thumb .play-dot {
    position: absolute;
    right: 4px; bottom: 4px;
    width: 22px; height: 22px;
    background: rgba(0,0,0,.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.video-item-title {
    font-size: .88rem;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.video-item-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .7rem;
    color: var(--text-dim);
}

.source-tag {
    font-size: .62rem;
    padding: 1px 7px;
    border-radius: 3px;
    font-weight: 500;
}

.source-tag.upload { background: rgba(255,255,255,.08); color: var(--text-dim); }
.source-tag.pc_output { background: var(--accent-dim); color: var(--accent); }

.video-item-arrow {
    color: var(--text-weak);
    flex-shrink: 0;
}

.video-item-arrow svg { width: 16px; height: 16px; }

/* ====== 底部导航 ====== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--btm-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: rgba(13,13,13,0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.06);
    z-index: 20;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-weak);
    font-size: .6rem;
    font-weight: 500;
    padding: 4px 12px;
    transition: color .15s;
    position: relative;
}

.nav-item svg { opacity: .45; transition: opacity .15s, color .15s; }

.nav-item.active { color: #fff; }

.nav-item.active svg { opacity: 1; color: #fff; }

.nav-item.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

/* ====== App 分发二级页 ====== */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(var(--btm-h) + 16px);
    -webkit-overflow-scrolling: touch;
}

.section-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
}

.section-head {
    font-size: .95rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-desc {
    font-size: .78rem;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.os-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.os-dot.ios { background: #007aff; }

.field { margin-bottom: 10px; }

.field label {
    display: block;
    font-size: .75rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

input[type="text"], input[type="url"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #111;
    color: var(--text);
    font-size: .85rem;
    font-family: inherit;
}

input:focus { outline: none; border-color: var(--accent); }

.help-text {
    font-size: .78rem;
    color: var(--text-dim);
    line-height: 1.7;
}

/* Toast */
.toast {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: .8rem;
    margin-top: 8px;
    display: none;
    word-break: break-all;
}

.toast.show { display: block; }

.toast.ok { background: rgba(37,211,102,.12); color: var(--success); }
.toast.err { background: rgba(254,44,85,.12); color: var(--accent); }

/* 通用隐藏 */
.hidden { display: none !important; }

/* 安全区 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        height: calc(var(--btm-h) + var(--safe-b));
        padding-bottom: var(--safe-b);
    }
}

/* ====== 模板选择弹窗 ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 50;
}
.modal-overlay.show { display: block; }

.modal-template {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100vw - 48px);
    max-width: 400px;
    max-height: 70vh;
    background: var(--card);
    border-radius: 16px;
    z-index: 51;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,.5);
    border: 1px solid var(--border);
}
.modal-template.show { display: flex; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.modal-close {
    width: 30px; height: 30px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 1.4rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 16px;
    -webkit-overflow-scrolling: touch;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    background: #111;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s, transform .1s;
}

.template-card:active { transform: scale(.95); }

.template-card.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.template-card-img {
    width: 100%;
    aspect-ratio: 9/16;
    background: var(--surface);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 1.5rem;
    position: relative;
}

.template-card-img img {
    width: 100%; height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0; left: 0;
}

.template-card-name {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

.template-card-check {
    position: absolute;
    top: 4px; right: 4px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--accent);
    display: none;
    align-items: center;
    justify-content: center;
}

.template-card.selected .template-card-check {
    display: flex;
}

.template-card-check::after {
    content: "";
    width: 6px; height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.modal-footer {
    padding: 12px 20px 16px;
    flex-shrink: 0;
    display: flex;
    gap: 10px;
}

.modal-footer .btn-accent { flex: 1; }

.modal-footer .btn-ghost {
    flex: 1;
    text-align: center;
}

.modal-footer .btn-accent:disabled {
    opacity: .4;
    cursor: not-allowed;
}
