:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --secondary-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --accent-color: #ec4899;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 40%);
}

.container {
    max-width: 1400px;
    width: 95%;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.2rem;
    color: #94a3b8;
    font-weight: 300;
}

main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.controls {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-end;
    justify-content: center;
}

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

.control-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-color);
    padding: 0.8rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.control-group {
    flex: 1;
    min-width: 200px;
}

.primary-btn, .secondary-btn, .midi-status {
    flex: 1;
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 64px;
}

.primary-btn {
    background: var(--primary-gradient);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.secondary-btn {
    background: var(--secondary-gradient);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.primary-btn:hover, .secondary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.primary-btn:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.secondary-btn:hover:not(:disabled) {
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.5);
}

.primary-btn:active, .secondary-btn:active, .midi-status:active {
    transform: translateY(0);
}

.action-buttons {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    align-items: flex-end;
}

.secondary-btn:disabled {
    opacity: 0.4;
    filter: grayscale(0.8);
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.midi-status {
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    opacity: 0.8;
    cursor: default;
}

.midi-status.connected {
    border-color: rgba(57, 255, 20, 0.3);
    color: #39ff14;
    opacity: 1;
    box-shadow: 0 4px 15px rgba(57, 255, 20, 0.4);
}

.midi-status.disconnected {
    border-color: rgba(239, 68, 68, 0.2);
    color: #94a3b8;
}

.small-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
}

.small-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.preview-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 800px;
    padding: 2rem;
    position: relative;
}

#preview-status {
    color: #94a3b8;
    font-style: italic;
    margin-bottom: 1rem;
    transition: opacity 0.5s ease;
}

.zoom-controls {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.zoom-controls button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.zoom-controls button:active {
    transform: scale(0.95);
}

#keyboard-preview {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#keyboard-preview svg {
    width: 100%;
    height: auto;
    max-height: 80vh;
}

footer {
    margin-top: 3rem;
    text-align: center;
    color: #475569;
    font-size: 0.9rem;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2.5rem;
    }

    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .primary-btn, .secondary-btn, .midi-status {
        width: 100%;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    animation: fadeIn 0.8s ease-out;
}

.hidden {
    display: none !important;
}

#custom-scale-group {
    margin-top: 1rem;
}

#custom-scale-group h3 {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#custom-layout-group {
    margin-top: 1rem;
}

#custom-layout-group h3 {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#custom-colors {
    margin-top: 1rem;
}

#custom-colors h3 {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

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

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

.color-input label {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 100%;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--glass-border);
    border-radius: 8px;
}

.custom-scale-inputs {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.custom-scale-inputs select, .custom-scale-inputs input,
.custom-layout-inputs input {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-color);
    padding: 0.8rem 1rem;
    font-family: inherit;
    font-size: 1rem;
}

.custom-layout-inputs {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.custom-scale-inputs input:focus {
    outline: none;
    border-color: #6366f1;
}