/* ═══════════════════════════════════════
   TOKENS & CORE SYSTEM
   ═══════════════════════════════════════ */
:root {
    --bg: #5C0606;
    --surface: rgba(0, 0, 0, 0.45);
    --surface-hover: rgba(0, 0, 0, 0.60);
    --surface-active: rgba(0, 0, 0, 0.75);
    --line: rgba(255, 255, 255, 0.08);
    --line-active: rgba(255, 255, 255, 0.18);

    /* Operators styling */
    --sprinkle: #00FFFF;
    --sprinkle-dim: rgba(0, 255, 255, 0.15);
    --sprinkle-glow: rgba(0, 255, 255, 0.4);

    --dollop: #FF007F;
    --dollop-dim: rgba(255, 0, 127, 0.15);
    --dollop-glow: rgba(255, 0, 127, 0.4);

    --mint: #39FF14;
    --white: #FFFFFF;
    --muted: #D29D9D;
    --muted-dim: rgba(210, 157, 157, 0.3);

    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    /* Animation timings */
    --transition: cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    background: var(--bg);
    color: var(--white);
    font-family: var(--font-mono);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    position: relative;
}

/* Cybernetic organic noise & glows */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
    background-size: 256px;
    pointer-events: none;
    z-index: 9999;
}

.ambient-glow {
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.15) 40%, transparent 70%);
    top: 20%;
    left: 20%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 0;
}

/* ═══════════════════════════════════════
   LAYOUT SYSTEM
   ═══════════════════════════════════════ */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    gap: 24px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.suite-return {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

.suite-return:hover,
.suite-return:focus-visible {
    color: var(--sprinkle);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-mark {
    font-size: 32px;
    filter: drop-shadow(0 0 8px rgba(255, 75, 114, 0.5));
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 28px;
    letter-spacing: 0.05em;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--white) 30%, var(--sprinkle) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.origin-tag {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.tag-label {
    font-size: 11px;
    background: var(--dollop-dim);
    color: var(--dollop);
    border: 1px solid rgba(255, 75, 114, 0.3);
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.tag-date {
    font-size: 10px;
    color: var(--muted);
    margin-top: 4px;
    letter-spacing: 0.1em;
}

/* Grid Layout */
.app-grid {
    display: flex;
    flex-direction: row;
    gap: 24px;
    flex: 1;
    justify-content: center; /* Center the visualizer card */
}

/* Panels */
.panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.panel-left {
    width: 330px;
    flex-shrink: 0;
}

.panel-right {
    width: 340px;
    flex-shrink: 0;
}

.panel-center {
    flex: 1;
    max-width: 720px; /* Constrain visualizer card width */
    width: 100%;
    justify-content: flex-start; /* Align content to the top instead of stretching vertically */
}

/* Cards (Glassmorphism) */
.section-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    transition: border-color 0.3s var(--transition), box-shadow 0.3s var(--transition);
}

.section-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.section-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-hint {
    font-size: 11px;
    color: var(--muted);
}

/* ═══════════════════════════════════════
   1. SOURCE PANEL COMPONENTS
   ═══════════════════════════════════════ */
.source-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    background: var(--surface-active);
    color: var(--white);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s var(--transition);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-source.active {
    border-color: var(--sprinkle);
    box-shadow: 0 0 12px var(--sprinkle-dim);
    background: rgba(0, 243, 255, 0.05);
}

.file-drop-zone {
    border: 1px dashed var(--muted-dim);
    border-radius: 6px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s var(--transition);
}

.file-drop-zone:hover, .file-drop-zone.dragover {
    border-color: var(--dollop);
    background: rgba(255, 75, 114, 0.03);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.drop-text {
    font-size: 11px;
    color: var(--muted);
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.btn-primary {
    background: var(--white);
    color: var(--bg);
    font-weight: 600;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(255, 255, 255, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.25);
}

.btn-primary.playing {
    background: var(--dollop);
    color: var(--white);
    box-shadow: 0 4px 14px var(--dollop-dim);
}

.volume-slider-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.slider-label {
    font-size: 9px;
    color: var(--muted);
    font-weight: 600;
}

/* ═══════════════════════════════════════
   2. TERRITORY SELECTION
   ═══════════════════════════════════════ */
.territory-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.territory-btn {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.015);
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    transition: all 0.25s var(--transition);
}

.territory-btn input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.territory-btn .t-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--white);
    transition: color 0.2s;
}

.territory-btn .t-desc {
    font-size: 10px;
    color: var(--muted);
}

.territory-btn:hover {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

/* Radio check states */
.territory-btn:has(input:checked) {
    border-color: var(--white);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.04);
}

.territory-btn:has(input:checked) .t-title {
    color: var(--white);
    font-weight: 600;
}

/* ═══════════════════════════════════════
   3. THE GOURMET PLATE VISUALIZER
   ═══════════════════════════════════════ */
.plate-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

.plate-header {
    display: none; /* Hidden per user request */
}

.pads-container {
    display: flex;
    gap: 16px;
    width: 100%;
}

.pad-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pad-title {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-align: center;
    transition: color 0.2s var(--transition);
}

.pad-wrapper:hover .pad-title {
    color: var(--white);
}

.plate-status {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.plate-status.running {
    color: var(--mint);
    animation: statusPulse 1.5s infinite;
}

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

.plate-mode-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 10px;
    color: var(--muted);
}

.visualizer-toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 4px 0 12px;
    width: 100%;
}

.visualizer-toolbar .plate-status,
.visualizer-toolbar .territory-readout {
    flex: 0 0 auto;
}

.btn-park-toggle {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 6px 14px;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.05em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s var(--transition);
}

.btn-park-toggle:hover {
    background: rgba(0, 255, 255, 0.08);
    color: var(--white);
    border-color: rgba(0, 255, 255, 0.4);
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

.btn-park-toggle.active {
    background: rgba(0, 255, 255, 0.18);
    color: var(--sprinkle);
    border-color: var(--sprinkle);
    box-shadow: 0 0 14px rgba(0, 255, 255, 0.4);
}

.territory-readout {
    border: 1px solid var(--line-active);
    border-radius: 999px;
    color: var(--white);
    padding: 4px 8px;
}

.indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.sprinkle-dot {
    background: var(--sprinkle);
    box-shadow: 0 0 6px var(--sprinkle);
}

.dollop-dot {
    background: var(--dollop);
    box-shadow: 0 0 6px var(--dollop);
}

.canvas-container {
    height: 380px; /* Constrain the height to a clean fixed value */
    position: relative;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

#sprinkle-canvas, #dollop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.canvas-overlay-text {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    text-align: center;
    opacity: 0.35;
    transition: opacity 0.3s;
}

.canvas-overlay-text p {
    font-size: 9px;
    letter-spacing: 0.15em;
    font-weight: 500;
}

.canvas-overlay-text span {
    font-size: 8px;
    color: var(--muted);
    letter-spacing: 0.05em;
}

.canvas-container:hover .canvas-overlay-text {
    opacity: 0.7;
}

/* Meters */
.plate-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.meter-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0;
    transition: width 0.1s linear;
}

.sprinkle-fill {
    background: var(--sprinkle);
    box-shadow: 0 0 6px var(--sprinkle);
}

.dollop-fill {
    background: var(--dollop);
    box-shadow: 0 0 6px var(--dollop);
}

.meter-label {
    font-size: 8px;
    letter-spacing: 0.15em;
    color: var(--muted);
    text-transform: uppercase;
}

.performance-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
    flex-wrap: wrap;
}

