/* ============================================================================
   BLE Dev Page - Unified Interface with Tabs
   ============================================================================ */

/* ============================================================================
   Toast Notifications
   ============================================================================ */

.toast {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.9), rgba(255, 167, 38, 0.9));
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    max-width: 90vw;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.15);
    border: none;
    border-radius: 50%;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.35);
    transform: scale(1.1);
}

.toast-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    animation: toast-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes toast-bounce {
    from { transform: translateY(-2px); }
    to { transform: translateY(2px); }
}

.toast-message {
    line-height: 1.4;
}

.toast.warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.9), rgba(255, 167, 38, 0.9));
    color: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast.error {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.9), rgba(238, 90, 90, 0.9));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.toast.success {
    background: linear-gradient(135deg, rgba(38, 222, 129, 0.9), rgba(32, 201, 151, 0.9));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .toast.warning {
    background: linear-gradient(135deg, rgba(255, 202, 87, 0.95), rgba(255, 179, 71, 0.95));
    color: #3d3020;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.3) inset;
}

[data-theme="light"] .toast-close {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .toast-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   Main Dashboard Layout
   ============================================================================ */

.bdev-dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1rem;
    gap: 0;
    max-width: 1800px;
    margin: 0 auto;
}

.bdev-dashboard .header {
    flex-shrink: 0;
    margin-bottom: 0;
}

/* ============================================================================
   Tab Navigation
   ============================================================================ */

.tab-nav {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 0;
    background: transparent;
    flex-shrink: 0;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--card-hover);
    border-color: var(--text-secondary);
}

.tab-btn.active {
    background: var(--accent-blue);
    color: var(--text-primary);
    border-color: var(--accent-blue);
    font-weight: 600;
}

.tab-icon {
    font-size: 1rem;
}

.tab-label {
    display: inline;
}

/* ============================================================================
   Main Content Area
   ============================================================================ */

.bdev-content {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-top: 2px solid var(--card-border);
    padding-top: 1rem;
}

/* ============================================================================
   Sidebar (Always Visible)
   ============================================================================ */

.sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar .ble-panel {
    flex-shrink: 0;
}

.sidebar .status-panel {
    flex-shrink: 0;
}

.sidebar .log-panel {
    flex: 1;
    min-height: 150px;
    display: flex;
    flex-direction: column;
}

.sidebar .log-panel .log-content {
    flex: 1;
    min-height: 0;
}

/* ============================================================================
   BLE Status
   ============================================================================ */

.ble-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--card-hover);
    border-radius: 8px;
    font-size: 0.85rem;
}

.ble-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.ble-status .status-dot.connected {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.robot-info {
    margin-top: 0.5rem;
}

.robot-info .info-item {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    background: var(--card-hover);
    border-radius: 6px;
}

.robot-info .info-item label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.robot-info .info-item .value {
    font-weight: 600;
    color: var(--accent-blue);
}

/* ============================================================================
   Robot Status Panel (from PING)
   ============================================================================ */

.status-panel h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.last-ping {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: normal;
    color: var(--text-muted);
    background: var(--card-hover);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.status-item {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    background: var(--card-hover);
    border-radius: 6px;
}

.status-item label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
}

.status-item .value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-item .value.mono {
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--accent-blue);
}

/* Temperature display */
.temp-values {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.temp-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.temp-label {
    color: var(--text-muted);
    font-weight: 500;
    min-width: 1.2rem;
}

.temp-ok {
    color: var(--accent-green);
}

.temp-warm {
    color: var(--accent-orange);
}

.temp-hot {
    color: var(--accent-red);
}

.temp-unavailable {
    color: var(--text-muted);
}

/* ============================================================================
   Tab Contents Area
   ============================================================================ */

.tab-contents {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tab-content {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    gap: 1rem;
}

.tab-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.tab-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================================================
   SUBPROGRAMS TAB
   ============================================================================ */

/* Subprograms List Panel */
.subprograms-panel h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subprograms-panel h2 .btn {
    margin-left: auto;
}

.subprogram-count {
    font-size: 0.75rem;
    font-weight: normal;
    color: var(--text-muted);
    background: var(--card-hover);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.button-assignments {
    background: var(--card-hover);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.assignment-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.btn-label {
    color: var(--text-muted);
    min-width: 70px;
}

.assignment-value {
    color: var(--accent-purple);
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-weight: 500;
}

.subprogram-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    min-height: 0;
    max-height: 300px;
}

.subprogram-actions {
    display: flex;
    gap: 0.5rem;
}

.subprogram-actions .btn {
    flex: 1;
}

.subprogram-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: var(--card-hover);
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.subprogram-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--card-border);
}

.subprogram-item.selected {
    border-color: var(--accent-blue);
    background: rgba(77, 171, 247, 0.15);
}

.subprogram-item.default {
    opacity: 0.7;
}

.subprogram-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-size: 1rem;
}

.subprogram-item.default .subprogram-icon {
    background: linear-gradient(135deg, var(--text-muted), var(--text-secondary));
}

.subprogram-info {
    flex: 1;
    min-width: 0;
}

