/* Art0 Studio - Liquid Glass Design */
/* Performance-optimized with GPU acceleration */

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

:root {
    --bg-primary: #f5f5f7;
    --bg-glass: rgba(255, 255, 255, 0.25);
    --bg-glass-dark: rgba(10, 10, 12, 0.75);
    --bg-terminal: rgba(12, 12, 14, 0.88);
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --accent: #fbbf24;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    --accent-purple: #a855f7;
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-border-light: rgba(255, 255, 255, 0.08);
    --glass-shadow: rgba(31, 38, 135, 0.12);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Performance tiers - Tier A (full quality) is default */
    --mesh-blur: 60px;
    --mesh-blur-secondary: 80px;
    --orb-blur: 60px;
    --backdrop-blur: 40px;
    --mesh-animation-state: running;
}

html {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* Animated Mesh Gradient Background - GPU Accelerated */
.mesh-gradient {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--bg-primary);
    /* Force GPU layer for compositing */
    transform: translateZ(0);
    contain: strict;
}

.mesh-gradient::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background:
        radial-gradient(circle at 20% 30%, rgba(251, 191, 36, 0.22) 0%, transparent 35%),
        radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.18) 0%, transparent 35%),
        radial-gradient(circle at 70% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 35%),
        radial-gradient(circle at 30% 70%, rgba(139, 92, 246, 0.12) 0%, transparent 35%),
        radial-gradient(circle at 50% 50%, rgba(34, 197, 94, 0.1) 0%, transparent 40%);
    animation: meshFlow 18s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    animation-play-state: var(--mesh-animation-state);
    filter: blur(var(--mesh-blur));
    /* GPU hints for smooth animation */
    will-change: transform;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

.mesh-gradient::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background:
        radial-gradient(circle at 60% 40%, rgba(251, 146, 60, 0.18) 0%, transparent 30%),
        radial-gradient(circle at 25% 60%, rgba(59, 130, 246, 0.12) 0%, transparent 35%),
        radial-gradient(circle at 85% 70%, rgba(168, 85, 247, 0.1) 0%, transparent 30%);
    animation: meshPulse 14s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    animation-delay: -4s;
    animation-play-state: var(--mesh-animation-state);
    filter: blur(var(--mesh-blur-secondary));
    /* GPU hints */
    will-change: transform, opacity;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

.mesh-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(var(--orb-blur));
    opacity: 0.35;
    animation: orbFloat 20s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    animation-play-state: var(--mesh-animation-state);
    /* GPU layer */
    will-change: transform;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

.mesh-orb:nth-child(1) {
    width: 40vmax;
    height: 40vmax;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.28) 0%, transparent 70%);
    top: -10%;
    left: -10%;
    animation-duration: 18s;
}

.mesh-orb:nth-child(2) {
    width: 35vmax;
    height: 35vmax;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.22) 0%, transparent 70%);
    top: 50%;
    right: -15%;
    animation-duration: 22s;
    animation-delay: -5s;
}

.mesh-orb:nth-child(3) {
    width: 30vmax;
    height: 30vmax;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.18) 0%, transparent 70%);
    bottom: -10%;
    left: 30%;
    animation-duration: 25s;
    animation-delay: -10s;
}

.mesh-orb:nth-child(4) {
    width: 25vmax;
    height: 25vmax;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.22) 0%, transparent 70%);
    top: 20%;
    left: 60%;
    animation-duration: 20s;
    animation-delay: -7s;
}

@keyframes meshFlow {
    0%, 100% { transform: translate(0%, 0%) rotate(0deg); }
    25% { transform: translate(2%, -2%) rotate(1deg); }
    50% { transform: translate(-1%, 2%) rotate(-1deg); }
    75% { transform: translate(1%, -1%) rotate(0.5deg); }
}

