:root {
    --bg-dark: #0a0b10;
    --card-bg: #161821;
    --neon-cyan: #00f2ff;
    --neon-purple: #7000ff;
    --text-main: #e0e0e0;
    --danger: #ff4d4d;
}

/* Base Setup */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }

body { 
    background-color: var(--bg-dark); 
    color: var(--text-main); 
    transition: background 0.3s;
    overflow-x: hidden;
}

body.light-theme {
    --bg-dark: #f0f2f5;
    --card-bg: #ffffff;
    --text-main: #1a1a1b;
    --neon-cyan: #007bff;
}

/* Header & Bars */
.header {
    background: var(--card-bg);
    padding: 15px;
    border-bottom: 2px solid var(--neon-cyan);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.logo-area h1 { font-size: 1.5rem; letter-spacing: 2px; }
.logo-area span { color: var(--neon-cyan); }

.header-right { display: flex; gap: 10px; }

.settings-bar, .action-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.btn-primary { background: var(--neon-cyan); color: #000; }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-outline { background: transparent; border: 1px solid var(--neon-cyan); color: var(--neon-cyan); }

.icon-btn {
    background: transparent;
    border: 1px solid #333;
    color: var(--text-main);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    width: 35px;
    height: 35px;
}

/* Main Container */
#preview-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    min-height: 80vh;
}

.empty-state { margin-top: 100px; color: #666; font-style: italic; }

/* Image Cards */
.image-card {
    position: relative;
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.image-card.selected { border-color: var(--neon-cyan); box-shadow: 0 0 15px rgba(0,242,255,0.3); }

.image-card img { width: 100%; display: block; }

/* TOOL BUTTONS (Restored) */
.card-tools {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-card:hover .card-tools { opacity: 1; }

.tool-btn {
    background: rgba(0,0,0,0.8);
    color: white;
    border: 1px solid var(--neon-cyan);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover { background: var(--neon-cyan); color: #000; }

.label-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    padding: 5px 10px;
    font-size: 12px;
}

/* Modals & Overlays */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hidden { display: none !important; }

.mobile-modal {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
}

/* Crop Workspace */
#cropWorkspace {
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    position: relative;
    margin: 15px 0;
    border: 1px solid #333;
}

#imageWrapper { position: relative; width: 100%; }
#imgToCrop { width: 100%; display: block; }

.crop-mask {
    position: absolute;
    left: 0; width: 100%;
    background: rgba(255, 0, 0, 0.4);
    pointer-events: none;
}
.crop-mask.top { top: 0; border-bottom: 2px dashed red; }
.crop-mask.bottom { bottom: 0; border-top: 2px dashed red; }

.crop-controls { padding: 10px 0; }
input[type="range"] { width: 100%; margin: 10px 0; accent-color: var(--neon-cyan); }

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 8px;
    background: #333;
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--neon-cyan);
    transition: width 0.3s;
}

.loader-box { text-align: center; color: white; }

/* Ensure tools show when the card is selected (for mobile) */
.image-card.selected .card-tools {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile-specific adjustments for tool buttons */
@media (max-width: 768px) {
    .card-tools {
        opacity: 0; /* Hidden by default */
        right: 15px;
        top: 15px;
        gap: 12px; /* Bigger gap for easier tapping */
    }

    .tool-btn {
        width: 44px;  /* Larger touch target for thumbs */
        height: 44px;
        font-size: 1.2rem;
        background: rgba(0, 0, 0, 0.9);
        border: 2px solid var(--neon-cyan);
    }
    
    .image-card.selected {
        border-width: 3px;
    }
}