:root {
    --bg: #0d1117;
    --bg-soft: #161b22;
    --bg-elevated: #21262d;
    --border: #30363d;
    --border-muted: #21262d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #2f81f7;
    --accent-hover: #1f6feb;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --shadow: 0 8px 24px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Helvetica, Arial, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 600;
    font-size: 16px;
}
.brand:hover { text-decoration: none; }
.brand-logo { color: var(--accent); flex: none; }
.topbar-actions { display: flex; gap: 8px; }
.link-btn {
    color: var(--text-muted);
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: transparent;
}
.link-btn:hover { color: var(--text); background: var(--bg-elevated); text-decoration: none; }

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 48px;
    width: 100%;
    flex: 1;
}
.hero { text-align: center; margin: 24px 0 32px; }
.hero h1 { font-size: 28px; margin: 0 0 8px; }
.hero-sub { color: var(--text-muted); margin: 0; font-size: 15px; }

/* Dropzone */
.dropzone-section { margin-bottom: 24px; }
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--bg-soft);
    transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone:focus {
    border-color: var(--accent);
    background: #161b22;
    color: var(--text);
    outline: none;
}
.dropzone.drag-over {
    border-color: var(--success);
    background: #0d2818;
    color: var(--success);
}
.dropzone svg { color: var(--text-muted); transition: color .2s; }
.dropzone:hover svg, .dropzone:focus svg { color: var(--accent); }
.dropzone-title { font-size: 16px; font-weight: 600; margin: 12px 0 4px; color: inherit; }
.dropzone-hint { font-size: 13px; margin: 0; color: var(--text-muted); }

/* Settings */
.settings {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    color: var(--text-muted);
}
.switch input { display: none; }
.switch-track {
    width: 38px;
    height: 22px;
    border-radius: 11px;
    background: var(--border);
    position: relative;
    transition: background .2s;
    flex: none;
}
.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text);
    transition: transform .2s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch-label { color: var(--text); }

/* Status */
.status-bar {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}
.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
}
.status-text { color: var(--text); }
.status-count { color: var(--text-muted); }
.progress {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    transition: width .3s ease;
}

/* Results */
.results { margin-top: 8px; }
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.results-header h2 { font-size: 18px; margin: 0; }
.results-actions { display: flex; gap: 8px; }
.btn {
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: #30363d; }
.btn-primary {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}
.btn-primary:hover { background: #388bfd; }
.btn-secondary { background: var(--bg-elevated); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.result-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color .2s, transform .2s;
    display: flex;
    flex-direction: column;
}
.result-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.result-thumb {
    position: relative;
    aspect-ratio: 1;
    background: #000;
    cursor: pointer;
    overflow: hidden;
}
.result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.result-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,.75);
    color: var(--text);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
}
.result-badge.warn { color: var(--warning); }
.result-badge.ok { color: var(--success); }
.result-badge.err { color: var(--danger); }
.result-info {
    padding: 10px 12px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.result-name {
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-meta { color: var(--text-muted); }
.result-actions { display: flex; gap: 6px; margin-top: 6px; }
.result-actions .btn { padding: 4px 10px; font-size: 12px; flex: 1; text-align: center; }

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(1,4,9,.92);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox-image-container {
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.lightbox-image-container img {
    max-width: 90vw;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
}
.lightbox-hint, .lightbox-filename {
    color: var(--text-muted);
    font-size: 13px;
    margin: 8px 0 0;
    text-align: center;
}
.lightbox-close, .lightbox-nav {
    position: absolute;
    background: rgba(255,255,255,.08);
    border: 1px solid var(--border);
    color: var(--text);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,.18); }
.lightbox-close { top: 20px; right: 24px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); }
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }
.lightbox-nav:disabled { opacity: .3; cursor: not-allowed; }
.lightbox-toggles {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}
.toggle-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.toggle-btn.active { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-content {
    position: relative;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px 32px;
    box-shadow: var(--shadow);
}
.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}
.modal h2 { margin: 0 0 12px; font-size: 20px; }
.modal h3 { font-size: 15px; margin: 16px 0 6px; color: var(--text); }
.modal p { color: var(--text-muted); font-size: 14px; margin: 8px 0; }
.modal-pre, .modal pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-size: 12px;
    color: var(--text);
    overflow-x: auto;
}
.modal ul { color: var(--text-muted); font-size: 14px; padding-left: 20px; }
.modal li { margin: 6px 0; }

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 14px;
    animation: toast-in .25s ease;
}
.toast.success { border-color: var(--success); }
.toast.warning { border-color: var(--warning); }
.toast.error { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-muted);
}

/* Spinner */
.spinner {
    display: inline-block;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
    .hero h1 { font-size: 22px; }
    .dropzone { padding: 32px 16px; }
    .results-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .lightbox-prev { left: 8px; }
    .lightbox-next { right: 8px; }
}