@keyframes meshPulse {
    0%, 100% { transform: translate(0%, 0%) scale(1); opacity: 1; }
    50% { transform: translate(-2%, 1%) scale(1.02); opacity: 0.85; }
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(4%, 6%) scale(1.08); }
    66% { transform: translate(-3%, 3%) scale(0.95); }
}

/* Hide scrollbars */
::-webkit-scrollbar { width: 0; display: none; }
* { -ms-overflow-style: none; scrollbar-width: none; }

::selection {
    background: #fde68a;
    color: #92400e;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

/* ====== MOBILE LAYOUT ====== */

/* Mobile Background Logo Watermark */
#logo-watermark {
    display: block;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vw;
    height: 60vw;
    max-width: 300px;
    max-height: 300px;
    z-index: 0;
    opacity: 0.04;
    pointer-events: none;
    filter: blur(1px);
}

#logo-watermark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Logo Badge - Mobile */
#logo {
    position: fixed;
    top: calc(12px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%) translateZ(0);
    z-index: 150;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-glass-dark);
    backdrop-filter: blur(var(--backdrop-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    opacity: 0;
    animation: fadeIn 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) 0.3s forwards;
    cursor: pointer;
    /* Responsive micro-interaction */
    transition: transform 0.18s cubic-bezier(0.2, 0, 0.2, 1);
    will-change: transform;
}

#logo:active { transform: translateX(-50%) scale(0.95); }

#logo img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.92) translateZ(0);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateZ(0);
    }
}

/* Controls Bar - Mobile */
#controls {
    position: fixed;
    bottom: calc(12px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateZ(0);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-glass);
    backdrop-filter: blur(var(--backdrop-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow:
        0 8px 32px var(--glass-shadow),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    z-index: 100;
    opacity: 0;
    animation: slideUp 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) 0.4s forwards;
    max-width: calc(100% - 24px);
    will-change: transform;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px) translateZ(0);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) translateZ(0);
    }
}

.control-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.control-group label { display: none; }

select {
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    min-width: 70px;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    min-height: 36px;
}

select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

select:disabled { opacity: 0.5; cursor: not-allowed; }

.divider { display: none; }

.icon-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
}

.icon-btn:active { transform: scale(0.95); }

.icon-btn.active {
    background: var(--text-primary);
    color: white;
    border-color: var(--text-primary);
}

/* Settings Panel - Mobile */
#settings-panel {
    position: fixed;
    bottom: calc(70px + var(--safe-bottom));
    left: 12px;
    right: 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(var(--backdrop-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 99;
    box-shadow: 0 8px 32px var(--glass-shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) translateZ(0);
    /* Premium ease: fast response (0.2), soft landing (0.9, 0.1) */
    transition: opacity 0.28s cubic-bezier(0.2, 0, 0.2, 1),
                transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
    will-change: transform, opacity;
}

#settings-panel.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.setting {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.setting label span {
    color: var(--text-primary);
    font-weight: 600;
}

input[type="range"] {
    -webkit-appearance: none;
    background: rgba(0, 0, 0, 0.1);
    height: 6px;
    border-radius: 3px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Canvas Container - Mobile */
#canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: calc(65px + var(--safe-top)) 12px calc(65px + var(--safe-bottom));
    z-index: 1;
}

#art-canvas {
    /* Centered by flexbox parent, prevent stretching */
    display: block;
    flex: 0 0 auto;
    margin: auto;
    opacity: 0;
    animation: canvasIn 0.8s cubic-bezier(0.2, 0.9, 0.3, 1) 0.2s forwards;
    filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.12));
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@keyframes canvasIn {
    from {
        opacity: 0;
        transform: scale(0.97) translateZ(0);
    }
    60% {
        opacity: 1;
    }
    to {
        opacity: 1;
        transform: scale(1) translateZ(0);
    }
}

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: opacity 0.5s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.spinner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-glass-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.spinner img {
    width: 26px;
    height: 26px;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

#loading-text {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.progress-bar {
    width: 160px;
    height: 3px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

#progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Mobile Status Bar (replaces terminal) */
#mobile-status {
    position: fixed;
    top: calc(12px + var(--safe-top));
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(var(--backdrop-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    z-index: 100;
    opacity: 0;
    animation: fadeIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) 0.6s forwards;
    transform: translateZ(0);
}

#mobile-status .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#mobile-status .status-text {
    color: var(--text-primary);
    font-weight: 600;
}

