/* X / Twitter 视频下载工具 — /tools/xvideo
   全站 CSS 变量驱动，自动跟随浅色 / 深色主题；三端响应式。 */
body.page-xvideo-full .app { max-width: 100%; }

.xv-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 18px 16px 34px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* ---------- 标题区 ---------- */
.xv-hero { text-align: center; padding: 26px 12px 22px; }
.xv-hero-icon {
    width: 64px; height: 64px;
    margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #5b9bff);
    box-shadow: 0 10px 26px -8px color-mix(in srgb, var(--accent) 55%, transparent);
}
.xv-hero-icon svg { display: block; }
.xv-title {
    font-size: clamp(22px, 3.6vw, 30px);
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
    color: var(--text-primary);
}
.xv-sub {
    max-width: 640px;
    margin: 0 auto;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ---------- 主面板 ---------- */
.xv-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px 18px 18px;
}

/* 模式切换 */
.xv-tabs {
    display: flex;
    gap: 22px;
    border-bottom: 1px solid var(--border-color);
    margin: 0 -18px;
    padding: 0 18px;
}
.xv-tab {
    appearance: none; border: 0; background: none; cursor: pointer;
    padding: 13px 2px 11px;
    font-size: 15px; font-weight: 600;
    color: var(--text-secondary);
    position: relative;
    transition: color .15s ease;
}
.xv-tab:hover { color: var(--text-primary); }
.xv-tab.is-active { color: var(--text-primary); }
.xv-tab.is-active::after {
    content: "";
    position: absolute; left: 0; right: 0; bottom: -1px;
    height: 3px; border-radius: 3px 3px 0 0;
    background: var(--accent);
}
.xv-pane { padding-top: 16px; }
.xv-pane[hidden] { display: none !important; }

/* 输入行 */
.xv-input-row { display: flex; gap: 10px; margin-bottom: 12px; }
.xv-input-row input {
    flex: 1; min-width: 0;
    padding: 11px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.xv-input-row input::placeholder { color: var(--text-secondary); opacity: .75; }
.xv-input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

textarea#xvBatchInput {
    width: 100%;
    resize: vertical;
    min-height: 150px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s ease, box-shadow .15s ease;
}
textarea#xvBatchInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

