/* ================================================================
   视频/图片混淆 · 最终样式
   苹果风格 · 亮/暗色跟随 · 主题按钮固定右上角
   ================================================================ */

/* ---------- 变量 ---------- */
:root {
    color-scheme: light;
    --page-bg: #F5F5F7;
    --panel: #FFFFFF;
    --panel-solid: #FFFFFF;
    --panel-soft: #F8F8FA;
    --text: #1D1D1F;
    --text-secondary: #515158;
    --text-muted: #8E8E93;
    --accent: #007AFF;
    --accent-hover: #0067D8;
    --accent-soft: rgba(0, 122, 255, 0.1);
    --success: #16845B;
    --success-soft: rgba(22, 132, 91, 0.12);
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.14);
    --track: rgba(120, 120, 128, 0.16);
    --control-surface: rgba(255, 255, 255, 0.92);
    --control-border: rgba(0, 0, 0, 0.08);
    --control-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    --overlay: rgba(0, 0, 0, 0.32);
    --shadow-panel: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-popover: 0 24px 64px rgba(0, 0, 0, 0.2), 0 4px 14px rgba(0, 0, 0, 0.1);
    --glass: blur(24px) saturate(180%);
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --page-bg: #1C1C1E;
    --panel: #2C2C2E;
    --panel-solid: #3A3A3C;
    --panel-soft: #242426;
    --text: #F5F5F7;
    --text-secondary: #D1D1D6;
    --text-muted: #98989D;
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --success: #63D2A0;
    --success-soft: rgba(99, 210, 160, 0.14);
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.2);
    --track: rgba(120, 120, 128, 0.24);
    --control-surface: rgba(58, 58, 60, 0.92);
    --control-border: rgba(255, 255, 255, 0.12);
    --control-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
    --overlay: rgba(0, 0, 0, 0.52);
    --shadow-panel: 0 8px 30px rgba(0, 0, 0, 0.24), 0 1px 3px rgba(0, 0, 0, 0.18);
    --shadow-popover: 0 26px 72px rgba(0, 0, 0, 0.55), 0 4px 18px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        color-scheme: dark;
        --page-bg: #1C1C1E;
        --panel: #2C2C2E;
        --panel-solid: #3A3A3C;
        --panel-soft: #242426;
        --text: #F5F5F7;
        --text-secondary: #D1D1D6;
        --text-muted: #98989D;
        --accent: #0A84FF;
        --accent-hover: #409CFF;
        --accent-soft: rgba(10, 132, 255, 0.18);
        --border: rgba(255, 255, 255, 0.12);
        --border-strong: rgba(255, 255, 255, 0.2);
        --track: rgba(120, 120, 128, 0.24);
        --control-surface: rgba(58, 58, 60, 0.92);
        --control-border: rgba(255, 255, 255, 0.12);
        --control-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
        --overlay: rgba(0, 0, 0, 0.52);
        --shadow-panel: 0 8px 30px rgba(0, 0, 0, 0.24), 0 1px 3px rgba(0, 0, 0, 0.18);
        --shadow-popover: 0 26px 72px rgba(0, 0, 0, 0.55), 0 4px 18px rgba(0, 0, 0, 0.3);
    }
}

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--page-bg);
    scroll-behavior: smooth;
}

body, button, input, select {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 24px 20px 60px;
    color: var(--text);
    background: var(--page-bg);
    font-size: 14px;
    line-height: 1.5;
    transition: background-color 300ms var(--ease), color 300ms var(--ease);
}

button, input, select { color: inherit; font-size: inherit; }

button {
    min-height: 44px;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    padding: 0 14px;
    background: var(--control-surface);
    box-shadow: var(--control-shadow);
    cursor: pointer;
    transition: transform 180ms var(--ease), color 180ms var(--ease),
                background-color 180ms var(--ease), border-color 180ms var(--ease),
                box-shadow 180ms var(--ease), opacity 180ms var(--ease);
}

button:hover:not(:disabled) {
    border-color: var(--border-strong);
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.08);
}

button:active:not(:disabled) { transform: scale(0.98); }

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent);
    outline-offset: 3px;
}

button:disabled, input:disabled, select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

h1, h2, h3 { font-size: 17px; font-weight: 600; }

