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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: none;
}

header p {
    font-size: 1.1rem;
    opacity: 1;
}

.status-bar {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

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

.status-dot.ready {
    background-color: #10b981;
    animation: none;
}

.status-dot.error {
    background-color: #ef4444;
    animation: none;
}

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

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.devices-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.panel {
    background: white;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.panel h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.3rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.log-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

/* Devices List */
.devices-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.device-item {
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-item.device-output {
    cursor: pointer;
}

.device-item.device-output:hover {
    background: #ede9fe;
    border-color: #667eea;
}

.device-item.device-input {
    cursor: default;
}

.device-item.selected {
    background: #dbeafe;
    border-color: #667eea;
    font-weight: 600;
}

.device-name {
    font-weight: 500;
    color: #333;
}

.device-id {
    font-size: 0.8rem;
    color: #999;
    margin-top: 3px;
}

.device-info {
    text-align: right;
}

.device-badge {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.placeholder {
    color: #999;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

/* Buttons */
.btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* MIDI Keyboard */
#keyboardSection {
    grid-column: 1 / -1;
}

.keyboard-container {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

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

.key {
    width: 50px;
    height: 80px;
    background: white;
    border: 1px solid #333;
    border-radius: 4px 4px 8px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #333;
    transition: all 0.1s ease;
    user-select: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.key:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.key.active {
    background: #667eea;
    color: white;
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.key.black {
    width: 35px;
    height: 60px;
    background: #1a1a1a;
    color: white;
    border-color: #000;
    margin-left: -20px;
    margin-right: -20px;
    z-index: 1;
}

.key.black:hover {
    background: #333;
}

.key.black.active {
    background: #764ba2;
}

.key-note {
    font-size: 0.9rem;
    font-weight: 700;
}

.key-label {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 2px;
}

.keyboard-info {
    background: #f3f4f6;
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #666;
}

.keyboard-info p {
    margin: 5px 0;
}

/* Event Log */
.log-container {
    background: #1a1a1a;
    color: #0f0;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    padding: 15px;
    border-radius: 6px;
    height: 400px;
    overflow-y: auto;
    line-height: 1.4;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #333;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-timestamp {
    color: #0a0;
    font-weight: bold;
}

.log-type {
    color: #0ff;
}

.log-message {
    color: #0f0;
}

/* Direction-based coloring */
.log-entry.log-send .log-type {
    color: #0ff;
}

.log-entry.log-send .log-message {
    color: #0f0;
}

.log-entry.log-receive .log-type {
    color: rgb(255, 255, 255);
}

.log-entry.log-receive .log-message {
    color: #0af;
}

.log-device {
    color: #bbff00;
    font-size: 0.8rem;
}

.log-data {
    color: #fa0;
    font-size: 0.8rem;
}

.log-container .placeholder {
    color: #444;
    padding: 0;
    margin: 0;
}

/* Scrollbar styling */
.log-container::-webkit-scrollbar {
    width: 8px;
}

.log-container::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

.log-container::-webkit-scrollbar-thumb {
    background: #0f0;
    border-radius: 4px;
}

.log-container::-webkit-scrollbar-thumb:hover {
    background: #0a0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .devices-wrapper {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .key {
        width: 40px;
        height: 65px;
    }

    .key.black {
        width: 28px;
        height: 48px;
        margin-left: -16px;
        margin-right: -16px;
    }

    .log-container {
        max-height: 250px;
    }
}