.subprogram-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subprogram-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.subprogram-badges {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Button number badges (1-5) */
.badge-btn {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    min-width: 18px;
    text-align: center;
}

.badge-btn-1 {
    background: rgba(162, 155, 254, 0.3);
    color: var(--accent-purple);
}

.badge-btn-2 {
    background: rgba(77, 171, 247, 0.3);
    color: var(--accent-blue);
}

.badge-btn-3 {
    background: rgba(38, 222, 129, 0.3);
    color: var(--accent-green);
}

.badge-btn-4 {
    background: rgba(254, 202, 87, 0.3);
    color: var(--accent-orange);
}

.badge-btn-5 {
    background: rgba(255, 107, 107, 0.3);
    color: var(--accent-red);
}

.badge-default {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

/* Button Assignments Header */
.button-assignments-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.button-assignments-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.btn-label-1 { color: var(--accent-purple); }
.btn-label-2 { color: var(--accent-blue); }
.btn-label-3 { color: var(--accent-green); }
.btn-label-4 { color: var(--accent-orange); }
.btn-label-5 { color: var(--accent-red); }

/* Assign Buttons in Editor */
.assign-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 0.25rem;
}

.assign-buttons-container {
    display: flex;
    gap: 0.25rem;
}

.assign-buttons-container .btn {
    min-width: 32px;
    padding: 0.4rem 0.6rem;
    font-weight: 600;
}

.assign-buttons-container .btn-assigned {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: #1a1a2e;
}

/* Editor Panel */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.editor-title h2 {
    margin-bottom: 0.25rem;
}

.editor-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Block Palette */
.block-palette {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.palette-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.palette-block {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 2px solid transparent;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.palette-block:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.palette-block.block-setaxis {
    background: rgba(77, 171, 247, 0.2);
    color: var(--accent-blue);
    border-color: rgba(77, 171, 247, 0.3);
}

.palette-block.block-setaxis:hover:not(:disabled) {
    background: rgba(77, 171, 247, 0.3);
    border-color: var(--accent-blue);
}

.palette-block.block-wait {
    background: rgba(254, 202, 87, 0.2);
    color: var(--accent-orange);
    border-color: rgba(254, 202, 87, 0.3);
}

.palette-block.block-wait:hover:not(:disabled) {
    background: rgba(254, 202, 87, 0.3);
    border-color: var(--accent-orange);
}

.block-icon {
    font-size: 1rem;
}

/* Block Canvas */
.block-canvas {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 1rem;
    overflow-y: auto;
    min-height: 200px;
    border: 2px dashed var(--card-border);
}

.canvas-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.canvas-placeholder p {
    font-size: 0.95rem;
    margin: 0.25rem 0;
}

.placeholder-hint {
    font-size: 0.8rem !important;
    opacity: 0.7;
}

/* Blocks in Canvas */
.block-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.code-block {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: all 0.2s;
    position: relative;
    cursor: grab;
}

.code-block:active {
    cursor: grabbing;
}

.code-block.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.code-block.drag-over {
    border-top: 3px solid var(--accent-blue) !important;
    margin-top: -3px;
}

.code-block.block-setaxis {
    background: rgba(77, 171, 247, 0.15);
    border-color: rgba(77, 171, 247, 0.3);
}

.code-block.block-wait {
    background: rgba(254, 202, 87, 0.15);
    border-color: rgba(254, 202, 87, 0.3);
}

.code-block:hover {
    border-color: var(--text-secondary);
}

.block-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.block-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.block-header.setaxis-header {
    color: var(--accent-blue);
}

.block-header.wait-header {
    color: var(--accent-orange);
}

.block-header-note {
    font-size: 0.65rem;
    font-weight: normal;
    color: var(--text-muted);
    font-style: italic;
    margin-left: 0.5rem;
}

.block-params {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.block-param {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.block-param label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: fit-content;
}

.param-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: normal;
}

.block-param input[type="number"] {
    width: 80px;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-primary);
    /* Remove spinner in Firefox */
    -moz-appearance: textfield;
}

/* Remove spinner in WebKit browsers */
.block-param input[type="number"]::-webkit-outer-spin-button,
.block-param input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.block-param input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.block-delete {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.block-delete:hover {
    background: rgba(255, 107, 107, 0.2);
    color: var(--accent-red);
}

.empty-program {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-program-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

/* Editor Footer */
.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--card-border);
    flex-shrink: 0;
}

.bytecode-info {
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.85rem;
}

.bytecode-info span:first-child {
    color: var(--accent-green);
}

.bytecode-limit {
    color: var(--text-muted);
}

.editor-buttons {
    display: flex;
    gap: 0.5rem;
}

/* ============================================================================
   CONTROLLER TAB
   ============================================================================ */

/* Settings Panel */
.settings-panel {
    flex-shrink: 0;
}

.panel-disabled {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.panel-disabled h2::after {
    content: ' (connect to enable)';
    font-size: 0.65rem;
    font-weight: normal;
    color: var(--text-muted);
}

.setting-item {
    margin-bottom: 1rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slider-row input[type="range"] {
    flex: 1;
}

.slider-value {
    min-width: 40px;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent-green);
    text-align: right;
}

/* Controller Panel */
.controller-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.controller-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

.controller-placeholder .placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.controller-placeholder p {
    font-size: 1rem;
    margin: 0.25rem 0;
}

.controller-placeholder .placeholder-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

.controller-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.controller-header .controller-notice {
    flex-basis: 100%;
}

.controller-hints {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.controller-hints kbd {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    background: var(--card-hover);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    margin: 0 0.15rem;
}

.controller-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.controller-notice .notice-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.controller-notice .notice-text {
    line-height: 1.4;
}

.controller-notice strong {
    color: var(--accent-color);
}

[data-theme="light"] .controller-notice {
    background: rgba(255, 193, 7, 0.2);
    border-color: rgba(255, 152, 0, 0.4);
}

/* Controller Layout */
.controller-layout {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    min-height: 350px;
}

.controller-left,
.controller-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.controller-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* D-Pad */
.dpad-container {
    display: flex;
    justify-content: center;
}

.dpad {
    display: grid;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
    gap: 2px;
}

.dpad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-hover);
    border: 2px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.1s;
}

.dpad-btn:hover:not(.dpad-center) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.dpad-btn:active:not(.dpad-center),
.dpad-btn.active:not(.dpad-center) {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
    transform: scale(0.95);
}

.dpad-center {
    background: rgba(0, 0, 0, 0.3);
    cursor: default;
    border: none;
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* Joysticks */
.joystick-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.joystick-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.joystick {
    position: relative;
    width: 140px;
    height: 140px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.joystick-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.2) 100%);
    border: 3px solid var(--card-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.joystick-base::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--card-border);
    border-radius: 50%;
}

.joystick-base::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(to right, transparent 49%, var(--card-border) 49%, var(--card-border) 51%, transparent 51%),
        linear-gradient(to bottom, transparent 49%, var(--card-border) 49%, var(--card-border) 51%, transparent 51%);
    opacity: 0.3;
    border-radius: 50%;
}