/* ---------- 主容器 ---------- */
.tool-card {
    width: min(100%, 800px);
    margin: 0 auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--text);
    background: transparent;
    box-shadow: none;
}

/* ---------- 顶部工具栏 ---------- */
.module-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 24px;
    padding: 0 0 18px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
}

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

.brand-title {
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.tab-container {
    display: inline-flex;
    gap: 2px;
    margin: 0;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--panel-soft);
}

.module-tab,
.module-tab.active {
    width: auto;
    min-width: 0;
    height: 32px;
    min-height: 32px;
    border: 0;
    border-radius: 8px;
    padding: 0 14px;
    color: var(--text-muted);
    background: transparent;
    box-shadow: none;
    font-size: 13px;
    font-weight: 600;
    transition: color 160ms var(--ease), background 160ms var(--ease), box-shadow 160ms var(--ease);
}

.module-tab:hover:not(.active) {
    color: var(--text);
}

.module-tab.active {
    color: var(--text);
    background: var(--control-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 主题切换按钮：固定右上角 */
#themeToggle {
    position: fixed;
    z-index: 1001;
    top: 16px;
    right: 16px;
    left: auto;
    display: grid;
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    padding: 0;
    color: var(--text-secondary);
    background: var(--control-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    line-height: 1;
    transition: transform 200ms var(--ease), color 200ms var(--ease),
                border-color 200ms var(--ease), background-color 200ms var(--ease);
}

#themeToggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: scale(1.06);
}

#themeToggle:active { transform: scale(0.94); }

.theme-toggle svg { display: none; pointer-events: none; }

.theme-icon-sun,
.theme-icon-moon { display: none; }

html:not([data-theme]) .theme-icon-moon,
html[data-theme="light"] .theme-icon-moon { display: inline-block; }

html[data-theme="dark"] .theme-icon-sun { display: inline-block; }

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) .theme-icon-moon { display: none; }
    html:not([data-theme]) .theme-icon-sun { display: inline-block; }
}

/* ---------- 页面容器 ---------- */
.module-page { display: none; }

.module-page.active-page {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    animation: pageFadeIn 200ms var(--ease);
}

@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 上传区 ---------- */
.unified-upload-zone {
    display: grid;
    gap: 10px;
    margin: 0 0 24px;
    border: 1px dashed rgba(120, 120, 128, 0.35);
    border-radius: 18px;
    padding: 24px 20px 18px;
    background: transparent;
    text-align: center;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.unified-upload-zone:focus-within,
.unified-upload-zone:hover,
.unified-upload-zone.drag-active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.unified-upload-zone.drag-active {
    border-style: solid;
    border-width: 2px;
    transform: scale(1.005);
    box-shadow: 0 0 0 4px var(--accent-soft), 0 8px 24px rgba(0, 0, 0, 0.12);
}

.unified-upload-title {
    margin: 0;
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
}

.unified-upload-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
}

.unified-upload-options {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    margin-top: 14px;
    border-top: 0;
}

.unified-upload-target {
    position: relative;
    display: flex;
    min-height: 132px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    background: rgba(120, 120, 128, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease,
                box-shadow 160ms ease, transform 160ms ease;
}

.unified-upload-target:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.08);
}

.unified-upload-target:active { transform: scale(0.995); }

.upload-target-title {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.upload-target-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.upload-target-button,
.drop-zone-browse {
    display: inline-flex;
    min-height: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 11px;
    color: var(--text-secondary);
    background: var(--control-surface);
    font-size: 12px;
    pointer-events: none;
}

.file-select input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.unified-upload-options #imageFilePicker,
.unified-upload-options #videoFileInput {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.drop-zone-count {
    justify-self: center;
    width: auto;
    max-width: 100%;
    min-height: 20px;
    height: auto;
    border: 0;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
    font-size: 12px;
    text-align: center;
}

/* ---------- 实时预览 ---------- */
.live-preview {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin: 14px 0 4px;
}

.live-preview[hidden] { display: none; }

.live-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(120, 120, 128, 0.06);
}

.live-preview-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.preview-nav.compact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.preview-nav.compact button {
    width: 28px;
    height: 28px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.preview-nav.compact button:active {
    transform: scale(0.9);
    background: rgba(120, 120, 128, 0.12);
}

.preview-nav.compact .preview-counter {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: 13px;
}

.live-preview-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    max-height: 340px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(120, 120, 128, 0.06);
}