/* Terminal - Hidden on Mobile */
#terminal { display: none; }

/* ====== TABLET (min-width: 600px) ====== */
@media (min-width: 600px) {
    #logo-watermark { display: none; }

    #logo {
        top: calc(20px + var(--safe-top));
        width: 48px;
        height: 48px;
    }

    #logo img { width: 24px; height: 24px; }

    #controls {
        bottom: calc(20px + var(--safe-bottom));
        padding: 8px 14px;
        gap: 8px;
    }

    select {
        min-width: 80px;
        font-size: 13px;
    }

    .divider {
        display: block;
        width: 1px;
        height: 24px;
        background: rgba(0, 0, 0, 0.08);
        margin: 0 4px;
    }

    #settings-panel {
        bottom: calc(85px + var(--safe-bottom));
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(10px);
        flex-direction: row;
        flex-wrap: wrap;
        gap: 20px;
        max-width: 480px;
    }

    #settings-panel.visible {
        transform: translateX(-50%) translateY(0);
    }

    .setting { min-width: 130px; }

    #canvas-container {
        padding: calc(85px + var(--safe-top)) 24px calc(90px + var(--safe-bottom));
    }

    #art-canvas {
        filter: drop-shadow(0 16px 36px rgba(0, 0, 0, 0.14));
    }

    #mobile-status { display: none; }
}