.joystick-stick {
    position: absolute;
    width: 55px;
    height: 55px;
    background: linear-gradient(145deg, #4a4a5a, #3a3a4a);
    border: 3px solid var(--accent-purple);
    border-radius: 50%;
    cursor: grab;
    transition: transform 0.05s ease-out;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 2px 5px rgba(255, 255, 255, 0.1);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.joystick-stick:hover {
    border-color: var(--accent-blue);
}

.joystick-stick:active,
.joystick-stick.active {
    cursor: grabbing;
    border-color: var(--accent-green);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(38, 222, 129, 0.3),
        inset 0 2px 5px rgba(255, 255, 255, 0.1);
}

.joystick-values {
    display: flex;
    gap: 0.75rem;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--accent-green);
}

/* Shoulder Buttons */
.shoulder-buttons {
    display: flex;
    gap: 0.5rem;
}

.shoulder-btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--card-hover);
    border: 2px solid var(--card-border);
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.1s;
}

.shoulder-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-orange);
    color: var(--text-primary);
}

.shoulder-btn:active,
.shoulder-btn.active {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    color: white;
    transform: scale(0.95);
}

.shoulder-btn.l2-btn,
.shoulder-btn.r2-btn {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

.shoulder-btn.l2-btn:hover,
.shoulder-btn.r2-btn:hover {
    background: rgba(162, 155, 254, 0.2);
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.shoulder-btn.l2-btn:active,
.shoulder-btn.l2-btn.active,
.shoulder-btn.r2-btn:active,
.shoulder-btn.r2-btn.active {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: white;
}

/* Pause Button */
.pause-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 700;
    background: linear-gradient(145deg, #3a3a4a, #2a2a3a);
    border: 2px solid var(--accent-orange);
    border-radius: 25px;
    color: var(--accent-orange);
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pause-btn:hover {
    background: var(--accent-orange);
    color: #1a1a2e;
    box-shadow: 0 0 20px rgba(254, 202, 87, 0.4);
}

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

.pause-btn.paused {
    background: linear-gradient(145deg, var(--accent-green), #20c997);
    border-color: var(--accent-green);
    color: #1a1a2e;
    box-shadow: 0 0 15px rgba(38, 222, 129, 0.4);
}

/* Send Status Indicator */
.send-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--card-hover);
    border-radius: 20px;
    font-size: 0.8rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.1s;
}

.status-indicator.sending {
    background: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 0.5s infinite;
}

.status-indicator.error {
    background: var(--accent-red);
    box-shadow: 0 0 10px var(--accent-red);
}

.status-indicator.paused {
    background: var(--accent-orange);
    box-shadow: 0 0 10px var(--accent-orange);
}

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

/* Values Display */
.values-display {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    min-width: 120px;
}

.value-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.value-label {
    color: var(--text-muted);
}

.value-num {
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    color: var(--accent-blue);
    min-width: 50px;
    text-align: right;
}

/* System Buttons */
.system-buttons {
    display: flex;
    gap: 1rem;
}

.system-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.1s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.system-btn:hover {
    background: var(--card-hover);
    color: var(--text-secondary);
}

.system-btn:active,
.system-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
    transform: scale(0.95);
}

/* Action Buttons (A, B, X, Y) */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 4px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.1s;
    border: 3px solid;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.action-btn:active,
.action-btn.active {
    transform: scale(0.9);
}

.btn-y {
    grid-column: 2;
    grid-row: 1;
    background: linear-gradient(145deg, #f1c40f, #d4ac0d);
    border-color: #b7950b;
    color: #1a1a2e;
}

.btn-y:hover {
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
}

.btn-y:active, .btn-y.active {
    background: #f1c40f;
    box-shadow: 0 0 25px rgba(241, 196, 15, 0.8);
}

.btn-x {
    grid-column: 1;
    grid-row: 2;
    background: linear-gradient(145deg, #3498db, #2980b9);
    border-color: #1f6dad;
    color: white;
}

.btn-x:hover {
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
}

.btn-x:active, .btn-x.active {
    background: #3498db;
    box-shadow: 0 0 25px rgba(52, 152, 219, 0.8);
}

.btn-b {
    grid-column: 3;
    grid-row: 2;
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    border-color: #a93226;
    color: white;
}

.btn-b:hover {
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
}

.btn-b:active, .btn-b.active {
    background: #e74c3c;
    box-shadow: 0 0 25px rgba(231, 76, 60, 0.8);
}

.btn-a {
    grid-column: 2;
    grid-row: 3;
    background: linear-gradient(145deg, #27ae60, #229954);
    border-color: #1d8348;
    color: white;
}

.btn-a:hover {
    box-shadow: 0 0 15px rgba(39, 174, 96, 0.5);
}

.btn-a:active, .btn-a.active {
    background: #27ae60;
    box-shadow: 0 0 25px rgba(39, 174, 96, 0.8);
}

/* Controller Footer */
.controller-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--card-border);
    flex-shrink: 0;
}

.keyboard-hints {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.key-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.key-label {
    color: var(--text-muted);
}

.keyboard-hints kbd {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    background: var(--card-hover);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    color: var(--text-secondary);
}

.controller-actions-hint {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--card-border);
}

/* ============================================================================
   MELODY TAB
   ============================================================================ */

/* Melody Info Panel */
.melody-info-panel {
    flex-shrink: 0;
}

.melody-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.melody-info-panel .info-item {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    background: var(--card-hover);
    border-radius: 6px;
}

.melody-info-panel .info-item label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.melody-info-panel .info-item .value {
    font-weight: 600;
    color: var(--text-primary);
}

.melody-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.melody-actions .btn {
    flex: 1;
    min-width: 100px;
}

/* Amplitude Control */
.amplitude-control {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--card-border);
}

.amplitude-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.amplitude-header label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.amplitude-info {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.amplitude-info span {
    color: var(--accent-orange);
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
}

.amplitude-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.amplitude-row input[type="range"] {
    flex: 1;
}

.amplitude-value {
    min-width: 2.5rem;
    text-align: right;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent-green);
    font-weight: 600;
}

/* Melody Panel */
.melody-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.melody-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}

