:root {
    --bg: #0d1117;
    --bg-soft: #161b22;
    --bg-elevated: #21262d;
    --border: #30363d;
    --border-muted: #21262d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #2f81f7;
    --accent-hover: #1f6feb;
    --accent-grad: linear-gradient(135deg, #2f81f7, #1f6feb);
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --shadow: 0 8px 24px rgba(0,0,0,.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
    --radius: 12px;
    --radius-sm: 8px;
    --touch: 44px;
    --transition: .25s cubic-bezier(.4,0,.2,1);
}

* { 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;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

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

/* ===== Topbar ===== */
.topbar {
    background: rgba(22,27,34,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    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: 700;
    font-size: 16px;
    text-decoration: none;
}
.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: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: transparent;
    transition: var(--transition);
    min-height: var(--touch);
    display: inline-flex;
    align-items: center;
}
.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 ===== */
.hero { text-align: center; margin: 16px 0 32px; animation: fadeInUp .5s ease; }
.hero-badge {
    display: inline-block;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 6px 16px;
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 16px;
    font-weight: 500;
}
.hero h1 {
    font-size: 32px;
    margin: 0 0 10px;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-sub { color: var(--text-muted); margin: 0 auto; font-size: 15px; max-width: 560px; }

/* ===== Dropzone ===== */
.dropzone-section { margin-bottom: 24px; }
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--bg-soft);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dropzone:hover, .dropzone:focus {
    border-color: var(--accent);
    background: #161b22;
    color: var(--text);
    outline: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.dropzone.drag-over {
    border-color: var(--success);
    background: #0d2818;
    color: var(--success);
    transform: scale(1.01);
}
.dropzone-guide, .dropzone-active { width: 100%; }
.dropzone-active { animation: bounceIn .3s ease; }
.dropzone svg { color: var(--text-muted); transition: color .2s; }
.dropzone:hover svg, .dropzone:focus svg { color: var(--accent); }
.dropzone.drag-over svg { color: var(--success); }
.guide-icon { animation: float 3s ease-in-out infinite; }
.dropzone-title { font-size: 17px; font-weight: 600; margin: 14px 0 4px; color: inherit; }
.dropzone-hint { font-size: 13px; margin: 0; color: var(--text-muted); }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
@keyframes bounceIn {
    0% { transform: scale(.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== 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);
    min-height: var(--touch);
}
.switch input { display: none; }
.switch-track {
    width: 40px;
    height: 24px;
    border-radius: 12px;
    background: var(--border);
    position: relative;
    transition: background .2s;
    flex: none;
}
.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    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 Bar ===== */
.status-bar {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
    animation: fadeInUp .3s ease;
}
.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
}
.status-left { display: flex; align-items: center; gap: 10px; }
.status-text { color: var(--text); }
.status-count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.status-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex: none;
}
.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;
    border-radius: 3px;
    position: relative;
}
.progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Results ===== */
.results { margin-top: 8px; animation: fadeInUp .4s ease; }
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.results-header h2 { font-size: 20px; margin: 0; }
.results-actions { display: flex; gap: 8px; }

/* ===== Buttons ===== */
.btn {
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    min-height: var(--touch);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}
.btn:hover { background: #30363d; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
    background: var(--accent-grad);
    border-color: transparent;
    color: #fff;
}
.btn-primary:hover { filter: brightness(1.15); }
.btn-secondary { background: var(--bg-elevated); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ===== Results Grid ===== */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.result-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    animation: cardIn .35s ease backwards;
}
.result-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow); }
@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.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;
    transition: transform .3s;
}
.result-card:hover .result-thumb img { transform: scale(1.03); }
.result-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,.75);
    color: var(--text);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    font-weight: 500;
}
.result-badge.warn { color: var(--warning); }
.result-badge.ok { color: var(--success); }
.result-badge.err { color: var(--danger); }
.result-info {
    padding: 12px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.result-name {
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    font-size: 13px;
}
.result-meta { color: var(--text-muted); }
.result-actions { display: flex; gap: 6px; margin-top: 8px; }
.result-actions .btn { padding: 8px 12px; font-size: 13px; flex: 1; min-height: 40px; }

/* ===== Lightbox ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(1,4,9,.94);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 24px;
    animation: fadeIn .2s ease;
    touch-action: pan-y;
}
.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: var(--radius-sm);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: opacity .15s;
}
.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: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
}
.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: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    min-height: var(--touch);
    transition: var(--transition);
}
.toggle-btn.active { background: var(--accent-grad); border-color: transparent; color: #fff; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .2s ease; }
.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: var(--radius);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px 32px;
    box-shadow: var(--shadow);
    animation: modalIn .3s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    width: var(--touch);
    height: var(--touch);
    display: flex;
    align-items: center;
    justify-content: center;
}
.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 {
    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;
    width: 100%;
    max-width: 400px;
    padding: 0 16px;
}
.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 14px;
    animation: toastIn .25s ease;
    width: 100%;
    text-align: center;
}
.toast.success { border-color: var(--success); }
.toast.warning { border-color: var(--warning); }
.toast.error { border-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Celebration ===== */
.celebration-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    pointer-events: none;
}
.celebration-overlay[hidden] { display: none; }
.celebration-check {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
}
.celebration-check circle {
    fill: none;
    stroke: var(--success);
    stroke-width: 3;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    animation: drawCircle .6s ease forwards;
}
.celebration-check path {
    fill: none;
    stroke: var(--success);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: drawCheck .4s .5s ease forwards;
}
@keyframes drawCircle { to { stroke-dashoffset: 0; } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }

.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    animation: confettiFall 1.2s ease-out forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(300px) rotate(360deg); opacity: 0; }
}

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

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .topbar-inner { padding: 10px 16px; }
    .brand-text { font-size: 14px; }
    .link-btn { padding: 6px 10px; font-size: 13px; }
    .container { padding: 16px 16px 32px; }
    .hero { margin: 8px 0 20px; }
    .hero h1 { font-size: 24px; }
    .hero-sub { font-size: 14px; }
    .dropzone { padding: 36px 16px; min-height: 180px; }
    .dropzone-title { font-size: 15px; }
    .dropzone-hint { font-size: 12px; }
    .guide-icon { width: 48px; height: 48px; }
    .results-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .results-header h2 { font-size: 18px; }
    .results-actions { width: 100%; }
    .results-actions .btn { flex: 1; }
    .lightbox { padding: 16px; }
    .lightbox-close { top: 12px; right: 12px; width: 44px; height: 44px; }
    .lightbox-nav { width: 44px; height: 44px; }
    .lightbox-prev { left: 8px; }
    .lightbox-next { right: 8px; }
    .lightbox-image-container img { max-height: 60vh; }
    .lightbox-hint { font-size: 12px; }
    .toast-container { bottom: 16px; }
    .modal-content { padding: 24px 20px; }
}

@media (max-width: 480px) {
    .hero h1 { font-size: 20px; }
    .hero-badge { font-size: 12px; padding: 4px 12px; }
    .dropzone { padding: 28px 12px; }
    .settings { font-size: 13px; }
    .switch-label { font-size: 13px; }
    .result-actions .btn { font-size: 12px; padding: 8px 8px; }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
