: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: 1.25rem 2rem;
}

header {
    margin-bottom: 1rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.title-group {
    text-align: left;
}

header h1 {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.1rem;
    white-space: nowrap;
}

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

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

.icon-btn .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    display: block;
    pointer-events: none;
}

.icon-btn:hover {
    transform: scale(1.1) rotate(10deg);
    background: var(--primary-gradient);
    border-color: transparent;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    background: var(--glass-bg);
    border-color: var(--glass-border);
    box-shadow: none;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.modal-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    line-height: 1.6;
    color: #cbd5e1;
}

.modal-body h3 {
    margin: 1.5rem 0 0.8rem 0;
    color: var(--text-color);
    font-size: 1.3rem;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body ul, .modal-body ol {
    margin-bottom: 1.2rem;
    padding-left: 1.5rem;
}

.modal-body li {
    margin-bottom: 0.5rem;
}

.modal-body strong {
    color: #f1f5f9;
}

.modal-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
}

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

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

.controls {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    align-items: stretch;
}

.controls-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.15rem 1.5rem;
    width: 100%;
    align-items: flex-start;
}

.control-group.disabled, .toggle-control-group.disabled {
    opacity: 0.35;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    text-align: left;
}

.control-group label {
    display: block !important;
    width: 100% !important;
    font-size: 0.95rem;
    font-weight: 600;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: normal;
    text-align: left !important;
    margin: 0 !important;
    padding: 0 0 0 5px !important;
}

select {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    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 cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

select:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

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;
}

.controls > .control-group {
    max-width: 260px;
}

.toggle-control-group {
    flex: 1;
    min-width: 200px;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Row elements spacing & widths overrides to prevent wrapping and layout jumps */
.controls-row > .control-group,
.controls-row > .toggle-control-group {
    flex: 1;
}

#edo-select-group {
    max-width: 180px;
    min-width: 130px;
}

#custom-edo-group,
#custom-middle-c-group {
    max-width: 120px;
    min-width: 90px;
}

#layout-select-group {
    max-width: 220px;
    min-width: 140px;
}

#color-scheme-group {
    max-width: 240px;
    min-width: 160px;
}

#color-mode-group {
    flex: 1.5;
    max-width: 280px;
    min-width: 220px;
}

#scale-select-group {
    max-width: 220px;
    min-width: 140px;
}

#scale-center-group {
    max-width: 160px;
    min-width: 100px;
}

#scale-rotation-group {
    max-width: 240px;
    min-width: 180px;
}

#relayout-group,
#disable-out-of-scale-group {
    flex: 1.5;
    max-width: 280px;
    min-width: 220px;
}

.primary-btn, .secondary-btn, .midi-status {
    flex: 1;
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 1.05rem;
    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: 50px;
}

.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: 0.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    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 1.5rem;
    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: 240px;
    padding: 0.9rem 1.25rem;
    position: relative;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1.25rem;
    color: var(--text-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    pointer-events: none;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.toast.success {
    border-color: rgba(34, 197, 94, 0.4);
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.1);
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.1);
}

.toast.info {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.1);
}

.toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast.success .toast-icon {
    color: #4ade80;
}

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

.toast.info .toast-icon {
    color: #818cf8;
}

.preview-footer-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.5rem;
    z-index: 10;
}

.hardware-quick-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.hw-quick-btn {
    height: 34px;
    padding: 0 0.75rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: #cbd5e1;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    white-space: nowrap;
}

.hw-quick-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(99, 102, 241, 0.5);
    color: #ffffff;
}

.hw-quick-btn.active {
    background: var(--primary-gradient);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

.hw-quick-btn.syncing {
    box-shadow: 0 0 14px rgba(6, 182, 212, 0.65);
}

.hw-quick-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.zoom-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    z-index: 10;
}