.btn-utility {
    background: rgba(255, 255, 255, 0.025);
    color: var(--muted);
    font-size: 10px;
    justify-content: center;
    padding: 8px 12px;
    text-transform: uppercase;
}

.btn-utility:hover,
.btn-utility.active {
    border-color: var(--sprinkle);
    color: var(--sprinkle);
    box-shadow: 0 0 12px var(--sprinkle-dim);
}

#btn-bypass.active {
    border-color: var(--dollop);
    color: var(--dollop);
    box-shadow: 0 0 12px var(--dollop-dim);
}

/* ═══════════════════════════════════════
   4. DEPOSITION OPERATORS (RIGHT PANEL)
   ═══════════════════════════════════════ */
.card-sprinkle {
    border-left: 3px solid var(--sprinkle);
}

.card-dollop {
    border-left: 3px solid var(--dollop);
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}

.text-sprinkle {
    color: var(--sprinkle) !important;
}

.text-dollop {
    color: var(--dollop) !important;
}

.operator-mode {
    font-size: 9px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.operator-desc {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 500;
}

.val-display {
    color: var(--muted);
}

/* Range Sliders */
.range-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--muted-dim);
    border-radius: 2px;
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--white);
    cursor: pointer;
    transition: transform 0.15s var(--transition);
}

.range-slider:hover::-webkit-slider-thumb {
    transform: scale(1.2);
}

.sprinkle-slider::-webkit-slider-thumb {
    background: var(--sprinkle);
    box-shadow: 0 0 6px var(--sprinkle);
}

.dollop-slider::-webkit-slider-thumb {
    background: var(--dollop);
    box-shadow: 0 0 6px var(--dollop);
}

/* ═══════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════ */
.app-footer {
    border-top: 1px solid var(--line);
    padding-top: 16px;
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.05em;
}

.app-footer strong {
    color: var(--white);
}

/* ═══════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════ */
@media (max-width: 1100px) {
    .header-actions {
        align-items: flex-end;
        flex-direction: column-reverse;
        gap: 8px;
    }

    .app-grid {
        flex-direction: column;
        gap: 24px;
    }

    .panel-left, .panel-right {
        width: 100%;
    }

    .panel-center {
        order: -1;
    }
    .canvas-container {
        min-height: 450px;
    }
}
