:root {
    --bg: #0a0a0a;
    --surface: rgba(18, 18, 24, 0.85);
    --surface-hover: rgba(28, 28, 36, 0.95);
    --surface-elevated: rgba(24, 24, 32, 0.9);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.06);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #475569;
    --accent: #ec4899;
    --accent-light: #f472b6;
    --accent-dark: #db2777;
    --accent-glow: rgba(236, 72, 153, 0.15);
    --accent-soft: rgba(236, 72, 153, 0.08);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 15px rgba(236, 72, 153, 0.15);
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width-desktop: 220px;
    --sidebar-width-mobile: 56px;
}

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

html { scroll-behavior: smooth; }

/* Honour users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: radial-gradient(ellipse at 20% 30%, #0f0f14 0%, #0a0a0c 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Animated background orbs */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    pointer-events: none;
    z-index: 0;
}

body::before {
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.08) 0%, transparent 70%);
    top: -30%;
    right: -30%;
    animation: floatOrb 20s ease-in-out infinite;
}

body::after {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(244, 114, 182, 0.06) 0%, transparent 70%);
    bottom: -30%;
    left: -20%;
    animation: floatOrb 25s ease-in-out infinite reverse;
}

@keyframes floatOrb {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.4; }
    50% { transform: translate(3%, 3%) scale(1.1); opacity: 0.6; }
}

/* Header */
header {
    background: rgba(10, 10, 12, 0.8);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-icon img, .logo-icon i {
    width: 100%;
    height: 100%;
    object-fit: cover;
    font-size: 1rem;
    color: white;
}

.logo span {
    background: linear-gradient(135deg, #fff, var(--text-secondary));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.badge {
    font-size: 0.7rem;
    padding: 4px 12px;
    border-radius: 100px;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    font-weight: 500;
    white-space: nowrap;
}

/* App Container */
.app-container {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - 56px);
    position: relative;
    z-index: 1;
}

/* Sidebar - Mobile First Approach */
.sidebar {
    width: var(--sidebar-width-mobile);
    background: var(--surface);
    backdrop-filter: blur(12px);
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    /* Pin the tool nav so it stays reachable while the content scrolls */
    position: sticky;
    top: 56px;
    align-self: flex-start;
    height: calc(100vh - 56px);
    overflow-y: auto;
    border-right: 1px solid var(--glass-border);
    transition: width 0.2s ease;
}

.sidebar-section {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    padding: 12px 8px 4px;
    font-weight: 600;
    display: none;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 10px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    font-family: inherit;
    position: relative;
}

.tool-btn .tool-text {
    display: none;
}

.tool-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleX(0);
    width: 3px;
    height: 50%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    transition: transform var(--transition);
}

.tool-btn:hover::before,
.tool-btn.active::before {
    transform: translateY(-50%) scaleX(1);
}

.tool-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.tool-btn.active {
    background: linear-gradient(90deg, var(--accent-soft), transparent);
    color: var(--text-primary);
}

.tool-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    transition: all var(--transition-fast);
}

.tool-btn:hover .tool-icon {
    background: var(--accent-soft);
    transform: scale(1.05);
}

/* Desktop Sidebar */
@media (min-width: 769px) {
    .sidebar {
        width: var(--sidebar-width-desktop);
        padding: 16px 10px;
    }
    
    .sidebar-section {
        display: block;
        padding: 12px 12px 6px;
    }
    
    .tool-btn {
        justify-content: flex-start;
        gap: 10px;
        padding: 10px 12px;
    }
    
    .tool-btn .tool-text {
        display: inline;
        font-size: 0.85rem;
        font-weight: 500;
    }
    
    .tool-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

/* Main Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (min-width: 768px) {
    .content {
        padding: 24px 28px;
    }
}

/* Tool Panels */
.tool-panel {
    display: none;
    animation: fadeInScale 0.25s var(--transition);
}

.tool-panel.active {
    display: block;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.98) translateY(5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Typography - Compact */
h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

h2 i {
    color: var(--accent-light);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.85rem;
    padding-left: 12px;
    position: relative;
}

.subtitle::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--accent), var(--accent-light));
    border-radius: 2px;
}

/* Cards - Compact */
.card {
    background: var(--surface-elevated);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
    border: 1px solid var(--glass-border);
}

@media (min-width: 768px) {
    .card {
        padding: 20px 24px;
        margin-bottom: 20px;
    }
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: rgba(236, 72, 153, 0.2);
}

.card-header {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

/* Dropzone */
.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 14px;
    background: var(--glass);
}

@media (min-width: 768px) {
    .dropzone {
        padding: 32px 24px;
    }
}

.dropzone-icon {
    font-size: 2rem;
    margin-bottom: 6px;
    display: block;
    opacity: 0.7;
}

/* Buttons - Compact */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
}

@media (min-width: 768px) {
    .btn {
        padding: 8px 18px;
        font-size: 0.85rem;
    }
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.7rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

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

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0;
}

/* Form Elements - Compact */
select, input[type="text"], input[type="number"], textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.8rem;
    width: 100%;
    transition: all var(--transition-fast);
}

@media (min-width: 768px) {
    select, input[type="text"], input[type="number"], textarea {
        padding: 9px 12px;
        font-size: 0.85rem;
    }
}

label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Form Layouts - Tighter */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.form-row > div {
    flex: 1;
    min-width: 120px;
}