.zoom-controls button {
    width: 34px;
    height: 34px;
    min-width: 34px;
    flex-shrink: 0;
    box-sizing: border-box;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

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

.zoom-controls button.active {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

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

select.label-mode-select {
    height: 34px;
    width: 100px;
    max-width: 100px;
    flex-shrink: 0;
    box-sizing: border-box;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: #cbd5e1;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0 0.4rem;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.35rem center;
    padding-right: 1.2rem;
}

select.label-mode-select.key-type-select {
    width: 120px;
    max-width: 120px;
}

select.label-mode-select:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(99, 102, 241, 0.5);
    color: #ffffff;
}

select.label-mode-select option {
    background: #0f172a;
    color: #f8fafc;
}

.zoom-divider {
    width: 1px;
    height: 20px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.25);
    margin: 0 0.15rem;
}

.zoom-controls button.export-btn {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0 0.55rem;
    width: auto;
    min-width: 42px;
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(168, 85, 247, 0.3);
    color: #cbd5e1;
}

.zoom-controls button.export-btn:hover {
    background: rgba(99, 102, 241, 0.35);
    border-color: rgba(168, 85, 247, 0.6);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

#keyboard-preview {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#keyboard-preview svg {
    width: 100%;
    height: auto;
    max-height: 80vh;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

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.2rem;
}

.seed-control {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 220px;
}

.seed-control label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: normal;
    padding-left: 5px;
}

.seed-control select {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1rem;
}

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

.color-input {
    display: block;
    text-align: left;
}

.color-input label {
    display: block !important;
    width: 100% !important;
    font-size: 0.95rem;
    color: #cbd5e1;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: normal;
    text-align: left !important;
    margin: 0 0 0.5rem 0 !important;
    padding: 0 !important;
}

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, #custom-edo-input, #custom-middle-c-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;
    text-align: left;
}

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

#custom-middle-c-group, #custom-edo-group {
    margin-top: 0;
}

.custom-scale-inputs input:focus, .custom-layout-inputs input:focus, #custom-edo-input:focus, #custom-middle-c-input:focus {
    outline: none;
    border-color: #6366f1;
}

details {
    margin-top: 1.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.3);
    overflow: hidden;
    transition: all 0.3s ease;
}

summary {
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: '▼';
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

details[open] summary::after {
    transform: rotate(180deg);
}

.additional-colors-padding, .per-note-grid-padding {
    padding: 1.5rem;
    padding-top: 0;
}

#per-note-grid {
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    gap: 0.75rem;
}

#per-note-grid .color-input label {
    font-size: 0.8rem;
    margin-bottom: 4px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.context-menu {
    position: fixed;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 6px;
    min-width: 150px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.ctx-item:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.ctx-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 6px 4px;
}

.ctx-item span {
    font-size: 1.1rem;
    width: 20px;
    display: flex;
    justify-content: center;
}

.ctx-item:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Relayout to Scale section */
.relayout-section {
    width: 100%;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.relayout-toggle {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
    font-size: 1rem;
    text-transform: none !important;
    letter-spacing: normal !important;
    padding: 0 !important;
    margin: 0 !important;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #94a3b8;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-label input:checked + .toggle-switch {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-color: rgba(99, 102, 241, 0.5);
}

.toggle-label input:checked + .toggle-switch::after {
    left: 24px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toggle-text {
    user-select: none;
}

.relayout-hint {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 400;
    line-height: 1.4;
}

.pianoteq-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 0.25rem;
    padding: 0.65rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 12px;
    animation: fadeIn 0.3s ease-out;
}

.info-icon {
    font-size: 1.2rem;
    color: #818cf8;
    flex-shrink: 0;
    margin-top: 1px;
}

.info-content {
    font-size: 0.9rem;
    color: #cbd5e1;
    line-height: 1.5;
}

.info-content strong {
    color: #a5b4fc;
}

#pianoteq-channel {
    display: inline-block;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

/* Preview Header Controls & Chord Visualizer Dropdown */
.preview-header-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 0.75rem;
    z-index: 10;
    gap: 1rem;
    padding-right: 0;
    box-sizing: border-box;
}

.header-controls-wrapper {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.synth-controls-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.synth-control-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.synth-control-item label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.synth-control-item select {
    width: 140px;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    height: 38px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.synth-control-item select:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

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

.synth-octave-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.2rem 0.6rem;
    height: 38px;
    width: 130px;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.synth-octave-wrapper .small-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    height: 24px;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.synth-octave-wrapper .small-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.synth-octave-wrapper .octave-status-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-color);
    min-width: 20px;
    text-align: center;
}

