/* ── Reset and Variables ── */
:root {
    --bg: #0a0a0f;
    --surface: #111118;
    --surface-elevated: #1a1a24;
    --border: #2a2a38;
    --border-hover: #3a3a50;
    --text-primary: #e8e8f0;
    --text-muted: #6b6b80;
    --text-secondary: #9090a8;
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-amber: #d29922;
    --font-mono: 'JetBrains Mono', monospace;
    --font-space: 'Space Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-mono);
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ── Typography & Global Utility ── */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 13px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mb-6 {
    margin-bottom: 24px;
}

.mt-4 {
    margin-top: 16px;
}

.mt-6 {
    margin-top: 24px;
}

.mt-16 {
    margin-top: 64px;
}

.pt-2 {
    padding-top: 8px;
}

.pt-4 {
    padding-top: 16px;
}

.pt-8 {
    padding-top: 32px;
}

.w-full {
    width: 100%;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-4 {
    gap: 16px;
}

.border-t {
    border-top: 1px solid var(--border);
}

.border-dark {
    border-color: var(--border);
}

/* ── Header ── */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 24px;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.logo {
    font-family: var(--font-space);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.02em;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 0.8;
}

.logo-dim {
    color: var(--text-muted);
    font-weight: 300;
}

.logo-accent {
    color: var(--accent-green);
}

.nav {
    display: flex;
    height: 100%;
}

.nav-tab {
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-tab:hover {
    color: var(--text-primary);
}

.nav-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* ── Main content ── */
.main-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 64px 24px;
}

/* ── Hero ── */
.hero {
    margin-bottom: 48px;
}

.title {
    font-family: var(--font-space);
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
}

.desc {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.2);
    color: var(--accent-green);
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

/* ── Panels ── */
.panel {
    display: none;
}

.panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Drop Zone ── */
.drop-zone {
    position: relative;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 64px 24px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    overflow: hidden;
}

.drop-zone:hover {
    border-color: var(--border-hover);
    background: var(--surface-elevated);
}

.drop-zone.dragover {
    border-color: var(--accent-green);
    background: rgba(63, 185, 80, 0.05);
}

.dz-icon {
    color: var(--text-muted);
    margin-bottom: 16px;
    transition: color 0.2s;
}

.drop-zone:hover .dz-icon {
    color: var(--text-primary);
}

.drop-zone.dragover .dz-icon {
    color: var(--accent-green);
}

.dz-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.hidden-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ── Workspace ── */
.workspace {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ── File Card & Merge List ── */
.file-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.fc-info {
    flex: 1;
    min-width: 0;
}

.fc-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.fc-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.fc-remove {
    color: var(--text-muted);
    font-size: 20px;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.fc-remove:hover {
    color: var(--accent-red);
}

.merge-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

/* Draggable states */
.merge-list .file-card {
    cursor: grab;
}

.merge-list .file-card:active {
    cursor: grabbing;
}

.merge-list .file-card.dragging {
    opacity: 0.5;
    border-color: var(--accent-blue);
}

.merge-summary {
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 0;
    border-top: 1px solid var(--border);
    text-align: right;
    margin-bottom: 16px;
}

/* ── Controls & Buttons ── */
.control-group {
    margin-bottom: 24px;
}

.control-label {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 500;
}

.slider-wrapper {
    position: relative;
    padding: 0 8px;
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    margin-bottom: 16px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: 2px solid var(--bg);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.action-bar {
    display: flex;
    justify-content: center;
}

.action-bar-spaced {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-blue);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: #4a96e6;
}

.btn-secondary {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--border-hover);
    background: var(--border);
}

.btn-large {
    padding: 12px 24px;
    font-size: 15px;
}

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

.link {
    color: var(--accent-blue);
}

.link:hover {
    text-decoration: underline;
}

/* ── Results & Progress ── */
.result-box {
    background: rgba(63, 185, 80, 0.05);
    border: 1px solid rgba(63, 185, 80, 0.2);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
}

.res-stats {
    font-size: 18px;
    color: var(--accent-green);
    font-weight: 600;
}

.progress-box {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-blue);
    width: 0%;
    transition: width 0.2s ease-out;
}

.progress-text {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

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

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

/* ── JPG Grid ── */
.jpg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    text-align: left;
}

.jpg-item {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jpg-thumb {
    width: 100%;
    aspect-ratio: 1 / 1.4;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
}

.jpg-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.btn-small {
    padding: 4px 8px;
    font-size: 11px;
}

/* ── Footer & Toast ── */
.footer {
    text-align: center;
    padding: 32px 24px;
    font-size: 13px;
    color: var(--text-muted);
}

.footer a {
    color: var(--text-primary);
}

.footer a:hover {
    text-decoration: underline;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ── Mobile ── */
@media (max-width: 640px) {
    .jpg-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .header {
        padding: 0 16px;
    }

    .logo {
        font-size: 13px;
    }

    .nav-tab {
        padding: 0 12px;
        font-size: 12px;
    }

    .title {
        font-size: 28px;
    }
}