.form-col-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

@media (min-width: 768px) {
    .form-row {
        gap: 16px;
        margin-bottom: 16px;
    }
    .form-col-3 {
        gap: 16px;
        margin-bottom: 16px;
    }
}

/* Stat Grid - Compact */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

@media (min-width: 768px) {
    .stat-grid {
        gap: 14px;
    }
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    border: 1px solid var(--glass-border);
}

.stat-label {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: copy;
    transition: color var(--transition-fast);
}

.stat-value:hover {
    color: var(--accent-light);
}

.stat-value.small {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Result Area */
.result-area {
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.7rem;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    color: var(--success);
    line-height: 1.5;
}

/* ⌘K trigger button in header */
.cmdk-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 100px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.cmdk-trigger:hover {
    color: var(--text-primary);
    border-color: rgba(236, 72, 153, 0.3);
    background: var(--surface-hover);
}

.cmdk-trigger kbd,
.cmdk-foot kbd {
    font-family: inherit;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Command palette overlay */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(6, 6, 10, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    animation: cmdkFade 0.12s ease;
}

.cmdk-overlay[hidden] { display: none; }

@keyframes cmdkFade { from { opacity: 0; } to { opacity: 1; } }

.cmdk-box {
    width: min(560px, 92vw);
    background: var(--surface-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: cmdkPop 0.14s var(--transition);
}

@keyframes cmdkPop { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: none; } }

.cmdk-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-tertiary);
}

.cmdk-input-row input {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.cmdk-input-row input:focus { outline: none; }

.cmdk-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    max-height: 46vh;
    overflow-y: auto;
}

.cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
}

.cmdk-item .cmdk-ic {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-light);
}

.cmdk-item .cmdk-label { font-size: 0.9rem; font-weight: 500; color: var(--text-primary); }
.cmdk-item .cmdk-cat { margin-left: auto; font-size: 0.68rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; }

.cmdk-item.active,
.cmdk-item:hover {
    background: linear-gradient(90deg, var(--accent-soft), transparent);
    color: var(--text-primary);
}

.cmdk-item.active .cmdk-ic { background: var(--accent-soft); }

.cmdk-empty { padding: 20px; text-align: center; color: var(--text-tertiary); font-size: 0.85rem; }

.cmdk-foot {
    display: flex;
    gap: 16px;
    padding: 8px 16px;
    border-top: 1px solid var(--glass-border);
    font-size: 0.68rem;
    color: var(--text-tertiary);
}

.cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }

@media (max-width: 600px) {
    .cmdk-trigger-text, .badge-text { display: none; }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(30, 30, 38, 0.95);
    backdrop-filter: blur(16px);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 40px;
    font-weight: 500;
    font-size: 0.8rem;
    opacity: 0;
    transform: translateY(15px) scale(0.96);
    transition: all 0.2s var(--transition);
    pointer-events: none;
    z-index: 200;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
}

/* Scope tabs */
.scope-tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    border-color: transparent;
}

/* Color grading workspace: image + scopes on the left (pinned), controls on
   the right, so the picture, wheels and sliders are all visible while grading. */
.grade-workspace { display: grid; grid-template-columns: 1fr; gap: 0; }
.grade-visual, .grade-controls { min-width: 0; }

@media (min-width: 1024px) {
    .grade-workspace {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
        gap: 20px;
        align-items: start;
    }
    .grade-visual {
        position: sticky;
        top: 68px;
        align-self: start;
        max-height: calc(100vh - 78px);
        overflow-y: auto;
        padding-right: 4px;
    }
    /* keep the preview image from pushing the scopes below the fold */
    .grade-visual #preview-canvas { max-height: 40vh; width: auto; }
}

/* ---------- interaction polish ---------- */

/* Custom range sliders — accent track + thumb, consistent across browsers */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    padding: 0;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    border: none;
    cursor: pointer;
    vertical-align: middle;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: transform var(--transition-fast);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.18); }
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 4px; background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

/* Focus glow on text fields for a clearer, softer focus state */
select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Keyboard focus ring on interactive controls */
.btn:focus-visible,
.tool-btn:focus-visible,
.preset-chip:focus-visible,
.scope-tab:focus-visible,
input[type="range"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* Gentle reveal when results appear */
@keyframes ndReveal {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
.stat-grid,
.result-area,
#lut-result-card,
#cdl-result-card,
#data-rate-result,
#scenes-shot-table {
    animation: ndReveal 0.28s var(--transition);
}

/* Press feedback so buttons feel responsive */
.btn:active { transform: translateY(1px) scale(0.99); }
.preset-chip:active { transform: scale(0.96); }
.preset-chip:hover { border-color: var(--accent); color: var(--accent-light); }

/* Preset Chips */
.preset-chip {
    display: inline-block;
    padding: 4px 12px;
    background: var(--glass);
    border-radius: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    font-weight: 500;
    border: 1px solid var(--glass-border);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 3px;
    background: var(--glass-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    .btn-group {
        gap: 6px;
        margin: 10px 0;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
    
    .stat-grid {
        gap: 8px;
    }
    
    .stat-box {
        padding: 8px 10px;
    }
    
    .card-header {
        margin-bottom: 12px;
    }
    
    h2 {
        font-size: 1.2rem;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 190px;
    }
    
    .tool-btn .tool-text {
        font-size: 0.8rem;
    }
}