.live-preview-stage img,
.live-preview-stage video {
    display: block;
    max-width: 100%;
    max-height: 340px;
    object-fit: contain;
}

.live-preview-stage img[hidden],
.live-preview-stage video[hidden] { display: none; }

/* ---------- 视频工作区 ---------- */
.main-decode-area {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    align-items: stretch;
    gap: 24px;
}

.video-preview-box {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: var(--shadow-panel);
}

.video-header {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--text-secondary);
}

.video-preview-title {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
}

#video-dim {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.video-wrapper {
    position: relative;
    display: grid;
    min-height: 240px;
    aspect-ratio: 16 / 9;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(120, 120, 128, 0.12);
    border-radius: 14px;
    background: #F1F1F4;
    cursor: pointer;
    touch-action: pan-y;
}

html[data-theme="dark"] .video-wrapper { background: #171719; }

.video-wrapper:fullscreen {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    border-radius: 0;
    background: #000;
}

.video-wrapper canvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.video-empty-state {
    position: absolute;
    z-index: 0;
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

.video-loading {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.video-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.video-preview-box:has(#video-dim:not(:empty)) .video-empty-state { display: none; }

.action-strip.video-actions {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

/* ---------- 按钮通用 ---------- */
.action-btn,
.img-action-btn,
.custom-alert-btn,
.btn-close,
.large-image-warning-choice,
.large-image-warning-ok {
    display: inline-flex;
    min-height: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    padding: 0 14px;
    color: var(--text);
    background: var(--control-surface);
    box-shadow: var(--control-shadow);
    font-weight: 650;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    transition: transform 180ms var(--ease), color 180ms var(--ease),
                background 180ms var(--ease), border-color 180ms var(--ease),
                box-shadow 180ms var(--ease), opacity 180ms var(--ease);
}

.action-btn:hover:not(:disabled),
.img-action-btn:hover:not(:disabled),
.custom-alert-btn:hover,
.btn-close:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.1);
}

.action-btn:active:not(:disabled),
.img-action-btn:active:not(:disabled),
.custom-alert-btn:active,
.btn-close:active:not(:disabled),
.large-image-warning-choice:active,
.large-image-warning-ok:active {
    transform: translateY(1px) scale(0.985);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.action-btn.primary,
.img-action-btn.primary,
.custom-alert-btn,
.btn-close,
.large-image-warning-choice.primary,
.large-image-warning-ok {
    color: #FFFFFF;
    border: 1px solid rgba(0, 122, 255, 0.12);
    background: linear-gradient(180deg, #0A84FF 0%, #007AFF 100%);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.32);
}

.action-btn.primary:hover:not(:disabled),
.img-action-btn.primary:hover:not(:disabled),
.custom-alert-btn:hover,
.btn-close:hover:not(:disabled),
.large-image-warning-choice.primary:hover,
.large-image-warning-ok:hover {
    color: #FFFFFF;
    background: linear-gradient(180deg, #2794FF 0%, #0877ED 100%);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.36);
}

.action-btn.primary:active:not(:disabled),
.img-action-btn.primary:active:not(:disabled),
.custom-alert-btn:active,
.btn-close:active:not(:disabled),
.large-image-warning-choice.primary:active,
.large-image-warning-ok:active {
    transform: scale(0.98);
    background: linear-gradient(180deg, #006FE6 0%, #0064D1 100%);
    box-shadow: 0 1px 3px rgba(0, 77, 164, 0.3);
}

.action-btn:not(.primary),
.img-action-btn:not(.primary) {
    color: var(--text-secondary);
    background: var(--control-surface);
    border: 1px solid var(--control-border);
}

.img-action-btn.small {
    min-height: 38px;
    height: 38px;
    padding: 0 12px;
    font-size: 0.94rem;
}

.img-action-btn.highlight {
    color: #FFFFFF;
    border-color: transparent;
    background: var(--success);
    box-shadow: 0 5px 14px rgba(22, 132, 91, 0.2);
}

/* ---------- 图片工作区 ---------- */
.image-workspace {
    display: grid;
    gap: 20px;
}

.image-header-actions {
    display: block;
    margin: 0;
}

.image-primary-actions.core-actions,
.video-primary-actions.core-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.video-primary-actions.core-actions .action-btn {
    width: 100%;
    height: 56px;
    min-height: 56px;
    font-size: 15px;
    font-weight: 600;
}

/* 解密预览是次要操作，占满一整行，避免三个按钮挤压换行
   （仅在存在“导出解密视频”按钮时生效，兼容旧版页面） */
.video-primary-actions.core-actions:has(#startExportDecryptBtn) #startDecodeBtn {
    grid-column: 1 / -1;
    height: 48px;
    min-height: 48px;
}

.video-export-btn {
    width: 100%;
    margin-top: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid var(--control-border);
    background: var(--control-surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.video-export-btn:hover:not(:disabled) {
    background: var(--panel-soft);
    border-color: var(--accent);
}

.video-export-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 视频信息栏 */
.video-info-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}
.video-info-bar[hidden] { display: none; }
.video-info-item {
    font-weight: 500;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.video-info-sep {
    color: var(--text-muted);
    opacity: 0.5;
}

/* 录制中动画 */
.video-export-btn.recording {
    animation: recordingPulse 1.5s ease-in-out infinite;
    border-color: var(--accent);
    color: var(--accent);
}

@keyframes recordingPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4); }
    50% { opacity: 0.85; box-shadow: 0 0 0 8px rgba(0, 122, 255, 0); }
}

.video-primary-actions #startDecodeBtn.secondary-action {
    color: var(--text-secondary);
    background: var(--control-surface);
    border-color: var(--control-border);
}

.core-actions .img-action-btn {
    width: 100%;
    height: 56px;
    min-height: 56px;
    font-size: 15px;
    font-weight: 600;
}

#startDecryptImg.secondary-action {
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: rgba(120, 120, 128, 0.12);
    box-shadow: none;
}

#startDecryptImg.secondary-action:hover:not(:disabled) {
    background: rgba(120, 120, 128, 0.18);
}

#startDecryptImg.secondary-action:active:not(:disabled) {
    background: rgba(120, 120, 128, 0.24);
}

/* 导出栏：进度 + 下载，无卡片 */
.image-export-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 0 16px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.image-export-bar progress {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    height: 6px;
}

.image-export-bar #downloadAllBtn {
    flex: 0 0 auto;
    display: inline-flex;
    min-height: 34px;
    height: 34px;
    padding: 0 16px;
    font-size: 13px;
}

/* ---------- 设置区 ---------- */
.visible-image-settings,
.visible-video-settings {
    display: grid;
    gap: 0;
    margin: 0;
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.visible-image-settings .setting-row,
.visible-video-settings .setting-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    min-height: 60px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 10px 0;
    background: transparent;
    text-align: left;
}

.visible-image-settings .setting-row > label,
.visible-image-settings .method-info .label,
.visible-video-settings .setting-row > label,
.visible-video-settings .method-info .label,
.setting-label,
.key-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.visible-image-settings .export-format-wrapper select,
.visible-image-settings .key-input-wrapper .key-value,
.visible-video-settings .export-format-wrapper select,
.visible-video-settings .key-input-wrapper .key-value {
    width: 100%;
    max-width: none;
    min-width: 0;
}

.method-info.setting-row,
.video-block-params.setting-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 14px;
    width: 100%;
    align-items: center;
}

