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

:root {
    --bg: #f5f5f5;
    --text: #333;
    --heading: #222;
    --svg-bg: #fff;
    --svg-grid: #999;
    --svg-label: #333;
    --svg-nut: #333;
    --notes-layer-bg: #e3f2fd;
    --types-layer-bg: #fff3e0;
    --note-btn-bg: #2196f3;
    --note-btn-bg-hover: #1976d2;
    --note-btn-bg-active: #1565c0;
    --type-btn-bg: #ff9800;
    --type-btn-bg-hover: #f57c00;
    --type-btn-bg-active: #e65100;
    --link-note-bg: #e3f2fd;
    --link-note-hover: #bbdefb;
    --link-type-bg: #fff3e0;
    --link-type-hover: #ffe0b2;
    --link-note-active: #2196f3;
    --link-type-active: #ff9800;
    --panel-bg: rgba(255,255,255,0.9);
    --panel-border: rgba(0,0,0,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
}

.hidden {
    display: none !important;
}

.theme-light {
    --bg: #f5f5f5;
    --text: #333;
    --svg-bg: #fff;
}

.theme-dark {
    --bg: #121212;
    --text: #e0e0e0;
    --heading: #ffffff;
    --svg-bg: #1e1e1e;
    --svg-grid: #bbb;
    --svg-label: #e0e0e0;
    --svg-nut: #e0e0e0;
    --notes-layer-bg: #1f2b36;
    --types-layer-bg: #2e2416;
    --note-btn-bg: #1976d2;
    --note-btn-bg-hover: #1565c0;
    --note-btn-bg-active: #0d47a1;
    --type-btn-bg: #f57c00;
    --type-btn-bg-hover: #e65100;
    --type-btn-bg-active: #bf360c;
    --link-note-bg: #1f2b36;
    --link-note-hover: #274055;
    --link-type-bg: #2e2416;
    --link-type-hover: #40321f;
    --link-note-active: #1976d2;
    --link-type-active: #f57c00;
    --panel-bg: rgba(30,30,30,0.9);
    --panel-border: rgba(255,255,255,0.08);
}

header {
    padding: 1rem;
    background: var(--svg-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    background: #4a90d9;
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.menu-toggle .arrow {
    transition: transform 0.3s;
}

.menu-toggle.expanded .arrow {
    transform: rotate(180deg);
}

.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 100;
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mobile-menu.hidden {
    display: none;
}

.menu-layer {
    padding: 0.75rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.notes-layer {
    background: var(--notes-layer-bg);
}

.types-layer {
    background: var(--types-layer-bg);
}

.menu-layer h3 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--heading);
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    width: 100%;
}

.types-grid {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
}

.type-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 0.4rem;
}

.note-btn, .type-btn {
    padding: 0.75rem 0.25rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    width: 100%;
}

.note-btn {
    background: var(--note-btn-bg);
    color: white;
}

.note-btn:hover {
    background: var(--note-btn-bg-hover);
}

.note-btn:active {
    transform: scale(0.95);
}

.note-btn.active {
    background: var(--note-btn-bg-active);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.type-btn {
    background: var(--type-btn-bg);
    color: white;
}

.type-btn:hover {
    background: var(--type-btn-bg-hover);
}

.type-btn:active {
    transform: scale(0.95);
}

.type-btn.active {
    background: var(--type-btn-bg-active);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.desktop-menu {
    display: none;
    padding: 1rem;
    background: var(--svg-bg);
    gap: 0.75rem;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

@media (min-width: 768px) {
    .desktop-menu {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .mobile-menu {
        display: none !important;
    }

    header {
        display: none;
    }
}

.notes-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.types-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.notes-row .note-link {
    flex: 1;
    max-width: 80px;
    text-align: center;
}

.types-row .type-row {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    gap: 0.5rem;
    width: 100%;
}

.note-link, .type-link {
    padding: 0.75rem 0.5rem;
    text-decoration: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
}

.note-link {
    background: var(--link-note-bg);
}

.note-link:hover {
    background: var(--link-note-hover);
}

.type-link {
    background: var(--link-type-bg);
}

.type-link:hover {
    background: var(--link-type-hover);
}

.note-link.active {
    background: var(--link-note-active);
    color: white;
    font-weight: 700;
}

.type-link.active {
    background: var(--link-type-active);
    color: white;
    font-weight: 700;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    text-align: center;
}

h1 {
    margin-bottom: 1.5rem;
    color: var(--heading);
    font-size: 2rem;
}

.diagrams {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.diagram-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.starting-fret {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
}

.diagram {
    max-width: 280px;
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background: var(--svg-bg);
    padding: 0.5rem;
}

.no-diagrams {
    color: #999;
    font-style: italic;
    padding: 2rem;
}

@media (max-width: 767px) {
    .desktop-menu {
        display: none;
    }

    .menu-toggle {
        display: flex;
    }
}

@media (min-width: 768px) {
    .desktop-menu {
        display: flex;
    }

    .menu-toggle {
        display: none;
    }

    main {
        padding-top: 2rem;
    }
}

@media (max-width: 400px) {
    .notes-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .note-btn {
        flex: 1 1 calc(33.33% - 0.4rem);
    }
}

.control-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--panel-bg);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--panel-border);
    z-index: 200;
}

.control-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    background: #4a90d9;
    color: #fff;
}

.control-btn:hover {
    background: #3b7fc3;
}

.rotated-90 {
    display: inline-block;
    transform: rotate(90deg);
    transform-origin: center center;
}
