:root {
    --bg-dark: #121212;
    --bg-card: #1E1E1E;
    --bg-hover: #2C2C2C;
    --text-main: #E0E0E0;
    --text-muted: #A0A0A0;
    --accent: #BB86FC;
    --accent-hover: #9965f4;
    --border: #333333;
    --radius: 12px;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.header-left {
    grid-column: 1;
    justify-self: start;
    display: flex;
    align-items: center;
}

.header-left h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.header-center {
    grid-column: 2;
    justify-self: center;
}

.app-logo {
    max-height: 100px;
    /* Increased to 100px */
    width: auto;
    object-fit: contain;
}

.icon {
    font-size: 1.6rem;
}

.global-controls {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    margin-left: 10px;
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 350px 1fr 320px;
    /* Widened left sidebar */
    flex: 1;
    overflow: hidden;
}

section {
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

section:last-child {
    border-right: none;
}

h2 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

h3 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    color: var(--text-main);
}

/* Tabs in Sidebar */
.sidebar-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: bold;
}

.tab-content {
    display: none;
    /* height: 100%; */
}

.tab-content.active {
    display: block;
}

/* Search Bar */
.search-bar {
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    font-family: var(--font-body);
}

.search-input:focus {
    border-color: var(--accent);
    outline: none;
}

/* Palette List */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.8rem;
}

.color-item {
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
    position: relative;
}

.color-item:hover {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Tooltip */
.color-item::after {
    content: attr(data-name);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 20;
}

.color-item:hover::after {
    opacity: 1;
}

.color-code-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.6rem;
    padding: 2px 4px;
    border-bottom-left-radius: 6px;
    border-top-right-radius: 50%;
    /* Match circular shape roughly */
    pointer-events: none;
    font-family: monospace;
}

.ownership-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    color: #555;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 5;
}

.ownership-btn:hover {
    background: #fff;
    color: #000;
}

.ownership-btn.owned {
    background: #4CAF50;
    /* Green */
    color: #fff;
    border-color: #4CAF50;
}

.ownership-btn.owned {
    background: #4CAF50;
    /* Green */
    color: #fff;
    border-color: #4CAF50;
}

/* Metallic Effect */
.metallic-shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0) 35%,
            rgba(255, 255, 255, 0.6) 50%,
            rgba(255, 255, 255, 0) 65%,
            rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    z-index: 5;
    mix-blend-mode: overlay;
    /* Or soft-light */
    opacity: var(--metallic-intensity, 1);
}

/* Harder shine for mixing bowl */
.mixing-bowl.metallic-shine::before {
    background: radial-gradient(circle at 30% 30%,
            rgba(255, 255, 255, 0.8) 0%,
            rgba(255, 255, 255, 0.2) 20%,
            rgba(255, 255, 255, 0) 60%);
    mix-blend-mode: normal;
    opacity: var(--metallic-intensity, 1);
}

/* Icon for catalog items */
.metallic-icon {
    position: absolute;
    bottom: 2px;
    left: 4px;
    color: #FFD700;
    /* Gold */
    font-size: 0.7rem;
    pointer-events: none;
    text-shadow: 0 0 2px black;
    z-index: 6;
}

/* Mixing Section Layout */
.mixing-layout-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    width: 100%;
}

.palette-side-logo {
    max-height: 250px;
    max-width: 250px;
    object-fit: contain;
}

@media (max-width: 1200px) {
    .mixing-layout-wrapper {
        flex-direction: column;
    }
}

.subtitle {
    font-size: 0.7rem;
    background: var(--accent);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 10px;
    font-weight: 700;
}

/* Malerpalette (Clean Grid) */
.palette-container {
    display: grid;
    /* Revert to flexible columns */
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    justify-content: center;
    padding: 2rem;
    flex: 1;
    /* Allow to grow */
    width: 100%;
}

.mixing-bowl {
    aspect-ratio: 1;
    border-radius: 50%;
    /* Ensure it fills the grid cell */
    width: 100%;
    min-width: 100px;
    /* Minimum reasonable size */
    background-color: var(--bg-card);
    box-shadow:
        inset 5px 5px 15px rgba(0, 0, 0, 0.8),
        /* Tiefer Schatten innen */
        inset -2px -2px 10px rgba(255, 255, 255, 0.05),
        /* Lichtkante */
        0 4px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    position: relative;
    border: none;
    transition: all 0.2s;
}

.mixing-bowl:hover {
    transform: scale(1.05);
}

.mixing-bowl.active {
    box-shadow:
        0 0 0 2px var(--accent),
        0 0 15px rgba(187, 134, 252, 0.4),
        inset 5px 5px 15px rgba(0, 0, 0, 0.8);
}

.mixing-bowl::after {
    content: attr(data-index);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: monospace;
}

/* Result Sidebar */
.result-card {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1.5rem;
}

.result-preview {
    width: 100%;
    height: 100px;
    border-radius: 8px;
    background-color: transparent;
    border: 1px solid var(--border);
    margin-bottom: 0.8rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.result-info span {
    display: block;
    font-family: monospace;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

#result-hex {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: bold;
}

/* Active Mix List */
.active-colors-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 100px;
}

.active-color-row {
    background: var(--bg-card);
    padding: 0.6rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.color-preview {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 10px;
}

.color-name {
    flex: 1;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drop-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.drop-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.drop-btn:hover {
    background: var(--bg-hover);
}

.drop-count {
    font-weight: bold;
    min-width: 18px;
    text-align: center;
    font-size: 0.9rem;
}

/* Controls */
.water-control {
    margin-top: 1rem;
    padding: 0.8rem;
    background: var(--bg-card);
    border-radius: var(--radius);
}

.water-control label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type=range] {
    width: 100%;
    margin-bottom: 0.2rem;
}

/* Harmony */
.harmony-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.harmony-swatch {
    width: 35px;
    height: 35px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border);
}

/* Error/Hints */
.hint,
.hint-small {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 1rem;
}

/* Projects List */
.projects-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.project-item {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.project-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.project-name {
    font-weight: bold;
    color: var(--text-main);
}

.project-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.project-preview-bar {
    display: flex;
    gap: 4px;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #000;
}

.project-preview-segment {
    flex: 1;
}

.delete-project-btn {
    background: transparent;
    border: none;
    color: #ff4444;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
}

.delete-project-btn:hover {
    color: #ff0000;
}

/* Label unter Mixing Bowl */
.mixing-bowl-label {
    position: absolute;
    bottom: -45px;
    /* Unter der Zahl */
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-main);
    font-size: 0.75rem;
    white-space: nowrap;
    max-width: 120%;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Fullscreen Overlay */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.fullscreen-overlay.hidden {
    display: none;
}

.btn-close-fullscreen {
    position: absolute;
    bottom: 50px;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.3s;
    font-family: var(--font-heading);
}

.btn-close-fullscreen:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
    border-color: #fff;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Calibration Panel */
.calibration-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius);
    z-index: 100;
    width: 250px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.calibration-panel.hidden {
    display: none;
}

/* Apply Calibration Filters */
:root {
    --cal-brightness: 100%;
    --cal-saturation: 100%;
}

.color-item,
.mixing-bowl,
.result-preview,
.project-preview-segment,
.color-preview,
.harmony-swatch {
    filter: brightness(var(--cal-brightness)) saturate(var(--cal-saturation));
}