.method-segments {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: 11px;
    background: rgba(120, 120, 128, 0.1);
    width: 100%;
}

.method-segments label {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    padding: 8px 6px;
    font-size: 12px;
    text-align: center;
    color: var(--text-secondary);
    background: transparent;
    transition: background-color 180ms var(--ease), color 180ms var(--ease);
}

.method-segments label:active { transform: scale(0.965); }

.method-segments input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.method-segments label:has(input:checked) {
    background: var(--panel-solid);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ---------- 表单控件 ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
.key-value,
.export-format-wrapper select,
.param-row input,
.param-row select,
#batchCount,
#batchFormat {
    min-height: 44px;
    height: 44px;
    width: 100%;
    min-width: 0;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    padding: 0 14px;
    color: var(--text);
    background: var(--control-surface);
    outline: none;
}

input[type="range"] {
    height: 6px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(120, 120, 128, 0.16);
    accent-color: var(--accent);
}

/* ---------- 进度条 ---------- */
progress {
    display: block;
    width: 100%;
    min-width: 48px;
    height: 8px;
    overflow: hidden;
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: var(--track);
    accent-color: var(--accent);
}

progress::-webkit-progress-bar {
    border-radius: 999px;
    background: var(--track);
}

progress::-webkit-progress-value {
    border-radius: 999px;
    background: var(--accent);
    transition: width 140ms linear;
}

