/* Prevent FOUC for MusicXML */
    music[xml="1"], musicxml, .musicxml-placeholder { display: none !important; }
    
    /* Disable overscroll bounce to prevent showing background */
    html, body {
        overflow-x: hidden;
    }
    
    /* Book Typography & Aesthetic */
    @import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400&family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');
    
    .font-serif { 
        font-family: 'EB Garamond', 'Crimson Text', 'Georgia', 'Times New Roman', serif; 
    }
    
    .scrollbar-book::-webkit-scrollbar { width: 6px; }
    .scrollbar-book::-webkit-scrollbar-track { background: rgba(0,0,0,0.02); }
    .scrollbar-book::-webkit-scrollbar-thumb { background: #b08d5744; border-radius: 10px; }
    .scrollbar-book::-webkit-scrollbar-thumb:hover { background: #b08d5788; }

    .player-container {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .perspective-2000 { perspective: 2000px; }
    
    .book-page {
        transform-style: preserve-3d;
    }

    /* Article Content Styling - Premium Book Typography */
    .article-content {
        font-family: 'EB Garamond', 'Crimson Text', 'Georgia', serif;
        font-size: 1.125rem;
        line-height: 1.8;
        color: #2a2620;
        text-align: justify;
        hyphens: auto;
    }
    
    .article-content h1 {
        font-family: 'Crimson Text', 'EB Garamond', serif;
        font-weight: 700;
        font-size: 2.5rem;
        color: #1a1612;
        margin-bottom: 1.5rem;
        margin-top: 3rem;
        line-height: 1.2;
        letter-spacing: -0.02em;
        position: relative;
        padding-bottom: 1rem;
    }
    
    .article-content h1::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 60px;
        height: 3px;
        background: linear-gradient(to right, #b08d57, transparent);
    }
    
    .article-content h2 {
        font-family: 'Crimson Text', 'EB Garamond', serif;
        font-weight: 600;
        font-size: 2rem;
        color: #2a2620;
        margin-bottom: 1.25rem;
        margin-top: 2.5rem;
        line-height: 1.3;
        letter-spacing: -0.01em;
    }
    
    .article-content h3 {
        font-family: 'EB Garamond', serif;
        font-weight: 600;
        font-size: 1.5rem;
        color: #3a3630;
        margin-bottom: 1rem;
        margin-top: 2rem;
        line-height: 1.4;
    }
    
    .article-content p {
        margin-bottom: 1.5rem;
        opacity: 0.95;
        text-indent: 0;
    }
    
    /* Beautiful drop cap for first paragraph */
    .article-content > p:first-of-type::first-letter {
        font-family: 'Crimson Text', serif;
        font-size: 4.5rem;
        font-weight: 700;
        line-height: 0.8;
        float: left;
        margin: 0.1em 0.1em 0 0;
        color: #b08d57;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    }
    
    .article-content strong {
        font-weight: 600;
        color: #1a1612;
    }
    
    .article-content em {
        font-style: italic;
        color: #3a3630;
    }
    
    .article-content blockquote {
        border-left: 4px solid #b08d57;
        padding-left: 1.5rem;
        margin: 2rem 0;
        font-style: italic;
        color: #5c544a;
        font-size: 1.2rem;
        position: relative;
    }
    
    .article-content blockquote::before {
        content: '"';
        font-family: 'Crimson Text', serif;
        font-size: 4rem;
        position: absolute;
        left: -0.5rem;
        top: -1rem;
        color: #b08d5733;
        line-height: 1;
    }
    
    .article-content ul, .article-content ol {
        margin: 1.5rem 0;
        padding-left: 2rem;
    }
    
    .article-content li {
        margin-bottom: 0.75rem;
        line-height: 1.7;
    }
    
    .article-content a {
        color: #b08d57;
        text-decoration: none;
        border-bottom: 1px solid #b08d5744;
        transition: all 0.3s ease;
    }
    
    .article-content a:hover {
        color: #8b7e6d;
        border-bottom-color: #8b7e6d;
    }
    
    .article-content code {
        font-family: 'Courier New', monospace;
        background: #f5f3ef;
        padding: 0.2em 0.4em;
        border-radius: 3px;
        font-size: 0.9em;
        color: #5c544a;
    }
    
    .article-content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    
    /* Hint for mobile: there's more content */
    .article-content table::after {
        content: "⟵ swipe ⟶";
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        color: #999;
        font-size: 0.7rem;
        background: rgba(255,255,255,0.9);
        padding: 2px 6px;
        border-radius: 4px;
        pointer-events: none;
        opacity: 0;
    }
    
    @media (max-width: 767px) {
        .article-content table::after {
            opacity: 0.6;
            animation: table-hint 2s infinite;
        }
    }
    
    @keyframes table-hint {
        0%, 100% { opacity: 0.3; }
        50% { opacity: 0.8; }
    }
    
    @media (min-width: 768px) {
        .article-content table {
            display: table;
            white-space: normal;
        }
    }
    
    .article-content pre {
        background: #f5f3ef;
        padding: 1.5rem;
        border-radius: 8px;
        overflow-x: auto;
        margin: 2rem 0;
        border-left: 4px solid #b08d57;
    }

    /* Page Shadow Separator - 3D Curved Book Fold Effect */
    .page-shadow {
        height: 80px;
        position: relative;
        background: 
            /* 3D fold pattern - lines getting smaller for perspective */
            repeating-linear-gradient(
                to bottom,
                rgba(0,0,0,0.12) 0px,
                rgba(0,0,0,0.12) 1px,
                transparent 1px,
                transparent 8px
            ),
            repeating-linear-gradient(
                to bottom,
                rgba(0,0,0,0.10) 8px,
                rgba(0,0,0,0.10) 9px,
                transparent 9px,
                transparent 14px
            ),
            repeating-linear-gradient(
                to bottom,
                rgba(0,0,0,0.08) 14px,
                rgba(0,0,0,0.08) 15px,
                transparent 15px,
                transparent 18px
            ),
            repeating-linear-gradient(
                to bottom,
                rgba(0,0,0,0.06) 18px,
                rgba(0,0,0,0.06) 19px,
                transparent 19px,
                transparent 21px
            ),
            /* Base gradient shadow */
            linear-gradient(to bottom, 
                rgba(0,0,0,0) 0%,
                rgba(0,0,0,0.08) 20%,
                rgba(0,0,0,0.15) 50%,
                rgba(0,0,0,0.08) 80%,
                rgba(0,0,0,0) 100%);
    }
    
    /* Add subtle curve effect to the fold */
    .page-shadow::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 100%;
        background: radial-gradient(ellipse at center, 
            rgba(0,0,0,0.15) 0%, 
            transparent 70%);
    }
    
    /* Smooth color transition from white to blue */
    .page-shadow::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 40px;
        background: linear-gradient(to bottom,
            transparent 0%,
            rgba(30, 58, 95, 0.15) 50%,
            rgba(30, 58, 95, 0.25) 100%);
    }

    /* Musical Tools - Book Aesthetic Override */
    /* Clean, unified styling without heavy boxes and shadows */
    /* Scoped to book-page to not affect menu/footer */
    
    /* Remove heavy backgrounds and shadows from controls */
    .book-page .unified-controls-container {
        background: transparent !important;
        backdrop-filter: none !important;
        border: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.15) !important;
        border-radius: 0 !important;
        padding: 1rem 0 1.5rem 0 !important;
        box-shadow: none !important;
    }
    
    /* Clean select inputs */
    /* Bug fix: previously these rules set background but no color, so the
       Tailwind `text-white` class won → invisible (white-on-white). We MUST
       also set color with !important, including for <option> children, so the
       chosen value is visible after selection. */
    .book-page .unified-controls-container select,
    .book-page #unified-root-note,
    .book-page #unified-accidental,
    .book-page #unified-instrument-select {
        background: rgba(255,255,255,0.05) !important;
        color: rgba(255,255,255,0.95) !important;
        border: 1px solid rgba(255,255,255,0.2) !important;
        border-radius: 8px !important;
        box-shadow: none !important;
        transition: all 0.2s ease !important;
    }
    .book-page .unified-controls-container select option,
    .book-page #unified-root-note option,
    .book-page #unified-accidental option,
    .book-page #unified-instrument-select option {
        background-color: #1f2937 !important; /* gray-800 */
        color: #f9fafb !important;             /* gray-50  */
    }
    
    .book-page .unified-controls-container select:hover {
        background: rgba(255,255,255,0.08) !important;
        border-color: rgba(176, 141, 87, 0.4) !important;
    }
    
    .book-page .unified-controls-container select:focus {
        background: rgba(255,255,255,0.1) !important;
        border-color: rgba(176, 141, 87, 0.6) !important;
        outline: none !important;
        box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.1) !important;
    }
    
    /* Clean labels */
    .book-page .unified-controls-container label {
        color: rgba(255,255,255,0.7) !important;
        font-size: 0.75rem !important;
        letter-spacing: 0.05em !important;
        font-weight: 500 !important;
    }
    
    /* Remove boxes from visualizers */
    .book-page #piano-visualizer,
    .book-page #fretboard-visualizer,
    .book-page .visualizer-container {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        padding: 1.5rem 0 !important;
    }
    
    /* Clean SVG containers */
    .book-page #piano-visualizer svg,
    .book-page #fretboard-visualizer svg {
        filter: drop-shadow(0 2px 8px rgba(0,0,0,0.15)) !important;
    }
    
    /* Remove heavy styling from result cards */
    .book-page #backend-result > div,
    .book-page .result-card {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 1rem 0 !important;
    }
    
    /* Clean MusicXML score container */
    .book-page #osmd-container,
    .book-page .osmd-wrapper {
        background: rgba(255,255,255,0.03) !important;
        border: 1px solid rgba(255,255,255,0.1) !important;
        border-radius: 12px !important;
        padding: 1.5rem !important;
        box-shadow: none !important;
    }
    
    /* Clean buttons */
    .book-page .unified-controls-container button,
    .book-page button[id*="play"],
    .book-page button[id*="audio"] {
        background: rgba(176, 141, 87, 0.15) !important;
        border: 1px solid rgba(176, 141, 87, 0.3) !important;
        color: rgba(255,255,255,0.9) !important;
        border-radius: 8px !important;
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
        font-weight: 500 !important;
        box-shadow: none !important;
        transition: all 0.2s ease !important;
    }
    
    .book-page .unified-controls-container button:hover,
    .book-page button[id*="play"]:hover,
    .book-page button[id*="audio"]:hover {
        background: rgba(176, 141, 87, 0.25) !important;
        border-color: rgba(176, 141, 87, 0.5) !important;
        transform: translateY(-1px) !important;
    }
    
    /* Clean wheel displays */
    .book-page .wheel-display {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
    }
    
    .book-page #wheels-wrapper {
        background: transparent !important;
        padding: 0.5rem 0 !important;
    }
    
    /* Remove boxes from wheel labels */
    .book-page #wheels-wrapper span {
        color: rgba(255,255,255,0.6) !important;
        font-size: 0.75rem !important;
        letter-spacing: 0.1em !important;
    }
    
    /* Clean exercise controls */
    .book-page .exercise-controls,
    .book-page .exercise-buttons {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 1rem 0 !important;
    }
    
    /* Unified spacing */
    .book-page .musical-tools-container > div {
        margin-bottom: 2rem !important;
    }
    
    /* Clean count-in display */
    .book-page #count-in-display {
        background: rgba(0,0,0,0.3) !important;
        border: 2px solid rgba(176, 141, 87, 0.4) !important;
        box-shadow: 0 4px 16px rgba(0,0,0,0.2) !important;
    }
    
    /* Remove unnecessary borders and backgrounds - scoped */
    .book-page .border-gray-700,
    .book-page .border-gray-800,
    .book-page .bg-gray-800,
    .book-page .bg-gray-900 {
        border-color: rgba(255,255,255,0.1) !important;
        background: rgba(255,255,255,0.03) !important;
    }
    
    /* Clean dividers - scoped */
    .book-page .border-t,
    .book-page .border-b {
        border-color: rgba(255,255,255,0.1) !important;
    }
    
    /* Subtle hover effects - scoped */
    .book-page .hover\:bg-gray-700:hover,
    .book-page .hover\:bg-gray-800:hover {
        background: rgba(255,255,255,0.05) !important;
    }
    
    /* Clean text colors - scoped */
    .book-page .text-gray-400 {
        color: rgba(255,255,255,0.6) !important;
    }
    
    .book-page .text-gray-300 {
        color: rgba(255,255,255,0.8) !important;
    }
    
    /* Remove rounded corners from incompatible elements - scoped */
    .book-page .rounded-2xl,
    .book-page .rounded-xl,
    .book-page .rounded-lg {
        border-radius: 8px !important;
    }
    
    /* Clean shadows - scoped */
    .book-page .shadow-lg,
    .book-page .shadow-xl,
    .book-page .shadow-2xl {
        box-shadow: none !important;
    }