.melody-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

.melody-placeholder .placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.melody-placeholder p {
    font-size: 1rem;
    margin: 0.25rem 0;
}

.melody-placeholder .placeholder-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

.melody-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.melody-stats {
    display: flex;
    gap: 1rem;
}

.melody-stats .stat {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.3rem 0.75rem;
    background: var(--card-hover);
    border-radius: 20px;
}

.melody-stats .stat span {
    color: var(--accent-orange);
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-weight: 600;
}

/* Note Input Section */
.note-input-section {
    flex-shrink: 0;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.note-input-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.note-select,
.duration-select {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    border: 2px solid var(--card-border);
    border-radius: 8px;
    background: var(--card-hover);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 160px;
    transition: all 0.2s;
}

.note-select:focus,
.duration-select:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(162, 155, 254, 0.3);
}

.note-select option,
.duration-select option {
    background: var(--bg-gradient-2);
    color: var(--text-primary);
}

.note-select optgroup {
    color: var(--accent-blue);
    font-weight: 600;
}

.custom-duration input {
    width: 80px;
    padding: 0.6rem;
    font-size: 0.9rem;
    border: 2px solid var(--card-border);
    border-radius: 8px;
    background: var(--card-hover);
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
}

.custom-duration input:focus {
    outline: none;
    border-color: var(--accent-orange);
}

.add-note-btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.add-pause-btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--card-border);
}

.add-pause-btn:hover {
    border-color: var(--accent-orange);
    background: rgba(254, 202, 87, 0.1);
}

.preview-note-btn {
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
}

/* Piano Section */
.piano-section {
    flex-shrink: 0;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.piano-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.piano {
    display: flex;
    justify-content: center;
    position: relative;
    height: 120px;
    padding: 0 10px;
}

.piano-key {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.1s;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.piano-key.white {
    width: 36px;
    height: 100%;
    background: linear-gradient(to bottom, #f8f8f8, #e8e8e8);
    border: 1px solid #bbb;
    border-radius: 0 0 4px 4px;
    color: #333;
    z-index: 1;
    margin: 0 1px;
}

.piano-key.white:hover {
    background: linear-gradient(to bottom, #fff, #f0f0f0);
}

.piano-key.white:active,
.piano-key.white.active {
    background: linear-gradient(to bottom, #ddd, #ccc);
    transform: translateY(2px);
}

.piano-key.black {
    width: 24px;
    height: 65%;
    background: linear-gradient(to bottom, #444, #222);
    border: 1px solid #000;
    border-radius: 0 0 3px 3px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.5rem;
    z-index: 2;
    margin-left: -13px;
    margin-right: -13px;
}

.piano-key.black:hover {
    background: linear-gradient(to bottom, #555, #333);
}

.piano-key.black:active,
.piano-key.black.active {
    background: linear-gradient(to bottom, #333, #111);
    transform: translateY(2px);
}

/* Notes List Section */
.notes-list-section {
    flex: 1;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.notes-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.notes-list-header h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.notes-list-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-content: flex-start;
}

.notes-empty {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
}

.notes-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.notes-empty p {
    font-size: 0.85rem;
}

/* Individual Note Item */
.note-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--card-hover);
    border: 2px solid var(--card-border);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: all 0.2s;
    cursor: grab;
}

.note-item:hover {
    border-color: var(--accent-purple);
    background: rgba(162, 155, 254, 0.1);
}

.note-item.rest {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.2);
}

.note-item.playing {
    border-color: var(--accent-green);
    background: rgba(38, 222, 129, 0.2);
    box-shadow: 0 0 15px rgba(38, 222, 129, 0.3);
}

.note-item.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    cursor: grabbing;
}

.note-item.drag-over-before::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-blue);
    border-radius: 2px;
    box-shadow: 0 0 10px var(--accent-blue);
}

.note-item.drag-over-after::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-blue);
    border-radius: 2px;
    box-shadow: 0 0 10px var(--accent-blue);
}

.note-item {
    position: relative;
}

/* Drag handle */
.note-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 0.9rem;
    padding: 0 0.25rem;
    user-select: none;
}

.note-item:active .note-drag-handle,
.note-item.dragging .note-drag-handle {
    cursor: grabbing;
}

/* Editable fields */
.note-item .editable {
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    transition: all 0.15s;
}

.note-item .editable:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--accent-blue);
}

/* Inline edit input */
.note-edit-input {
    width: 70px;
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    background: var(--input-bg);
    border: 2px solid var(--accent-blue);
    border-radius: 4px;
    color: var(--text-primary);
    outline: none;
}

.note-edit-input:focus {
    box-shadow: 0 0 8px rgba(77, 171, 247, 0.4);
}

.note-item .note-name {
    font-weight: 600;
    color: var(--accent-blue);
    min-width: 50px;
}

.note-item.rest .note-name {
    color: var(--text-muted);
}

.note-item .note-duration {
    color: var(--text-muted);
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.75rem;
}

.note-item .note-freq {
    color: var(--accent-orange);
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.7rem;
    opacity: 0.7;
}

.note-item .note-delete {
    margin-left: auto;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 4px;
    color: var(--accent-red);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}

.note-item:hover .note-delete {
    opacity: 1;
}

.note-item .note-delete:hover {
    background: rgba(255, 107, 107, 0.2);
}

.note-item .note-index {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
}

/* Melody Controls */
.melody-controls {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.play-btn,
.stop-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}


.upload-controls {
    display: flex;
    gap: 0.5rem;
}

