:root {
    --bg-primary: #0b0e14;
    --bg-secondary: #131924;
    --bg-card: rgba(23, 31, 46, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #ff7a00;
    --accent-amber: #ff7a00;
    --accent-gold: #f5a623;
    --accent-fuji: #10b981;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
.app-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.camera-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--accent-amber), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #ffffff;
}

.logo-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.badge {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Main Layout */
.app-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    height: calc(100vh - 66px);
    overflow: hidden;
}

/* Viewport Section */
.viewport-section {
    position: relative;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, #151c28 0%, #0b0e14 100%);
    overflow: hidden;
    padding: 1.5rem;
}

.drop-zone {
    flex: 1;
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.2s ease;
}

.drop-zone.drag-over {
    border-color: var(--accent-amber);
    background: rgba(255, 122, 0, 0.05);
}

.drop-prompt {
    text-align: center;
    cursor: pointer;
    padding: 2rem;
}

.drop-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.drop-prompt h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.drop-prompt p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.tag {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    color: var(--text-muted);
}

/* Split Comparison Container */
.comparison-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    user-select: none;
    overflow: hidden;
}

.image-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-wrapper img, .image-wrapper canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.processed-wrapper {
    /* Clipped via JS clip-path */
    z-index: 10;
}

.view-label {
    position: absolute;
    top: 1rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    border-radius: 4px;
    letter-spacing: 0.05em;
    pointer-events: none;
}

.label-original {
    left: 1rem;
    background: rgba(0, 0, 0, 0.65);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.label-processed {
    right: 1rem;
    background: rgba(255, 122, 0, 0.85);
    color: #ffffff;
    font-weight: 600;
}

/* Slider Handle */
.slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    margin-left: -20px;
    z-index: 20;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
}

.handle-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #ffffff;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}

.handle-button {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #ffffff;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 25;
}

/* Loading Overlay */
.render-overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 14, 20, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 40;
    gap: 1rem;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 122, 0, 0.2);
    border-top-color: var(--accent-amber);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Controls Sidebar */
.controls-sidebar {
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

/* Presets Grid */
.presets-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.preset-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.6rem;
    text-align: left;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: relative;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
}

.preset-btn.active {
    border-color: var(--accent-amber);
    background: rgba(255, 122, 0, 0.1);
}

.preset-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.preset-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    width: fit-content;
}

.preset-badge.kodak { background: #d97706; color: #fff; }
.preset-badge.fuji { background: #059669; color: #fff; }
.preset-badge.vintage { background: #7c3aed; color: #fff; }
.preset-badge.bw { background: #4b5563; color: #fff; }
.preset-badge.custom { background: #e11d48; color: #fff; }

.preset-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: 3px;
    opacity: 0.6;
    transition: all 0.2s;
}

.preset-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    opacity: 1;
}

.preset-btn strong {
    font-size: 0.85rem;
}

.preset-btn span {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.preset-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.85rem;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-text-sm {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-text-sm:hover {
    color: var(--accent-amber);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 420px;
    padding: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.05rem;
    color: #ffffff;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
}

.btn-close:hover {
    color: #fff;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 0.5rem;
}

/* Quartz Date Stamp Box */
.stamp-preview-box {
    background: #000000;
    border: 1px solid #222;
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.75rem;
}

.retro-stamp-display {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    letter-spacing: 0.15em;
    font-style: italic;
    color: var(--accent-amber);
    text-shadow: 0 0 10px rgba(255, 122, 0, 0.7), 0 0 20px rgba(255, 122, 0, 0.4);
}

.form-row {
    margin-bottom: 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-row label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-row select, .form-row input[type="text"] {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #fff;
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
}

.form-row select:focus, .form-row input[type="text"]:focus {
    border-color: var(--accent-amber);
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-picker-row input[type="color"] {
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
}

.color-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Sliders */
.slider-group {
    margin-bottom: 0.85rem;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.val-display {
    font-family: var(--font-mono);
    color: var(--accent-amber);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent-amber);
    cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-amber);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.55rem 1rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn-primary {
    background: var(--accent-amber);
    color: #ffffff;
}

.btn-primary:hover {
    background: #e66e00;
    box-shadow: 0 2px 10px rgba(255, 122, 0, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-accent {
    background: var(--accent-gold);
    color: #111;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 0.85rem;
    font-size: 0.95rem;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent-amber);
    cursor: pointer;
    font-size: 0.75rem;
}

/* Batch Bar */
.batch-bar {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.batch-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.3rem;
}

.batch-thumb {
    width: 52px;
    height: 52px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    cursor: pointer;
    flex-shrink: 0;
}

.batch-thumb.active {
    border-color: var(--accent-amber);
    box-shadow: 0 0 6px var(--accent-amber);
}

.batch-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

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

/* Responsive */
@media (max-width: 900px) {
    .app-main {
        grid-template-columns: 1fr;
        height: auto;
    }
    .viewport-section {
        height: 60vh;
    }
}
