/* ==========================================================================
   tools.css — 工作台（Studio）专用样式：布局、面板、文件列表、历史
   ========================================================================== */

/* ─── Studio Layout ───────────────────────────────────── */
.studio-layout {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 40px;
}
.studio-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
    flex-wrap: wrap;
}
.studio-header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.studio-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* Back button */
.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }
.back-btn:active { transform: scale(0.96); }

/* Action buttons */
.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    transition: all var(--transition-fast);
}
.action-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.action-btn:active:not(:disabled) { transform: scale(0.95); box-shadow: none; }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.action-btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.action-btn.primary:active:not(:disabled) { transform: scale(0.95); background: var(--accent); }
/* Download/primary btn pulse when newly enabled */
.action-btn.primary.pulse-hint:not(:disabled) {
    animation: btnPulseHint 2s ease-in-out 2;
}
@keyframes btnPulseHint {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
    50% { box-shadow: 0 0 0 6px rgba(99,102,241,0.2); }
}
/* Success flash on action buttons */
.action-btn.success-flash {
    animation: btnSuccessFlash 0.6s ease;
}
@keyframes btnSuccessFlash {
    0% { background: var(--accent); }
    30% { background: var(--success); }
    100% { background: var(--accent); }
}

/* ─── Upload Zone ─────────────────────────────────────── */
.studio-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-height) - 140px);
}
.upload-zone {
    width: 100%;
    max-width: 560px;
    padding: 64px 40px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--bg-secondary);
    position: relative;
}
.upload-zone:hover, .upload-zone:focus-visible {
    border-color: var(--accent);
    background: var(--accent-light);
}
.upload-zone:hover .upload-zone-icon { transform: translateY(-3px) scale(1.05); }
.upload-zone.dragover {
    border-color: var(--accent);
    border-style: solid;
    background: var(--accent-light);
    transform: scale(1.02);
    box-shadow: 0 0 0 6px var(--accent-light), 0 0 30px rgba(99,102,241,0.12);
    animation: uploadPulse 1.2s ease-in-out infinite;
}
@keyframes uploadPulse {
    0%, 100% { box-shadow: 0 0 0 6px var(--accent-light), 0 0 30px rgba(99,102,241,0.12); }
    50% { box-shadow: 0 0 0 10px var(--accent-light), 0 0 50px rgba(99,102,241,0.2); }
}
.upload-zone.dragover .upload-zone-icon {
    animation: iconBounce 0.6s ease infinite;
    color: var(--accent);
}
@keyframes iconBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.08); }
}
.upload-zone.drag-reject {
    border-color: var(--danger);
    animation: shake 0.4s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}
.upload-zone-icon {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 20px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.upload-zone-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.upload-zone-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.upload-zone-formats { font-size: 12px; color: var(--text-tertiary); }

/* ─── Workspace Layout ────────────────────────────────── */
.studio-workspace {
    display: grid;
    grid-template-columns: 200px 1fr 220px;
    gap: 16px;
    min-height: calc(100vh - var(--nav-height) - 120px);
}

/* ─── File Sidebar ────────────────────────────────────── */
.file-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.file-sidebar-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.file-count { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.file-sidebar-actions { display: flex; gap: 2px; }
.icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 12px;
    transition: all var(--transition-fast);
}
.icon-btn:hover { background: var(--accent-light); color: var(--accent); }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); }
.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.file-thumb {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    aspect-ratio: 1;
    background: var(--bg-tertiary);
}
.file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}
.file-thumb:hover { border-color: var(--border-color); transform: scale(1.04); box-shadow: var(--shadow-sm); }
.file-thumb:hover img { transform: scale(1.05); }
.file-thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.file-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-thumb.selected::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.file-thumb-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px 6px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Workspace Main ──────────────────────────────────── */
.workspace-main {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

/* ─── Tool Tabs ───────────────────────────────────────── */
.tool-tabs {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
    overflow-x: auto;
}
.tool-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}
.tool-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.tool-tab:active { transform: scale(0.95); }
.tool-tab[aria-selected="true"], .tool-tab.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px rgba(99,102,241,0.25);
    animation: tabPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes tabPop {
    0% { transform: scale(0.93); }
    60% { transform: scale(1.04); }
    100% { transform: scale(1); }
}
.tool-tab i { font-size: 13px; }