.upload-btn {
    padding: 0.75rem 2rem;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Presets Section */
.presets-section {
    flex-shrink: 0;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
}

.presets-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.presets-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: var(--card-hover);
    border: 2px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    border-color: var(--accent-purple);
    background: rgba(162, 155, 254, 0.1);
    transform: translateY(-1px);
}

/* ============================================================================
   MAPPING TAB
   ============================================================================ */

/* Connected Controller Display */
.connected-controller-panel {
    flex-shrink: 0;
}

.connected-controller-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--card-hover);
    border-radius: 8px;
}

.connected-controller-info .controller-name {
    flex: 1;
    font-weight: 600;
    color: var(--accent-green);
    font-size: 0.95rem;
}

/* Controller Type Selection */
.controller-type-panel {
    flex-shrink: 0;
}

.controller-select-wrapper {
    margin-bottom: 0.75rem;
}

.controller-select-wrapper select {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.9rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

.controller-select-wrapper select option {
    background: #2a2a3e;
    color: var(--text-primary);
}

.controller-select-wrapper select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

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

.mapping-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--card-hover);
    border-radius: 8px;
}

.mapping-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.mapping-badge.default {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.mapping-badge.custom {
    background: rgba(77, 171, 247, 0.2);
    color: var(--accent-blue);
}

.mapping-status .btn {
    margin-left: auto;
}

/* Config Panel */
.config-panel {
    flex-shrink: 0;
}

.config-panel h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.config-panel h2 .btn {
    margin-left: auto;
}

.config-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.config-section {
    background: var(--card-hover);
    border-radius: 8px;
    padding: 0.75rem;
}

.config-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.config-icon {
    font-size: 1rem;
}

.config-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.config-note {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0.5rem 0;
    font-style: italic;
    line-height: 1.4;
}

.config-values {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.config-row label {
    color: var(--text-muted);
}

.config-value {
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-weight: 600;
    color: var(--accent-blue);
}

.config-value.muted {
    color: var(--text-muted);
    font-weight: normal;
}

.config-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.config-input-row label {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 30px;
}

.config-input-row input[type="number"] {
    flex: 1;
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-primary);
    min-width: 0;
    /* Remove spinner in Firefox */
    -moz-appearance: textfield;
}

/* Remove spinner in WebKit browsers */
.config-input-row input[type="number"]::-webkit-outer-spin-button,
.config-input-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.config-input-row input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.config-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.config-input-group .config-input-row:last-child {
    justify-content: flex-end;
    margin-top: 0.25rem;
}

.config-section.recalibrate-section {
    border-top: 1px solid var(--card-border);
    margin-top: 0.5rem;
    padding-top: 1rem;
}

.recalibrate-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-orange), #e67e22);
    color: #1a1a2e;
    font-weight: 600;
}

.btn-warning:hover {
    box-shadow: 0 5px 20px rgba(254, 202, 87, 0.4);
}

.btn-warning:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-full {
    width: 100%;
}

/* Mapping Panel */
.mapping-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mapping-header {
    flex-shrink: 0;
    margin-bottom: 1rem;
}

.mapping-header h2 {
    margin-bottom: 0.25rem;
}

.mapping-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.mapping-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.mapping-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

.mapping-placeholder .placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.mapping-placeholder p {
    font-size: 1rem;
    margin: 0.25rem 0;
}

.mapping-placeholder .placeholder-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Mapping Sections */
.mapping-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
}

.mapping-section h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.section-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.mapping-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0.6rem 0.8rem;
    background: rgba(38, 222, 129, 0.08);
    border-radius: 6px;
    border-left: 3px solid var(--accent-green);
    line-height: 1.5;
}

.note-indicator-demo {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin: 0 0.15rem;
}

.note-indicator-demo .indicator-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: indicatorPulse 1.5s ease-in-out infinite;
}

@keyframes indicatorPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--accent-green); }
    50% { opacity: 0.6; box-shadow: 0 0 4px var(--accent-green); }
}

/* Button Grid */
.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.button-mapping {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.75rem;
    background: var(--card-hover);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.button-mapping:hover {
    border-color: var(--card-border);
}

.button-mapping.changed {
    border-color: var(--accent-orange);
}

.button-mapping .button-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.button-mapping .button-icon {
    font-size: 1rem;
}

.button-mapping select {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.85rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-primary);
}

.button-mapping select option {
    background: #2a2a3e;
    color: var(--text-primary);
}

.button-mapping select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Axis Grid */
.axis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.axis-mapping {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--card-hover);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.axis-mapping:hover {
    border-color: var(--card-border);
}

.axis-mapping.changed {
    border-color: var(--accent-orange);
}

.axis-mapping .axis-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.axis-mapping .axis-icon {
    font-size: 1.25rem;
}

.axis-mapping .axis-name {
    font-weight: 600;
    color: var(--text-primary);
}

.axis-mapping .axis-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.axis-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.axis-controls select {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.85rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-primary);
}

.axis-controls select option {
    background: #2a2a3e;
    color: var(--text-primary);
}

.axis-controls select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.invert-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.invert-toggle:hover {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.05);
}

.invert-toggle.active {
    background: rgba(77, 171, 247, 0.2);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Button State Indicator */
.button-state {
    margin-left: auto;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: all 0.1s;
}

.button-state.pressed {
    color: var(--accent-green);
    text-shadow: 0 0 8px var(--accent-green);
}

/* Live Axis Values Section */
.axis-live-values {
    grid-column: 1 / -1;
    background: var(--card-hover);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 0.5rem;
    border: 2px solid rgba(77, 171, 247, 0.2);
}

.axis-live-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.axis-live-icon {
    font-size: 1.1rem;
}

.axis-live-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.axis-values-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.axis-value-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-size: 0.8rem;
}

.axis-value-name {
    color: var(--text-muted);
}

.axis-value-display {
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
    transition: all 0.1s;
}

.axis-value-display.active {
    color: var(--accent-green);
    text-shadow: 0 0 5px rgba(38, 222, 129, 0.4);
}

