/* ============================================================
   视频转码中心 · 响应式样式
   断点：  >=1024 PC 三栏外两栏  |  641-1023 iPad  |  <=640 Phone
   ============================================================ */
:root {
    --bg: #0b1020;
    --bg-soft: #111a2f;
    --panel: #151f38;
    --panel-2: #1b2745;
    --line: #253354;
    --text: #e7ecf7;
    --text-dim: #94a3c4;
    --brand: #4c8dff;
    --brand-2: #7c5cff;
    --ok: #35d399;
    --warn: #ffb020;
    --err: #ff5f6d;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(4, 10, 26, .45);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f3f6fd;
        --bg-soft: #e9effa;
        --panel: #ffffff;
        --panel-2: #f5f8ff;
        --line: #dde5f5;
        --text: #16213a;
        --text-dim: #5a6b8c;
        --shadow: 0 8px 24px rgba(30, 55, 110, .10);
    }
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    background-image:
        radial-gradient(900px 500px at 12% -8%, rgba(76, 141, 255, .20), transparent 60%),
        radial-gradient(800px 500px at 92% 0%, rgba(124, 92, 255, .16), transparent 55%);
    background-attachment: fixed;
}

.app {
    max-width: 1320px;
    margin: 0 auto;
    padding: 18px clamp(12px, 3vw, 32px) calc(28px + var(--safe-bottom));
}

/* ---------------- 顶栏 ---------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; font-size: 17px;
    box-shadow: 0 8px 20px rgba(76, 141, 255, .38);
    flex: none;
}

.brand-text h1 {
    margin: 0;
    font-size: clamp(17px, 2.4vw, 21px);
    letter-spacing: .4px;
    white-space: nowrap;
}
.brand-text p {
    margin: 0;
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--text-dim);
    max-width: 100%;
}
.device-chip .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 4px rgba(53, 211, 153, .16);
    flex: none;
}
.device-chip #deviceLabel {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ---------------- 布局 ---------------- */
.layout {
    display: grid;
    grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
    gap: clamp(14px, 2vw, 22px);
    align-items: start;
}

