:root {
    --bg-dark: #0a0a0a;
    --card-bg: #1a1a1a;
    --gold: #d4af37;
    --gold-hover: #f1c40f;
    --text-white: #ffffff;
    --text-muted: #a0a0a0;
    --accent-red: #e74c3c;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-white);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

.brand-logo {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    letter-spacing: 2px;
    color: var(--gold);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.preview-panel {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: radial-gradient(circle, #2a2a2a 1px, transparent 1px);
    background-size: 20px 20px;
}

#mainCanvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: crosshair;
    touch-action: none;
}

.controls-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 25px;
    border-radius: 50px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-group label {
    font-size: 0.8rem;
    white-space: nowrap;
}

input[type="range"] {
    accent-color: var(--gold);
    width: 150px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.brows-gallery {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid rgba(212, 175, 55, 0.1);
}

.brows-gallery h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--gold);
    text-align: center;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    overflow-y: auto;
    padding-right: 5px;
}

.gallery-item {
    background: #252525;
    border-radius: 8px;
    aspect-ratio: 16/9;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gallery-item:hover {
    border-color: rgba(212, 175, 55, 0.5);
    background: #333;
}

.gallery-item.active {
    border-color: var(--gold);
    background: #333;
}

.gallery-item img {
    width: 80%;
    height: auto;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

.btn {
    padding: 12px 20px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--gold);
    color: #000;
}

.btn-primary:hover {
    background: var(--gold-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: #333;
    color: var(--text-white);
}

.btn-secondary:hover {
    background: #444;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

.btn-outline:hover {
    background: var(--accent-red);
    color: white;
}

.app-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

.faces-gallery {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid rgba(212, 175, 55, 0.1);
}

.faces-gallery h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--gold);
    text-transform: uppercase;
}

.faces-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.face-item {
    min-width: 60px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid transparent;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.face-item:hover {
    border-color: rgba(212, 175, 55, 0.5);
}

.face-item.active {
    border-color: var(--gold);
}

.face-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.color-controls {
    margin-top: 20px;
    text-align: center;
}

.color-controls h4 {
    font-size: 0.8rem;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.color-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.color-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.color-btn[data-color="original"] {
    background: linear-gradient(45deg, #333, #666);
}

.color-btn.active::after {
    content: '✓';
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.color-btn:hover {
    transform: scale(1.1);
}

/* Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: var(--gold);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}