/* Light Theme Overrides for Live Values */
[data-theme="light"] .axis-live-values {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(80, 137, 181, 0.25);
}

[data-theme="light"] .axis-value-item {
    background: rgba(248, 246, 242, 0.95);
    border: 1px solid rgba(140, 125, 105, 0.1);
}

[data-theme="light"] .button-state.pressed {
    color: var(--accent-green);
}

/* Mapping Footer */
.mapping-footer {
    flex-shrink: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* ============================================================================
   Modals
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-gradient-2);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    min-width: 320px;
    max-width: 400px;
}

.modal h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.modal p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.modal input[type="text"] {
    width: 100%;
    margin-bottom: 1rem;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ============================================================================
   Loading States
   ============================================================================ */

.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--card-border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   Navigation Button Variants
   ============================================================================ */

.nav-btn-subprograms {
    background: linear-gradient(135deg, var(--accent-purple), #9b59b6);
}

.nav-btn-subprograms:hover {
    box-shadow: 0 5px 20px rgba(165, 94, 234, 0.4);
}

.nav-btn-controller {
    background: linear-gradient(135deg, var(--accent-green), #20c997);
}

.nav-btn-controller:hover {
    box-shadow: 0 5px 20px rgba(38, 222, 129, 0.4);
}

.nav-btn-melody {
    background: linear-gradient(135deg, #ff6b9d, #c44569);
}

.nav-btn-melody:hover {
    box-shadow: 0 5px 20px rgba(255, 107, 157, 0.4);
}

.nav-btn-ble {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
}

.nav-btn-ble:hover {
    box-shadow: 0 5px 20px rgba(77, 171, 247, 0.4);
}

.nav-btn-serial {
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-red));
}

.nav-btn-serial:hover {
    box-shadow: 0 5px 20px rgba(254, 202, 87, 0.4);
}

.nav-btn-active {
    box-shadow: 0 0 0 2px var(--text-primary);
}

/* ============================================================================
   Light Theme Overrides for BDev
   ============================================================================ */

[data-theme="light"] .tab-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(140, 125, 105, 0.28);
    color: var(--text-secondary);
}

[data-theme="light"] .tab-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(140, 125, 105, 0.4);
}

[data-theme="light"] .tab-btn.active {
    background: linear-gradient(145deg, #5089b5, #6098c2);
    border-color: transparent;
    color: #fff;
}

[data-theme="light"] .subprogram-item {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(140, 125, 105, 0.15);
}

[data-theme="light"] .subprogram-item:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(140, 125, 105, 0.25);
}

[data-theme="light"] .subprogram-item.selected {
    background: rgba(80, 137, 181, 0.12);
    border-color: rgba(80, 137, 181, 0.45);
}

[data-theme="light"] .badge-btn-1 {
    background: rgba(125, 107, 171, 0.18);
    color: #5a4a8a;
}

[data-theme="light"] .badge-btn-2 {
    background: rgba(80, 137, 181, 0.18);
    color: #356085;
}

[data-theme="light"] .badge-btn-3 {
    background: rgba(74, 153, 100, 0.18);
    color: #2d7045;
}

[data-theme="light"] .badge-btn-4 {
    background: rgba(192, 138, 69, 0.18);
    color: #7a5520;
}

[data-theme="light"] .badge-btn-5 {
    background: rgba(192, 107, 101, 0.18);
    color: #8a4540;
}

[data-theme="light"] .badge-default {
    background: rgba(140, 125, 105, 0.15);
    color: var(--text-muted);
}

[data-theme="light"] .assign-buttons-container .btn-assigned {
    background: var(--accent-green);
    color: #fff;
}

[data-theme="light"] .controller-bg {
    background: rgba(248, 246, 242, 0.98);
}

[data-theme="light"] .block-canvas {
    background: rgba(248, 246, 242, 0.95);
    border: 2px dashed rgba(140, 125, 105, 0.3);
}

[data-theme="light"] .command-block {
    box-shadow: 0 2px 8px rgba(140, 125, 105, 0.15);
}

[data-theme="light"] .command-block.dragging {
    box-shadow: 0 5px 14px rgba(140, 125, 105, 0.22);
}

[data-theme="light"] .block-delete:hover {
    background: rgba(192, 107, 101, 0.15);
}

[data-theme="light"] .dpad-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(140, 125, 105, 0.3);
}

[data-theme="light"] .dpad-btn:hover:not(.dpad-center) {
    background: rgba(255, 255, 255, 1);
    border-color: var(--accent-blue);
}

[data-theme="light"] .dpad-btn:active:not(.dpad-center),
[data-theme="light"] .dpad-btn.active:not(.dpad-center) {
    background: var(--accent-blue);
    color: #fff;
}

[data-theme="light"] .dpad-center {
    background: rgba(140, 125, 105, 0.12);
}

[data-theme="light"] .joystick-base {
    background: radial-gradient(circle at center, rgba(140, 125, 105, 0.18) 0%, rgba(140, 125, 105, 0.1) 100%);
    border-color: rgba(140, 125, 105, 0.25);
}

