/* Header runs edge-to-edge on lesson pages so the brand and nav align with the lesson content below.
   On other pages .container stays capped at --max-width via assets/styles.css. */
.site-header > .container {
    max-width: none;
    padding: 0 32px;
}

/* Lesson Page Layout: viewport-locked so the whole thing fits without page scroll.
   Each panel handles its own internal scroll (TOC on the left, study guide on the right).
   Body is a flex column so the lesson-layout consumes whatever is left under the site header,
   regardless of how tall that header actually renders. */
html, body {
    height: 100vh;
    height: 100dvh; /* dynamic viewport — handles browser URL/toolbars correctly */
    overflow: hidden;
    margin: 0;
    padding: 0;
}
body { display: flex; flex-direction: column; }
.site-header { flex: 0 0 auto; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    line-height: 1.47059;
    background-color: #fbfbfd;
    color: #1d1d1f;
    -webkit-font-smoothing: antialiased;
}

/* Phase 3 refactor: full-page scroll with the video sticky-pinned on desktop.
   Mobile rules (below) still use the fixed-viewport pattern with the video pinned
   to the top and the TOC scrolling beneath it. */
.lesson-layout {
    display: grid;
    grid-template-columns: minmax(300px, 32%) 1fr;
    grid-template-rows: 1fr; /* constrain row to layout's height instead of sizing to content */
    gap: 24px;
    padding: 16px 24px;
    box-sizing: border-box;
    /* Flex child takes whatever vertical space the body has left below the header. */
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.left-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
/* Items above the TOC stay pinned; only the TOC area scrolls. */
.left-panel > .breadcrumb,
.left-panel > .breadcrumbs,
.left-panel > .header,
.left-panel > #speed-controls-anchor,
.left-panel > .speed-controls {
    flex: 0 0 auto;
}
.left-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    /* Bigger buffer at the bottom so the last TOC item clears the sticky filter widget at the top */
    padding-bottom: 64px;
}
/* The "Filter topics" widget stays pinned at the top of the scrollable area. */
.left-scroll .lesson-search-widget {
    position: sticky;
    top: 0;
    background: #fbfbfd;
    z-index: 2;
    padding-bottom: 8px;
}

.right-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    /* override any earlier sticky positioning */
    position: static;
    height: 100%;
}
/* lesson-study-guide.js and lesson-notes.js inject their containers inside .video-sticky as siblings
   of .video-container. So make .video-sticky the flex column that owns video (fixed) + the
   notes/study-guide panes (scrollable). */
.right-panel > .video-sticky {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.video-sticky > .video-container { flex: 0 0 auto; }
.video-sticky > #study-guide-container,
.video-sticky > #notes-container {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    width: 100%;
    margin: 12px 0 0 0;
}

.video-sticky { width: 100%; }

.header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 8px;
    padding: 10px 0;
}

.header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.003em;
    color: #1d1d1f;
}

.header .subtitle {
    font-size: 28px;
    font-weight: 400;
    color: #86868b;
    margin: 0;
}

.video-container {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 1px solid #d2d2d7;
    background: #000;
}