.synth-mute-btn {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    height: 38px;
    width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.synth-mute-btn:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.synth-mute-btn.muted {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.synth-mute-btn.muted:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.6);
}

.synth-mute-btn .icon {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "Android Emoji", sans-serif;
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chord-visualizer-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chord-visualizer-control label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.chord-visualizer-control select {
    width: 220px;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    height: 38px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chord-visualizer-control select:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

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

@media (max-width: 950px) {
    .preview-header-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding-right: 0;
    }
    .header-controls-wrapper {
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 1rem;
    }
}

@media (max-width: 700px) {
    .header-controls-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    .synth-controls-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .synth-control-item {
        justify-content: space-between;
    }
    .synth-control-item select,
    .synth-control-item .synth-octave-wrapper,
    .synth-control-item .synth-mute-btn {
        width: 60%;
    }
    .chord-controls-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .chord-visualizer-control {
        justify-content: space-between;
    }
    .chord-visualizer-control select {
        width: 60%;
    }
}

/* --- Scale Rotation & MOS Generator Styles --- */
.rotation-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.rotation-status-text {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 0.25rem;
    font-family: monospace;
}

.mos-generator-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.mos-generator-inputs .control-group {
    flex: 1 1 200px;
}

.slider-with-value {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-with-value input[type="range"] {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider-with-value input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-gradient);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    transition: transform 0.1s ease;
}

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

.slider-with-value span {
    font-family: monospace;
    font-size: 1rem;
    font-weight: 600;
    min-width: 2ch;
    text-align: right;
}

.mos-gen-details-text {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mos-status {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    display: inline-block;
    align-self: flex-start;
}

.mos-status.success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.mos-status.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.mos-detail-item {
    font-size: 0.9rem;
    color: #cbd5e1;
}

.mos-detail-item strong {
    color: #f8fafc;
}

/* --- Floating Available Chords Controls & Overlay --- */
.chord-controls-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.available-chords-toggle-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    height: 38px;
    white-space: nowrap;
}

.available-chords-toggle-header:hover {
    transform: translateY(-1px);
    border-color: rgba(168, 85, 247, 0.75);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.25);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(168, 85, 247, 0.3) 100%);
}

.available-chords-toggle-header.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.35) 0%, rgba(168, 85, 247, 0.35) 100%);
    border-color: rgba(168, 85, 247, 0.7);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 12px rgba(139, 92, 246, 0.25);
}

.available-chords-toggle-header span {
    font-size: 1rem;
}


.available-chords-overlay {
    position: absolute;
    top: calc(100% + 0.75rem);
    left: 0;
    width: 320px;
    max-height: 360px;
    z-index: 100;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.overlay-header h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
}

.close-overlay-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: #94a3b8;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    transition: all 0.2s ease;
}

.close-overlay-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.overlay-hint {
    font-size: 0.78rem;
    color: #94a3b8;
    margin: 0;
}

#available-chords-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom scrollbar for overlay list */
#available-chords-list::-webkit-scrollbar {
    width: 6px;
}

#available-chords-list::-webkit-scrollbar-track {
    background: transparent;
}

#available-chords-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#available-chords-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Compact Chord Items inside overlay */
.overlay-chord-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
}

.overlay-chord-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

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

.overlay-chord-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #e2e8f0;
}