[data-theme="light"] .joystick-stick {
    background: linear-gradient(145deg, #f3f1ee, #e5e3dc);
    border-color: var(--accent-purple);
    box-shadow: 
        0 3px 12px rgba(140, 125, 105, 0.22),
        inset 0 2px 4px rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .joystick-stick:hover {
    border-color: var(--accent-blue);
}

[data-theme="light"] .joystick-stick:active,
[data-theme="light"] .joystick-stick.active {
    border-color: var(--accent-green);
    box-shadow: 
        0 3px 12px rgba(140, 125, 105, 0.22),
        0 0 14px rgba(74, 153, 100, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .action-btn {
    box-shadow: 0 2px 8px rgba(140, 125, 105, 0.18);
}

[data-theme="light"] .action-btn:active,
[data-theme="light"] .action-btn.active {
    color: #fff;
}

[data-theme="light"] .nav-btn-ble {
    background: linear-gradient(145deg, #5089b5, #6098c2);
    color: #fff;
}

[data-theme="light"] .nav-btn-ble:hover {
    box-shadow: 0 3px 14px rgba(80, 137, 181, 0.3);
}

[data-theme="light"] .nav-btn-serial {
    background: linear-gradient(145deg, #c08a45, #cc9a58);
    color: #fff;
}

[data-theme="light"] .nav-btn-serial:hover {
    box-shadow: 0 3px 14px rgba(192, 138, 69, 0.3);
}

[data-theme="light"] .subprogram-icon {
    background: linear-gradient(145deg, #7d6bab, #5089b5);
}

[data-theme="light"] .subprogram-item.default .subprogram-icon {
    background: linear-gradient(145deg, #a8a2a0, #989290);
}

[data-theme="light"] .block-palette {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(140, 125, 105, 0.2);
}

[data-theme="light"] .palette-block {
    background: rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .palette-block:hover:not(:disabled) {
    background: rgba(255, 255, 255, 1);
}

[data-theme="light"] .palette-block.block-setaxis {
    background: rgba(80, 137, 181, 0.14);
    color: #356085;
    border-color: rgba(80, 137, 181, 0.35);
}

[data-theme="light"] .palette-block.block-wait {
    background: rgba(192, 138, 69, 0.14);
    color: #7a5520;
    border-color: rgba(192, 138, 69, 0.35);
}

[data-theme="light"] .code-block.block-setaxis {
    background: rgba(80, 137, 181, 0.12);
    border-color: rgba(80, 137, 181, 0.35);
}

[data-theme="light"] .code-block.block-wait {
    background: rgba(192, 138, 69, 0.12);
    border-color: rgba(192, 138, 69, 0.35);
}

[data-theme="light"] .controller-layout {
    background: rgba(248, 246, 242, 0.95);
    border: 1px solid rgba(140, 125, 105, 0.12);
}

[data-theme="light"] .values-display {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(140, 125, 105, 0.1);
}

[data-theme="light"] .send-status {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(140, 125, 105, 0.1);
}

[data-theme="light"] .shoulder-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(140, 125, 105, 0.3);
}

[data-theme="light"] .shoulder-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--accent-orange);
}

[data-theme="light"] .shoulder-btn:active,
[data-theme="light"] .shoulder-btn.active {
    background: var(--accent-orange);
    color: #fff;
}

[data-theme="light"] .shoulder-btn.l2-btn,
[data-theme="light"] .shoulder-btn.r2-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--accent-purple);
    color: #5a4a8a;
}

[data-theme="light"] .shoulder-btn.l2-btn:hover,
[data-theme="light"] .shoulder-btn.r2-btn:hover {
    background: rgba(125, 107, 171, 0.15);
}

[data-theme="light"] .shoulder-btn.l2-btn:active,
[data-theme="light"] .shoulder-btn.l2-btn.active,
[data-theme="light"] .shoulder-btn.r2-btn:active,
[data-theme="light"] .shoulder-btn.r2-btn.active {
    background: var(--accent-purple);
    color: #fff;
}

[data-theme="light"] .pause-btn {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--accent-orange);
    color: #7a5520;
}

[data-theme="light"] .pause-btn:hover {
    background: var(--accent-orange);
    color: #fff;
}

[data-theme="light"] .status-item,
[data-theme="light"] .button-assignments {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(140, 125, 105, 0.1);
}

[data-theme="light"] .note-input-section,
[data-theme="light"] .piano-section,
[data-theme="light"] .melody-controls,
[data-theme="light"] .presets-section {
    background: rgba(248, 246, 242, 0.95);
    border: 1px solid rgba(140, 125, 105, 0.12);
}

[data-theme="light"] .notes-list {
    background: rgba(248, 246, 242, 0.95);
    border: 1px solid rgba(140, 125, 105, 0.12);
}

[data-theme="light"] .note-item {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(140, 125, 105, 0.25);
}

[data-theme="light"] .note-item:hover {
    border-color: rgba(125, 107, 171, 0.45);
    background: rgba(255, 255, 255, 1);
}

[data-theme="light"] .note-select,
[data-theme="light"] .duration-select {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(140, 125, 105, 0.3);
}

[data-theme="light"] .note-select option,
[data-theme="light"] .duration-select option,
[data-theme="light"] .note-select optgroup {
    background: #efeee9;
    color: #1a1816;
}

[data-theme="light"] .controller-select-wrapper select {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(140, 125, 105, 0.28);
}

[data-theme="light"] .controller-select-wrapper select option {
    background: #efeee9;
    color: #1a1816;
}

[data-theme="light"] .button-mapping select {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(140, 125, 105, 0.28);
}

[data-theme="light"] .button-mapping select option {
    background: #efeee9;
    color: #1a1816;
}

[data-theme="light"] .axis-controls select {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(140, 125, 105, 0.28);
}

[data-theme="light"] .axis-controls select option {
    background: #efeee9;
    color: #1a1816;
}

[data-theme="light"] .preset-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(140, 125, 105, 0.25);
}

[data-theme="light"] .preset-btn:hover {
    border-color: rgba(125, 107, 171, 0.45);
    background: rgba(255, 255, 255, 1);
}

[data-theme="light"] .mapping-section {
    background: rgba(248, 246, 242, 0.95);
    border: 1px solid rgba(140, 125, 105, 0.12);
}

[data-theme="light"] .mapping-note {
    background: rgba(74, 153, 100, 0.1);
    border-left-color: #4a9964;
}

[data-theme="light"] .button-mapping,
[data-theme="light"] .axis-mapping {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(140, 125, 105, 0.12);
}

[data-theme="light"] .button-mapping:hover,
[data-theme="light"] .axis-mapping:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(140, 125, 105, 0.2);
}

[data-theme="light"] .config-section {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(140, 125, 105, 0.1);
}

[data-theme="light"] .btn-warning {
    background: linear-gradient(145deg, #c08a45, #cc9a58);
    color: #fff;
}

[data-theme="light"] .btn-warning:hover:not(:disabled) {
    background: linear-gradient(145deg, #b07a35, #c08a45);
    box-shadow: 0 3px 14px rgba(192, 138, 69, 0.3);
}

[data-theme="light"] .modal {
    background: var(--bg-gradient-2);
    border-color: rgba(140, 125, 105, 0.25);
}

/* ============================================================================
   Responsive Adjustments
   ============================================================================ */

@media (max-width: 1400px) {
    .tab-sidebar {
        width: 260px;
    }
}

@media (max-width: 1200px) {
    .sidebar {
        width: 280px;
    }
    
    .tab-sidebar {
        width: 240px;
    }
    
    .joystick {
        width: 120px;
        height: 120px;
    }
    
    .joystick-stick {
        width: 45px;
        height: 45px;
    }
    
    .button-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 1000px) {
    .tab-content.active {
        flex-direction: column;
    }
    
    .tab-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .tab-sidebar > .panel {
        flex: 1;
        min-width: 250px;
    }
    
    .subprogram-list {
        max-height: 200px;
    }
}

@media (max-width: 900px) {
    .bdev-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: visible;
    }
    
    .sidebar > .panel {
        flex: 1;
        min-width: 250px;
    }
    
    .controller-layout {
        flex-wrap: wrap;
        gap: 1rem;
        min-height: auto;
    }
    
    .melody-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .playback-controls,
    .upload-controls {
        justify-content: center;
    }
    
    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .tab-label {
        display: none;
    }
    
    .tab-icon {
        font-size: 1.2rem;
    }
}

@media (max-width: 600px) {
    .bdev-dashboard {
        padding: 0.5rem;
    }
    
    .tab-nav {
        gap: 0.25rem;
    }
    
    .header-right .nav-btn {
        display: none;
    }
}

/* ============================================================================
   CRYPTO TAB
   ============================================================================ */

/* Crypto Info Panel */
.crypto-info-panel {
    flex-shrink: 0;
}

.crypto-info-panel .panel-hint {
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.crypto-actions {
    display: flex;
    gap: 0.5rem;
}

.crypto-actions .btn {
    flex: 1;
}

/* Public Key Panel */
.public-key-panel {
    flex-shrink: 0;
}

.key-display {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.key-section {
    background: var(--card-hover);
    border-radius: 8px;
    padding: 0.75rem;
}

.key-section label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.key-value {
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.7rem;
    color: var(--accent-green);
    word-break: break-all;
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 4px;
}

.key-value.key-full {
    font-size: 0.65rem;
    color: var(--accent-blue);
}

.key-section .btn {
    margin-top: 0.5rem;
    width: 100%;
}

/* Crypto Panel (Main) */
.crypto-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.crypto-header {
    flex-shrink: 0;
    margin-bottom: 1rem;
}

.crypto-header h2 {
    margin-bottom: 0.25rem;
}

.crypto-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.crypto-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

.crypto-placeholder .placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.crypto-placeholder p {
    font-size: 1rem;
    margin: 0.25rem 0;
}

.crypto-placeholder .placeholder-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Signing Section */
.signing-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.signing-input {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
}

.signing-input label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.signing-input-row {
    display: flex;
    gap: 0.75rem;
}

.signing-input-row input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    background: var(--input-bg);
    border: 2px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.signing-input-row input:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(162, 155, 254, 0.3);
}

.signing-input-row input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.message-info {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
}

.signing-actions {
    display: flex;
    justify-content: center;
}

.signing-actions .btn-large {
    padding: 1rem 3rem;
    font-size: 1.1rem;
}

/* Signature Result */
.signature-result {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
}

.signature-result h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.result-section {
    margin-bottom: 1rem;
}

.result-section:last-of-type {
    margin-bottom: 1.5rem;
}

.result-section label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.result-value {
    font-family: 'Consolas', 'Monaco', 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--accent-orange);
    word-break: break-all;
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.6rem;
    border-radius: 6px;
}

.result-value.mono {
    color: var(--accent-blue);
}

.signature-full {
    font-size: 0.65rem;
    color: var(--accent-purple) !important;
}

/* Verification Section */
.verification-section {
    border-top: 1px solid var(--card-border);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.verification-section h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.verification-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
}

.verification-icon {
    font-size: 1.5rem;
}

.verification-status.verification-pending {
    background: rgba(254, 202, 87, 0.15);
    border: 2px solid rgba(254, 202, 87, 0.3);
    color: var(--accent-orange);
}

.verification-status.verification-success {
    background: rgba(38, 222, 129, 0.15);
    border: 2px solid rgba(38, 222, 129, 0.4);
    color: var(--accent-green);
    animation: successPulse 0.5s ease;
}

.verification-status.verification-error {
    background: rgba(255, 107, 107, 0.15);
    border: 2px solid rgba(255, 107, 107, 0.4);
    color: var(--accent-red);
    animation: errorShake 0.5s ease;
}

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

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Light Theme Overrides for Crypto Tab */
[data-theme="light"] .key-value {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .key-section {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(140, 125, 105, 0.1);
}

[data-theme="light"] .signing-input {
    background: rgba(248, 246, 242, 0.95);
    border: 1px solid rgba(140, 125, 105, 0.12);
}

[data-theme="light"] .signature-result {
    background: rgba(248, 246, 242, 0.95);
    border: 1px solid rgba(140, 125, 105, 0.12);
}

[data-theme="light"] .result-value {
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .verification-status.verification-success {
    background: rgba(74, 153, 100, 0.12);
    border-color: rgba(74, 153, 100, 0.35);
}

[data-theme="light"] .verification-status.verification-error {
    background: rgba(192, 107, 101, 0.12);
    border-color: rgba(192, 107, 101, 0.35);
}

[data-theme="light"] .verification-status.verification-pending {
    background: rgba(192, 138, 69, 0.12);
    border-color: rgba(192, 138, 69, 0.35);
}