/* ─── Preview Area ────────────────────────────────────── */
.preview-area {
    flex: 1;
    min-height: 300px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.preview-area canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.preview-info {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 14px;
    border-radius: var(--radius-full);
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.preview-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-tertiary); }

/* ─── Tool Panels ─────────────────────────────────────── */
.tool-panels { flex-shrink: 0; margin-top: 12px; }
.tool-panel {
    display: none;
    padding: 18px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    animation: panelIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.tool-panel.active { display: block; }
@keyframes panelIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.panel-row {
    margin-bottom: 16px;
}
.panel-row:last-child { margin-bottom: 0; }
.panel-row > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.panel-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 10px rgba(99,102,241,0.25); }
.btn-primary:active { background: var(--accent); box-shadow: none; }
.btn-primary.success-flash { animation: btnSuccessFlash 0.6s ease; }
.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary:active { background: var(--bg-tertiary); }

/* Slider */
.slider-group { display: flex; align-items: center; gap: 12px; }
.styled-range {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    transition: background var(--transition-fast);
    cursor: pointer;
}
.styled-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: grab;
    box-shadow: 0 2px 6px rgba(99,102,241,0.3);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.styled-range::-webkit-slider-thumb:hover { transform: scale(1.2); box-shadow: 0 3px 10px rgba(99,102,241,0.4); }
.styled-range::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.3); box-shadow: 0 0 0 6px rgba(99,102,241,0.15); }
.styled-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: grab;
    border: none;
    box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}
.styled-range::-moz-range-thumb:active { cursor: grabbing; }
.styled-range::-moz-range-progress {
    background: var(--accent);
    border-radius: 3px;
    height: 5px;
}
.slider-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    min-width: 36px;
    text-align: right;
    transition: transform 0.15s ease;
}
.slider-value.bump { animation: valueBump 0.2s ease; }
@keyframes valueBump {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Radio pills */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.radio-group.vertical { flex-direction: column; }
.radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
}
.radio-pill:hover { border-color: var(--accent); color: var(--accent); }
.radio-pill:active { transform: scale(0.95); }
.radio-pill.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    animation: pillPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pillPop {
    0% { transform: scale(0.92); }
    60% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.radio-pill input[type="radio"] { display: none; }

/* Input fields */
.input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.input-label { font-size: 12px; font-weight: 600; color: var(--text-tertiary); }
.styled-input {
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    width: 100%;
    max-width: 120px;
    transition: all var(--transition-fast);
}
.styled-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.input-suffix { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; }
.dimension-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}
.lock-ratio-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    border: 1px solid var(--border-color);
    font-size: 12px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.lock-ratio-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.lock-ratio-btn:hover { border-color: var(--accent); }

/* Estimate info */
.estimate-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    font-size: 12px;
    color: var(--text-secondary);
}

/* AI notice */
.ai-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    font-size: 12px;
    color: var(--accent);
    line-height: 1.5;
}
.ai-notice i { margin-top: 2px; flex-shrink: 0; }

/* Remove BG status bar */
.removebg-status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}
.removebg-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    transition: color 0.2s ease;
}
.removebg-status i { font-size: 10px; flex-shrink: 0; }
.removebg-status span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.removebg-status.idle { color: var(--text-tertiary); }
.removebg-status.idle i { color: var(--text-tertiary); }
.removebg-status.loading { color: var(--accent); }
.removebg-status.loading i { color: var(--accent); }
.removebg-status.ready { color: var(--success); }
.removebg-status.ready i { color: var(--success); }
.removebg-status.error { color: var(--danger); }
.removebg-status.error i { color: var(--danger); }
.btn.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
    gap: 4px;
    flex-shrink: 0;
}

/* Crop info */
.crop-info {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ─── History Sidebar ─────────────────────────────────── */
.history-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.history-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.history-header i { color: var(--text-tertiary); font-size: 13px; }
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    animation: historyItemIn 0.25s ease backwards;
}
.history-item:nth-child(n) { animation-delay: calc(var(--i, 0) * 0.03s); }
.history-item:hover { background: var(--bg-tertiary); color: var(--text-secondary); transform: translateX(2px); }
.history-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.history-item.dimmed { opacity: 0.4; }
@keyframes historyItemIn {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: translateX(0); }
}
.history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    flex-shrink: 0;
    transition: background var(--transition-fast);
}
.history-item.active .history-dot { background: var(--accent); }

