/**
 * Bricasti M7 Calculator - Theme System
 */

/* Font Face for Dot Matrix LCD Display */
@font-face {
    font-family: 'Dot Matrix';
    src: url('../fonts/DOTMATRI.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* Theme Variables - Dark Mode (Default) */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #252525;
    --text-primary: #e0e0e0;
    --text-secondary: #999;
    --text-accent: #ff3333;
    --border-primary: #333;
    --border-hover: #ff3333;
    --input-bg: #1a1a1a;
    --input-border: #333;
    --button-bg: #252525;
    --button-hover: #333;
    --table-header-bg: #0a0a0a;
    --table-row-hover: rgba(255, 51, 51, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --preset-card-bg: #1a1a1a;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 20px;
    min-height: 100vh;
    letter-spacing: 0.3px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Header */
.header {
    position: relative;
    background: var(--bg-secondary);
    color: var(--text-accent);
    padding: 30px;
    text-align: center;
    border-bottom: 1px solid var(--border-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    font-weight: 400;
    letter-spacing: 6px;
    text-transform: capitalize;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

.header p {
    font-size: 0.9em;
    opacity: 0.7;
    margin-bottom: 15px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* MIDI Popover Button */
.midi-popover-button {
    position: absolute;
    top: 30px;
    right: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
    font-weight: 600;
}

.midi-popover-button:hover {
    background: #252525;
    border-color: #ff3333;
    color: #ff3333;
    transform: translateY(-2px);
}

.midi-popover-button .midi-icon {
    font-size: 1.3em;
}

.midi-popover-button .midi-label {
    letter-spacing: 1px;
}

.header-stats {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 0.9em;
    opacity: 0.8;
    flex-wrap: wrap;
}

.header-stats span {
    white-space: nowrap;
}

/* Sections */
.calculator-section,
.timing-section,
.preset-section,
.parameters-section,
.midi-section,
.documentation-section {
    padding: 30px;
    border-bottom: 1px solid #333;
}

.calculator-section h2,
.timing-section h2,
.preset-section h2,
.parameters-section h2,
.midi-section h2,
.documentation-section h2 {
    font-size: 1.8em;
    margin-bottom: 20px;
    color: #ff3333;
    font-weight: 400;
    letter-spacing: 4px;
    text-transform: capitalize;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

/* Calculator Grid - Side by Side */
.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

/* BPM Calculator (Left) */
.bpm-calculator h2 {
    font-size: 1.6em;
    margin-bottom: 15px;
    color: #ff3333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    font-weight: 400;
    text-transform: capitalize;
}

.bpm-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.metronome-visual {
    width: 50px;
    height: 58px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.metronome-visual:hover {
    opacity: 0.8;
}

.metronome-visual:active {
    opacity: 0.6;
}

.metronome-image {
    width: 50px;
    height: 58px;
    pointer-events: none;
}

.metronome-image.flip {
    transform: scaleX(-1);
}

.bpm-controls #bpm {
    width: 140px;
    font-size: 2.2em;
    text-align: center;
    font-weight: 400;
    padding: 12px;
    background: #000;
    border: 2px solid #ff3333;
    border-radius: 4px;
    color: #ff3333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

.bpm-controls #bpm:focus {
    outline: none;
    border-color: #ff5555;
}

.button-group {
    display: flex;
    gap: 10px;
}

.tap-tempo,
.play-metronome {
    padding: 12px 20px;
    background: #1a1a1a;
    color: #ff3333;
    border: 2px solid #ff3333;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    white-space: nowrap;
}

.tap-tempo:hover,
.play-metronome:hover {
    background: #2a2a2a;
    border-color: #ff5555;
}

.tap-tempo:active,
.tap-tempo.tap-active {
    background: #000;
}

.play-metronome:active,
.play-metronome.playing {
    background: #000;
}

.play-metronome.playing {
    color: #33ff33;
    border-color: #33ff33;
}

/* Shortcuts Bar */
.shortcuts-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    margin-top: 20px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 1em;
    flex-wrap: wrap;
}

.shortcuts-label {
    color: #999;
    font-weight: 500;
    margin-right: 4px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #999;
}

.shortcuts-bar kbd {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 3px 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', monospace;
    font-size: 0.9em;
    color: #ddd;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Beats/Bars Calculator (Right) */
.beats-calculator h2 {
    font-size: 1.6em;
    margin-bottom: 15px;
    color: #ff3333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    font-weight: 400;
    text-transform: capitalize;
}

.beats-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.beats-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.beats-row label {
    font-weight: 600;
    color: #999;
    min-width: 50px;
}

.beats-row input[type="number"] {
    width: 80px;
    padding: 8px 12px;
    background: #000;
    border: 2px solid #ff3333;
    border-radius: 4px;
    font-size: 1.2em;
    text-align: center;
    color: #ff3333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    height: 43px;
    box-sizing: border-box;
}

.beats-row input[type="number"]:focus {
    outline: none;
    border-color: #ff5555;
}

/* Invalid input feedback */
.invalid-input {
    border-color: #ffaa00 !important;
    background: #221100 !important;
    animation: shake 0.3s ease-in-out;
}

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

.time-signature {
    padding: 8px 12px;
    background: #000;
    border: 2px solid #ff3333;
    border-radius: 4px;
    font-size: 1.2em;
    cursor: pointer;
    color: #ff3333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    height: 43px;
    box-sizing: border-box;
}

.time-signature:focus {
    outline: none;
    border-color: #ff5555;
}

.custom-time-signature {
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-time-signature input[type="number"] {
    width: 50px;
    padding: 8px 8px;
    background: #000;
    border: 2px solid #ff3333;
    border-radius: 4px;
    font-size: 1.2em;
    text-align: center;
    color: #ff3333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    height: 43px;
    box-sizing: border-box;
}

.custom-time-signature input[type="number"]:focus {
    outline: none;
    border-color: #ff5555;
}

.custom-denominator {
    width: 50px;
    padding: 8px 8px;
    background: #000;
    border: 2px solid #ff3333;
    border-radius: 4px;
    font-size: 1.2em;
    text-align: center;
    color: #ff3333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    height: 43px;
    box-sizing: border-box;
    cursor: pointer;
}

.custom-denominator:focus {
    outline: none;
    border-color: #ff5555;
}

.time-signature-slash {
    font-size: 1.4em;
    color: #ff3333;
    font-weight: 600;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

.calc-result {
    font-weight: 400;
    color: #ff3333;
    font-size: 1.5em;
    flex: 1;
    text-align: right;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

/* Timing Table */
.timing-hint {
    text-align: center;
    color: #999;
    font-size: 0.95em;
    margin: 15px 0 10px 0;
    font-style: italic;
}

.timing-table-container {
    overflow-x: auto;
    margin-top: 20px;
    background: #000;
    border: 1px solid #333;
    border-radius: 4px;
}

.timing-table {
    width: 100%;
    border-collapse: collapse;
    background: #000;
    font-size: 0.9em;
}

.timing-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #1a1a1a;
}

.timing-table th {
    background: #1a1a1a;
    color: #ff3333;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid #333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

.timing-table th.th-symbol {
    width: 60px;
    text-align: center;
}

.timing-table th.th-name {
    width: 140px;
}

.timing-table th.th-duration {
    width: 100px;
    text-align: right;
}

.timing-table th.th-frequency {
    width: 100px;
    text-align: right;
}

.timing-table th.th-group {
    background: #222;
    border-bottom: 2px solid #ff3333;
    font-weight: 700;
    text-align: center;
}

.timing-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #222;
}

.timing-table tr:hover {
    background: #1a1a1a;
}

.timing-table tr:last-child td {
    border-bottom: none;
}

.timing-table .note-symbol {
    font-size: 2em;
    text-align: center;
    color: #ff3333;
    font-family: 'Noto Music', 'Segoe UI Symbol', 'Apple Color Emoji', sans-serif;
    width: 60px;
}

.timing-table .note-symbol sup {
    font-size: 0.5em;
    color: #ff3333;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    vertical-align: top;
    margin-left: 1px;
    font-weight: 600;
}

.timing-table .note-name {
    font-weight: 600;
    color: #e0e0e0;
    white-space: nowrap;
}

.timing-table .note-duration,
.timing-table .note-frequency {
    text-align: right;
    font-weight: 600;
    color: #ff3333;
    font-family: 'Dot Matrix', 'Courier New', monospace;
    font-size: 1.5em;
    letter-spacing: 0.5px;
}

.timing-table .unit {
    font-size: 0.8em;
    color: #666;
    margin-left: 2px;
    font-weight: normal;
}

.timing-table .note-use {
    color: #999;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Clickable notes styling */
.timing-table .note-clickable {
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.timing-table .note-clickable:hover {
    background-color: #1a1a1a !important;
}

.timing-table .note-clickable:active {
    background-color: #222 !important;
}

/* Playing note indicator */
.timing-table .note-playing {
    background-color: #ff3333 !important;
    color: #000 !important;
}

.timing-table .note-playing.note-symbol {
    color: #000 !important;
}

.timing-table .note-playing .unit {
    color: #333 !important;
}

/* Keep text red when hovering over selected (playing) note */
.timing-table .note-playing:hover {
    color: var(--text-accent) !important;
}

.timing-table .note-playing.note-symbol:hover {
    color: var(--text-accent) !important;
}

.timing-table .note-playing:hover .unit {
    color: var(--text-accent) !important;
    opacity: 0.7;
}

/* Add pulse animation to playing notes */
.timing-table .note-playing {
    animation: notePulse 0.5s ease-in-out infinite alternate;
}

@keyframes notePulse {
    0% {
        background-color: #ff3333;
    }
    100% {
        background-color: #cc0000;
    }
}

/* Delay Metronome Controls */
.delay-controls {
    margin-top: 30px;
    padding: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    display: none; /* Hidden by default, shown when note is playing */
}

.delay-controls.visible {
    display: block;
}

.delay-controls h3 {
    font-size: 1.4em;
    margin-bottom: 20px;
    color: #ff3333;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    font-weight: 400;
    text-transform: capitalize;
    letter-spacing: 2px;
}

.delay-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.delay-section {
    padding: 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
}

.delay-header {
    margin-bottom: 15px;
}

.delay-label {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 0.95em;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.delay-control-row {
    display: grid;
    grid-template-columns: 80px 1fr 100px;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}

.delay-control-row:last-child {
    margin-bottom: 0;
}

.delay-control-row label {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.delay-control-row input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.delay-control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--text-accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.delay-control-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.delay-control-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--text-accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease;
}

.delay-control-row input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.value-display {
    font-size: 0.9em;
    color: var(--text-primary);
    text-align: right;
    font-weight: 500;
    min-width: 70px;
}

.delay2-controls {
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .delay-controls-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .delay-control-row {
        grid-template-columns: 70px 1fr 80px;
        gap: 10px;
    }
}

/* Alternating row colors */
.timing-table tbody tr:nth-child(odd) {
    background: #050505;
}

.timing-table tbody tr:nth-child(even) {
    background: #0a0a0a;
}

/* Parameters Grid */
.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.param-card {
    background: #000;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
    border-left: 4px solid #ff3333;
}

.param-card:hover {
    border-color: #ff3333;
}

.param-card h4 {
    font-size: 0.85em;
    margin-bottom: 8px;
    color: #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.param-card .value {
    font-size: 2.2em;
    font-weight: 700;
    color: #ff3333;
    margin-bottom: 8px;
    font-family: 'Dot Matrix', 'Courier New', monospace;
}

.param-card .description {
    font-size: 0.85em;
    color: #999;
    line-height: 1.4;
}

.param-card .param-desc {
    font-size: 0.85em;
    color: #999;
    margin-top: 10px;
    line-height: 1.5;
}

/* Preset Search */
.preset-search-wrapper {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.preset-search {
    flex: 1;
    min-width: 250px;
    padding: 12px 16px;
    border: 2px solid #333;
    border-radius: 8px;
    font-size: 1em;
    background: #000;
    color: #e0e0e0;
}

.preset-search:focus {
    outline: none;
    border-color: #ff3333;
}

.preset-search::placeholder {
    color: #666;
}

.category-select {
    padding: 12px 16px;
    border: 2px solid #333;
    border-radius: 8px;
    font-size: 1em;
    background: #000;
    color: #e0e0e0;
    cursor: pointer;
    min-width: 200px;
}

.category-select:focus {
    outline: none;
    border-color: #ff3333;
}

.view-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: 2px solid #333;
    border-radius: 8px;
    background: #000;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 1em;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.view-mode-toggle:hover {
    border-color: #ff3333;
    background: #1a1a1a;
}

.view-mode-toggle:focus {
    outline: none;
    border-color: #ff3333;
}

.view-mode-toggle[data-mode="table"] {
    border-color: #ff3333;
    background: #1a1a1a;
}

.toggle-icon {
    font-size: 1.2em;
    line-height: 1;
    color: #ff3333;
}

.toggle-label {
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffffff;
}

/* Preset Category Section */
.preset-category-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid #333;
}

.preset-category-section:last-child {
    border-bottom: none;
}

.preset-category-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.preset-category-header h3 {
    font-size: 1.5em;
    color: #e0e0e0;
    margin: 0;
}

.category-description {
    color: #999;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Preset Grid */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.preset-card {
    background: #000;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
}

.preset-card:hover {
    border-color: #ff3333;
}

.preset-card-header h4 {
    font-size: 1.1em;
    color: #e0e0e0;
    margin-bottom: 8px;
}

.preset-card-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #333;
    display: flex;
    justify-content: center;
}

.btn-send-preset {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #0a0a0a;
    color: #ff3333;
    border: 2px solid #ff3333;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-send-preset:hover {
    background: #1a1a1a;
    border-color: #ff3333;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 51, 51, 0.3);
}

.btn-send-preset:active {
    transform: translateY(0);
}

.btn-send-preset .btn-icon {
    font-size: 0.9em;
}

.preset-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.badge {
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.most-popular {
    background: #ff3333;
    color: white;
}

.badge.industry {
    background: #cc2222;
    color: white;
}

.badge.popular {
    background: #ff5555;
    color: white;
}

.badge-factory {
    background: #2a9d8f;
    color: white;
    border: 1px solid #21867a;
}

/* Preset Parameters Grid */
.preset-params-grid-full {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
    background: #000;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #333;
    overflow: hidden;
}

.preset-param {
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    background: #0a0a0a;
    border-radius: 4px;
    min-width: 0;
    overflow: hidden;
}

.preset-param .param-label {
    font-size: 0.7em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preset-param .param-value {
    font-size: 1.1em;
    font-weight: 700;
    color: #ff3333;
    font-family: 'Dot Matrix', 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Best Practices */
.best-practices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.practice-card {
    background: #000;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
}

.practice-card h4 {
    color: #ff3333;
    margin-bottom: 10px;
    font-size: 1.3em;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
    font-weight: 400;
    text-transform: capitalize;
}

.practice-card ul {
    list-style: none;
    font-size: 0.9em;
    line-height: 1.6;
}

.practice-card li {
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
    color: #ccc;
}

.practice-card li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #ff3333;
    font-weight: bold;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* Preset Table View */
.preset-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    margin-top: 20px;
    background: #000;
    border: 1px solid #333;
    border-radius: 4px;
    position: relative;
    max-height: 600px;
    /* Better scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    /* Scrollbar styling for webkit browsers */
    scrollbar-width: thin;
    scrollbar-color: #ff3333 #1a1a1a;
}

.preset-table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.preset-table-wrapper::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.preset-table-wrapper::-webkit-scrollbar-thumb {
    background: #ff3333;
    border-radius: 4px;
}

.preset-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #ff5555;
}

/* Scroll shadow indicators */
.preset-table-wrapper::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    pointer-events: none;
    z-index: 5;
}

/* Right scroll indicator shadow */
.preset-table-wrapper::before {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, rgba(0,0,0,0.6) 0%, transparent 100%);
    pointer-events: none;
    z-index: 5;
    float: right;
}

.preset-table {
    width: 100%;
    min-width: 900px; /* Ensure table is wide enough to show all columns */
    border-collapse: collapse;
    background: #000;
    font-size: 0.9em;
}

.preset-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #1a1a1a;
}

.preset-table th {
    background: #1a1a1a;
    color: #ff3333;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #333;
    white-space: nowrap;
}

/* Dot Matrix font for numeric column headers only */
.preset-table th.numeric {
    font-family: 'Dot Matrix', 'Courier New', monospace;
    font-weight: 400;
    letter-spacing: 1px;
    font-size: 0.9em;
}

.preset-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.preset-table th.sortable:hover {
    background: #222;
    color: #ff5555;
}

.preset-table th.numeric {
    text-align: right;
}

.preset-table td {
    padding: 10px;
    border-bottom: 1px solid #222;
}

.preset-table tr:hover {
    background: #1a1a1a;
}

.preset-table .preset-name {
    font-weight: 600;
    color: #e0e0e0;
    white-space: nowrap;
}

.preset-table .category-name {
    color: #999;
    font-size: 0.9em;
}

.preset-table .numeric {
    text-align: right;
    color: #ff3333;
    font-family: 'Dot Matrix', 'Courier New', monospace;
    font-size: 1.1em;
    letter-spacing: 1px;
}

.preset-table tbody tr:nth-child(odd) {
    background: #050505;
}

.preset-table tbody tr:nth-child(even) {
    background: #0a0a0a;
}

.preset-table .action-column {
    text-align: center;
    min-width: 120px;
}

.preset-table .action-cell {
    text-align: center;
    padding: 8px;
}

/* Footer */
.footer {
    background: #0a0a0a;
    color: #999;
    text-align: center;
    padding: 25px 30px;
    font-size: 0.9em;
    border-top: 1px solid #333;
}

.footer p {
    margin: 5px 0;
}

.footer a {
    color: #ff3333;
    text-decoration: none;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

.footer a:hover {
    color: #ff5555;
    text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .calculator-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .calculator-section,
    .timing-section,
    .preset-section,
    .parameters-section,
    .documentation-section {
        padding: 20px;
    }

    .header h1 {
        font-size: 2em;
        letter-spacing: 3px;
    }

    .bpm-controls {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    .metronome-visual {
        flex-shrink: 0;
    }

    .bpm-controls #bpm {
        flex: 1;
        min-width: 0;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .tap-tempo,
    .play-metronome {
        width: 100%;
        font-size: 1em;
    }

    .beats-row {
        flex-wrap: nowrap;
    }

    .beats-row label {
        min-width: 45px;
        font-size: 0.9em;
    }

    .beats-row input[type="number"] {
        width: 60px;
    }

    .custom-time-signature input[type="number"] {
        width: 45px;
        font-size: 1em;
    }

    .time-signature-slash {
        font-size: 1.2em;
    }

    .calc-result {
        font-size: 1.2em;
    }

    .shortcuts-bar {
        display: none;
    }

    .timing-table {
        font-size: 0.8em;
        table-layout: auto;
    }

    .timing-table th,
    .timing-table td {
        padding: 4px 6px;
    }

    .timing-table .note-symbol {
        font-size: 1.5em;
        width: 40px;
    }

    .timing-table th.th-symbol {
        width: 35px;
        text-align: center;
    }

    .timing-table th.th-name {
        width: 80px;
    }

    .timing-table th.th-duration {
        width: auto;
        text-align: right;
    }

    .timing-table th.th-frequency {
        width: 70px;
    }

    /* Hide Hz columns on mobile for better readability */
    .timing-table th.th-frequency,
    .timing-table .note-frequency {
        display: none;
    }

    /* Adjust group headers to span only 2 columns instead of 3 on mobile */
    .timing-table th.th-group {
        /* This is handled by hiding frequency columns - each group still shows symbol and ms */
    }

    .params-grid {
        grid-template-columns: 1fr;
    }

    .preset-grid {
        grid-template-columns: 1fr;
    }

    .best-practices-grid {
        grid-template-columns: 1fr;
    }
}


/* ========================================
   MIDI Control System - Tabbed Interface
   ======================================== */

/* MIDI Popover Modal */
.midi-popover {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

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

.midi-popover-content {
    background: #0a0a0a;
    border: 2px solid #333;
    border-radius: 12px;
    width: 100%;
    max-width: 1400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

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

/* MIDI Popover Header */
.midi-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    background: #0a0a0a;
    border-bottom: 2px solid #333;
}

.midi-popover-header h2 {
    margin: 0;
    font-size: 1.8em;
    color: #ff3333;
    font-weight: 400;
    letter-spacing: 4px;
    text-transform: capitalize;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

.midi-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.midi-popover-close {
    background: transparent;
    border: 2px solid #333;
    color: #999;
    font-size: 2em;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.midi-popover-close:hover {
    background: #ff3333;
    border-color: #ff3333;
    color: #fff;
    transform: rotate(90deg);
}

/* Override for popover panels - allow scrolling */
.midi-popover .midi-panels {
    overflow-y: auto;
    flex: 1;
}

/* MIDI Header (Legacy - for backward compatibility) */
.midi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.midi-header h2 {
    margin: 0;
}

/* Status Indicator */
.midi-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ef4444;
    animation: pulse 2s ease-in-out infinite;
}

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

.status-text {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.9em;
}

/* Tab Navigation */
.midi-tabs {
    display: flex;
    background: #0a0a0a;
    border-bottom: 2px solid #333;
}

.midi-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #999;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95em;
    font-weight: 600;
}

.midi-tab:hover {
    background: #1a1a1a;
    color: #e0e0e0;
}

.midi-tab.active {
    color: #ff3333;
    border-bottom-color: #ff3333;
    background: #1a1a1a;
}

.tab-icon {
    font-size: 1.2em;
}

.tab-shortcut {
    font-size: 0.75em;
    color: #666;
    margin-left: auto;
}

/* Tab Panels */
.midi-panels {
    min-height: 400px;
}

.midi-panel {
    display: none;
    padding: 30px;
    animation: fadeIn 0.2s ease-in;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Connection Panel Styles */
.connection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

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

.midi-control-group label {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.9em;
}

.midi-control-group small {
    color: #999;
    font-size: 0.85em;
    margin-top: -4px;
}

.midi-select,
.midi-input,
.patch-select,
.patch-input,
.filter-select,
.patch-search {
    padding: 10px 12px;
    background: #0a0a0a;
    border: 1px solid #444;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.95em;
    font-family: inherit;
}

.midi-select:focus,
.midi-input:focus,
.patch-select:focus,
.patch-input:focus,
.filter-select:focus,
.patch-search:focus {
    outline: none;
    border-color: #ff3333;
    background: #1a1a1a;
}

.midi-device-info {
    padding: 12px;
    background: #0a0a0a;
    border-radius: 6px;
    color: #999;
    font-size: 0.85em;
    margin-bottom: 15px;
}

.midi-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Button Styles */
.btn-primary,
.btn-connect,
.btn-disconnect,
.btn-secondary,
.btn-capture,
.btn-import,
.btn-export-all,
.btn-import-backup,
.btn-send,
.btn-export,
.btn-view,
.btn-delete {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95em;
    font-family: inherit;
}

.btn-large {
    padding: 15px 30px;
    font-size: 1.1em;
}

.btn-primary {
    background: #22c55e;
    color: white;
}

.btn-primary:hover {
    background: #16a34a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-connect {
    flex: 1;
    background: #3b82f6;
    color: white;
}

.btn-connect:hover {
    background: #2563eb;
}

.btn-connect:disabled {
    background: #374151;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-disconnect {
    flex: 1;
    background: #ef4444;
    color: white;
}

.btn-disconnect:hover {
    background: #dc2626;
}

.btn-secondary {
    background: #4b5563;
    color: white;
}

.btn-secondary:hover {
    background: #374151;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-capture {
    width: 100%;
    background: #9333ea;
    color: white;
}

.btn-capture:hover {
    background: #7e22ce;
}

.btn-capture:disabled {
    background: #374151;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Library Panel Styles */
.library-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #0a0a0a;
    border-radius: 8px;
    border: 1px solid #333;
}

.library-section h3,
.debug-section h3 {
    margin: 0 0 20px 0;
    color: #ff3333;
    font-size: 1.3em;
    font-weight: 400;
    letter-spacing: 2px;
    font-family: 'Dot Matrix', 'SF Mono', 'Monaco', monospace;
}

.capture-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 15px;
    align-items: end;
}

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

.patch-control-group label {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.9em;
}

.import-export-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.btn-import,
.btn-export-all,
.btn-import-backup {
    padding: 12px 20px;
    background: #3b82f6;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9em;
}

.btn-import:hover,
.btn-export-all:hover {
    background: #2563eb;
}

.btn-import-backup {
    background: #4b5563;
}

.btn-import-backup:hover {
    background: #374151;
}

/* Backup Settings */
.backup-settings {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #333;
}

.backup-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.backup-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e0e0e0;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
}

.backup-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.btn-backup-now {
    padding: 10px 18px;
    background: #22c55e;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
}

.btn-backup-now:hover {
    background: #16a34a;
}

.backup-info {
    margin: 0;
    color: #888;
    font-size: 0.85em;
    font-style: italic;
}

/* Library Header */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.library-header h3 {
    margin: 0;
    color: #e0e0e0;
}

.patch-count {
    font-size: 0.85em;
    color: #999;
    font-weight: normal;
    margin-left: 10px;
}

.library-controls {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 600px;
}

.patch-search {
    flex: 1;
    min-width: 200px;
}

.view-mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #0a0a0a;
    border: 1px solid #444;
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.view-mode-toggle:hover {
    background: #1a1a1a;
    border-color: #ff3333;
}

.toggle-icon {
    font-size: 1.1em;
}

/* Batch Actions */
.batch-actions-bar {
    display: none;
    justify-content: space-between;
    align-items: center;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 15px;
}

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

.batch-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.batch-selection label {
    color: #e0e0e0;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
}

.selected-count {
    color: #ff3333;
    font-weight: 600;
    font-size: 0.9em;
}

.batch-buttons {
    display: flex;
    gap: 10px;
}

.btn-batch {
    padding: 8px 16px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #0a0a0a;
    color: #e0e0e0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-batch:hover:not(:disabled) {
    background: #1a1a1a;
    border-color: #ff3333;
    color: #ff3333;
}

.btn-batch:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-batch.btn-danger:hover:not(:disabled) {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fca5a5;
}

/* Patch List (Card View) */
.patch-list {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 5px;
}

.no-patches {
    text-align: center;
    color: #666;
    padding: 60px 20px;
    font-style: italic;
    font-size: 1.1em;
}

.patch-card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.patch-card:hover {
    border-color: #ff3333;
    transform: translateX(5px);
}

.patch-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.patch-checkbox {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.patch-title-wrapper {
    flex: 1;
}

.patch-title {
    margin: 0 0 5px 0;
    color: #e0e0e0;
    font-size: 1.05em;
    font-weight: 600;
}

.patch-meta {
    margin: 0;
    color: #999;
    font-size: 0.85em;
}

.patch-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.patch-actions button {
    flex: 1;
    min-width: 80px;
    padding: 8px 16px;
    font-size: 0.85em;
}

.btn-send {
    background: #22c55e;
    color: white;
}

.btn-send:hover {
    background: #16a34a;
}

.btn-export {
    background: #3b82f6;
    color: white;
}

.btn-export:hover {
    background: #2563eb;
}

.btn-view {
    background: #8b5cf6;
    color: white;
}

.btn-view:hover {
    background: #7c3aed;
}

.btn-delete {
    background: #ef4444;
    color: white;
}

.btn-delete:hover {
    background: #dc2626;
}

/* Patch Details (Expandable) */
.patch-details {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.patch-details-content h6 {
    margin: 0 0 10px 0;
    color: #ff3333;
    font-size: 0.9em;
    text-transform: uppercase;
}

.patch-details-content p {
    margin: 5px 0;
    color: #ccc;
    font-size: 0.9em;
}

/* Patch Table View */
.patch-table-container {
    max-height: 500px;
    overflow-y: auto;
}

.patch-table {
    width: 100%;
    border-collapse: collapse;
}

.patch-table thead {
    position: sticky;
    top: 0;
    background: #0a0a0a;
    z-index: 10;
}

.patch-table th {
    padding: 12px;
    text-align: left;
    color: #e0e0e0;
    font-weight: 600;
    border-bottom: 2px solid #333;
    font-size: 0.9em;
}

.patch-table th:hover {
    color: #ff3333;
}

.patch-table td {
    padding: 12px;
    border-bottom: 1px solid #222;
    color: #ccc;
    font-size: 0.9em;
}

.patch-table tr:hover {
    background: #1a1a1a;
}

.patch-name {
    font-weight: 600;
    color: #e0e0e0;
}

.checkbox-header {
    width: 40px;
    text-align: center;
}

.patch-checkbox-cell {
    width: 40px;
    text-align: center;
}

.patch-actions-cell {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 6px 10px;
    background: #374151;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1em;
}

.btn-icon:hover {
    background: #4b5563;
    transform: scale(1.1);
}

/* Debug Panel Styles */
.debug-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #0a0a0a;
    border-radius: 8px;
    border: 1px solid #333;
}

/* Hex Viewer */
.hex-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.hex-viewer {
    background: #000;
    color: #0f0;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    line-height: 1.6;
    max-height: 400px;
    overflow: auto;
    border: 1px solid #333;
}

.hex-row {
    white-space: pre;
}

.hex-offset {
    color: #888;
}

.hex-sysex-start {
    color: #22c55e;
    font-weight: bold;
}

.hex-sysex-end {
    color: #ef4444;
    font-weight: bold;
}

.hex-data {
    color: #60a5fa;
}

.hex-ascii {
    color: #fbbf24;
}

/* MIDI Monitor */
.monitor-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.monitor-filters,
.monitor-buttons {
    display: flex;
    gap: 15px;
    align-items: center;
}

.monitor-filters label,
.monitor-buttons label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ccc;
    font-size: 0.9em;
    cursor: pointer;
}

.monitor-filters input[type="checkbox"],
.monitor-buttons input[type="checkbox"] {
    cursor: pointer;
}

.midi-monitor {
    background: #000;
    color: #e0e0e0;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #333;
}

.log-entry {
    padding: 6px 0;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    gap: 12px;
    align-items: center;
}

.log-time {
    color: #888;
    min-width: 90px;
}

.log-direction {
    font-size: 1.2em;
    min-width: 20px;
}

.log-in {
    color: #22c55e;
}

.log-out {
    color: #3b82f6;
}

.log-type {
    min-width: 120px;
    font-weight: 600;
}

.log-type-sysex {
    color: #8b5cf6;
}

.log-type-pc {
    color: #22c55e;
}

.log-type-cc {
    color: #3b82f6;
}

.log-data {
    color: #60a5fa;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-size {
    color: #888;
    font-size: 0.85em;
}

.log-empty {
    text-align: center;
    color: #666;
    padding: 40px;
    font-style: italic;
}

/* SysEx Comparison */
.section-help {
    color: #888;
    font-size: 0.9em;
    margin: -5px 0 15px 0;
    font-style: italic;
}

.comparison-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.comparison-selects {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

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

.comparison-select-group label {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.9em;
}

.comparison-result {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 20px;
    margin-top: 20px;
}

.comparison-header h4 {
    color: #e0e0e0;
    margin: 0 0 10px 0;
    font-size: 1.1em;
}

.comparison-summary {
    color: #888;
    margin: 0 0 15px 0;
}

.comparison-summary strong {
    color: #ff3333;
}

.comparison-message {
    text-align: center;
    padding: 30px;
    color: #22c55e;
    font-size: 1.1em;
}

.comparison-stats {
    display: flex;
    gap: 20px;
    padding: 12px;
    background: #1a1a1a;
    border-radius: 4px;
    margin-bottom: 20px;
}

.comparison-stats .stat-item {
    color: #888;
    font-size: 0.9em;
}

.diff-table-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 4px;
    margin-bottom: 15px;
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.diff-table thead {
    background: #1a1a1a;
    position: sticky;
    top: 0;
    z-index: 1;
}

.diff-table th {
    padding: 10px 12px;
    text-align: left;
    color: #e0e0e0;
    font-weight: 600;
    border-bottom: 2px solid #333;
}

.diff-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #222;
    color: #e0e0e0;
}

.diff-table tr:hover {
    background: #1a1a1a;
}

.offset-col {
    color: #888;
    font-weight: 600;
}

.hex-col {
    color: #60a5fa;
    font-family: 'Courier New', monospace;
}

.delta-col {
    font-weight: 600;
}

.delta-positive {
    color: #22c55e;
}

.delta-negative {
    color: #f87171;
}

.ascii-col {
    color: #a78bfa;
    font-size: 0.9em;
}

.more-diffs {
    color: #888;
    font-style: italic;
    text-align: center;
    margin: 10px 0;
    font-size: 0.9em;
}

.comparison-hints {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 15px;
    margin-top: 15px;
}

.comparison-hints h5 {
    color: #e0e0e0;
    margin: 0 0 10px 0;
    font-size: 1em;
}

.comparison-hints ul {
    margin: 0;
    padding-left: 20px;
    color: #888;
}

.comparison-hints li {
    margin: 5px 0;
    line-height: 1.5;
}

/* Messages */
.error-message,
.patch-message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.9em;
    font-weight: 500;
}

.error-message {
    background: #7f1d1d;
    border: 1px solid #991b1b;
    color: #fca5a5;
}

.patch-message-success {
    background: #14532d;
    border: 1px solid #166534;
    color: #86efac;
}

.patch-message-error {
    background: #7f1d1d;
    border: 1px solid #991b1b;
    color: #fca5a5;
}

.patch-message-info {
    background: #1e3a8a;
    border: 1px solid #1e40af;
    color: #93c5fd;
}

/* Scrollbar Styling */
.patch-list::-webkit-scrollbar,
.patch-table-container::-webkit-scrollbar,
.hex-viewer::-webkit-scrollbar,
.midi-monitor::-webkit-scrollbar {
    width: 8px;
}

.patch-list::-webkit-scrollbar-track,
.patch-table-container::-webkit-scrollbar-track,
.hex-viewer::-webkit-scrollbar-track,
.midi-monitor::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.patch-list::-webkit-scrollbar-thumb,
.patch-table-container::-webkit-scrollbar-thumb,
.hex-viewer::-webkit-scrollbar-thumb,
.midi-monitor::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.patch-list::-webkit-scrollbar-thumb:hover,
.patch-table-container::-webkit-scrollbar-thumb:hover,
.hex-viewer::-webkit-scrollbar-thumb:hover,
.midi-monitor::-webkit-scrollbar-thumb:hover {
    background: #ff3333;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .midi-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .midi-tab {
        flex-direction: column;
        padding: 12px 10px;
        gap: 4px;
    }

    .tab-label {
        font-size: 0.85em;
    }

    .tab-shortcut {
        display: none;
    }

    .connection-grid {
        grid-template-columns: 1fr;
    }

    .midi-buttons {
        flex-direction: column;
    }

    .midi-buttons button {
        width: 100%;
    }

    .capture-grid {
        grid-template-columns: 1fr;
    }

    .import-export-grid {
        grid-template-columns: 1fr;
    }

    .library-header {
        flex-direction: column;
        align-items: stretch;
    }

    .library-controls {
        flex-direction: column;
        max-width: none;
    }

    .patch-actions {
        grid-template-columns: 1fr 1fr;
    }

    .monitor-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .monitor-filters,
    .monitor-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .batch-actions-bar {
        flex-direction: column;
        gap: 12px;
    }

    .batch-buttons {
        width: 100%;
        flex-direction: column;
    }

    .btn-batch {
        width: 100%;
    }

    .comparison-selects {
        grid-template-columns: 1fr;
    }

    .backup-setting-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-backup-now {
        width: 100%;
    }
}

/* ========================================
   Parameter Display & Analysis
   ======================================== */

/* Patch Viewer */
.patch-viewer {
    font-size: 0.9em;
}

.patch-metadata {
    margin-bottom: 20px;
    padding: 15px;
    background: #0a0a0a;
    border-radius: 6px;
}

.patch-metadata h6 {
    margin: 0 0 12px 0;
    color: #ff3333;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metadata-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.metadata-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: #1a1a1a;
    border-radius: 4px;
}

.metadata-label {
    color: #999;
    font-weight: 600;
}

.metadata-value {
    color: #e0e0e0;
}

.metadata-value.valid {
    color: #22c55e;
}

.metadata-value.invalid {
    color: #ef4444;
}

/* Unparsed State */
.unparsed-state {
    padding: 15px;
    background: #1a1a1a;
    border-radius: 6px;
    border-left: 3px solid #8b5cf6;
}

.unparsed-state h6 {
    margin: 0 0 12px 0;
    color: #8b5cf6;
    font-size: 0.95em;
}

.info-note {
    color: #ccc;
    font-style: italic;
    margin: 10px 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    background: #0a0a0a;
    border-radius: 4px;
}

.stat-label {
    color: #999;
    font-size: 0.85em;
    font-weight: 600;
}

.stat-value {
    color: #60a5fa;
    font-size: 1.1em;
    font-weight: 600;
}

.help-text {
    color: #888;
    font-size: 0.85em;
    margin-top: 12px;
    padding: 10px;
    background: #0a0a0a;
    border-radius: 4px;
    border-left: 2px solid #3b82f6;
}

/* Parsed Parameters */
.parsed-parameters {
    padding: 15px;
    background: #1a1a1a;
    border-radius: 6px;
}

.parsed-parameters > h6 {
    margin: 0 0 15px 0;
    color: #22c55e;
    font-size: 0.95em;
    text-transform: uppercase;
}

.param-category {
    margin-bottom: 20px;
}

.param-category:last-child {
    margin-bottom: 0;
}

.param-category h7 {
    display: block;
    margin: 0 0 10px 0;
    color: #ff3333;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.param-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    background: #0a0a0a;
    border-radius: 4px;
    transition: all 0.2s;
}

.param-item:hover {
    background: #2a2a2a;
    transform: translateX(3px);
}

.param-label {
    color: #999;
    font-weight: 600;
}

.param-value {
    color: #60a5fa;
    font-weight: 600;
}

/* Analysis Hints */
.analysis-hints {
    margin-top: 15px;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 6px;
    border-left: 3px solid #fbbf24;
}

.analysis-hints h6 {
    margin: 0 0 10px 0;
    color: #fbbf24;
    font-size: 0.9em;
}

.hints-list {
    margin: 0;
    padding-left: 20px;
    color: #ccc;
}

.hints-list li {
    margin: 5px 0;
    font-size: 0.85em;
}

/* Parse Error */
.parse-error {
    padding: 15px;
    background: #7f1d1d;
    border: 1px solid #991b1b;
    border-radius: 6px;
    color: #fca5a5;
}

.parse-error h6 {
    margin: 0 0 8px 0;
    color: #fca5a5;
}

/* Patch Comparison */
.patch-comparison {
    padding: 15px;
    background: #1a1a1a;
    border-radius: 6px;
}

.comparison-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #333;
}

.comparison-header .patch-name {
    flex: 1;
    color: #e0e0e0;
    font-weight: 600;
    font-size: 1.1em;
}

.vs-divider {
    padding: 0 20px;
    color: #ff3333;
    font-weight: 700;
    font-size: 1.2em;
}

.param-comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.param-comparison-table th {
    padding: 10px;
    background: #0a0a0a;
    color: #999;
    text-align: left;
    border-bottom: 2px solid #333;
    font-weight: 600;
}

.param-comparison-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #222;
}

.param-comparison-table tr.different {
    background: rgba(239, 68, 68, 0.1);
}

.param-comparison-table tr.different td:first-child {
    border-left: 3px solid #ef4444;
}

.param-comparison-table tr.same {
    opacity: 0.5;
}

.param-comparison-table tr:hover {
    background: #1a1a1a;
    opacity: 1;
}

.byte-comparison {
    padding: 15px;
    background: #0a0a0a;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
}

.diff-list {
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.diff-item {
    padding: 5px;
    margin: 3px 0;
    background: #1a1a1a;
    border-radius: 3px;
    font-size: 0.85em;
    color: #60a5fa;
}

.more-diffs {
    margin-top: 10px;
    color: #888;
    font-style: italic;
}

/* No Data State */
.no-data {
    text-align: center;
    color: #666;
    padding: 40px;
    font-style: italic;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .metadata-grid,
    .stats-grid,
    .param-grid {
        grid-template-columns: 1fr;
    }

    .comparison-header {
        flex-direction: column;
        gap: 10px;
    }

    .vs-divider {
        padding: 10px 0;
    }

    .param-comparison-table {
        font-size: 0.8em;
    }

    .param-comparison-table th,
    .param-comparison-table td {
        padding: 6px;
    }
}

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

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 6px;
    padding: 16px 20px;
    min-width: 300px;
    max-width: 500px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-out;
    pointer-events: all;
    cursor: pointer;
}

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

.toast-hide {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon {
    font-size: 1.5em;
    line-height: 1;
    flex-shrink: 0;
}

.toast-message {
    color: #e0e0e0;
    font-size: 0.95em;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Toast types */
.toast-info {
    border-color: #3399ff;
}

.toast-info .toast-icon {
    color: #3399ff;
}

.toast-success {
    border-color: #33cc33;
}

.toast-success .toast-icon {
    color: #33cc33;
}

.toast-warning {
    border-color: #ffaa00;
}

.toast-warning .toast-icon {
    color: #ffaa00;
}

.toast-error {
    border-color: #ff3333;
}

.toast-error .toast-icon {
    color: #ff3333;
}

/* ===================
   Modal Dialogs
   =================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

.modal-backdrop.modal-show {
    opacity: 1;
}

.modal-confirm {
    background: #1a1a1a;
    border: 2px solid #ff3333;
    border-radius: 8px;
    padding: 30px;
    min-width: 400px;
    max-width: 600px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.modal-message {
    color: #e0e0e0;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 24px;
    white-space: pre-line;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 24px;
    border: 2px solid;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.modal-btn-cancel {
    background: transparent;
    border-color: #666;
    color: #999;
}

.modal-btn-cancel:hover {
    border-color: #888;
    color: #ccc;
}

.modal-btn-confirm {
    background: #ff3333;
    border-color: #ff3333;
    color: #fff;
}

.modal-btn-confirm:hover {
    background: #ff5555;
    border-color: #ff5555;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: 0;
        max-width: 100%;
    }

    .modal-confirm {
        min-width: 0;
        max-width: calc(100% - 40px);
        margin: 20px;
    }
}

/* ========================================
   Preset Library Browser Styles
   ======================================== */

.library-section-presets {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #444;
}

.preset-library-actions {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.btn-add-preset,
.btn-export-presets,
.btn-import-presets {
    padding: 8px 16px;
    border: 1px solid #666;
    background: #2a2a2a;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.btn-add-preset:hover,
.btn-export-presets:hover,
.btn-import-presets:hover {
    background: #3a3a3a;
    border-color: #888;
}

.preset-message {
    padding: 12px;
    border-radius: 4px;
    margin: 15px 0;
    font-size: 0.9em;
}

.preset-message-success {
    background: #1a4d1a;
    border: 1px solid #2d7a2d;
    color: #7fff7f;
}

.preset-message-error {
    background: #4d1a1a;
    border: 1px solid #7a2d2d;
    color: #ff7f7f;
}

.preset-message-info {
    background: #1a2d4d;
    border: 1px solid #2d4d7a;
    color: #7f9fff;
}

.preset-library-list,
.preset-library-table-container {
    margin-top: 20px;
}

.preset-card {
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    margin-bottom: 15px;
    padding: 15px;
    transition: all 0.2s ease;
}

.preset-card:hover {
    border-color: #666;
    background: #303030;
}

.preset-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.preset-title-wrapper {
    flex: 1;
}

.preset-title {
    margin: 0 0 5px 0;
    font-size: 1.1em;
    color: #e0e0e0;
}

.preset-meta {
    margin: 0;
    font-size: 0.85em;
    color: #999;
}

.preset-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.preset-actions .btn-send,
.preset-actions .btn-edit,
.preset-actions .btn-duplicate,
.preset-actions .btn-delete {
    padding: 6px 12px;
    font-size: 0.85em;
    border: 1px solid #666;
    background: #333;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-actions .btn-send {
    background: #2d5a2d;
    border-color: #3d6a3d;
    color: #7fff7f;
}

.preset-actions .btn-send:hover {
    background: #3d6a3d;
    border-color: #4d7a4d;
}

.preset-actions .btn-edit:hover,
.preset-actions .btn-duplicate:hover {
    background: #3a3a3a;
    border-color: #888;
}

.preset-actions .btn-delete {
    background: #5a2d2d;
    border-color: #6a3d3d;
    color: #ff7f7f;
}

.preset-actions .btn-delete:hover {
    background: #6a3d3d;
    border-color: #7a4d4d;
}

.preset-params-preview {
    font-size: 0.85em;
    color: #999;
    padding-top: 10px;
    border-top: 1px solid #333;
}

.preset-table {
    width: 100%;
    border-collapse: collapse;
}

.preset-table th,
.preset-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #333;
}

.preset-table th {
    background: #2a2a2a;
    color: #999;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preset-table tr:hover {
    background: #2a2a2a;
}

.preset-table .preset-name {
    font-weight: 600;
    color: #e0e0e0;
}

.preset-table .preset-params-cell {
    font-size: 0.9em;
    color: #999;
}

.preset-table .preset-actions-cell {
    white-space: nowrap;
}

.preset-count {
    font-size: 0.85em;
    color: #999;
    font-weight: normal;
    margin-left: 8px;
}

.no-presets {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-size: 0.95em;
}

/* Incomplete preset styling */
.preset-incomplete {
    color: #ff9955 !important;
    font-style: italic;
}

.preset-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.preset-actions button:disabled:hover {
    background: inherit;
    border-color: inherit;
}

/* ========================================
   Preset Editor Modal
   ======================================== */

.preset-editor-modal {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

.midi-listen-section {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 25px;
    border: 2px dashed #555;
}

.btn-listen-midi {
    padding: 12px 24px;
    background: #2d5a2d;
    border: 2px solid #3d6a3d;
    color: #7fff7f;
    border-radius: 6px;
    font-size: 1.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    font-weight: 600;
}

.btn-listen-midi:hover {
    background: #3d6a3d;
    border-color: #4d7a4d;
}

.btn-listen-midi.listening {
    background: #5a2d2d;
    border-color: #6a3d3d;
    color: #ff7f7f;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.midi-listen-status {
    margin: 12px 0 0 0;
    padding: 10px;
    background: #1a1a1a;
    border-radius: 4px;
    font-size: 0.9em;
    color: #999;
    text-align: center;
    min-height: 20px;
}

.midi-listen-status.success {
    color: #7fff7f;
    background: #1a4d1a;
}

.midi-listen-status.error {
    color: #ff7f7f;
    background: #4d1a1a;
}

.midi-listen-status.listening {
    color: #7f9fff;
    background: #1a2d4d;
}

.preset-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.param-section {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #444;
}

.param-section h4 {
    margin: 0 0 15px 0;
    color: #7f9fff;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.param-field {
    margin-bottom: 15px;
}

.param-field-full {
    grid-column: 1 / -1;
    background: #2a2a2a;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #444;
}

.param-field label {
    display: block;
    margin-bottom: 6px;
    color: #999;
    font-size: 0.85em;
    font-weight: 600;
}

.param-field small {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 0.75em;
}

.param-input {
    width: 100%;
    padding: 10px 12px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.95em;
    font-family: inherit;
    transition: all 0.2s ease;
}

.param-input:focus {
    outline: none;
    border-color: #7f9fff;
    background: #222;
}

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

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #444;
    margin-top: 25px;
}

.btn-cancel,
.btn-save {
    padding: 12px 24px;
    border: 2px solid;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel {
    background: transparent;
    border-color: #666;
    color: #999;
}

.btn-cancel:hover {
    border-color: #888;
    color: #ccc;
}

.btn-save {
    background: #2d5a2d;
    border-color: #3d6a3d;
    color: #7fff7f;
}

.btn-save:hover {
    background: #3d6a3d;
    border-color: #4d7a4d;
}

/* Modal overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: #1a1a1a;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 0;
    position: relative;
    max-width: 600px;
    width: 100%;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #e0e0e0;
    font-size: 1.3em;
}

.modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 2em;
    line-height: 0.8;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 24px;
}
/* ====================================
   User Preset Manager Styles
   ==================================== */

/* Capture buttons grid */
.capture-buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.btn-capture-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: #1a1a1a;
    border: 2px solid #444;
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
    font-weight: 600;
}

.btn-capture-action:hover {
    background: #252525;
    border-color: #ff3333;
    transform: translateY(-2px);
}

.btn-capture-action .btn-icon {
    font-size: 1.8em;
}

.btn-capture-action .btn-label {
    text-align: center;
}

/* User presets container */
.user-presets-container {
    margin-top: 20px;
}

.user-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.user-preset-card {
    background: #1a1a1a;
    border: 2px solid #333;
    transition: all 0.2s ease;
}

.user-preset-card:hover {
    border-color: #ff3333;
}

.badge-user {
    background: #7b2d7b;
    color: white;
    border: 1px solid #9b3d9b;
}

/* Preset card footer with multiple buttons */
.preset-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #333;
}

.preset-card-footer button {
    flex: 1;
    min-width: 80px;
    padding: 8px 12px;
    font-size: 0.85em;
}

.btn-edit-preset {
    background: #1a4d80;
    border: 1px solid #2a5d90;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-edit-preset:hover {
    background: #2a5d90;
    transform: translateY(-1px);
}

.btn-copy-preset {
    background: #4d7a4d;
    border: 1px solid #5d8a5d;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-copy-preset:hover {
    background: #5d8a5d;
    transform: translateY(-1px);
}

.btn-delete-preset {
    background: #7a2d2d;
    border: 1px solid #8a3d3d;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete-preset:hover {
    background: #8a3d3d;
    transform: translateY(-1px);
}

/* Capture modal */
.capture-modal .modal-content {
    max-width: 600px;
}

.capture-instructions {
    background: #252525;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}

.capture-instructions ol {
    margin-left: 20px;
    margin-top: 10px;
}

.capture-instructions li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.capture-status {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-radius: 6px;
    font-weight: 600;
}

.status-indicator.waiting {
    background: #252525;
    border: 2px solid #ff9933;
}

.status-indicator.success {
    background: #1a3d1a;
    border: 2px solid #4d7a4d;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.status-indicator.waiting .status-dot {
    background: #ff9933;
}

.status-indicator.success .status-dot {
    background: #4d7a4d;
    animation: none;
}

.capture-result {
    padding: 20px;
    border-top: 1px solid #444;
}

.captured-preset-info {
    background: #252525;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}

.captured-preset-info h3 {
    color: #ff3333;
    margin-bottom: 12px;
}

.preset-params-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.preset-params-summary p {
    background: #1a1a1a;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9em;
}

.capture-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.capture-actions label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9em;
    color: #ccc;
}

.capture-actions button {
    padding: 12px 20px;
    font-size: 0.95em;
}

.btn-save-factory {
    background: #ff9933;
    border: 1px solid #ffaa44;
    color: white;
}

.btn-save-factory:hover {
    background: #ffaa44;
}

.btn-add-v2 {
    background: #3d6a3d;
    border: 1px solid #4d7a4d;
    color: white;
}

.btn-add-v2:hover {
    background: #4d7a4d;
}

.btn-save-user {
    background: #7b2d7b;
    border: 1px solid #9b3d9b;
    color: white;
}

.btn-save-user:hover {
    background: #9b3d9b;
}

.btn-edit-captured {
    background: #1a4d80;
    border: 1px solid #2a5d90;
    color: white;
}

.btn-edit-captured:hover {
    background: #2a5d90;
}

/* Preset editor modal */
.preset-editor-modal {
    max-width: 800px;
}

.preset-editor-grid {
    display: grid;
    gap: 20px;
}

.param-section {
    background: #252525;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 16px;
}

.param-section h4 {
    color: #ff3333;
    margin-bottom: 12px;
    font-size: 1.1em;
}

.param-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.param-field label {
    font-size: 0.9em;
    color: #ccc;
    font-weight: 600;
}

.param-field small {
    font-size: 0.8em;
    color: #999;
}

.param-field-full {
    grid-column: 1 / -1;
}

.param-input {
    background: #1a1a1a;
    border: 2px solid #444;
    border-radius: 4px;
    padding: 10px 12px;
    color: #e0e0e0;
    font-size: 0.95em;
    transition: border-color 0.2s ease;
}

.param-input:focus {
    outline: none;
    border-color: #ff3333;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #444;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel {
    background: #444;
    border: 1px solid #555;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background: #555;
}

.btn-save {
    background: #ff3333;
    border: 1px solid #ff4444;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.btn-save:hover {
    background: #ff4444;
}

/* Bidirectional MIDI - Highlighted preset */
.preset-card.highlighted {
    border-color: #4d7a4d;
    box-shadow: 0 0 20px rgba(77, 122, 77, 0.5);
    animation: highlight-pulse 2s ease-in-out;
}

@keyframes highlight-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(77, 122, 77, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(77, 122, 77, 0.8);
    }
}

/* Preset params compact view */
.preset-params-grid-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* Section help text */
.section-help {
    color: #999;
    font-size: 0.9em;
    margin-top: 8px;
    line-height: 1.4;
}

/* Message styles */
.preset-message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9em;
}

.preset-message-success {
    background: #1a3d1a;
    border: 1px solid #4d7a4d;
    color: #b3ffb3;
}

.preset-message-error {
    background: #3d1a1a;
    border: 1px solid #7a2d2d;
    color: #ffb3b3;
}

.preset-message-info {
    background: #1a2d3d;
    border: 1px solid #2d4d7a;
    color: #b3d9ff;
}

/* MIDI Listen Button */
.midi-listen-section {
    margin-bottom: 20px;
}

.btn-listen-midi {
    width: 100%;
    padding: 12px 20px;
    background: #ff9933;
    border: 2px solid #ffaa44;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-listen-midi:hover {
    background: #ffaa44;
    transform: translateY(-2px);
}

.midi-listen-status {
    margin-top: 12px;
    padding: 8px 12px;
    background: #252525;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 0.9em;
    text-align: center;
    color: #ccc;
}

/* ====================================
   MIDI Message Log Viewer Styles
   ==================================== */

.message-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.message-log-header h3 {
    margin: 0;
    color: #ff3333;
}

.message-log-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    color: #ccc;
    cursor: pointer;
}

.message-log-stats {
    display: flex;
    gap: 20px;
    padding: 10px 12px;
    background: #252525;
    border: 1px solid #444;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 0.9em;
    color: #999;
}

.message-log-list {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #444;
    border-radius: 4px;
    background: #0a0a0a;
}

.no-messages {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.message-log-entry {
    border-bottom: 1px solid #333;
    padding: 12px;
    transition: background 0.2s ease;
}

.message-log-entry:hover {
    background: #1a1a1a;
}

.message-log-entry.msg-send {
    border-left: 3px solid #ff9933;
}

.message-log-entry.msg-receive {
    border-left: 3px solid #4d7a4d;
}

.message-log-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.message-log-id {
    font-weight: bold;
    color: #ff3333;
    font-family: monospace;
    min-width: 40px;
}

.message-log-timestamp {
    color: #999;
    font-size: 0.85em;
    font-family: monospace;
}

.message-log-type {
    background: #333;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.85em;
    color: #ccc;
}

.message-log-direction {
    font-size: 0.85em;
    font-weight: 600;
}

.msg-badge {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: 600;
}

.msg-badge-success {
    background: #1a3d1a;
    color: #b3ffb3;
    border: 1px solid #4d7a4d;
}

.msg-badge-error {
    background: #3d1a1a;
    color: #ffb3b3;
    border: 1px solid #7a2d2d;
}

.btn-expand-msg {
    margin-left: auto;
    background: #444;
    border: 1px solid #555;
    padding: 4px 12px;
    border-radius: 3px;
    color: #ccc;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
}

.btn-expand-msg:hover {
    background: #555;
}

.message-log-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-left: 52px;
}

.msg-description {
    color: #999;
    font-size: 0.9em;
}

.msg-preset-name {
    color: #ff9933;
    font-weight: 600;
}

.message-log-details {
    margin-top: 12px;
    margin-left: 52px;
    padding: 16px;
    background: #252525;
    border: 1px solid #444;
    border-radius: 4px;
}

.msg-section {
    margin-bottom: 20px;
}

.msg-section:last-child {
    margin-bottom: 0;
}

.msg-section h4 {
    color: #ff3333;
    margin-bottom: 10px;
    font-size: 1em;
}

.msg-params-table {
    width: 100%;
    border-collapse: collapse;
}

.msg-params-table tr {
    border-bottom: 1px solid #333;
}

.msg-params-table tr:last-child {
    border-bottom: none;
}

.msg-params-table td {
    padding: 6px 8px;
    font-size: 0.9em;
}

.param-key {
    color: #999;
    width: 40%;
    font-family: monospace;
}

.param-value {
    color: #e0e0e0;
    font-weight: 600;
    font-family: monospace;
}

.msg-json {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.85em;
    color: #b3ffb3;
    font-family: monospace;
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
}

.msg-hex {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.85em;
    color: #ffa500;
    font-family: monospace;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
}

.hex-more {
    color: #666;
    font-style: italic;
}

.msg-error {
    background: #3d1a1a;
    border: 1px solid #7a2d2d;
    padding: 12px;
    border-radius: 4px;
}

.msg-error p {
    color: #ffb3b3;
    margin: 0;
}

.msg-bytes {
    color: #999;
    font-size: 0.9em;
    margin: 0;
}

.btn-copy-json,
.btn-copy-hex,
.btn-show-full-hex {
    background: #444;
    border: 1px solid #555;
    padding: 6px 12px;
    border-radius: 3px;
    color: #ccc;
    cursor: pointer;
    font-size: 0.85em;
    margin-top: 8px;
    margin-right: 8px;
    transition: all 0.2s ease;
}

.btn-copy-json:hover,
.btn-copy-hex:hover,
.btn-show-full-hex:hover {
    background: #555;
}

.btn-copy-json:active,
.btn-copy-hex:active {
    background: #4d7a4d;
    color: white;
}

/* Keyboard Shortcuts Modal */
.keyboard-shortcuts-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.shortcuts-content {
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 32px var(--shadow-color);
    animation: slideIn 0.3s ease;
}

.shortcuts-content h2 {
    color: var(--text-accent);
    margin: 0 0 20px 0;
    font-size: 1.5em;
    text-align: center;
}

.shortcuts-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.shortcuts-table tr {
    border-bottom: 1px solid var(--border-primary);
}

.shortcuts-table tr:last-child {
    border-bottom: none;
}

.shortcut-keys {
    padding: 12px 0;
    width: 40%;
}

.shortcut-keys kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: monospace;
    font-size: 0.9em;
    color: var(--text-primary);
    box-shadow: 0 2px 0 var(--border-primary);
}

.shortcut-description {
    padding: 12px 0;
    color: var(--text-primary);
}

.shortcuts-close {
    width: 100%;
    padding: 12px;
    background: var(--button-bg);
    border: 2px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.shortcuts-close:hover {
    background: var(--button-hover);
    border-color: var(--border-hover);
    color: var(--text-accent);
}

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

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===================================
   SEO & Educational Content Styles
   =================================== */

/* Introduction Section */
.intro-section {
    padding: 20px 30px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
}

.intro-text {
    font-size: 1.05em;
    line-height: 1.8;
    color: var(--text-primary);
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
}

/* Subtitle Styling */
.subtitle {
    font-size: 1.1em !important;
    opacity: 0.85 !important;
    margin-bottom: 0 !important;
}

/* Education Section */
.education-section {
    padding: 40px 30px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
}

.education-section h2 {
    font-size: 2em;
    margin-bottom: 30px;
    color: var(--text-accent);
    text-align: center;
    font-family: 'Dot Matrix', monospace;
    letter-spacing: 4px;
}

.education-content {
    max-width: 900px;
    margin: 0 auto;
}

.education-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.education-item:hover {
    border-color: var(--border-hover);
}

.education-item summary {
    padding: 20px;
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.education-item summary::-webkit-details-marker {
    display: none;
}

.education-item summary::after {
    content: '+';
    font-size: 1.5em;
    color: var(--text-accent);
    transition: transform 0.3s ease;
}

.education-item[open] summary::after {
    content: '−';
}

.education-body {
    padding: 0 20px 20px 20px;
    color: var(--text-secondary);
    line-height: 1.8;
    animation: fadeIn 0.3s ease;
}

.education-body p {
    margin-bottom: 15px;
}

.education-body ul {
    margin: 10px 0 15px 20px;
    list-style: disc;
}

.education-body li {
    margin-bottom: 8px;
}

.education-body strong {
    color: var(--text-primary);
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    color: var(--text-secondary);
}

.footer p {
    margin: 5px 0;
    font-size: 0.95em;
}

.footer .dedication {
    font-size: 0.85em;
    opacity: 0.6;
    font-style: italic;
    margin-top: 10px;
}

/* Mobile Responsiveness for Education Section */
@media (max-width: 768px) {
    .education-section {
        padding: 30px 20px;
    }

    .education-section h2 {
        font-size: 1.6em;
    }

    .education-item summary {
        font-size: 1.05em;
        padding: 15px;
    }

    .education-body {
        font-size: 0.95em;
    }

    .intro-text {
        font-size: 1em;
        padding: 0 10px;
    }
}