.overlay-chord-type {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.overlay-chord-roots {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.overlay-chord-root-btn {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.overlay-chord-root-btn:hover {
    background: var(--primary-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
    transform: scale(1.05);
}

.overlay-chord-root-btn.active-chord {
    background: var(--secondary-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}

.overlay-no-chords {
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    padding: 1.5rem 0;
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .available-chords-overlay {
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: 1rem;
        width: calc(100% - 2rem);
        max-height: 220px;
    }
    .chord-controls-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .available-chords-toggle-header {
        width: 100%;
        justify-content: center;
    }
}

/* --- Synthesizer Controls and Active Playing Styles --- */
.key-hex.active-playing {
    fill: url(#active-key-gradient) !important; /* Indigo-to-purple gradient */
    filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.8));
    transition: fill 0.05s ease, filter 0.05s ease;
}

/* ==========================================================================
   EDO Visualizer Styles (Levi McClain Style)
   ========================================================================== */

.visualizer-controls-group {
    display: flex;
    align-items: center;
}

.visualizer-header-btn {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
}

#edo-visualizer-section {
    margin-top: 0;
    padding: 1.25rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#edo-visualizer-section.hidden {
    display: none;
}

.visualizer-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.visualizer-section-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.edo-visualizer-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: stretch;
}

@media (max-width: 900px) {
    .edo-visualizer-wrapper {
        grid-template-columns: 1fr;
    }
}

.edo-visualizer-card {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.5);
    height: 100%;
}

.edo-card-header {
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
}

.edo-card-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #cbd5e1;
    text-transform: uppercase;
}

/* EDO Circle Styles */
.edo-circle-container {
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.edo-circle-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.edo-circle-ring {
    fill: none;
    stroke: rgba(148, 163, 184, 0.25);
    stroke-width: 1.5;
}

.edo-circle-tick {
    stroke: rgba(148, 163, 184, 0.4);
    stroke-width: 1;
}

.edo-circle-node-dot {
    fill: #475569;
    transition: all 0.2s ease;
}

.edo-circle-node-dot.active {
    fill: #c084fc;
    r: 5;
    filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.9));
}

.edo-circle-label {
    fill: #94a3b8;
    font-family: var(--font-family);
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: central;
    transition: all 0.2s ease;
    user-select: none;
}

.edo-circle-label.active {
    fill: #ffffff;
    font-weight: 800;
    filter: drop-shadow(0 0 8px #c084fc);
}

.edo-circle-node-dot.scale-step {
    fill: #a855f7;
    r: 4;
}

.edo-circle-node-dot.non-scale-step {
    opacity: 0.3;
}

.edo-circle-label.scale-step {
    fill: #e9d5ff;
    font-weight: 700;
}

.edo-circle-label.non-scale-step {
    opacity: 0.35;
}

.edo-polygon-shape {
    fill: rgba(168, 85, 247, 0.18);
    stroke: url(#edo-active-gradient);
    stroke-width: 2.5;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.6));
    transition: all 0.2s ease;
}

.edo-polygon-line {
    stroke: url(#edo-active-gradient);
    stroke-width: 2.5;
    stroke-linecap: round;
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.7));
}

.edo-polygon-single {
    fill: url(#edo-active-gradient);
    filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.8));
}

/* EDO Box Grid Styles */
.edo-box-grid-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0.5rem;
}

.edo-box-grid {
    display: grid;
    grid-template-columns: repeat(var(--edo-cols, 6), 1fr);
    gap: 6px;
    width: 100%;
    max-width: 420px;
}

.edo-box-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #94a3b8;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.edo-box-cell.scale-step {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(99, 102, 241, 0.15);
    color: #f1f5f9;
    font-weight: 700;
}

.edo-box-cell.non-scale-step {
    opacity: 0.35;
    background: rgba(15, 23, 42, 0.4);
}

.edo-box-cell.active {
    background: var(--primary-gradient);
    border-color: #c084fc;
    color: #ffffff;
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.6);
    transform: scale(1.04);
    opacity: 1 !important;
}

/* Randomizer Modal Styles */
.randomizer-modal-content {
    max-width: 580px !important;
}

.randomizer-modal-body {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.randomizer-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.edo-chips-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.chip-btn {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--glass-border);
    color: #94a3b8;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip-btn:hover {
    border-color: #a855f7;
    color: #f8fafc;
}

.chip-btn.active {
    background: var(--primary-gradient);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

.rand-toggles-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.randomizer-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--glass-border);
}