/* 单栏布局：404 页等只有一个 panel 的场合 */
.layout.single {
    grid-template-columns: minmax(0, 1fr);
    max-width: 720px;
    margin: 0 auto;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(14px, 2vw, 20px);
    min-width: 0;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.panel-head h2 {
    margin: 0;
    font-size: 15.5px;
    letter-spacing: .3px;
}
.quota {
    font-size: 12px;
    color: var(--text-dim);
    background: var(--panel-2);
    border: 1px solid var(--line);
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

/* ---------------- 上传区 ---------------- */
.dropzone {
    border: 2px dashed var(--line);
    border-radius: 14px;
    padding: clamp(20px, 4vw, 34px) 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, transform .12s ease;
    background: var(--panel-2);
    outline: none;
}
.dropzone:hover, .dropzone:focus-visible {
    border-color: var(--brand);
    background: rgba(76, 141, 255, .07);
}
.dropzone.dragover {
    border-color: var(--brand);
    background: rgba(76, 141, 255, .13);
    transform: scale(.995);
}
.dropzone.busy { opacity: .6; pointer-events: none; }

.dz-icon { font-size: 30px; color: var(--brand); line-height: 1; }
.dz-title { margin: 10px 0 4px; font-size: 14.5px; }
.dz-hint { margin: 0; font-size: 12px; color: var(--text-dim); }

.upload-list { margin-top: 12px; display: grid; gap: 10px; }

/* ---- 转码档位选择 ---- */
.profile-box {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}
.profile-head {
    display: flex; align-items: baseline; gap: 10px;
    justify-content: space-between; margin-bottom: 10px;
}
.profile-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; flex: none; }
.profile-hint {
    font-size: 11.5px; color: var(--text-dim);
    text-align: right; line-height: 1.35;
    min-width: 0; flex: 1 1 auto;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.profile-options {
    display: grid; gap: 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.profile-option {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 6px;
    font: inherit;
    font-size: 12.5px;
    line-height: 1.25;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
    display: grid; gap: 3px; justify-items: center;
    min-height: 52px;
}
.profile-option:hover { border-color: var(--brand); }
.profile-option .po-label { font-weight: 600; }
.profile-option .po-sub {
    font-size: 10.5px; color: var(--text-dim); font-variant-numeric: tabular-nums;
}
.profile-option.active {
    border-color: var(--brand);
    background: color-mix(in srgb, var(--brand) 14%, transparent);
}
.profile-option.active .po-label { color: var(--brand); }
.profile-option:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.profile-options.busy { opacity: .6; pointer-events: none; }
.task .task-profile, .task .task-format {
    font-size: 11px; color: var(--text-dim);
    border: 1px solid var(--line); border-radius: 99px;
    padding: 1px 7px; flex: none;
}
/* 格式选择器项数比档位多（8 项），4 列正好两行；窄屏逐级退回 */
#formatOptions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* 不可预览的格式：副标题用警示色，和"可直接预览"的档位一眼区分 */
.profile-option.no-preview .po-sub { color: var(--warn, #b45309); font-weight: 600; }
.profile-option .po-label { white-space: nowrap; }
#formatOptions .po-label { font-size: 12px; }

.upload-item {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
}
.upload-item .row {
    display: flex; justify-content: space-between; gap: 10px;
    align-items: baseline;
}
.upload-item .fname {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 68%;
}
.upload-item .fpct {
    color: var(--text-dim); font-variant-numeric: tabular-nums; flex: none;
}
.upload-item .fsize { color: var(--text-dim); font-size: 11.5px; }

.bar {
    height: 6px;
    border-radius: 99px;
    background: rgba(148, 163, 196, .20);
    overflow: hidden;
    margin-top: 8px;
}
.bar > i {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
    transition: width .2s ease;
}
.bar.ok > i { background: linear-gradient(90deg, #2bb673, var(--ok)); }
.bar.err > i { background: linear-gradient(90deg, #e03c4b, var(--err)); }

.meta-box {
    margin-top: 16px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    display: grid;
    gap: 6px;
}
.meta-row {
    display: flex; justify-content: space-between; gap: 12px;
    font-size: 12.5px; color: var(--text-dim);
}
.meta-row code {
    color: var(--text);
    font-size: 12px;
    max-width: 62%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------------- 过滤 ---------------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text-dim);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
}
.chip:hover { color: var(--text); border-color: var(--brand); }
.chip.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

/* ---------------- 任务列表 ---------------- */
.task-list { display: grid; gap: 10px; max-height: min(70vh, 780px); overflow-y: auto; padding-right: 2px; }
.task-list::-webkit-scrollbar { width: 8px; }
.task-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.empty {
    text-align: center;
    color: var(--text-dim);
    padding: 46px 10px;
    font-size: 13.5px;
}
.empty span { font-size: 34px; display: block; margin-bottom: 8px; opacity: .8; }
.empty .empty-icon {
    width: 38px; height: 38px;
    display: block; margin: 0 auto 10px;
    color: var(--text-dim); opacity: .65;
}

.task {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 12px 14px;
    transition: border-color .16s ease, transform .16s ease;
}
.task:hover { border-color: #31456e; }

.task-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.task-name {
    font-size: 13.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}
.task-sub {
    font-size: 11.5px;
    color: var(--text-dim);
    margin-top: 2px;
    display: flex; gap: 10px; flex-wrap: wrap;
}
.task-sub code { font-family: ui-monospace, Menlo, monospace; }

.status {
    font-size: 11.5px;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
    flex: none;
    font-weight: 600;
}
.status.queued     { background: rgba(148,163,196,.16); color: var(--text-dim); }
.status.processing { background: rgba(76,141,255,.16);  color: #79a8ff; }
.status.completed  { background: rgba(53,211,153,.16);  color: var(--ok); }
.status.failed     { background: rgba(255,95,109,.16);  color: var(--err); }
.status.canceled   { background: rgba(255,176,32,.14);  color: var(--warn); }

.task-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: all .15s ease;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-color: transparent;
    color: #fff;
}
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.progress-line {
    margin-top: 9px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11.5px;
    color: var(--text-dim);
}
.progress-line .bar { flex: 1; margin-top: 0; }
.progress-line b { font-variant-numeric: tabular-nums; color: var(--text); min-width: 34px; text-align: right; }

.err-text {
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--err);
    word-break: break-word;
    background: rgba(255,95,109,.08);
    border-radius: 8px;
    padding: 7px 10px;
}

/* ---------------- SEO 正文（对用户也有用，不是纯堆词） ---------------- */
.seo-intro {
    margin-top: 18px;
    padding: 22px 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.seo-intro h2 {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 650;
    color: var(--text);
}
.seo-intro > p {
    margin: 0 0 16px;
    font-size: 13px;
    line-height: 1.75;
    color: var(--text-dim);
}
.seo-intro strong { color: var(--text); font-weight: 650; }
.seo-cols {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px 24px;
}
.seo-cols h3 {
    margin: 0 0 6px;
    font-size: 12.5px;
    font-weight: 650;
    color: var(--text);
}
.seo-cols p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text-dim);
}
.seo-faq { margin-top: 22px; }
.seo-faq h3 {
    margin: 0 0 10px;
    font-size: 12.5px;
    font-weight: 650;
    color: var(--text);
}
.faq-item {
    border-top: 1px solid var(--line);
    padding: 10px 0;
}
.faq-item:first-of-type { border-top: none; }
.faq-item summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    list-style: none;
    position: relative;
    padding-right: 22px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    /* 用单箭头而不是 "+"：加号旋转 45° 会变成 "×"，视觉上像删除/关闭按钮 */
    content: "\203A";          /* › */
    position: absolute;
    right: 4px; top: 0;
    font-size: 17px;
    line-height: 1.2;
    color: var(--text-dim);
    transition: transform .18s ease;
}
.faq-item[open] summary::after { transform: rotate(90deg); }
.faq-item p {
    margin: 8px 0 2px;
    font-size: 12.5px;
    line-height: 1.75;
    color: var(--text-dim);
}
@media (max-width: 1023px) {
    .seo-cols { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 640px) {
    .seo-intro { padding: 18px 16px; }
    .seo-intro > p, .seo-cols p { font-size: 13px; }
}

/* ---------------- 页脚 ---------------- */
.footer {
    margin-top: 18px;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-dim);
}

/* ---------------- 弹窗 ---------------- */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 90;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal.open { display: flex; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(5, 10, 22, .72);
    backdrop-filter: blur(3px);
}
.modal-body {
    position: relative;
    width: min(920px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
    padding: 16px;
    animation: pop .18s ease;
}
.modal-body.small { width: min(640px, 100%); }
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: scale(1); opacity: 1; } }

.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 12px;
}
.modal-head h3 {
    margin: 0; font-size: 14.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 17px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
    font-family: inherit;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

#previewVideo {
    width: 100%;
    max-height: 66vh;
    background: #000;
    border-radius: 10px;
    display: block;
}
.modal-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-top: 12px; flex-wrap: wrap;
    font-size: 12px; color: var(--text-dim);
}

.json-view {
    margin: 0;
    max-height: 62vh;
    overflow: auto;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    font-size: 12px;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---------------- Toast ---------------- */
.toast-wrap {
    position: fixed;
    left: 50%;
    bottom: calc(24px + var(--safe-bottom));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 120;
    width: min(92vw, 460px);
    pointer-events: none;
}
.toast {
    background: rgba(20, 30, 52, .96);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 11px;
    padding: 10px 14px;
    font-size: 12.8px;
    box-shadow: var(--shadow);
    animation: toastIn .2s ease;
    word-break: break-word;
}
.toast.ok { border-color: rgba(53, 211, 153, .5); }
.toast.err { border-color: rgba(255, 95, 109, .55); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   iPad（竖屏平板 & 小笔记本）
   ============================================================ */
@media (max-width: 1023px) {
    .layout { grid-template-columns: 1fr; }
    .task-list { max-height: none; }
    .brand-text p { display: none; }
}

/* ============================================================
   Phone
   ============================================================ */
@media (max-width: 1023px) {
    #formatOptions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    html, body { font-size: 14.5px; }
    .app { padding: 12px 12px calc(20px + var(--safe-bottom)); }
    .topbar { gap: 10px; margin-bottom: 12px; }
    .logo { width: 38px; height: 38px; border-radius: 12px; font-size: 15px; }
    .brand-text h1 { font-size: 16.5px; }
    .device-chip { font-size: 11px; padding: 6px 10px; width: 100%; justify-content: flex-start; }
    .panel { padding: 13px; border-radius: 14px; }
    .dropzone { padding: 22px 12px; }
    .dz-icon { font-size: 26px; }
    .task-actions .btn { flex: 1; padding: 9px 10px; }
    .meta-row { font-size: 11.5px; }
    .meta-row code { max-width: 56%; font-size: 11px; }
    .modal { padding: 8px; }
    .modal-body { padding: 12px; max-height: 94vh; }
    #previewVideo { max-height: 52vh; }
    .modal-foot .btn { width: 100%; }
    .toast-wrap { bottom: calc(14px + var(--safe-bottom)); width: calc(100vw - 24px); }
    .filters { width: 100%; }
    .chip { flex: 1; text-align: center; padding: 6px 4px; }
    .profile-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* ID 选择器优先级高于 .profile-options，手机端要单独覆盖一次 */
    #formatOptions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-option { min-height: 46px; }
}

/* 横屏手机：视频最大化 */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    #previewVideo { max-height: 64vh; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