progress::-moz-progress-bar {
    border-radius: 999px;
    background: var(--accent);
}

/* ---------- 视频进度条 ---------- */
.video-export-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 22px;
}

.video-export-progress progress {
    flex: 1 1 auto;
    width: auto;
    height: 6px;
}

.video-export-progress #status-text {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

/* ---------- 高级设置折叠 ---------- */
.advanced-settings {
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.advanced-settings > summary {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    list-style: none;
}

.advanced-settings > summary::-webkit-details-marker { display: none; }

.advanced-settings > summary::after {
    color: var(--text-muted);
    content: "+";
    font-size: 18px;
    font-weight: 400;
}

.advanced-settings[open] > summary::after { content: "−"; }

.advanced-content { padding: 0 0 16px; }

.video-advanced-settings .advanced-content .action-btn { width: 100%; }

/* ---------- 弹窗 ---------- */
.modal-overlay,
.custom-alert-overlay,
.large-image-warning-modal,
.large-image-compress-loader {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--overlay);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    backdrop-filter: blur(18px) saturate(130%);
}

.custom-alert-overlay { z-index: 3000; }
.large-image-warning-modal { z-index: 1200; padding: 18px; }
.large-image-compress-loader { z-index: 1300; }

.param-window,
.custom-alert,
.large-image-warning-window,
.large-image-compress-card {
    width: min(100%, 560px);
    max-height: min(88vh, 860px);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 24px;
    color: var(--text);
    background: var(--panel-solid);
    box-shadow: var(--shadow-popover);
    animation: panelMaterialize 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes panelMaterialize {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.param-window h2 {
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.param-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.param-row > label,
.param-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-soft);
}

.radio-group label {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    cursor: pointer;
}

.btn-close,
.custom-alert-btn {
    width: 100%;
    margin-top: 10px;
}

.encrypt-method-window { width: min(100%, 660px); }

#imgEncryptModeGroup {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 0;
    border: 0;
    background: transparent;
}

#imgEncryptModeGroup label {
    position: relative;
    display: flex;
    min-height: 72px;
    justify-content: center;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-soft);
    text-align: center;
}

#imgEncryptModeGroup label:has(input:checked) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

#imgEncryptModeGroup input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.batch-process-window { width: min(100%, 420px); }

.custom-alert { width: min(100%, 460px); }

.custom-alert-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.custom-alert-message {
    color: var(--text);
    line-height: 1.6;
    text-align: center;
    overflow-wrap: anywhere;
}

.custom-alert-buttons { display: flex; justify-content: center; }

/* 图片预览弹窗 */
.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

#previewModal .param-window {
    width: min(96vw, 1100px);
    max-width: 1100px;
    padding: 14px;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.preview-img-wrapper {
    display: grid;
    width: 100%;
    height: min(68vh, 760px);
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #111114;
}

#previewImg {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    touch-action: pan-x pan-y;
}

#previewImg:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    background: #000;
    object-fit: contain;
    cursor: zoom-out;
}

.preview-nav {
    display: flex;
    min-height: 48px;
    align-items: center;
    gap: 12px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel);
}

.preview-nav button {
    min-width: 42px;
    min-height: 38px;
    padding: 5px 11px;
    color: var(--accent);
    font-size: 1.15rem;
}

.preview-counter {
    min-width: 72px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    text-align: center;
    cursor: pointer;
}

/* 大图提醒弹窗 */
.large-image-warning-window { width: min(520px, 100%); }

.large-image-warning-window h3 {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 1.25rem;
}

.large-image-warning-window p {
    margin: 10px 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.large-image-warning-summary {
    max-height: 160px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 13px;
    color: var(--text-secondary);
    background: var(--panel-soft);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.large-image-warning-list { display: grid; gap: 9px; margin: 14px 0; }

.large-image-warning-item {
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-soft);
}

.large-image-warning-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.large-image-warning-choice,
.large-image-warning-ok { min-width: 132px; }

.large-image-compress-card { width: min(520px, 100%); }

.large-image-compress-title {
    margin-bottom: 8px;
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 700;
}

.large-image-compress-progress {
    height: 8px;
    overflow: hidden;
    margin: 16px 0 12px;
    border-radius: 999px;
    background: var(--track);
}

.large-image-compress-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    animation: largeImageProgress 1s ease-out forwards;
}