/* 按钮 */
.xv-btn {
    appearance: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    font-size: 14px; font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: background-color .15s ease, border-color .15s ease, opacity .15s ease, transform .1s ease;
    user-select: none;
}
.xv-btn:disabled { opacity: .55; cursor: not-allowed; }
.xv-btn:active:not(:disabled) { transform: scale(.98); }
.xv-btn-primary {
    background: var(--accent); color: #fff;
}
.xv-btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.xv-btn-ghost {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.xv-btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.xv-btn-block { width: 100%; padding: 13px; margin-top: 12px; }
.xv-input-row .xv-btn { padding: 0 16px; }

/* 批量工具行 */
.xv-batch-tools {
    display: flex; align-items: center; gap: 10px;
    margin-top: 12px;
}
.xv-batch-tools .xv-btn-primary { margin-left: auto; }
.xv-batch-count {
    font-size: 12.5px;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
    border-radius: 999px;
    padding: 4px 12px;
    font-weight: 600;
}
.xv-batch-count.is-limit { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* 进度条 */
.xv-progress { margin-top: 16px; }
.xv-progress[hidden] { display: none !important; }
.xv-progress-head {
    display: flex; justify-content: space-between;
    font-size: 13px; color: var(--text-secondary);
    margin-bottom: 6px;
}
.xv-progress-track {
    height: 8px; border-radius: 999px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    overflow: hidden;
}
.xv-progress-bar {
    height: 100%; width: 0;
    border-radius: 999px;
    background: var(--accent);
    transition: width .3s ease;
}
.xv-progress-bar.is-done { background: #22a06b; }
.xv-progress-url {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 状态信息 */
.xv-result { margin-top: 16px; }
.xv-status {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}
.xv-status svg { flex-shrink: 0; margin-top: 1px; }
.xv-status-error {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
}
.xv-status-tip {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
    color: var(--accent);
}

/* ---------- 单个解析结果 ---------- */
.xv-single {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    animation: xvFade .35s ease-out;
}
.xv-single-head {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}
.xv-single-avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 17px;
    background: linear-gradient(135deg, var(--accent), #5b9bff);
    letter-spacing: .5px;
    user-select: none;
}
.xv-single-author {
    min-width: 0;
    font-weight: 700; font-size: 15px;
    color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.xv-single-platform { font-size: 12px; color: var(--text-secondary); }
.xv-single-badge {
    margin-left: auto; flex-shrink: 0;
    font-size: 11.5px; font-weight: 700;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border-radius: 999px;
    padding: 4px 10px;
}
.xv-single-body { display: flex; gap: 16px; padding: 16px; }
.xv-single-thumb {
    flex-shrink: 0;
    width: 46%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border-color);
}
.xv-single-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.xv-single-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.xv-single-text {
    font-size: 13.5px; color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.xv-single-text a { color: var(--accent); }
.xv-vlist { display: flex; flex-direction: column; gap: 8px; max-height: 264px; overflow-y: auto; padding-right: 2px; }
.xv-vrow {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.xv-vrow-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.xv-vquality { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.xv-vbadge {
    font-size: 10.5px; font-weight: 700;
    color: #fff; background: var(--danger);
    padding: 1px 7px; border-radius: 999px;
    line-height: 1.6;
}
.xv-vsize {
    margin-left: auto; flex-shrink: 0;
    font-size: 11.5px; color: var(--text-secondary);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 2px 8px; border-radius: 6px;
}
.xv-vactions { display: flex; gap: 8px; flex-wrap: wrap; }
.xv-act {
    appearance: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 12.5px; font-weight: 600;
    padding: 7px 12px;
    text-decoration: none;
    transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.xv-act:hover { border-color: var(--accent); color: var(--accent); }
.xv-act-dl {
    background: var(--accent); border-color: var(--accent);
    color: #fff;
}
.xv-act-dl:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.xv-act-copied { color: #22a06b !important; border-color: #22a06b !important; }
.xv-vurl-row { display: flex; gap: 6px; margin-top: 8px; }
.xv-vurl-row input {
    flex: 1; min-width: 0;
    font-size: 11px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 8px;
    outline: none;
    cursor: text;
}
.xv-vurl-row input:focus { border-color: var(--accent); }

/* ---------- 批量结果网格 ---------- */
.xv-batch-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.xv-batch-grid[hidden] { display: none !important; }
.xv-bcard {
    display: flex; flex-direction: column;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    animation: xvFade .35s ease-out;
}
.xv-bcard-thumb {
    aspect-ratio: 16 / 9;
    background: #000;
    position: relative;
}
.xv-bcard-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.xv-bcard-ok {
    position: absolute; right: 8px; bottom: 8px;
    font-size: 10.5px; font-weight: 700; color: #fff;
    background: rgba(0,0,0,.62);
    border-radius: 999px;
    padding: 3px 9px;
    backdrop-filter: blur(4px);
}
.xv-bcard-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.xv-bcard-author {
    font-weight: 700; font-size: 13px; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.xv-bcard-text {
    font-size: 12px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.xv-bcard-videos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.xv-bcard-q {
    font-size: 11px; font-weight: 700;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 9px;
    text-decoration: none;
    transition: border-color .15s ease;
}
.xv-bcard-q:hover { border-color: var(--accent); }
.xv-bcard-orig {
    font-size: 10.5px; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.xv-bcard-orig a { color: var(--text-secondary); }
.xv-bcard-orig a:hover { color: var(--accent); }

.xv-bcard-fail {
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    background: color-mix(in srgb, var(--danger) 4%, var(--bg-primary));
    padding: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.xv-bcard-fail-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; color: var(--danger); }
.xv-bcard-fail-title svg { flex-shrink: 0; }
.xv-bcard-fail-msg { font-size: 12.5px; color: var(--danger); opacity: .9; }
.xv-bcard-fail-url {
    margin-top: auto;
    font-size: 11px; font-family: ui-monospace, Menlo, Consolas, monospace;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 5px 8px;
    word-break: break-all;
}

/* ---------- 示例 / 说明 ---------- */
.xv-samples { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 14px; font-size: 12.5px; color: var(--text-secondary); flex-wrap: wrap; }
.xv-link {
    appearance: none; border: 0; background: none; cursor: pointer;
    color: var(--accent); font-size: 12.5px; font-weight: 600;
    padding: 2px;
}
.xv-link:hover { text-decoration: underline; }

.xv-help {
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}
.xv-help summary {
    cursor: pointer;
    font-weight: 700; font-size: 14px;
    color: var(--text-primary);
    list-style: none;
    user-select: none;
}
.xv-help summary::-webkit-details-marker { display: none; }
.xv-help summary::before { content: "▸ "; color: var(--text-secondary); }
.xv-help[open] summary::before { content: "▾ "; }
.xv-help ol { margin: 12px 0 8px; padding-left: 22px; }
.xv-help li { margin-bottom: 6px; color: var(--text-secondary); font-size: 13.5px; }
.xv-tip { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0 0; }
.xv-help ol a, .xv-help a { color: var(--accent); }

/* ---------- 危险按钮 ---------- */
.xv-btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}
.xv-btn-danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* ---------- 设置齿轮（仅超管可见） ---------- */
.xv-hero { position: relative; }
.xv-gear {
    position: absolute; top: 10px; right: 10px;
    width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.xv-gear:hover { color: var(--accent); border-color: var(--accent); background: var(--bg-hover); }

/* ---------- 下载记录 ---------- */
.xv-hist-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.xv-hist-bar input[type="text"] {
    flex: 1 1 200px; min-width: 0;
    padding: 9px 12px; font-size: 13.5px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
}
.xv-hist-bar input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.xv-hist-count { font-size: 12.5px; color: var(--text-secondary); }
.xv-hist-all { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.xv-hist-all[hidden] { display: none; }

.xv-hint { padding: 26px 12px; text-align: center; font-size: 13px; color: var(--text-secondary); }

.xv-hist-list { display: flex; flex-direction: column; gap: 10px; }
.xv-hitem {
    display: flex; gap: 12px; padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    animation: xvFade .2s ease;
}
.xv-hitem-thumb {
    flex: 0 0 96px; width: 96px; aspect-ratio: 16 / 10;
    border-radius: 8px; overflow: hidden; background: var(--bg-secondary);
}
.xv-hitem-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.xv-hitem-main { flex: 1; min-width: 0; }
.xv-hitem-author {
    font-size: 13.5px; font-weight: 600; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.xv-hitem-tid { font-weight: 400; font-size: 12.5px; color: var(--text-secondary); }
.xv-hitem-text {
    margin-top: 3px; font-size: 12.5px; color: var(--text-secondary);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.xv-hitem-meta { margin-top: 5px; font-size: 12px; color: var(--text-secondary); opacity: .9; }
.xv-hitem-ops { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.xv-hact {
    appearance: none; border: 1px solid var(--border-color); background: transparent;
    color: var(--text-secondary); padding: 5px 10px; border-radius: 8px;
    font-size: 12.5px; cursor: pointer; text-decoration: none;
    text-align: center; white-space: nowrap;
    transition: color .15s ease, border-color .15s ease;
}
.xv-hact:hover { color: var(--accent); border-color: var(--accent); }
.xv-hact-danger:hover { color: var(--danger); border-color: var(--danger); }

.xv-pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 14px; }
.xv-pager[hidden] { display: none; }
.xv-pg {
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid var(--border-color); background: var(--bg-primary);
    color: var(--text-primary); border-radius: 8px; font-size: 13px; cursor: pointer;
}
.xv-pg:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.xv-pg.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.xv-pg:disabled { opacity: .45; cursor: not-allowed; }
.xv-pg-dots { padding: 0 2px; color: var(--text-secondary); }

/* ---------- 设置弹窗（仅超管） ---------- */
.xv-mask {
    position: fixed; inset: 0; z-index: 100000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .5); padding: 16px;
}
.xv-mask[hidden] { display: none; }
.xv-modal {
    width: 100%; max-width: 420px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
    overflow: hidden;
}
.xv-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border-color); }
.xv-modal-head h2 { margin: 0; font-size: 16px; color: var(--text-primary); }
.xv-modal-x { border: 0; background: transparent; color: var(--text-secondary); font-size: 15px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.xv-modal-x:hover { background: var(--bg-hover); color: var(--text-primary); }
.xv-modal-body { padding: 16px; }
.xv-set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text-primary); cursor: pointer; }
.xv-set-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.xv-set-tip { margin: 10px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--text-secondary); }
.xv-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border-color); background: var(--bg-secondary); }

/* ---------- 动画 ---------- */
@keyframes xvFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .xv-single-body { flex-direction: column; }
    .xv-single-thumb { width: 100%; }
    .xv-single-text { -webkit-line-clamp: 4; }
}
@media (max-width: 700px) {
    .xv-page { padding: 10px 10px 26px; }
    .xv-card { padding: 6px 12px 14px; border-radius: 14px; }
    .xv-tabs { gap: 16px; margin: 0 -12px; padding: 0 12px; }
    .xv-batch-grid { grid-template-columns: 1fr; }
    .xv-batch-tools { flex-wrap: wrap; }
    .xv-batch-tools .xv-btn-primary { margin-left: 0; flex: 1; }
    .xv-batch-count { order: -1; width: 100%; }
    .xv-vactions { flex-wrap: wrap; }
    .xv-act { flex: 1; min-width: 0; padding: 8px 6px; }
    .xv-single-badge { display: none; }

    /* 下载记录：手机端操作按钮整行平铺，便于点按 */
    .xv-hist-bar input[type="text"] { flex: 1 1 100%; }
    .xv-hist-bar .xv-btn { flex: 1; }
    .xv-hitem { flex-wrap: wrap; }
    .xv-hitem-ops { flex-direction: row; flex-wrap: wrap; width: 100%; }
    .xv-hact { flex: 1; min-width: 0; }
}
@media (max-width: 460px) {
    .xv-hero { padding-top: 16px; }
    .xv-hero-icon { width: 54px; height: 54px; }
    .xv-input-row { flex-direction: column; }
    .xv-input-row .xv-btn { padding: 12px; width: 100%; }
    .xv-vrow-head { flex-wrap: wrap; }

    .xv-hitem-thumb { flex: 0 0 72px; width: 72px; }
    .xv-modal-foot { flex-direction: column-reverse; }
    .xv-modal-foot .xv-btn { width: 100%; }
}