/* ─── Placeholder ─────────────────────────────────────── */
.studio-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-height) - 140px);
    color: var(--text-tertiary);
    gap: 16px;
}
.studio-placeholder i { font-size: 48px; opacity: 0.3; }
.studio-placeholder p { font-size: 16px; font-weight: 500; }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {
    .studio-workspace {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .file-sidebar {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto;
        border-radius: var(--radius-md);
    }
    .file-sidebar-header { grid-column: 1 / -1; }
    .file-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
        gap: 8px;
        grid-column: 1 / -1;
    }
    .file-thumb {
        width: 64px;
        height: 64px;
        flex-shrink: 0;
        aspect-ratio: auto;
    }
    .history-sidebar { display: none; }
}
@media (max-width: 768px) {
    .studio-layout { padding: 0 12px 24px; }
    .studio-header { padding: 14px 0; gap: 10px; }
    .studio-header h1 { font-size: 17px; }
    .studio-header-actions { gap: 4px; }
    .action-btn { padding: 6px 10px; font-size: 12px; }
    .action-btn span { display: none; }
    .tool-tabs { gap: 2px; padding: 4px; }
    .tool-tab { padding: 8px 12px; font-size: 12px; gap: 4px; }
    .tool-tab span { display: none; }
    .tool-panel { padding: 14px; }
    .upload-zone { padding: 48px 24px; }
    .upload-zone-icon { font-size: 36px; }
    .upload-zone-title { font-size: 16px; }
    .preview-area { min-height: 200px; }
    .panel-actions { flex-wrap: wrap; }
    .btn { padding: 8px 14px; font-size: 12px; flex: 1; justify-content: center; }
    .file-thumb { width: 52px; height: 52px; }
}
@media (max-width: 480px) {
    .studio-header-actions { width: 100%; justify-content: flex-end; }
}

/* ==========================================================================
   PDF Studio Styles
   ========================================================================== */

/* PDF Panel system */
.pdf-panel { display: none; margin-top: 16px; }
.pdf-panel.active { display: block; animation: panelIn 0.2s ease; }

.pdf-upload-area {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 340px;
}

.pdf-workspace { animation: panelIn 0.25s ease; }

.pdf-options-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    flex-wrap: wrap;
}

.panel-row.inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}
.panel-row.inline > label {
    display: inline;
    margin-bottom: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* Styled select */
.styled-select {
    height: 34px;
    padding: 0 30px 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all var(--transition-fast);
}
.styled-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Page info */
.pdf-page-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    font-size: 13px;
    color: var(--text-secondary);
}
.pdf-info-sep { color: var(--border-color); }

/* Thumbnail grid */
.pdf-thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px 0;
}

.pdf-thumb-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: pointer;
    aspect-ratio: 3/4;
}
.pdf-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: white;
    transition: transform 0.3s ease;
}
.pdf-thumb-item:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.pdf-thumb-item:hover img { transform: scale(1.02); }
.pdf-thumb-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pdf-thumb-item.dragging { opacity: 0.5; transform: rotate(2deg) scale(1.02); }

.pdf-thumb-label {
    position: absolute;
    bottom: 6px;
    right: 6px;
    padding: 2px 8px;
    background: rgba(0,0,0,0.65);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.pdf-thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition-fast);
    z-index: 2;
}
.pdf-thumb-item:hover .pdf-thumb-remove { opacity: 1; }
.pdf-thumb-remove:hover { background: var(--danger); }