.randomizer-shortcut-hint {
    font-size: 0.85rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.randomizer-shortcut-hint kbd {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    font-family: inherit;
    color: #e2e8f0;
}

.randomizer-footer-btns {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.randomizer-footer-btns .primary-btn,
.randomizer-footer-btns .secondary-btn {
    height: 46px;
    padding: 0 1.5rem;
    min-width: 110px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 12px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: initial;
}

.btn-icon-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

/* Presets Modal Styles */
.presets-modal-content {
    max-width: 640px !important;
}

.presets-modal-body {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.save-preset-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.preset-form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.save-preset-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.save-preset-input-group input[type="text"] {
    flex: 1;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.save-preset-input-group input[type="text"]:focus {
    border-color: #a855f7;
}

.save-preset-btn {
    height: 40px !important;
    padding: 0 1.25rem !important;
    font-size: 0.9rem !important;
    border-radius: 10px !important;
    white-space: nowrap;
    flex: initial !important;
}

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

.saved-presets-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 340px;
    overflow-y: auto;
    padding-right: 4px;
}

.empty-presets-msg {
    text-align: center;
    padding: 2rem 1rem;
    color: #94a3b8;
    font-size: 0.95rem;
    font-style: italic;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 10px;
    border: 1px dashed var(--glass-border);
}

.preset-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.preset-card:hover {
    border-color: rgba(168, 85, 247, 0.4);
    background: rgba(30, 41, 59, 0.85);
}

.preset-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.preset-info h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f8fafc;
}

.preset-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.preset-tag {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}

.preset-tag.tag-edo {
    border-color: rgba(99, 102, 241, 0.4);
    color: #818cf8;
}

.preset-tag.tag-layout {
    border-color: rgba(6, 182, 212, 0.4);
    color: #22d3ee;
}

.preset-tag.tag-scale {
    border-color: rgba(168, 85, 247, 0.4);
    color: #c084fc;
}

.preset-tag.tag-scheme {
    border-color: rgba(236, 72, 153, 0.4);
    color: #f472b6;
}

.preset-tag.tag-relayout {
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

.preset-card-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.preset-card-actions .btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.6rem;
}

.preset-card-actions .btn-delete {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.4rem 0.6rem;
}

.preset-card-actions .btn-delete:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ffffff;
}

.presets-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--glass-border);
}

.presets-backup-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.presets-backup-actions .small-btn {
    height: 42px;
    padding: 0 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--glass-border);
    white-space: nowrap;
    text-transform: none;
    letter-spacing: normal;
}

.presets-backup-actions .small-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(168, 85, 247, 0.4);
}

.presets-modal-footer .secondary-btn {
    height: 42px;
    padding: 0 1.5rem;
    min-width: 110px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 12px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: initial;
}

/* Hardware Preset Modal Styles */
.hw-preset-modal-content {
    max-width: 480px !important;
}

.hw-preset-modal-content .modal-header h2 {
    font-size: 1.5rem;
}

.hw-preset-modal-body {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.hw-preset-hint {
    font-size: 0.92rem;
    color: #94a3b8;
    line-height: 1.55;
}

.hw-preset-slots-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.65rem;
}

.hw-slot-btn {
    height: 52px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #cbd5e1;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
}

.hw-slot-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(168, 85, 247, 0.6);
    color: #ffffff;
    transform: translateY(-1px);
}

.hw-slot-btn.active {
    background: var(--primary-gradient);
    border-color: rgba(192, 132, 252, 0.7);
    color: #ffffff;
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.55);
}

/* Confirm Modal Styles */
#confirm-modal {
    z-index: 1100;
}

.confirm-modal-content {
    max-width: 440px !important;
}

.confirm-modal-body {
    padding: 1.5rem 2rem;
    color: #e2e8f0;
    font-size: 1.05rem;
}

.confirm-modal-footer,
.hw-preset-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--glass-border);
}

.confirm-modal-footer .primary-btn,
.confirm-modal-footer .secondary-btn,
.hw-preset-modal-footer .primary-btn,
.hw-preset-modal-footer .secondary-btn {
    height: 42px;
    padding: 0 1.4rem;
    min-width: 100px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: initial;
}

.confirm-modal-footer .secondary-btn,
.hw-preset-modal-footer .secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: #cbd5e1;
    box-shadow: none;
}

.confirm-modal-footer .secondary-btn:hover:not(:disabled),
.hw-preset-modal-footer .secondary-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    box-shadow: none;
}

.danger-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4) !important;
}

.danger-btn:hover {
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.6) !important;
}