:root {
    --bg-main: #070b14;
    --bg-card: #111827;
    --bg-glass: rgba(17, 24, 39, 0.75);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    /* Dynamic Theme Variables */
    --accent-cyan: #06b6d4;
    --accent-cyan-dark: color-mix(in srgb, var(--accent-cyan) 75%, black);
    --accent-cyan-light: color-mix(in srgb, var(--accent-cyan) 75%, white);
    --accent-cyan-glow: color-mix(in srgb, var(--accent-cyan) 35%, transparent);
    --border-color: rgba(51, 65, 85, 0.6);
    --border-glow: color-mix(in srgb, var(--accent-cyan) 30%, transparent);

    --white-key-base: #f8fafc;
    --white-key-grad: #cbd5e1;
    --black-key-base: #090d16;
    --black-key-grad: #1e293b;

    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: "Segoe UI Variable", "Segoe UI", Inter, system-ui, sans-serif;
    background-color: var(--bg-main);
    background-image:
        radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent-cyan) 10%, transparent) 0%, transparent 50%),
        radial-gradient(circle at 10% 90%, rgba(139, 92, 246, 0.05) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 24px;
}

header {
    background-color: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.3), 0 0 0 1px var(--border-color);
    transition: var(--transition-smooth);
    overflow: visible !important;
    position: relative; /* <-- Add this */
    z-index: 100;       /* <-- Add this to sit above the piano */
}

header:hover {
    box-shadow: 0 12px 30px -5px rgb(0 0 0 / 0.4), 0 0 0 1px var(--border-glow);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 14px;
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff 30%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-cyan-dark));
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 5px 10px;
    border-radius: 8px;
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.status-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.6);
    padding: 6px 14px;
    border-radius: 99px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

.status-dot.connected {
    background-color: #10b981;
    box-shadow: 0 0 12px #10b981;
}

/* Piano Container */
.piano-container {
    background: linear-gradient(180deg, #0b1120 0%, #020617 100%);
    padding: 28px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px -10px rgb(0 0 0 / 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.keyboard-wrapper {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 250px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
}

.keyboard {
    display: flex;
    position: relative;
    width: 100%;
    height: 250px;
    background: #020617;
    overflow: hidden;
}

.key {
    position: relative;
    cursor: pointer;
    transition: background 0.08s ease;
}

.key.white {
    height: 100%;
    background: linear-gradient(to bottom, var(--white-key-base) 0%, var(--white-key-grad) 100%);
    border-left: 1px solid #cbd5e1;
    border-bottom: 2px solid #94a3b8;
    border-radius: 0 0 6px 6px;
    z-index: 1;
    flex: 1;
    box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.1);
}

.key.black {
    width: var(--black-key-width);
    margin-left: calc(var(--black-key-width) / -2);
    margin-right: calc(var(--black-key-width) / -2);
    height: 60%;
    z-index: 2;
    background: linear-gradient(to bottom, var(--black-key-base) 0%, var(--black-key-grad) 100%);
    border-radius: 0 0 5px 5px;
    box-shadow: -2px 4px 8px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid #000;
}

.key.white.active,
.key.black.active {
    background: linear-gradient(to bottom, var(--accent-cyan), var(--accent-cyan-dark)) !important;
    box-shadow: 0 0 18px var(--accent-cyan), inset 0 0 10px rgba(255, 255, 255, 0.4) !important;
    border-color: var(--accent-cyan-light) !important;
}

.key-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.note-letter {
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: clamp(14px, 1.2vw, 24px);
    line-height: 1;
    color: #1e293b;
}

.note-octave {
    margin-bottom: 3px;
    font-weight: 700;
    font-size: clamp(9px, 0.8vw, 14px);
    line-height: 1;
    color: #64748b;
}

/* Main Display & Notation Section */
.main-display-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    padding: 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    gap: 24px;
}

.notation-header {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.subtitle {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Controls & Inputs */
#themeSelector,
#keySelector,
#keyboardSize,
#instrumentSelector {
    background: #1e293b;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#themeSelector:hover,
#keySelector:hover,
#keyboardSize:hover,
#instrumentSelector:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}

#themeSelector {
    margin-right: 15px;
}

/* Toggle Switches */
.toggle-switch {
    position: relative;
    width: 46px;
    height: 26px;
}

.toggle-switch input {
    display: none;
}

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: #334155;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
}

.slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: var(--transition-smooth);
}