.toc-container {
    margin-top: 10px;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.sections-wrapper { flex: 1; }

.rewinderator-plug {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    border-top: 1px solid #f5f5f7;
    font-size: 15px;
    color: #86868b;
}

.rewinderator-plug a {
    color: #0066cc;
    text-decoration: none;
    font-weight: 500;
}

.rewinderator-plug a:hover { text-decoration: underline; }

/* Speed Controls */
/* Modernized control cluster: one row, no card chrome, design-tokens. */
.speed-controls {
    margin: 0 0 14px 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}
.speed-controls-header { display: none; } /* legacy wrapper, no longer used by v2 lesson-page.js */
.speed-controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.speed-control-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.speed-controls .control-buttons {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.speed-btn,
.metronome-btn,
.video-controls-btn {
    background: #FFFFFF;
    border: 1px solid #D8D2C8;
    color: #2A2A2A;
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
}
.metronome-btn,
.video-controls-btn {
    background: transparent;
    color: #6B6B6B;
    font-size: 0.78rem;
    padding: 0.35rem 0.65rem;
}
.speed-btn:hover { background: #F8F5F0; border-color: #B5AFA4; }
.metronome-btn:hover,
.video-controls-btn:hover { background: #F8F5F0; color: #0E0E0E; border-color: #B5AFA4; }
.speed-btn.active { background: #1B4F99; border-color: #1B4F99; color: #FFFFFF; }
.current-speed { display: none; }

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

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #d2d2d7;
}

.modal-header h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
    color: #1d1d1f;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #86868b;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f5f5f7;
    color: #1d1d1f;
}

.modal-body {
    padding: 20px 24px;
}

.keyboard-shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f5f5f7;
}

.keyboard-shortcut:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.keyboard-shortcut .key {
    background: #f5f5f7;
    color: #1d1d1f;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    min-width: 60px;
    text-align: center;
    font-family: Monaco, 'Courier New', monospace;
}

.keyboard-shortcut .action {
    color: #1d1d1f;
    font-size: 15px;
    flex: 1;
    margin-left: 16px;
}

/* Loop Button Styles */
.subsection-content { display: flex; align-items: center; flex: 1; cursor: pointer; }

.loop-btn {
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 14px;
    color: #86868b;
    transition: all 0.2s ease;
    margin-left: 12px;
    flex-shrink: 0;
}

.loop-btn:hover { background: #f5f5f7; border-color: #007aff; color: #007aff; transform: scale(1.1); }

/* Favorites Button Styles */
.favorite-btn {
    background: white;
    border: 1px solid #d2d2d7;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.favorite-btn:hover { 
    background: #f5f5f7; 
    border-color: #007aff;
    transform: scale(1.1); 
}

.favorite-btn .guitar-icon {
    filter: grayscale(100%) opacity(0.4);
    transition: filter 0.2s ease;
}

.favorite-btn.favorited .guitar-icon {
    filter: none;
}

/* Favorites Controls - integrated into speed controls */
.favorites-divider {
    width: 100%;
    height: 1px;
    background: #e5e5e7;
    margin: 16px 0 12px 0;
}

.favorites-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.favorites-label-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.favorites-section label {
    font-size: 15px;
    font-weight: 500;
    color: #1d1d1f;
    margin: 0;
}

.favorites-toggle-btn {
    background: #007aff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.favorites-toggle-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.favorites-toggle-btn:not(.active) {
    background: #f5f5f7;
    color: #007aff;
    border: 1px solid #d2d2d7;
}

.favorites-toggle-btn:not(.active):hover {
    background: #e8e8ed;
}

.favorites-count {
    font-size: 13px;
    color: #86868b;
    font-weight: 400;
}

.favorites-help {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f5f5f7;
    color: #86868b;
    cursor: help;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.favorites-help:hover {
    background: #007aff;
    color: white;
}

.favorites-help .tooltip {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1d1d1f;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.favorites-help .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1d1d1f;
}

.favorites-help:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

.toggle-button {
    background-color: transparent;
    color: #0066cc;
    border: 1px solid #d2d2d7;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 400;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.toggle-button:hover { background-color: #f5f5f7; border-color: #b0b0b0; }

.section {
    background: #fff;
    margin-bottom: 2px;
    border-radius: 0;
    overflow: hidden;
    border: 1px solid #d2d2d7;
}

.section:first-child { border-radius: 12px 12px 0 0; }
.section:last-child { border-radius: 0 0 12px 12px; margin-bottom: 0; }
.section:only-child { border-radius: 12px; }

.section-header {
    background: #fff;
    color: #1d1d1f;
    padding: 20px 56px 20px 24px; /* space for chevron */
    font-size: 19px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    border-bottom: 1px solid #d2d2d7;
    transition: background-color 0.15s ease;
}

.section-header:hover { background-color: #f5f5f7; }
.section-header.collapsed { border-bottom: none; }

.section-header::after {
    content: '';
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 13px;
    height: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23666' viewBox='0 0 13 8'%3E%3Cpath d='M1 1l5.5 5.5L12 1'/%3E%3C/svg%3E");
    transition: transform 0.15s ease;
}

.section-header.collapsed::after { transform: translateY(-50%) rotate(-90deg); }
.section-header .duration { margin: 0 20px 0 0; display: inline-block; }

.section-content { padding: 0; overflow: hidden; transition: max-height 0.15s ease;}
.section-content.collapsed { max-height: 0; }

.subsection {
    padding: 16px 24px;
    border-bottom: 1px solid #f5f5f7;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.subsection:hover { background-color: #f5f5f7; }

.subsection.current-topic {
    background-color: #007aff;
    color: white;
    border-radius: 8px;
    margin: 2px 8px;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.subsection.current-topic .timestamp {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.subsection.current-topic .topic {
    color: white;
    font-weight: 500;
}

.subsection.current-topic:hover {
    background-color: #0056b3;
}
.subsection:last-child { border-bottom: none; }

.timestamp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f7;
    color: #1d1d1f;
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    margin-right: 16px;
    min-width: 70px;
    transition: all 0.15s ease;
    font-variant-numeric: tabular-nums;
}

.timestamp:hover { background-color: #e8e8ed; color: #1d1d1f; text-decoration: none; }

.topic { color: #1d1d1f; font-weight: 400; font-size: 17px; flex: 1; }
.duration { color: #86868b; font-size: 17px; font-weight: 400; margin-left: 0; }

@media (max-width: 900px) {
    /* Mobile: video stacks above the TOC; both scroll naturally with the page.
       Video stays sticky just below the site header so it remains visible while reading. */
    .lesson-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        grid-template-areas: 'video' 'content';
        padding: 0 0 32px 0;
        gap: 0;
    }
    .right-panel {
        grid-area: video;
        display: block;
        position: sticky;
        top: var(--header-h, 64px);
        z-index: 5;
        background: #fbfbfd;
        padding: 0 0 12px 0;
    }
    .video-sticky { width: 100%; }
    .left-panel {
        grid-area: content;
        padding: 10px 16px 0 16px;
    }
    .breadcrumbs {
        padding: 12px 16px 16px 16px;
        font-size: 14px;
        color: #86868b;
        margin-bottom: 8px;
    }
    .breadcrumbs a {
        color: #007aff;
        text-decoration: none;
        padding: 8px;
        margin: -8px;
        border-radius: 6px;
        transition: background-color 0.2s ease;
    }
    .breadcrumbs a:hover {
        background: #f0f0f0;
    }
    .left-scroll, .toc-container { overflow: visible; }
    .header { gap: 10px; }
    .header h1, .header .subtitle { font-size: 20px; }
    .section-header { padding: 16px 48px 16px 20px; font-size: 17px; }
    .section-header::after { right: 20px; }
    .section-header .duration { display: block; margin: 2px 0 0 0 !important; padding: 0; text-indent: 0; }
    .subsection { 
        padding: 12px 20px; 
        display: grid;
        grid-template-columns: auto 1fr auto auto;
        grid-template-rows: auto auto;
        gap: 8px 12px;
        align-items: center;
    }
    
    .timestamp { 
        grid-column: 1;
        grid-row: 1;
        margin: 0 12px 0 0; 
        min-width: 60px; 
        font-size: 14px; 
        padding: 4px 8px; 
        justify-self: start;
    }
    
    .favorite-btn {
        grid-column: 3;
        grid-row: 1;
        margin: 0;
        justify-self: end;
        font-size: 14px;
        padding: 4px 6px;
    }
    
    .loop-btn {
        grid-column: 4;
        grid-row: 1;
        margin: 0 0 0 4px;
        justify-self: end;
    }
    
    .topic { 
        grid-column: 1 / -1;
        grid-row: 2;
        font-size: 15px; 
        margin: 0;
        line-height: 1.3;
    }
}

/* Metronome Styles */
.control-buttons {
    display: flex;
    gap: 12px;
}

.metronome-btn {
    background: white;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.metronome-btn:hover {
    background: #f5f5f7;
    transform: translateY(-1px);
}

.metronome-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metronome-content {
    max-width: 450px;
    width: 95%;
}

.metronome-body {
    padding: 24px;
}

.metronome-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.beat-indicator {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 20px 0;
}

.beat-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #d2d2d7;
    transition: all 0.1s ease;
}

.beat-dot.active {
    background: #007aff;
    transform: scale(1.3);
}

.beat-dot.accent {
    background: #ff3b30;
}

.tempo-control {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tempo-control label {
    font-weight: 500;
    color: #1d1d1f;
}

#tempo-display {
    color: #007aff;
    font-weight: 600;
}

#tempo-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #d2d2d7;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#tempo-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007aff;
    cursor: pointer;
    transition: all 0.2s ease;
}

#tempo-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

#tempo-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007aff;
    cursor: pointer;
    border: none;
}

.tempo-presets {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.preset-btn {
    background: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
}

.preset-btn:hover {
    background: #e5e5e7;
    transform: translateY(-1px);
}

.metronome-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.metronome-play-btn {
    background: #34c759;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.metronome-play-btn:hover {
    background: #30d158;
    transform: translateY(-1px);
}

.metronome-play-btn.playing {
    background: #ff3b30;
}

.metronome-play-btn.playing:hover {
    background: #d70015;
}

.accent-btn {
    background: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.accent-btn:hover {
    background: #e5e5e7;
}

.accent-btn.active {
    background: #007aff;
    color: white;
    border-color: #007aff;
}

.sound-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.sound-selection label {
    font-weight: 500;
    color: #1d1d1f;
}

.sound-buttons {
    display: flex;
    gap: 8px;
}

.sound-btn {
    background: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sound-btn:hover {
    background: #e5e5e7;
}

.sound-btn.active {
    background: #007aff;
    color: white;
    border-color: #007aff;
}

/* Notes Interface Styles */
.notes-container {
    margin-top: 24px;
    margin-bottom: 40px;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    width: 70%;
    align-self: flex-start;
}

.notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #d2d2d7;
    background: #f9f9f9;
}

.notes-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1d1d1f;
}

.notes-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: #d2d2d7;
    margin: 0 4px;
}

.notes-btn {
    background: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notes-btn:hover {
    background: #e8e8ed;
    border-color: #b0b0b0;
}

.notes-btn.active {
    background: #007aff;
    color: white;
    border-color: #007aff;
}

.format-btn {
    font-weight: 600;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    min-width: 36px;
}

.bold-btn strong {
    font-weight: 700;
}

.italic-btn em {
    font-style: italic;
}

.heading-btn {
    font-weight: 700;
    color: #1d1d1f;
}

.bullet-btn, .numbered-btn {
    font-size: 12px;
    min-width: 44px;
}

.notes-content {
    position: relative;
    height: 220px;
}

.notes-textarea {
    width: 100%;
    height: 100%;
    border: none;
    padding: 16px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #1d1d1f;
    background: white;
    resize: none;
    outline: none;
    box-sizing: border-box;
}

.notes-textarea::placeholder {
    color: #86868b;
}

.notes-preview {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px 20px;
    overflow-y: auto;
    background: white;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #1d1d1f;
}

.notes-preview h1 {
    font-size: 24px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 8px 0 12px 0;
}

.notes-preview h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 8px 0 12px 0;
}

.notes-preview h3 {
    font-size: 17px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 8px 0 12px 0;
}

.notes-preview p {
    margin: 12px 0;
    line-height: 1.6;
}

.notes-preview ul, .notes-preview ol {
    margin: 12px 0;
    padding-left: 24px;
}

.notes-preview li {
    margin: 6px 0;
}

.notes-preview strong {
    font-weight: 600;
    color: #1d1d1f;
}

.notes-preview em {
    font-style: italic;
    color: #1d1d1f;
}

.notes-preview code {
    background: #f5f5f7;
    color: #af52de;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 14px;
}

.notes-preview .empty-notes {
    color: #86868b;
    font-style: italic;
    text-align: center;
    margin-top: 60px;
}

.notes-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #1d1d1f;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

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

/* Study Guide Interface Styles */
.study-guide-container {
    margin-top: 24px;
    margin-bottom: 40px;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    width: 70%;
    align-self: flex-start;
}

.study-guide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #d2d2d7;
    background: #f9f9f9;
}

.study-guide-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1d1d1f;
}

.study-guide-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.study-guide-btn {
    background: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.study-guide-btn:hover {
    background: #e8e8ed;
    border-color: #b0b0b0;
}

.study-guide-content {
    position: relative;
    /* Outer #study-guide-container handles scroll; this used to cap at 400px which clipped content. */
}

.study-guide-text {
    padding: 16px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #1d1d1f;
}

.study-guide-text h1 {
    font-size: 24px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 16px 0 12px 0;
}

.study-guide-text h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 16px 0 12px 0;
}

.study-guide-text h3 {
    font-size: 17px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 14px 0 10px 0;
}

.study-guide-text h4 {
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 12px 0 8px 0;
}

.study-guide-text h5 {
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 10px 0 6px 0;
}

.study-guide-text h6 {
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 8px 0 4px 0;
}

.study-guide-text p {
    margin: 12px 0;
    line-height: 1.6;
}

.study-guide-text ul, .study-guide-text ol {
    margin: 12px 0;
    padding-left: 24px;
}

.study-guide-text li {
    margin: 6px 0;
}

.study-guide-text strong {
    font-weight: 600;
    color: #1d1d1f;
}

.study-guide-text em {
    font-style: italic;
    color: #1d1d1f;
}

.study-guide-text code {
    background: #f5f5f7;
    color: #af52de;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 14px;
}

.study-guide-text del {
    text-decoration: line-through;
    color: #86868b;
}

.study-guide-text hr {
    border: none;
    border-top: 2px solid #f5f5f7;
    margin: 24px 0;
}

.study-guide-text .empty-study-guide {
    color: #86868b;
    font-style: italic;
    text-align: center;
    margin-top: 60px;
}

.study-guide-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #1d1d1f;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

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

/* Study Guide Focus Modal */
.study-guide-focus-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.study-guide-focus-modal.show {
    opacity: 1;
}

.study-guide-focus-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.study-guide-focus-modal .modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.study-guide-focus-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #d2d2d7;
    background: #fbfbfd;
}

.study-guide-focus-modal .modal-header h2 {
    margin: 0;
    font-size: 21px;
    font-weight: 600;
    color: #1d1d1f;
}

.study-guide-focus-modal .modal-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.study-guide-focus-modal .modal-btn {
    background: #f5f5f7;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    cursor: pointer;
    transition: all 0.2s ease;
}

.study-guide-focus-modal .modal-btn:hover {
    background: #e8e8ed;
}

.study-guide-focus-modal .close-modal {
    background: none;
    border: none;
    font-size: 24px;
    color: #86868b;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.study-guide-focus-modal .close-modal:hover {
    background: #f5f5f7;
    color: #1d1d1f;
}

.study-guide-focus-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: white;
}

.study-guide-focus-modal .modal-study-guide-text {
    font-size: 16px;
    line-height: 1.6;
    color: #1d1d1f;
    max-width: none;
}

.study-guide-focus-modal .modal-study-guide-text h1,
.study-guide-focus-modal .modal-study-guide-text h2,
.study-guide-focus-modal .modal-study-guide-text h3,
.study-guide-focus-modal .modal-study-guide-text h4,
.study-guide-focus-modal .modal-study-guide-text h5,
.study-guide-focus-modal .modal-study-guide-text h6 {
    margin-top: 32px;
    margin-bottom: 16px;
    font-weight: 600;
    color: #1d1d1f;
}

.study-guide-focus-modal .modal-study-guide-text h1:first-child,
.study-guide-focus-modal .modal-study-guide-text h2:first-child,
.study-guide-focus-modal .modal-study-guide-text h3:first-child,
.study-guide-focus-modal .modal-study-guide-text h4:first-child,
.study-guide-focus-modal .modal-study-guide-text h5:first-child,
.study-guide-focus-modal .modal-study-guide-text h6:first-child {
    margin-top: 0;
}

.study-guide-focus-modal .modal-study-guide-text h1 { font-size: 24px; }
.study-guide-focus-modal .modal-study-guide-text h2 { font-size: 21px; }
.study-guide-focus-modal .modal-study-guide-text h3 { font-size: 19px; }
.study-guide-focus-modal .modal-study-guide-text h4 { font-size: 17px; }
.study-guide-focus-modal .modal-study-guide-text h5 { font-size: 16px; }
.study-guide-focus-modal .modal-study-guide-text h6 { font-size: 15px; }

.study-guide-focus-modal .modal-study-guide-text p {
    margin-bottom: 16px;
}

.study-guide-focus-modal .modal-study-guide-text ul,
.study-guide-focus-modal .modal-study-guide-text ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.study-guide-focus-modal .modal-study-guide-text li {
    margin-bottom: 8px;
}

.study-guide-focus-modal .modal-study-guide-text strong {
    font-weight: 600;
}

.study-guide-focus-modal .modal-study-guide-text em {
    font-style: italic;
}

.study-guide-focus-modal .modal-study-guide-text code {
    background: #f5f5f7;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Roboto Mono', Consolas, monospace;
    font-size: 14px;
}

.study-guide-focus-modal .modal-study-guide-text del {
    text-decoration: line-through;
    opacity: 0.7;
}

.study-guide-focus-modal .modal-study-guide-text hr {
    border: none;
    border-top: 1px solid #d2d2d7;
    margin: 32px 0;
}

@media (max-width: 600px) {
    .study-guide-focus-modal .modal-content {
        width: 95%;
        max-height: 95vh;
        margin: 20px;
    }
    
    .study-guide-focus-modal .modal-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .study-guide-focus-modal .modal-toolbar {
        width: 100%;
        justify-content: space-between;
    }
    
    .study-guide-focus-modal .modal-body {
        padding: 16px;
    }
}

@media (max-width: 900px) {
    .notes-container {
        width: 100%;
        margin-top: 16px;
        margin-bottom: 32px;
        border-radius: 8px;
    }
    
    .notes-header {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .notes-toolbar {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .notes-btn {
        padding: 6px 8px;
        font-size: 12px;
        min-width: 28px;
    }
    
    .notes-content {
        height: 250px;
    }
    
    .notes-textarea, .notes-preview {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .toolbar-divider {
        display: none;
    }
    
    .study-guide-container {
        width: 100%;
        margin-top: 16px;
        margin-bottom: 32px;
        border-radius: 8px;
    }
    
    .study-guide-header {
        padding: 12px 16px;
    }
    
    .study-guide-btn {
        padding: 6px 8px;
        font-size: 12px;
        min-width: 28px;
    }
    
    .study-guide-content {
        max-height: 300px;
    }
    
    .study-guide-text {
        padding: 12px 16px;
        font-size: 14px;
    }
}

@media (max-width: 900px) {
    .speed-controls {
        padding: 12px 16px;
    }
    
    .speed-controls-row {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .control-buttons {
        gap: 8px;
        justify-content: center;
        order: 1;
    }
    
    .speed-control-group {
        justify-content: center;
        order: 2;
    }
    
    .metronome-btn {
        padding: 8px 16px;
        font-size: 13px;
        font-weight: 600;
    }
    
    .video-controls-btn {
        display: none;
    }
    
    .toggle-button {
        display: none;
    }
    
    .metronome-content {
        margin: 20px;
        width: calc(100% - 40px);
    }
    
    .beat-indicator {
        gap: 8px;
        padding: 16px 0;
    }
    
    .beat-dot {
        width: 12px;
        height: 12px;
    }
    
    .tempo-presets {
        gap: 6px;
    }
    
    .preset-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 36px;
    }
    
    .metronome-controls {
        gap: 8px;
        flex-direction: column;
    }
    
    .metronome-play-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .sound-buttons {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .sound-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .favorites-section {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .favorites-label-group {
        justify-content: center;
    }
    
    .favorites-toggle-btn {
        padding: 8px 12px;
        font-size: 13px;
        align-self: center;
    }
    
    .favorites-help .tooltip {
        white-space: normal;
        max-width: 200px;
    }
}

/* Lesson Search Widget */
.lesson-search-widget {
    margin-bottom: 20px;
    padding: 16px;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
}
.lesson-search-input-wrapper {
    position: relative;
    margin-bottom: 8px;
}
.lesson-search-input {
    width: 100%;
    padding: 10px 36px 10px 12px;
    font-size: 15px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}
.lesson-search-input:focus {
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}
.lesson-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: #86868b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}
.lesson-search-clear:hover {
    background: #f5f5f7;
    color: #1d1d1f;
}
.lesson-search-results-count {
    font-size: 13px;
    color: #86868b;
    display: none;
}
.lesson-search-widget mark {
    background: #fff59d;
    color: #1d1d1f;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}
@media (max-width: 900px) {
    .lesson-search-widget {
        padding: 12px;
        margin-bottom: 16px;
    }
    .lesson-search-input {
        font-size: 14px;
        padding: 8px 32px 8px 10px;
    }
}

