:root {
    --bg-color: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --surface: #ffffff;
    --border: #e2e8f0;

    --primary: #3b82f6;
    --primary-hover: #2563eb;

    --font-main: 'Inter', system-ui, sans-serif;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --text-main: #f8fafc;
        --text-muted: #94a3b8;
        --surface: #1e293b;
        --border: #334155;
    }
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    /* App fills viewport */
}

/* Base App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

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

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.select-input {
    background: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.select-input:focus {
    border-color: var(--primary);
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border);
}

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

.upload-btn {
    display: inline-block;
    cursor: pointer;
}

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

.btn-icon:hover {
    color: var(--text-main);
}

.w-full {
    width: 100%;
    margin-bottom: 0.5rem;
}

/* Palette Display */
.palette-container {
    flex: 1;
    display: flex;
    width: 100%;
}

.color-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    transition: background-color 0.4s ease;
    padding: 2rem 1rem;
}

.color-column:hover .col-actions {
    opacity: 1;
}

.col-actions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.action-btn {
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    color: inherit;
}

.action-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.action-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.action-btn.active svg {
    fill: currentColor;
}

/* Locked state */

.col-details {
    text-align: center;
    margin-bottom: 2rem;
}

.hex-val {
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.hex-val:hover {
    transform: scale(1.05);
    display: inline-block;
}

.color-name {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.8;
}

.contrast-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 1rem;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Tools Panel */
.tools-panel {
    display: flex;
    height: 250px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.panel-section {
    flex: 1;
    padding: 1.5rem;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.panel-section:last-child {
    border-right: none;
}

.panel-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

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

.section-header h3 {
    margin-bottom: 0;
}

/* UI Preview */
.ui-preview {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    height: 100%;
}

.ui-card {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.ui-title {
    margin-bottom: 0.5rem;
}

.ui-text {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.ui-actions {
    display: flex;
    gap: 0.5rem;
}

.ui-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
}

.ui-badges {
    display: flex;
    gap: 0.5rem;
}

.ui-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: scale(1.02);
}

.hist-color {
    flex: 1;
}

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-color);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    z-index: 1000;
    transition: var(--transition);
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
}

/* Responsive */
@media (max-width: 768px) {
    .palette-container {
        flex-direction: column;
    }

    .color-column {
        padding: 1rem;
        align-items: flex-start;
        justify-content: center;
    }

    .col-actions {
        position: static;
        transform: none;
        flex-direction: row;
        opacity: 1;
        margin-top: 0.5rem;
    }

    .action-btn {
        width: 32px;
        height: 32px;
    }

    .col-details {
        text-align: left;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 1rem;
        width: 100%;
        justify-content: space-between;
    }

    .hex-val {
        font-size: 1.1rem;
        margin: 0;
    }

    .tools-panel {
        flex-direction: column;
        height: auto;
    }
}