.toggle-switch input:checked+.slider {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.toggle-switch input:checked+.slider::before {
    transform: translateX(20px);
}

/* Content Row & Panels */
.content-row {
    display: flex;
    flex-direction: row;
    gap: 24px;
    align-items: stretch;
    justify-content: center;
    width: 100%;
}

.notation-section {
    flex: 0 0 480px;
    max-width: 480px !important;
    display: flex;
    flex-direction: column;
    height: 400px;
}

.staff-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    background: #ffffff;
    border-radius: 16px;
    padding: 12px;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.06);
}

#notation-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.chord-side-panel {
    width: 320px;
    background: linear-gradient(145deg, #111827 0%, #0b1120 100%);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    height: 400px;
}

.chord-display-box {
    text-align: center;
    padding: 20px 12px;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.chord-title,
.notes-list-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    font-weight: 700;
}

.chord-name-large {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-cyan);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 0 20px var(--accent-cyan-glow);
}

.notes-list-box {
    background: rgba(15, 23, 42, 0.7);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 16px;
}

.notes-badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow-y: auto;
    align-content: flex-start;
}

.note-badge {
    background: linear-gradient(135deg, var(--accent-cyan-dark), var(--accent-cyan));
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px var(--accent-cyan-glow);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Navigation Links */
.nav {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(15, 23, 42, 0.8);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.nav a:hover {
    color: var(--text-primary);
    background-color: rgba(51, 65, 85, 0.5);
}

.nav a.active {
    color: var(--accent-cyan);
    background-color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 1px var(--border-glow);
}



.help-icon:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}



.help-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: bold;
    cursor: help;
    transition: var(--transition-smooth);
}

.help-icon:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

/* Tooltip & Quick Help Box */
.help-container {
    position: relative;
    display: inline-block;
}

.help-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: bold;
    cursor: help;
    transition: var(--transition-smooth);
}

.help-container:hover .help-icon {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.help-box {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 280px;
    background: #111827;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 18px;
    font-size: 0.88rem;
    line-height: 1.5;
    box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: var(--transition-smooth);
    z-index: 99999;
}

.help-container:hover .help-box {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}



.help-tooltip:hover .help-box {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Visibility states */
.notation-section.hidden,
.chord-side-panel.hidden,
.staff-container.hidden {
    display: none !important;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 10px 0 20px 0;
}

@media (max-width: 1024px) {
    .content-row {
        flex-direction: column;
        align-items: center;
    }

    .notation-section,
    .chord-side-panel {
        width: 100%;
        max-width: 100% !important;
    }
}

/*About page*/
/* --- About Page Specific & Missing Component Styles --- */

.container {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: var(--border-glow);
    box-shadow: 0 22px 45px -15px rgb(0 0 0 / 0.6);
}

.card h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-init: -0.02em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.card p, .card li {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.card ul {
    margin-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.feature {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feature h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

.feature p {
    font-size: 0.88rem;
}

.btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-cyan-dark));
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 12px 24px;
    border-radius: 12px;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 4px 15px var(--accent-cyan-glow);
    transition: var(--transition-smooth);
    width: fit-content;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-cyan-glow);
    filter: brightness(1.1);
}

.mobile-header .header-left select#instrumentSelector {
    background: #1e293b;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

/* Mobile View & Orientation Overlay Styles */
.mobile-body {
    background-color: var(--bg-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
    overflow: hidden;
}

.mobile-header {
    background-color: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.3);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mobile-keyboard-container {
    flex-grow: 1;
    display: flex;
    width: 100%;
    height: calc(100vh - 90px);
    background: linear-gradient(180deg, #0b1120 0%, #020617 100%);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.nav-btn {
    background: #1e293b;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.nav-btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* Rotate Overlay */
#rotate-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 11, 20, 0.95);
    backdrop-filter: blur(10px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

@media (orientation: portrait) {
    #rotate-overlay {
        display: flex;
    }
}

.rotate-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-primary);
}

.phone-icon {
    font-size: 3rem;
    animation: rotatePulse 2s infinite ease-in-out;
}

@keyframes rotatePulse {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

/* Ensure the mobile piano key can anchor absolute elements */
.mobile-body .piano-key,
.mobile-body .key {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important; /* Changes alignment from bottom to top */
}

/* Force the note label to the top of the key */
.mobile-body .piano-key .note-label,
.mobile-body .key-label {
    position: absolute !important;
    top: 10px !important;
    bottom: unset !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    color: var(--text-secondary) !important;
    pointer-events: none !important;
    z-index: 2;
}