/* Base Variables */
:root {
    --bg-dark: #050507;
    --bg-card: rgba(18, 18, 24, 0.6);
    --bg-input: rgba(10, 10, 12, 0.8);
    --text-main: #ffffff;
    --text-muted: #8b92a5;
    --accent-primary: #00e5ff;
    --accent-secondary: #b07cff;
    --accent-secondary-dim: rgba(176, 124, 255, 0.2);
    --border-glass: rgba(255, 255, 255, 0.08);
    --danger: #ff4757;
    --warning: #ffa502;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: radial-gradient(circle at 85% 30%, rgba(176, 124, 255, 0.05) 0%, transparent 60%);
}

/* Navbar */
.app-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(5, 5, 7, 0.8);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1.1rem;
}

.logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
}

.back-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
    transition: all 0.3s ease;
}

.back-btn:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.08);
}

/* Workspace Layout */
.workspace {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    padding: 2rem 5%;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.panel-header {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--accent-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Text Editor */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-input);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    position: relative;
    min-height: 300px;
}

textarea {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    color: #d1d5db;
    padding: 1.5rem;
    font-family: inherit;
    font-size: 1.1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.editor-footer {
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: monospace;
}

/* Transport Controls */
.transport-controls {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: center;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 1rem 2rem;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
}

.btn-play {
    background: var(--accent-secondary);
    color: #000;
}

.btn-play:hover {
    box-shadow: 0 0 20px var(--accent-secondary-dim);
    transform: scale(1.02);
}

.btn-pause {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
}

.btn-pause:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-stop {
    background: rgba(255, 71, 87, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn-stop:hover {
    background: rgba(255, 71, 87, 0.2);
}

/* Side Panel Controls */
.control-group {
    margin-bottom: 2rem;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

select {
    width: 100%;
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
    color: #fff;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    appearance: none;
}

select:focus {
    border-color: var(--accent-secondary);
}

/* Custom Knobs */
.knobs-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    text-align: center;
}

.knob-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.knob-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.knob-val {
    font-family: monospace;
    color: var(--accent-secondary);
    font-size: 0.9rem;
}

.knob {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(from 210deg, var(--bg-input) 0deg, var(--bg-input) 300deg, #000 300deg, #000 360deg);
    border: 3px solid #111;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8), 0 5px 15px rgba(0, 0, 0, 0.4);
    cursor: grab;
    display: flex;
    justify-content: center;
    align-items: center;
}

.knob:active {
    cursor: grabbing;
}

.knob-indicator {
    width: 3px;
    height: 18px;
    background: var(--accent-secondary);
    border-radius: 2px;
    position: absolute;
    top: 4px;
    box-shadow: 0 0 8px var(--accent-secondary-dim);
    transform-origin: 50% 28px;
    /* 32px to center, 4px top offset = 28px pivot */
    transform: rotate(-150deg);
    pointer-events: none;
}

/* Oscilloscope Visualizer */
.viz-container {
    width: 100%;
    height: 140px;
    background: #020203;
    border-radius: 12px;
    border: 1px solid #1a1a24;
    position: relative;
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.viz-status {
    position: absolute;
    top: 12px;
    left: 12px;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 6px;
}

.viz-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.viz-status.active {
    color: #2ed573;
}

.viz-status.active::before {
    background: #2ed573;
    box-shadow: 0 0 8px #2ed573;
}

.viz-status.paused {
    color: var(--warning);
}

.viz-status.paused::before {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .app-navbar {
        padding: 1rem 1.5rem;
    }

    .transport-controls {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
    }
}