/* Delete page marking */
.pdf-thumb-item.deletable { cursor: pointer; }
.pdf-delete-marker {
    position: absolute;
    inset: 0;
    background: rgba(239, 68, 68, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.pdf-thumb-item.marked-delete {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px var(--danger-light);
    animation: markDelete 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes markDelete {
    0% { transform: scale(1); }
    30% { transform: scale(0.94); }
    60% { transform: scale(1.03); }
    100% { transform: scale(1); }
}
.pdf-thumb-item.marked-delete .pdf-delete-marker { opacity: 1; }
.pdf-thumb-item.marked-delete .pdf-delete-marker > i {
    animation: deleteIconPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes deleteIconPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.pdf-thumb-item.marked-delete img { filter: saturate(0.3) brightness(0.9); }

/* Drag hint */
.pdf-drag-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 8px 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pdf-drag-hint::before {
    content: '↕';
    font-size: 14px;
    color: var(--accent);
}

.pdf-delete-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

/* PDF file list (merge) */
.pdf-file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
}
.pdf-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}
.pdf-file-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
    transform: translateX(3px);
}
.pdf-file-item.dragging { opacity: 0.5; transform: rotate(1deg) scale(1.02); cursor: grabbing; }
.pdf-file-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pdf-file-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--danger-light);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.pdf-file-info { flex: 1; min-width: 0; }
.pdf-file-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pdf-file-pages {
    font-size: 11px;
    color: var(--text-tertiary);
}
.pdf-file-order {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pdf-add-more {
    padding: 12px 0;
}

/* ==========================================================================
   OCR Studio Styles
   ========================================================================== */

.ocr-upload-area {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-height) - 180px);
}

.ocr-workspace { animation: panelIn 0.25s ease; }

.ocr-options-bar {
    margin-bottom: 12px;
}

/* Preprocess toggle */
.ocr-preprocess-toggle {
    gap: 6px !important;
}
.ocr-preprocess-toggle .toggle-label {
    display: flex !important;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
}
.ocr-preprocess-toggle .toggle-label i {
    color: var(--accent);
    font-size: 12px;
}
.preprocess-hint {
    color: var(--text-tertiary);
    font-size: 12px;
    cursor: help;
    position: relative;
}
.preprocess-hint i { font-size: 12px; }

/* Toggle switch component */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    transition: var(--transition-fast);
}
.switch-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: var(--text-tertiary);
    border-radius: 50%;
    transition: var(--transition-fast);
}
.switch input:checked + .switch-slider {
    background: var(--accent);
    border-color: var(--accent);
}
.switch input:checked + .switch-slider::before {
    background: #fff;
    transform: translateX(16px);
}
.switch input:focus-visible + .switch-slider {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Image tabs */
.ocr-image-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 0;
    overflow-x: auto;
    flex-wrap: nowrap;
}
.ocr-image-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
}
.ocr-image-tab:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.ocr-image-tab:active { transform: scale(0.96); }
.ocr-image-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    animation: tabPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ocr-image-tab.done > i:first-child { color: var(--success); }
.ocr-image-tab.active.done > i:first-child { color: rgba(255,255,255,0.8); }
.ocr-image-tab.processing > i:first-child { color: var(--warning); }
.ocr-tab-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.ocr-tab-remove {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: inherit;
    opacity: 0.5;
    transition: all var(--transition-fast);
    margin-left: 2px;
}
.ocr-tab-remove:hover { opacity: 1; background: rgba(0,0,0,0.15); }

/* Dual pane layout */
.ocr-dual-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    min-height: calc(100vh - var(--nav-height) - 320px);
}

.ocr-image-pane {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 300px;
}
.ocr-image-pane img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Loading overlay */
.ocr-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: white;
    z-index: 5;
}
.ocr-loading-overlay p { font-size: 14px; font-weight: 500; }
.ocr-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ocr-progress-wrap span {
    font-size: 13px;
    font-weight: 600;
    min-width: 36px;
}

/* Text pane */
.ocr-text-pane {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ocr-text-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.ocr-text-content {
    flex: 1;
    padding: 16px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    outline: none;
    min-height: 200px;
}
.ocr-text-content:empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    font-style: italic;
}
.ocr-text-content:focus {
    box-shadow: inset 0 0 0 2px var(--accent-light);
}

/* Responsive */
@media (max-width: 768px) {
    .pdf-thumbnail-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    .pdf-options-bar {
        gap: 10px;
        padding: 10px 12px;
    }
    .ocr-dual-pane {
        grid-template-columns: 1fr;
    }
    .ocr-image-pane { min-height: 200px; }
    .ocr-image-tabs { padding: 4px 0; gap: 3px; }
    .ocr-image-tab { padding: 6px 10px; font-size: 11px; }
}