/* ====== DESKTOP (min-width: 1000px) ====== */
@media (min-width: 1000px) {
    #logo {
        top: 28px;
        left: 28px;
        transform: none;
        width: 52px;
        height: 52px;
    }

    #logo:hover {
        transform: scale(1.05);
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: scale(0.9); }
        to { opacity: 1; transform: scale(1); }
    }

    #logo img { width: 26px; height: 26px; }

    #controls {
        bottom: 28px;
        padding: 10px 16px;
        gap: 10px;
        border-radius: 22px;
    }

    .control-group label {
        display: block;
        font-size: 10px;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    select {
        min-width: 90px;
        border-radius: 10px;
    }

    select:hover {
        background: rgba(255, 255, 255, 0.85);
    }

    .icon-btn:hover {
        background: rgba(255, 255, 255, 0.85);
        color: var(--text-primary);
    }

    #settings-panel {
        bottom: 95px;
        gap: 28px;
    }

    .setting { min-width: 150px; }

    input[type="range"] { height: 4px; }

    input[type="range"]::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
        transition: transform 0.15s ease;
    }

    input[type="range"]::-webkit-slider-thumb:hover {
        transform: scale(1.15);
    }

    #canvas-container {
        /* Center canvas area, exclude logo and terminal */
        position: fixed;
        top: 0;
        left: 100px;
        right: 280px;
        bottom: 0;
        padding: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: visible;
    }

    #art-canvas {
        filter: drop-shadow(0 20px 48px rgba(0, 0, 0, 0.15));
    }

    /* ====== TERMINAL - Apple Liquid Glass ====== */
    #terminal {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 50%;
        transform: translateY(-50%) translateZ(0);
        right: 20px;
        width: 240px;
        max-height: calc(100vh - 120px);
        /* Apple liquid glass: light frosted effect */
        background: rgba(255, 255, 255, 0.45);
        backdrop-filter: blur(40px) saturate(180%);
        -webkit-backdrop-filter: blur(40px) saturate(180%);
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, 0.6);
        box-shadow:
            0 8px 40px rgba(0, 0, 0, 0.08),
            0 0 0 0.5px rgba(0, 0, 0, 0.05);
        z-index: 50;
        opacity: 0;
        animation: terminalIn 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) 0.8s forwards;
        overflow: hidden;
        font-family: "SF Mono", "JetBrains Mono", "Fira Code", Monaco, monospace;
    }

    @keyframes terminalIn {
        from {
            opacity: 0;
            transform: translateY(-50%) translateX(20px);
        }
        to {
            opacity: 1;
            transform: translateY(-50%) translateX(0);
        }
    }

    .terminal-header {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 14px;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.2) 100%);
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        flex-shrink: 0;
    }

    .terminal-dots {
        display: flex;
        gap: 6px;
    }

    .terminal-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        position: relative;
    }

    .terminal-dot::after {
        content: '';
        position: absolute;
        inset: 2px;
        border-radius: 50%;
        background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, transparent 50%);
    }

    .terminal-dot.red {
        background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
        box-shadow: 0 0 8px rgba(255, 107, 107, 0.4);
    }
    .terminal-dot.yellow {
        background: linear-gradient(135deg, #ffd93d 0%, #f5c800 100%);
        box-shadow: 0 0 8px rgba(255, 217, 61, 0.4);
    }
    .terminal-dot.green {
        background: linear-gradient(135deg, #6bcb77 0%, #4ade80 100%);
        box-shadow: 0 0 8px rgba(107, 203, 119, 0.4);
    }

    .terminal-title {
        margin-left: auto;
        font-size: 10px;
        font-weight: 600;
        color: rgba(0, 0, 0, 0.35);
        letter-spacing: 0.3px;
    }

    #terminal-content {
        flex: 1;
        padding: 10px 12px;
        overflow-y: auto;
        font-size: 10px;
        line-height: 1.6;
        mask-image: linear-gradient(to bottom, transparent 0%, black 8px, black calc(100% - 16px), transparent 100%);
        -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 8px, black calc(100% - 16px), transparent 100%);
    }

    #terminal-content::-webkit-scrollbar {
        width: 3px;
        display: block;
    }

    #terminal-content::-webkit-scrollbar-track {
        background: transparent;
    }

    #terminal-content::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.15);
        border-radius: 2px;
    }

    .log-line {
        display: flex;
        gap: 8px;
        margin-bottom: 4px;
        animation: logIn 0.3s ease;
        padding: 2px 0;
    }

    @keyframes logIn {
        from { opacity: 0; transform: translateY(4px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .log-line .timestamp {
        color: rgba(0, 0, 0, 0.25);
        flex-shrink: 0;
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.3px;
    }

    .log-line .message {
        color: rgba(0, 0, 0, 0.55);
        word-break: break-word;
    }

    /* Log type colors - light theme */
    .log-line.system .message { color: #059669; }
    .log-line.config .message { color: #d97706; }
    .log-line.zone .message { color: #7c3aed; }
    .log-line.info .message { color: #2563eb; }
    .log-line.event .message { color: #db2777; }
    .log-line.error .message { color: #dc2626; }
    .log-line.perf .message { color: #0891b2; }

    .log-line .highlight {
        color: #0369a1;
        font-weight: 600;
    }

    .log-line .dim {
        color: rgba(0, 0, 0, 0.3);
    }

    .log-line .tag {
        display: inline-block;
        padding: 1px 5px;
        background: rgba(0, 0, 0, 0.06);
        border-radius: 3px;
        font-size: 9px;
        font-weight: 600;
        margin-right: 4px;
    }

    .log-line.system .tag { background: rgba(5, 150, 105, 0.12); color: #059669; }
    .log-line.config .tag { background: rgba(217, 119, 6, 0.12); color: #d97706; }
    .log-line.zone .tag { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
    .log-line.perf .tag { background: rgba(8, 145, 178, 0.12); color: #0891b2; }

    /* Terminal Stats Footer */
    .terminal-footer {
        padding: 10px 12px;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.4) 100%);
        border-top: 1px solid rgba(0, 0, 0, 0.06);
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 9px;
        color: rgba(0, 0, 0, 0.4);
        flex-shrink: 0;
    }

    .terminal-footer .stat {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .terminal-footer .stat-value {
        color: rgba(0, 0, 0, 0.6);
        font-weight: 600;
    }

    .terminal-footer .fps-indicator {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .terminal-footer .fps-bar {
        width: 32px;
        height: 3px;
        background: rgba(0, 0, 0, 0.08);
        border-radius: 2px;
        overflow: hidden;
    }

    .terminal-footer .fps-fill {
        height: 100%;
        background: linear-gradient(90deg, #059669, #0891b2);
        border-radius: 2px;
        transition: width 0.3s ease;
    }
}

/* ====== LARGE DESKTOP (min-width: 1400px) ====== */
@media (min-width: 1400px) {
    #terminal {
        width: 260px;
    }

    #canvas-container {
        left: 120px;
        right: 300px;
        padding: 100px;
    }

    .terminal-footer {
        padding: 10px 14px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #logo {
        top: 8px;
        width: 32px;
        height: 32px;
    }

    #logo img { width: 16px; height: 16px; }

    #controls {
        bottom: 8px;
        padding: 4px 8px;
    }

    select {
        min-height: 30px;
        padding: 4px 8px;
        font-size: 12px;
    }

    .icon-btn {
        min-width: 30px;
        min-height: 30px;
        padding: 5px;
    }

    #canvas-container {
        padding: 45px 12px;
    }

    #mobile-status {
        top: 8px;
        padding: 4px 10px;
        font-size: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* PERFORMANCE TIERS - Adaptive quality for 60fps guarantee                    */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Tier B: Reduced blur for mid-range devices */
.perf-tier-b {
    --mesh-blur: 40px;
    --mesh-blur-secondary: 50px;
    --orb-blur: 40px;
    --backdrop-blur: 25px;
}

.perf-tier-b .mesh-gradient::before,
.perf-tier-b .mesh-gradient::after {
    animation-duration: 24s; /* Slower = fewer repaints */
}

.perf-tier-b .mesh-orb {
    animation-duration: 30s;
}

/* Tier C: Minimal effects for low-end devices */
.perf-tier-c {
    --mesh-blur: 30px;
    --mesh-blur-secondary: 30px;
    --orb-blur: 30px;
    --backdrop-blur: 15px;
    --mesh-animation-state: paused;
}

.perf-tier-c .mesh-gradient::before,
.perf-tier-c .mesh-gradient::after,
.perf-tier-c .mesh-orb {
    animation: none;
}

/* Static fallback for Tier C */
.perf-tier-c .mesh-gradient {
    background: linear-gradient(
        135deg,
        rgba(251, 191, 36, 0.15) 0%,
        rgba(6, 182, 212, 0.1) 25%,
        rgba(236, 72, 153, 0.08) 50%,
        rgba(139, 92, 246, 0.1) 75%,
        rgba(34, 197, 94, 0.08) 100%
    );
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* REDUCED MOTION - Accessibility support                                       */
/* ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .mesh-gradient::before,
    .mesh-gradient::after,
    .mesh-orb {
        animation: none !important;
    }

    /* Static gradient for reduced motion */
    .mesh-gradient {
        background: linear-gradient(
            135deg,
            rgba(251, 191, 36, 0.12) 0%,
            rgba(6, 182, 212, 0.08) 50%,
            rgba(139, 92, 246, 0.08) 100%
        );
    }

    .mesh-gradient::before,
    .mesh-gradient::after {
        display: none;
    }

    .mesh-orb {
        display: none;
    }

    #loading-overlay {
        transition: none;
    }

    .spinner {
        animation: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* CANVAS OPTIMIZATION                                                          */
/* ═══════════════════════════════════════════════════════════════════════════ */

#art-canvas {
    /* GPU compositing hint */
    will-change: contents;
}