@keyframes largeImageProgress {
    from { width: 0; }
    to   { width: 100%; }
}

/* 视频块尺寸参数（块打乱模式可见） */
.video-block-params {
    display: none;
}
.video-block-params.setting-row {
    grid-template-columns: 110px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
}
.video-block-params input[type="number"] {
    width: 80px;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    border: 1px solid var(--control-border);
    border-radius: 12px;
    padding: 0 14px;
    color: var(--text);
    background: var(--control-surface);
    outline: none;
}
.video-block-params .dims-x {
    color: var(--text-muted);
    font-size: 14px;
}

/* 格式兼容性提示 */
.format-note {
    grid-column: 1 / -1;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}
.format-note.warn {
    color: #E67E22;
}
.format-note.ok {
    color: var(--success);
}

/* ---------- 隐藏节点（保留给 JS） ---------- */
.screen-reader-only,
.refresh-tab-btn.screen-reader-only,
.tab-container.screen-reader-only,
.tab-container.screen-reader-only .module-tab,
.hidden-legacy-control,
.legacy-controls,
.disclaimer-disclosure,
.disclaimer,
.footer,
#imageSpeedStatus,
#imageSpeedStatusText,
#imageCompatNote,
#exportConfigImg,
#resetToOriginalBtn,
#reencryptToggleBtn,
#encryptCounter,
#largeImageWarningHelp,
#packDownload,
#exportKeyFileCheckbox,
#xorToggle,
#largeImageWarningToggle,
.mirror-toggle,
.speed-status-pill,
.block-params-inline,
#hidden-video {
    display: none !important;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    body { padding: 18px 16px 60px; }

    .main-decode-area { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

@media (max-width: 640px) {
    body { padding: 16px 14px 56px; }

    #themeToggle {
        top: 12px;
        right: 12px;
        width: 34px;
        min-width: 34px;
        height: 34px;
        min-height: 34px;
    }

    .unified-upload-zone { padding: 20px 14px 14px; }
    .unified-upload-target { min-height: 120px; }

    .live-preview-stage {
        min-height: 160px;
        max-height: 240px;
    }

    .image-primary-actions.core-actions,
    .video-primary-actions.core-actions {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .core-actions .img-action-btn,
    .video-primary-actions.core-actions .action-btn {
        height: 52px;
        min-height: 52px;
    }

    .image-export-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .image-export-bar #downloadAllBtn {
        width: 100%;
        justify-content: center;
    }

    .visible-image-settings .setting-row,
    .method-info.setting-row,
    .visible-video-settings .setting-row,
    .video-block-params.setting-row {
        grid-template-columns: 82px minmax(0, 1fr);
        gap: 10px;
    }

    .method-segments { grid-template-columns: 1fr; }

    /* 块尺寸保持一行显示：标签 · 宽 · × · 高 */
    .visible-video-settings .video-block-params.setting-row {
        grid-template-columns: 72px 64px 14px 64px;
        justify-content: start;
        align-items: center;
    }

    .video-block-params.setting-row input[type="number"] {
        width: 64px;
    }

    /* 主题按钮固定在右上角，标题栏需要让出位置 */
    .module-tabs { padding-right: 48px; }

    .brand-title { font-size: 16px; }

    .param-window,
    .custom-alert,
    .large-image-warning-window,
    .large-image-compress-card {
        max-height: 90vh;
        padding: 20px;
    }

    #imgEncryptModeGroup { grid-template-columns: minmax(0, 1fr); }

    #imgEncryptModeGroup label {
        min-height: 52px;
        justify-content: flex-start;
    }

    .preview-img-wrapper { height: 58vh; }
    .preview-nav { gap: 6px; }
}

/* ---------- 无障碍 ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: more) {
    :root {
        --border: rgba(0, 0, 0, 0.28);
        --border-strong: rgba(0, 0, 0, 0.38);
    }
    html[data-theme="dark"] {
        --border: rgba(255, 255, 255, 0.34);
        --border-strong: rgba(255, 255, 255, 0.46);
    }
}