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

html {
    width: 100%;
    height: 100%;
    margin: 0px;
    padding: 0px;
    background: #f7d155;
    /* Match gradient start to prevent white gaps at top */
}

body {
    width: 100%;
    height: 100%;
    margin: 0px;
    padding: 0px;
    background: white
        /*#e3f7fe*/
    ;
    transition: filter 0.5s;
}

body {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    display: flex;
    flex-direction: column;
    font-size: 100%;
    overflow-x: hidden;
}

/* label     { display: block; white-space: nowrap; } */
/* input     { vertical-align: middle; } */
/* input[type=checkbox] { margin-top: 7px; }
input[type=number]   { width: 3.5em; } */
audio {
    display: none;
    margin-right: 5px;
    vertical-align: middle;
}

#knop {
    position: absolute;
    z-index: 2;
    display: none;
    margin: 5px;
}

#rollijn {
    position: fixed;
    height: 30px;
    width: 200px;
    z-index: 1;
    top: 30%;
}

#pdffile,
#mediafile,
#yubfile {
    display: inline-block;
}

#yubload {
    top: 10%;
}

#countin {
    left: 40%;
    font-size: 10em;
    color: green;
    background: none;
    padding: 0px;
}

.notation canvas {
    display: block;
    margin: 0 auto;
    max-width: none;
}

#menu {
    background-color: #eee;
    display: none;
}

#menu label,
#sync_out label {
    padding: 0.2em;
    padding-left: 0.5em;
}

#menu label input[type=number] {
    margin: 3px;
    width: 4em;
    margin-right: 1em;
}

#menu label span,
#sync_out span {
    display: inline-block;
    width: 8em;
    white-space: normal;
}

#mbar {
    padding: 10px;
    text-align: right;
    background-color: #eee;
}

#sync {
    position: absolute;
    right: 0px;
    top: 0px;
    font-size: inherit;
    visibility: hidden;
    z-index: 50;
    /* Standardized: Controls (Base 50) */
    overflow-y: auto;
    overflow-x: hidden;
}

#sync #sync_out {
    display: none;
    background-color: #0ff;
}

#sync_info {
    text-align: center;
    line-height: 1.5em;
}

#sync-visible {
    display: block;
    border-top-left-radius: 16px;
}

#saveDlg {
    position: absolute;
    top: 5%;
    left: 10%;
    width: 80%;
    height: 80%;
    z-index: 3;
    background: #eee;
    display: none;
    margin: 0px;
    border: medium black ridge;
    box-shadow: 10px 10px 5px #888888;
}

#saveDlg #div1 {
    height: 2%;
}

#saveDlg #div2 {
    height: 90%;
    width: 99%;
    overflow: scroll;
    background: white;
    display: inline-block;
    vertical-align: bottom;
}

#saveDlg #div4 {
    height: 90%;
    width: 1%;
    display: inline-block;
    vertical-align: bottom;
}

#saveDlg #div3 {
    height: 6%;
    overflow: hidden;
}

#saveDlg pre {
    margin: 0px;
    user-select: text;
    -webkit-user-select: text;
}

/*allow select save dialogue text */
#saveDlg button {
    margin-left: 1em;
}

/* Desktop nav user section */
.nav-user-section {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: 15px;
}

.nav-username {
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

/* Unified User Section (Transparent container) */
.nav-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    margin-right: 15px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    font-size: 14px;
}

.pill-link {
    color: #444;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    border: none;
    background: none;
    transition: color 0.2s ease;
}

.pill-link:hover {
    color: #5ba2a8;
}

.pill-link.logout {
    color: #666;
    margin-left: 5px;
    padding-left: 15px;
    border-left: 1px solid #ddd;
}

.pill-link.logout:hover {
    color: #5ba2a8;
    text-decoration: none;
    opacity: 1;
}

/* Admin Group - The "Badge" */
.pill-admin-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #d8eff1;
    /* Light Teal background */
    padding: 4px 12px;
    border-radius: 100px;
}

.admin-label {
    color: #2c5c61;
    /* Darker teal text */
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
    margin-right: 2px;
}

.nav-user-pill .admin-link {
    color: #2c5c61;
    text-decoration: none;
    font-weight: 600;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: color 0.2s;
}

.nav-user-pill .admin-link:hover {
    color: #5ba2a8;
    text-decoration: underline;
}

.nav-link {
    color: #333;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    margin-right: 12px;
}

.nav-link:hover {
    color: #5ba2a8;
}

/* User Dropdown Menu */
.nav-user-dropdown {
    position: relative;
}

.nav-user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    background: rgba(91, 162, 168, 0.15);
    border: 1px solid rgba(91, 162, 168, 0.3);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.nav-user-trigger:hover {
    background: rgba(91, 162, 168, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5ba2a8, #376a73);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.nav-user-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.nav-user-chevron {
    color: #666;
    transition: transform 0.2s ease;
}

.nav-dropdown-menu.open+.nav-user-trigger .nav-user-chevron,
.nav-user-trigger:focus .nav-user-chevron {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: fixed;
    min-width: 200px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 9999;
    overflow: hidden;
}

.nav-dropdown-menu.open {
    opacity: 1;
    visibility: visible;
}

.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    transition: background 0.15s ease;
}

.nav-dropdown-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    color: #333;
    font-size: 15px;
}

.nav-dropdown-menu a:hover {
    background: #f5f5f5;
    color: #333 !important;
}

.nav-dropdown-menu a svg {
    color: #666;
    flex-shrink: 0;
}

.nav-dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

.nav-dropdown-label {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
}

.nav-dropdown-logout {
    color: #666 !important;
}

.nav-dropdown-logout:hover {
    background: #fff5f5 !important;
    color: #c00 !important;
}

/* Modal backdrop overlay */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-backdrop.visible {
    display: block;
}

/* Help and About Modals - styled like history modal */
#help,
#about {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 420px;
    max-height: 85vh;
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    /* Modals always highest (1000+) */
    overflow: hidden;
}



#help.showhlp,
#about.showabout {
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #333;
}

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

.modal-close:hover {
    background: #e5e5e5;
    color: #333;
}

.modal-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-size: 15px;
    line-height: 1.6;
    color: #444;
}

.modal-content p {
    margin: 0 0 12px 0;
}

.modal-content ul {
    margin: 12px 0;
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 8px;
}

.help-note {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.helptbl {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.helptbl td {
    padding: 8px 4px;
    border-bottom: 1px solid #f0f0f0;
}

.helptbl tr:last-child td {
    border-bottom: none;
}

.helptbl td:first-child {
    font-weight: 500;
    color: #333;
}

.helptbl td:last-child {
    color: #666;
}

#helpm {
    text-align: center;
    padding: 3px;
}

#aboutm {
    text-align: center;
    padding: 3px;
}

#noklik {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgb(0, 0, 0, 0.3);
    z-index: 1;
    display: none;
}

.dlog {
    display: none;
    position: absolute;
    left: 30%;
    top: 30%;
    background: #a7f0ff;
    padding: 2em;
    z-index: 2;
    box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;
}

.helptbl {
    border: thin black solid;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    margin-left: 3%;
    width: 97%;
    table-layout: fixed;
    border-collapse: collapse;
}

.helptbl td {
    padding: 0.2em;
    vertical-align: top;
}

.helptbl tr:nth-child(even) {
    background-color: #eee;
}

.helptbl td:nth-child(3) {
    border-left: thin black solid
}

.noheight {
    display: none !important;
}

.preimp {
    color: red;
}

.dashed {
    border-bottom: thin dashed black;
}

.annmov {
    border: black dashed 1px;
}

.demaat,
.maten {
    pointer-events: none;
    position: absolute;
}

@media (hover: hover) {
    #mbar:hover {
        background: #aaa;
        cursor: pointer;
    }

    #drplbl:hover,
    #yublbl:hover {
        background: #aaa;
    }

    #err:hover {
        height: 50%;
        width: 100%;
        position: absolute;
        top: 50%;
    }

    #rollijn:hover,
    .rolgroen {
        cursor: row-resize;
        background: rgba(0, 255, 0, 0.3);
    }

    #menu label:hover,
    #sync_out label:hover {
        background: #aaa;
        cursor: pointer;
    }
}

a {
    text-decoration: none;
}

#notation a:link {
    color: #003954;
}

#notation a:hover {
    background-color: #ffc30042;
}

#notation a:visited {
    color: #003954;
}

#notation a:active {
    color: #003954;
}

#notation-scroll {
    position: relative;
    flex: 1;
    overflow: auto;
}

/* Two-up: pages touch each other; no row/column gap; size columns to the canvases */
#notation-scroll.two-up {
    display: grid;
    grid-template-columns: max-content max-content;
    /* columns shrink/grow with canvas width */
    column-gap: 0;
    row-gap: 0;
    justify-content: center;
    /* center the spread as a unit */
    align-content: start;
    --page-gap: 0px;
    /* keep layout and positioning math in sync */
}

/* Override centering/margins that cause drifting */
#notation-scroll.two-up canvas {
    justify-self: unset;
    margin: 0;
    /* kill the "auto" margins from .notation canvas */
}

#control-button-row .two-up-toggle.active {
    outline: 1px solid currentColor;
}

#control-button-row .two-up-toggle svg {
    width: 20px;
    height: 20px;
}

#header {
    height: 200px;
    display: flex;
    position: relative;
    justify-content: center;
    overflow-x: hidden;
    padding-top: env(safe-area-inset-top);
    /* Extend gradient into notch/status bar area */
    background: linear-gradient(145deg,
            #f7d155 0%,
            #e4c262 30%,
            #5ba2a8 70%,
            #376a73 100%);
}

#logo-bar-wrapper {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    max-width: 1400px;
    padding: 1em;
}

#header-content-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#logo-bar {
    max-height: 50px;
    display: flex;
    align-items: center;
}

#monkey-logo {
    width: 50px;
    filter: invert(0%);
    transition: filter 0.5s ease;
    margin-right: 10px;
}

#monkeywrench-logo-text {
    color: #1b4b5e;
    font-size: 1em;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

#monkeywrench-logo-text a {
    color: #1b4b5e;
    display: flex;
    flex-direction: column;
    align-items: end;
}

#monkeywrench-logo-text h2 {
    font-size: 1.8em;
    font-family: 'PixelOperator';
    font-weight: 400;
    margin: 0;
}

#logotext-line2 {
    font-family: 'PixelOperator';
    font-size: 1em;
    font-weight: 700;
    margin: 0;
}

#monkeywrench-logo-text,
.nav-menu>a:link,
#monkeywrench-logo-text,
.nav-menu>a:visited,
#monkeywrench-logo-text,
.nav-menu>a:hover,
#monkeywrench-logo-text,
.nav-menu>a:active {
    text-decoration: none !important;
}

.nav-menu a {
    color: #555;
    padding: 10px;
    font-size: 15px;
}

.nav-menu a:hover {
    color: #333;
}

.nav-menu {
    display: flex;
    flex-direction: row;
    align-items: center;
}



#vid,
#vidyub {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    align-self: end;
    width: 350px;
    height: 200px;
    z-index: 50;
    /* Standardized: Player (below Sidebar 100/Menu 200) */
}

section1 {
    margin-bottom: -100px;
}

section2 {
    width: 100%;
    min-width: 0;
    height: 100%;
    display: flex;
    overflow-x: hidden;
    overflow-y: hidden;
    margin-top: 10px;
    margin-left: 16px;
}

#loadingMessage2 {
    position: fixed;
    margin-left: 10px;
    z-index: 100;
}

.dot {
    opacity: 0;
    animation: blink 1.4s infinite both;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {

    0%,
    80%,
    100% {
        opacity: 0;
    }

    40% {
        opacity: 1;
    }
}

sidecontentbar {
    display: block;
    margin-top: 100px;
    padding: 1.25em;
    background: rgba(248, 250, 252, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 320px;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.05);
}

body:not(.recording-loaded) sidecontentbar {
    display: none;
}

sidecontentbar h3 {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin: 0 0 0.5em 0;
    font-weight: 600;
}

#composer-piece-name {
    margin-bottom: 1em;
}

#composer-piece-name h3 {
    font-size: 1em;
    text-transform: none;
    letter-spacing: normal;
    color: #1e293b;
    font-weight: 700;
    line-height: 1.3;
}

#sidecontent select {
    width: 100%;
    height: 44px;
    padding: 0 2.5rem 0 0.75rem;
    font-size: 0.875em;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#sidecontent select:hover {
    border-color: rgba(0, 0, 0, 0.2);
}

#sidecontent select:focus {
    border-color: #5ba2a8;
    box-shadow: 0 0 0 3px rgba(91, 162, 168, 0.15);
}

#change-part-wrapper,
.change-recording-wrapper {
    margin-bottom: 1.25em;
}

.homepage-sidecontent-copy {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    color: #1e293b;
}

.homepage-sidecontent-title {
    margin: 0;
    font-size: 1em;
    color: #1e293b;
    font-weight: 700;
    line-height: 1.3;
}

.homepage-sidecontent-list {
    margin: 0;
    padding-left: 1.1rem;
}

.homepage-sidecontent-list li {
    margin-bottom: 0.6rem;
    line-height: 1.4;
}

.homepage-sidecontent-list li:last-child {
    margin-bottom: 0;
}

.homepage-sidecontent-list li::marker {
    color: #5ba2a8;
}

.homepage-sidecontent-secondary {
    padding-top: 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.homepage-sidecontent-list-secondary {
    color: #475569;
}

.homepage-sidecontent-example {
    margin-top: 0.45rem;
    font-size: 0.88em;
}

.homepage-sidecontent-example-prefix {
    color: inherit;
}

.homepage-sidecontent-copy a:link,
.homepage-sidecontent-copy a:visited,
.homepage-sidecontent-copy a:active {
    color: #0645ad;
    text-decoration: none;
}

.homepage-sidecontent-copy a:hover {
    color: #0b0080;
    text-decoration: underline;
    background: none;
}

body:not(.recording-loaded) #composer-toggle-wrapper,
body:not(.recording-loaded) #first-controls,
body:not(.recording-loaded) .change-recording-wrapper,
body:not(.recording-loaded) #annotations-section {
    display: none;
}

body.recording-loaded .homepage-sidecontent-copy {
    display: none;
}

#sidecontent-toggle {
    display: none;
    /* hide if not tablet/mobile */
}

#speed-part-row {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

#speed-control {
    display: flex;
    align-items: center;
    flex-direction: column;
}

#speed-content {
    display: flex;
    align-items: center;
}

#highlight-control {
    display: flex;
    align-items: center;
}

invertButton {
    margin-top: 16px;
}

#control-buttons-row {
    display: flex;
    flex-direction: row;
    position: sticky;
    bottom: 0;
    left: 20px;
    z-index: 5;
}

#annotation-toolbar {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
}

.control-buttons {
    cursor: pointer;

}

#settings-button {
    cursor: pointer;
}

#decrementButton,
#incrementButton {
    background: rgba(255, 255, 255, 0.9);
    height: 44px;
    width: 44px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    color: #475569;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#incrementButton:hover,
#decrementButton:hover {
    background: #f1f5f9;
    border-color: rgba(0, 0, 0, 0.15);
}

#speedField {
    width: 60px;
    height: 44px;
    margin-left: 8px;
    padding: 0 0.5em;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 0.875em;
    font-weight: 600;
    color: #334155;
    box-sizing: border-box;
    line-height: normal;
}

#favcolor {
    background: #f8f8f8;
    border: none;
    height: 25px;
    box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 3px, rgba(0, 0, 0, 0.24) 0px 1px 2px;
    cursor: pointer;

}

#reset-button {
    background: inherit;
    padding-top: 2px;
    border: none;
    height: 25px;
    cursor: pointer;
}

#pieces-search-wrap {
    margin: .5rem 0 1rem;
}

#pieces-search {
    width: 100%;
    max-width: 600px;
    padding: .5rem .6rem;
    border: 1px solid #ccc;
    border-radius: .5rem;
}

#pieces-search-empty {
    display: none;
    font-style: italic;
    color: #888;
}

select {
    /* Reset */
    appearance: none;
    border: 0;
    outline: 0;
    font: inherit;
    /* Personalize */
    padding: 1rem 4rem 1rem 1rem;
    background: url(../img/Caret_down_font_awesome.svg) no-repeat right 0.8em center / 1.4em,
        linear-gradient(to left, #ddd 3em, #f8f8f8 3em);
    color: black;
    border-radius: 0.25em;
    box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 3px, rgba(0, 0, 0, 0.24) 0px 1px 2px;
    cursor: pointer;

    /* Remove IE arrow */
    &::-ms-expand {
        display: none;
    }

    /* Remove focus outline */
    &:focus {
        outline: none;
    }

    /* <option> colors */
    option {
        color: inherit;
        background-color: white;
    }
}

.instrument-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.instrument-group:nth-child(2) {
    break-inside: avoid;
    break-after: column;
    /* Set a column break after group 2 */
}

/* Tablet LANDSCAPE: Hide sidebar on homepage until recording loads */
@media screen and (min-width: 600px) and (max-width: 1024px) and (orientation: landscape) {
    /* Let content use full width when no sidebar */
    section2 {
        margin-left: 0;
    }
}

/* Any PORTRAIT device: Use bottom sheet layout */
@media screen and (orientation: portrait) {
    section2 {
        flex-direction: column;
        margin-top: 0px;
        margin-left: 0;
    }

    .section2-margin-top {
        margin-top: 100px;
    }

    .mobile-only {
        display: block !important;
    }

    sidecontentbar {
        position: fixed;
        bottom: -100%;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        box-sizing: border-box;
        height: auto;
        max-height: 92vh;
        max-width: none;
        margin: 0;
        z-index: 300;
        transition: bottom 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
        padding: 24px 20px max(20px, env(safe-area-inset-bottom)) 20px;
        border-radius: 24px 24px 0 0;
        background: rgba(250, 250, 253, 0.98);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
        border-top: 1px solid rgba(255, 255, 255, 0.5);
        display: block;
        overflow-y: auto;
    }

    sidecontentbar.active {
        bottom: 0;
    }
}

@media screen and (orientation:portrait) {
    /* Additional mobile-specific styles (sidecontentbar handled in 1024px portrait breakpoint) */

    .sidecontenbar-min-height {
        min-height: 25vh;
    }

    #sidecontent h3 {
        margin-bottom: 0;
    }

    #composer-toggle-wrapper {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center;
        padding-top: 20px;
        margin-bottom: 20px;
        flex-wrap: nowrap !important;
        /* Prevent wrapping */
    }

    /* Ensure the X button doesn't get crushed or wrapped */
    #composer-toggle-wrapper button {
        flex-shrink: 0;
        margin-left: 10px;
        white-space: nowrap;
    }

    #composer-piece-name {
        margin-bottom: 0;
        flex: 1;
        /* Take available space */
        min-width: 0;
        /* Allow text truncation */
        padding-right: 10px;
    }

    #composer-piece-name h3 {
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }





    /* Smaller player on mobile */
    #vid,
    #vidyub {
        width: 300px;
        height: 200px;
    }

    #sidecontent-toggle h3 {
        text-decoration: underline;
    }

    /* Layout adjustments for standardized controls on mobile */
    sidecontentbar select {
        padding: 0 40px 0 12px;
        /* Accommodate custom arrow */
    }

    #speed-content {
        gap: 12px;
    }

    #speedField {
        width: 64px;
        margin-left: 0;
    }

    /* Center modals on mobile/tablet like help/about */
    .history-modal,
    .favorites-modal,
    .annotations-modal {
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 380px;
        max-height: 80vh;
        border-radius: 12px;
        z-index: 1001;
    }

}

/* Tablet centering for modals (768px - 1024px) */
@media screen and (min-width: 768px) and (max-width: 1024px) {

    .history-modal,
    .favorites-modal,
    .annotations-modal {
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 420px;
        max-height: 80vh;
    }
}

/* Modern Loading Spinner */
#yubload {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0;
    /* Hide text */
    color: transparent;
    z-index: 1002;
    /* Above modals if needed */
    /* Override .dlog styles */
    background: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    width: 0;
    height: 0;
}


#yubload::after {
    content: "\1F527";
    /* Wrench Emoji 🔧 */
    display: block;
    width: 60px;
    height: 60px;
    /* Force Emoji Font and Grey Color */
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    color: #555;
    font-size: 50px;
    line-height: 60px;
    text-align: center;
    background: none;
    border: none;
    border-radius: 0;
    animation: spin 1.5s linear infinite;
    /* Ensure placement */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: spinCentered 1.5s linear infinite;
}

@keyframes spinCentered {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Legacy spin (keep if used elsewhere) */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media screen and (max-width: 767px) {

    /* Hide desktop nav links on mobile / phone only */
    .nav-menu>a,
    .nav-menu>div:not(#mobile-header-menu),
    .nav-user-pill {
        display: none !important;
    }

    /* Show Mobile Hamburger */
    #mobile-header-burger {
        display: flex !important;
    }

    .instrument-container {
        display: block;
        /*normal grid creates x-scrolling.*/
    }
}

@media screen and (max-width: 767px) and (orientation:portrait) {
    #header {
        flex-direction: column;
        justify-content: start;
        height: 275px;
        margin: 0;
        padding: 0;
    }

    #vidyub {
        position: relative;
        height: 200px;
        align-self: center;
        margin-top: 4px;
    }

    #logo-bar-wrapper {
        position: absolute;
        flex-direction: row;
        padding: 5px 50px 5px 5px;
    }

    body:not(.recording-loaded):not(.initial-recording-target) section1 {
        margin-bottom: 0;
    }

    body:not(.recording-loaded):not(.initial-recording-target) #header {
        height: auto;
        min-height: 60px;
    }

    body:not(.recording-loaded):not(.initial-recording-target) #logo-bar-wrapper {
        position: relative;
    }

    body:not(.recording-loaded):not(.initial-recording-target) section2 {
        margin-top: 0;
    }

    #monkey-logo {
        width: 36px;
    }

    .section2-margin-top {
        margin-top: 30px;
    }

    #sidecontent {
        display: flex;
        flex-direction: row;
        margin-top: -24px;
    }

    #invertButton {
        display: none;
    }

    #control-buttons-row {
        width: 100%;
        padding: 4px 0;
        left: 0;
        background-color: #f8f8f8;
        border-top: solid 1px #cecece;
    }

    #annotation-toolbar {
        position: fixed;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%);
        padding: 6px 10px !important;
        gap: 4px !important;
    }

    #annotation-toolbar button {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
    }

    #annotation-toolbar svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* Hide less essential items on very small mobile screens */
    #annotation-set-picker,
    #annotation-toolbar [title="Create New Notes"],
    #annotation-toolbar [title="Manage Notes"] {
        display: none !important;
    }

    .control-buttons {
        background-color: inherit;
        border: none;
    }

    #play-pause-button {
        margin-left: auto;
    }

    #settings-button {
        margin-left: auto;
    }
}

/*mobile lanscape*/
@media screen and (max-height: 500px) and (orientation:landscape) {
    section1 {
        margin-bottom: -150px;
        /* Keep sidebar logic as-is to preserve layout structure */
    }

    #logo-bar-wrapper {
        padding: 5px;
    }

    /* Hamburger starts at normal right position */
    #mobile-header-burger {
        display: flex !important;
        position: fixed;
        left: auto;
        right: 12px;
        /* Normal right position */
        top: 8px;
        z-index: 200;
        /* Standardized: Nav (above sidebar 100, below modal 1000) */
        transition: right 0.3s ease;
    }

    /* When recording is loaded, move hamburger left of player sidebar (200px + gap) */
    body.recording-loaded #mobile-header-burger {
        right: 210px;
    }

    /* Position mobile menu dropdown below the burger */
    #mobile-header-menu {
        top: 56px !important;
        right: 12px !important;
        left: auto !important;
    }

    /* Also move the menu dropdown when recording is loaded */
    body.recording-loaded #mobile-header-menu {
        right: 210px !important;
    }

    /* Hide desktop nav */
    .nav-menu>a,
    .nav-menu>div:not(#mobile-header-menu),
    .nav-user-pill {
        display: none !important;
    }

    #vidyub {
        max-width: 200px;
        height: 200px;
    }

    section2 {
        margin-left: 0;
    }

    sidecontentbar {
        display: none;
        /* Hidden until recording loads */
    }

    body.recording-loaded sidecontentbar {
        display: block;
        position: relative;
        /* Revert to flow */
        width: 200px;
        flex-shrink: 0;
        /* Prevent shrinking */
        padding-top: 50px;
        /* Push content down below player overlap */
        padding-right: 4px;
        padding-bottom: 4px;
        padding-left: 4px;
        box-sizing: border-box;
        /* Include padding in width */
        overflow-y: scroll;
        z-index: 49;
        /* User defined: Below Player (50) */
        height: 100vh;
        /* Ensure full height */
    }

    /* Wrap styles for notation to prevent overlap */
    #notation {
        flex: 1;
        /* Take remaining space */
        min-width: 0;
        /* Allow shrinking below content size */
        width: auto !important;
        margin-right: 0 !important;
        /* Remove margin as flex handles it */
    }

    /* Show Title in Landscape */




    #composer-piece-name {
        display: block;
        margin-bottom: 4px;
        text-align: center;
    }

    #composer-piece-name h3 {
        font-size: 11px;
        margin: 0;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 184px;
    }

    /* Ultra Compact Controls */
    #sidecontent h3 {
        margin-bottom: 0;
        font-size: 10px;
    }

    #sidecontent-toggle {
        display: none !important;
    }

    /* Compact dropdowns */
    /* Compact dropdowns - Hyper specific selector override */
    body sidecontentbar #sidecontent select,
    #instruments-dropdown,
    #recordings-dropdown {
        width: 100%;
        max-width: 100%;
        font-size: 11px;
        padding: 0 4px;
        height: 32px !important;
        margin-bottom: 2px;
    }

    /* REORDERING LOGIC */
    #speed-part-row {
        display: flex;
        flex-direction: column;
    }

    /* Speed Control First */
    #speed-control {
        order: 1;
        margin: 2px 0;
    }

    /* Change Part Second */
    #change-part-wrapper {
        order: 2;
        margin: 2px 0;
    }

    /* Speed Controls */

    #speed-content {
        gap: 4px;
        justify-content: center;
    }

    #speed-content button {
        padding: 0 6px;
        font-size: 11px;
        height: 32px;
        line-height: 32px;
    }

    #speedField {
        width: 40px;
        font-size: 11px;
        padding: 0 4px;
        height: 32px;
        line-height: 32px;
    }

    /* Reduce margins */
    .change-recording-wrapper {
        margin: 2px 0;
    }

    /* Hide the mobile-only elements */
    sidecontentbar .mobile-only,
    #share-btn-mobile {
        display: none !important;
    }

    #monkey-logo {
        width: 36px;
    }

    #logo-bar {
        max-height: 36px;
    }
}

#notation {
    display: flex;
    flex-direction: column;
}

.notation {
    min-width: 0;
    width: auto;
    margin: 5px;
    flex: 1 1 0;
    position: relative;
    overflow: auto;
    white-space: nowrap;
    background: #f8f8f8;
    box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset;
}

.fullscreen {
    max-width: 100%;
    margin: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

#sidecontent {
    display: block;
}

body.initial-recording-target:not(.recording-loaded) #sidecontent {
    display: none;
}

.tabs {
    position: sticky;
    top: -1px;
    padding: 20px 8px 8px 8px;
    background-color: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
}

.tab-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 0;
    padding: 0;
    list-style: none;
    position: relative;
}

/* Connecting line between steps */
.tab-header-row::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 15%;
    right: 15%;
    height: 2px;
    background: #e0e0e0;
    z-index: 0;
}

.tab-header {
    width: 33%;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    position: relative;
    z-index: 1;
    transition: none;
}

.tab-header:hover {
    background: transparent;
}

.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stepper-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e0e0;
    border: 3px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: #999;
    position: relative;
    transition: all 0.3s ease;
}

.stepper-number {
    display: block;
}

.stepper-check {
    display: none;
    font-size: 20px;
}

.tab-header h2 {
    font-family: 'IBM Plex Sans', sans-serif;
    margin: 0;
    color: #999;
    font-size: 1em;
    text-align: center;
    letter-spacing: 0;
    transition: color 0.3s ease;
}

/* Active state */
.tab-header.active .stepper-circle {
    background: #5ba2a8;
    border-color: #5ba2a8;
    color: white;
    box-shadow: 0 0 0 4px rgba(91, 162, 168, 0.2);
}

.tab-header.active h2 {
    color: #222;
    font-weight: 600;
}

/* Completed state (not disabled and not active) */
.tab-header:not(.disabled):not(.active) .stepper-circle {
    background: #5ba2a8;
    border-color: #5ba2a8;
    color: white;
}

.tab-header:not(.disabled):not(.active) .stepper-number {
    display: none;
}

.tab-header:not(.disabled):not(.active) .stepper-check {
    display: block;
    color: white;
}

.tab-header:not(.disabled):not(.active) h2 {
    color: #5ba2a8;
}

/* Disabled state */
.tab-header.disabled {
    pointer-events: none;
    cursor: default;
}

.tab-header.disabled .stepper-circle {
    background: #f8f8f8;
    border-color: #bbb;
    color: #bbb;
}

.tab-header.disabled h2 {
    color: #888;
}

.tab-header.disabled h2 {
    opacity: 0.5;
}

.tab-content {
    color: #444;
    margin-bottom: 4px;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.tab-header:hover {
    background-color: #f1f1f1;
}

.search-content {
    line-height: 1.5em;
    overflow-x: auto;
    white-space: nowrap;
    padding: 8px;
}

.search-content h2 {
    white-space: normal;
    /* piece title should wrap*/
}

.search-content p {
    margin: 0 0.25em;
}

.starter-browser {
    display: grid;
    grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    background: #ffffff;
    border-top: 1px solid #d8dde3;
    overflow: hidden;
}

.starter-browser .search-content {
    overflow-x: hidden;
    padding: 0;
    white-space: normal;
}

.starter-sidebar {
    background: #eef1f4;
    border-right: 1px solid #d8dde3;
    box-sizing: border-box;
    color: #24313f;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    padding: 16px 12px 22px;
}

.starter-sidebar h2,
.starter-main-header h2,
.starter-main-empty h2 {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 12px;
}

.starter-sidebar .instrument-container {
    display: block;
}

.starter-sidebar .instrument-group {
    margin: 0 0 18px;
}

.starter-sidebar .instrument-group h3 {
    color: #66717d;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0;
    margin: 14px 8px 6px;
    text-transform: uppercase;
}

.starter-sidebar .instrument-link {
    align-items: center;
    border-radius: 6px;
    color: #27323f;
    display: flex;
    font-size: 0.94rem;
    gap: 4px;
    justify-content: space-between;
    line-height: 1.2;
    margin: 1px 0;
    padding: 6px 8px;
}

#notation .starter-sidebar .instrument-link:hover,
#notation .starter-sidebar .instrument-link.selected {
    background: #dbe9ea;
}

#notation .starter-sidebar .instrument-link-a:hover {
    background: transparent;
}

.starter-sidebar .instrument-link-a {
    color: inherit;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-decoration: none;
    text-overflow: ellipsis;
}

.starter-sidebar .sheet-music-icon {
    color: #60717c;
    flex: 0 0 auto;
}

.instrument-mobile-layout {
    display: none;
}

.starter-sidebar-scroll-cue {
    display: none;
}

.starter-main {
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px 24px 34px;
}

.starter-main-empty {
    align-items: center;
    color: #5e6872;
    display: flex;
    justify-content: center;
    min-height: 100%;
    padding: 24px;
    box-sizing: border-box;
    text-align: left;
}

.starter-main-empty p {
    margin: 0;
    white-space: normal;
}

.starter-empty-copy {
    color: #1e293b;
    max-width: 420px;
    min-width: 0;
    white-space: normal;
}

.starter-empty-copy>p {
    color: #475569;
    line-height: 1.4;
    margin-bottom: 18px;
    overflow-wrap: anywhere;
}

.starter-empty-copy .homepage-sidecontent-list {
    font-size: 0.96rem;
}

.starter-empty-copy .homepage-sidecontent-example,
.starter-empty-copy .homepage-sidecontent-example a {
    overflow-wrap: anywhere;
}

.starter-empty-copy a:link,
.starter-empty-copy a:visited,
.starter-empty-copy a:active {
    color: #0645ad;
    text-decoration: none;
}

.starter-empty-copy a:hover {
    color: #0b0080;
    text-decoration: underline;
    background: none;
}

.starter-main-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.starter-main-header h2 {
    margin-bottom: 0;
}

.starter-main #pieces-search-wrap {
    margin: 0 0 14px;
}

.starter-main #pieces-search {
    background: #f7f8fa;
    border: 1px solid #cfd6dd;
    border-radius: 6px;
    box-shadow: none;
    max-width: 520px;
}

.starter-main #pieces-container>h3 {
    border-bottom: 1px solid #dfe4e8;
    color: #65717d;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    margin: 20px 0 0;
    padding: 0 0 6px;
    text-transform: uppercase;
}

.piece-row {
    border-bottom: 1px solid #edf0f2;
    margin: 0;
}

.pieces-link {
    align-items: center;
    color: #1f2933;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1fr) auto;
    line-height: 1.25;
    padding: 9px 10px;
    text-decoration: none;
}

#notation .pieces-link:hover {
    background: #eef8f8;
}

#notation .piece-row.expanded>.pieces-link {
    background: #ffc30042;
}

.piece-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.piece-count {
    color: #62707d;
    font-size: 0.8rem;
    white-space: nowrap;
}

.piece-expanded-panel {
    background: #f8fafb;
    border-bottom: 1px solid #dfe6ea;
    padding: 14px 16px 16px 28px;
}

.piece-expanded-panel h3 {
    color: #46525f;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.piece-part-picker {
    margin-bottom: 12px;
}

.piece-part-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.piece-part-button {
    background: #ffffff;
    border: 1px solid #cbd5dd;
    border-radius: 6px;
    color: #26313d;
    cursor: pointer;
    font: inherit;
    min-height: 34px;
    padding: 6px 10px;
}

.piece-part-button:hover,
.piece-part-button.selected {
    background: #dbe9ea;
    border-color: #86adb2;
}

.piece-recordings-list p {
    margin: 0;
}

.piece-recordings-list .recordings-link,
#recordings-container .recordings-link {
    color: #1f2933;
    display: block;
    padding: 7px 8px;
    text-decoration: none;
}

#notation .piece-recordings-list .recordings-link:hover,
#notation #recordings-container .recordings-link:hover {
    background: #eef8f8;
}

.starter-loading,
.starter-muted {
    color: #65717d;
    font-style: italic;
}

@media screen and (max-width: 767px) {
    .starter-browser {
        display: block;
        height: auto;
        min-height: auto;
        overflow: visible;
    }

    .starter-sidebar {
        border-bottom: 1px solid #d8dde3;
        border-right: 0;
        max-height: 34vh;
        position: relative;
        padding: 12px 10px;
    }

    .starter-sidebar::after {
        content: "";
        position: sticky;
        bottom: -12px;
        display: block;
        height: 38px;
        margin: -38px -10px 0;
        pointer-events: none;
        background: linear-gradient(to bottom, rgba(238, 241, 244, 0), #eef1f4 70%);
    }

    .starter-sidebar-scroll-cue {
        position: sticky;
        bottom: -4px;
        display: block;
        margin: -22px auto 0;
        color: #65717d;
        font-size: 0.74rem;
        font-weight: 600;
        line-height: 18px;
        pointer-events: none;
        text-align: center;
        z-index: 1;
    }

    .starter-sidebar .instrument-container {
        display: block;
    }

    .starter-sidebar .instrument-container>.instrument-group {
        display: none;
    }

    .instrument-mobile-layout {
        align-items: start;
        display: grid;
        gap: 14px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .instrument-mobile-column {
        min-width: 0;
    }

    .starter-sidebar .instrument-group {
        break-after: auto;
        margin-bottom: 10px;
        min-width: 0;
    }

    .starter-sidebar .instrument-group h3 {
        margin: 10px 6px 4px;
    }

    .starter-sidebar .instrument-link {
        font-size: 0.9rem;
        line-height: 1.15;
        padding: 5px 6px;
    }

    .starter-main {
        padding: 16px 12px 28px;
    }

    .pieces-link {
        align-items: start;
        gap: 3px;
        grid-template-columns: 1fr;
        padding: 11px 8px;
    }

    .piece-title {
        overflow: visible;
        text-overflow: clip;
    }

    .piece-count {
        white-space: normal;
    }

    .piece-expanded-panel {
        padding: 12px 8px 14px;
    }

    .piece-part-button {
        flex: 1 1 130px;
    }
}



html.inverted {
    filter: invert(100%);
    transition: filter 0.5s ease;
}

html.inverted #vidyub,
html.inverted #monkey-logo,
html.inverted #notation-scroll canvas {
    filter: invert(100%) !important;
}

/* Ensure fullscreen containers are inverted so children can 'un-invert' back to light colors */
html.inverted #notation:fullscreen,
html.inverted #vidyub:fullscreen,
html.inverted #notation:-webkit-full-screen,
html.inverted #vidyub:-webkit-full-screen {
    filter: invert(100%) !important;
}

html.inverted #vidyub:fullscreen {
    filter: invert(100%) !important;
}

html.inverted #vidyub:-webkit-full-screen {
    filter: invert(100%) !important;
}

html.inverted select option {
    background-color: #222 !important;
    color: #eee !important;
}

/* Un-invert color swatches in dark mode so they show true colors */
html.inverted .color-swatch {
    filter: invert(100%);
}

#instruments-dropdown {
    width: 200px;
}

#recordings-dropdown {
    max-width: 300px;
}

/* ========== History Modal Styles ========== */
.history-modal {
    display: none;
    position: fixed;
    top: 70px;
    right: 30px;
    width: 320px;
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    /* Standardized: Modals */
    overflow: hidden;
    transition: left 0.3s ease, right 0.3s ease;
}

.history-modal.visible {
    display: block !important;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #eee;
}

.history-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.history-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.history-close:hover {
    background: #f5f5f5;
    color: #666;
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
}

.history-list li {
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: background 0.2s;
}

.history-list li:hover {
    background: #fafafa;
}

.history-list li:last-child {
    border-bottom: none;
}

.history-entry-content {
    flex: 1;
    cursor: pointer;
    text-decoration: none;
    color: #333;
}

.history-composer {
    font-weight: 600;
    font-size: 14px;
    color: #222;
    margin: 0 0 2px 0;
}

.history-piece {
    font-size: 13px;
    color: #555;
    margin: 0 0 2px 0;
    line-height: 1.3;
}

.history-timestamp {
    font-size: 11px;
    color: #999;
    font-weight: 300;
}

.history-delete {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    margin-left: 8px;
    flex-shrink: 0;
}

.history-delete:hover {
    background: #f0f0f0;
    color: #444;
}

.history-clear-btn {
    width: 100%;
    padding: 12px;
    background: #f8f8f8;
    border: none;
    border-top: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    transition: background 0.2s, color 0.2s;
}

.history-clear-btn:hover {
    background: #eee;
    color: #333;
}

/* ========== Favorites Modal Styles ========== */
.favorites-modal {
    display: none;
    position: fixed;
    top: 70px;
    right: 30px;
    width: 320px;
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    overflow: hidden;
    transition: left 0.3s ease, right 0.3s ease;
}

.favorites-modal.visible {
    display: block !important;
}

.favorites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #eee;
}

.favorites-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.favorites-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.favorites-close:hover {
    background: #f5f5f5;
    color: #666;
}

.favorites-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
}

.favorites-list li {
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: background 0.2s;
}

.favorites-list li:hover {
    background: #fafafa;
}

.favorites-list li:last-child {
    border-bottom: none;
}

.favorites-entry-content {
    flex: 1;
    cursor: pointer;
    text-decoration: none;
    color: #333;
}

.favorites-composer {
    font-weight: 600;
    font-size: 14px;
    color: #222;
    margin: 0 0 2px 0;
}

.favorites-piece {
    font-size: 13px;
    color: #555;
    margin: 0 0 2px 0;
    line-height: 1.3;
}

.favorites-date {
    font-size: 11px;
    color: #999;
    font-weight: 300;
}

.favorites-delete {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    margin-left: 8px;
    flex-shrink: 0;
}

.favorites-delete:hover {
    background: #f0f0f0;
    color: #444;
}

/* Favorite star button states */
#favorite-btn.favorited svg {
    fill: #f4c542;
    stroke: #f4c542;
}

/* ========== Annotations Manager Modal ========== */
.annotations-modal {
    display: none;
    position: fixed;
    top: 70px;
    right: 30px;
    width: 320px;
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    overflow: hidden;
}

.annotations-modal.visible {
    display: block !important;
}

.annotations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #eee;
}

.annotations-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.annotations-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.annotations-close:hover {
    background: #f5f5f5;
    color: #666;
}

.annotations-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
}

.annotations-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.15s;
}

.annotations-list li:hover {
    background: #f9f9f9;
}

/* Active state removed - rely on hover only */

.annotation-item-info {
    flex: 1;
    min-width: 0;
}

.annotation-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.annotation-item-date {
    font-size: 11px;
    color: #999;
}

.annotation-composer {
    font-weight: 600;
    font-size: 14px;
    color: #222;
    margin: 0 0 2px 0;
}

.annotation-piece {
    font-size: 13px;
    color: #555;
    margin: 0 0 2px 0;
    line-height: 1.3;
}

.annotation-instrument {
    font-size: 12px;
    color: #888;
    font-style: italic;
    margin: 0 0 4px 0;
}

.annotation-item-actions {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.annotation-item-actions button {
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.annotation-item-actions button:hover {
    background: #f0f0f0;
    color: #666;
}

.annotations-new-btn {
    width: 100%;
    padding: 14px;
    background: #4a90d9;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: white;
    transition: background 0.2s;
}

.annotations-new-btn:hover {
    background: #3a7bc8;
}

.annotations-empty {
    padding: 32px 16px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* Mobile hamburger button */
#mobile-header-burger {
    display: none;
    position: fixed;
    right: 12px;
    top: 12px;
    z-index: 200;
    /* Standardized: Nav */
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

#mobile-header-burger svg {
    width: 24px;
    height: 24px;
    padding: 8px;
    color: #333;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Mobile header menu dropdown */
#mobile-header-menu {
    display: none;
    position: fixed;
    top: 64px;
    right: 12px;
    width: 200px;
    padding: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    z-index: 201;
    /* Standardized: Nav Dropdown */
    flex-direction: column;
}

#mobile-header-menu a {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    transition: background 0.15s;
}

#mobile-header-menu a:hover,
#mobile-header-menu a:active {
    background: #f5f5f5;
}

.mobile-menu-greeting {
    padding: 12px 16px;
    font-weight: 600;
    color: #666;
    font-size: 15px;
    border-bottom: 1px solid #eee;
    margin-bottom: 4px;
}

.mobile-menu-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

.mobile-menu-logout {
    color: #999 !important;
}

.mobile-menu-login {
    background: white !important;
    color: #444 !important;
    text-align: center;
    border-radius: 8px !important;
    border: 1px solid #ddd !important;
    margin: 4px;
    font-weight: 500;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 10px 16px !important;
}

.mobile-menu-login:hover {
    background: #f8f8f8 !important;
    border-color: #ccc !important;
}

/* Modern Backdrop Transition */
#mobile-drawer-backdrop {
    display: block !important;
    /* Force block to allow transition, hide via visibility */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    /* Below burger (200) */

    /* Transition Properties */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#mobile-drawer-backdrop.visible {
    visibility: visible;
    opacity: 1;
}

/* Custom Pen Cursor */
body.pen-cursor-active,
body.pen-cursor-active .annotation-canvas,
body.pen-cursor-active #pdf-container {
    cursor: url('../img/pen-cursor.svg') 2 2, crosshair !important;
}

body.eraser-cursor-active,
body.eraser-cursor-active .annotation-canvas,
body.eraser-cursor-active #pdf-container {
    cursor: url('../img/eraser2.svg?v=3') 2 20, crosshair !important;
}

body.hand-cursor-active,
body.hand-cursor-active .annotation-canvas,
body.hand-cursor-active #pdf-container {
    cursor: grab !important;
}

/* ========== Inline Style Cleanup ========== */

/* Modal header icons */
.modal-header-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 6px;
}

/* Inline SVG icons (e.g., Google login) */
.inline-svg-icon {
    vertical-align: middle;
    margin-right: 8px;
}

/* Mobile drawer close button */
.mobile-drawer-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #555;
    padding: 0 8px;
    cursor: pointer;
}

/* ========== Annotations Section ========== */
#annotations-section {
    margin-top: 15px;
}

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

.annotations-section-header h3 {
    margin: 0;
}

#annotation-toggle-btn {
    background: #4a90d9;
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

#annotation-toggle-btn:hover {
    background: #3a7bc8;
}

#annotations-visibility-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

#annotations-visibility-row label {
    font-size: 14px;
    color: #555;
}

#annotations-visibility-toggle {
    width: 16px;
    height: 16px;
}

/* ========== Mobile Controls ========== */
.mobile-controls-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 25px 0;
}

.mobile-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.mobile-controls-label {
    font-weight: 400;
    color: #333;
    font-size: 15px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    transition: 0.2s;
}

.toggle-slider-knob {
    position: absolute;
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background: #5ba2a8;
}

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

#share-btn-mobile {
    width: 100%;
    padding: 14px;
    background: #f1f1f1;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    color: #444;
    font-size: 15px;
    cursor: pointer;
}

#share-btn-mobile:hover {
    background: #e5e5e5;
}

/* ========== Annotation Toolbar ========== */
#annotation-toolbar {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    padding: 8px 16px;
    gap: 6px;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.08);
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
}

#annotation-toolbar.visible {
    display: flex;
}

.annotation-tool-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.annotation-tool-btn:hover {
    background: #e8e8e8;
}

.annotation-tool-btn.active {
    background: #4a90d9 !important;
}

/* Small screen optimization for Annotation Toolbar */
@media screen and (max-width: 400px) {
    #annotation-toolbar {
        padding: 4px 4px;
        gap: 1px;
        bottom: 70px;
        /* Adjust bottom position slightly */
        /* width: 98%; Removed per user request */
        /* Ensure it fits within screen width */
        max-width: 98%;
        justify-content: center;
        /* Center items */
        flex-wrap: nowrap;
        /* Prevent wrapping */
    }

    .annotation-tool-btn {
        width: 28px;
        height: 28px;
        padding: 0;
    }

    .annotation-tool-btn svg {
        width: 14px;
        height: 14px;
    }

    .toolbar-divider {
        margin: 0 1px;
        height: 16px;
    }
}

/* Fix PDF Controls fitting on small screens */
@media screen and (max-width: 425px) {
    #control-buttons-row {
        gap: 0;
        justify-content: center;
        /* Ensure centered if possible */
    }
}

.annotation-tool-btn.active svg {
    stroke: white;
}

#pen-btn {
    background: #e8e8e8;
}

.pen-popover-wrapper {
    position: static;
}

/* Pen Popover */
#pen-popover {
    display: none;
    position: absolute;
    /* Default: Align relative to button */
    bottom: 54px;
    left: 0;
    width: max-content;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 10001;
}

/* Mobile/Small Screens: Center fixed on screen, wrap only if needed */
@media screen and (max-width: 600px) {
    #pen-popover {
        position: fixed;
        bottom: 42px;
        /* Closer to toolbar */
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        max-width: calc(100vw - 16px);
    }

    /* Fix overlap with hamburger menu on small screens */
    #logo-bar-wrapper {
        padding-right: 60px;
    }

    #monkeywrench-logo-text h2 {
        font-size: 1.4em;
    }
}

#pen-popover.visible {
    display: block;
}

.pen-popover-content {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

/* Scale down pen popover on very small screens */
@media screen and (max-width: 360px) {
    #pen-popover {
        padding: 6px;
    }

    .pen-popover-content {
        gap: 2px;
    }

    .color-swatch {
        width: 18px;
        height: 18px;
    }

    .width-btn {
        width: 22px;
        height: 18px;
    }

    .toolbar-divider-small {
        margin: 0 2px;
    }
}

/* Color Swatches */
.color-swatch {
    width: 22px;
    height: 22px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
}

.color-swatch.active {
    border-color: #333;
}

/* Width Buttons */
.width-btn {
    width: 28px;
    height: 22px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.width-btn.active {
    border: 2px solid #333;
    background: #f5f5f5;
}

.width-btn-line {
    width: 14px;
    background: #333;
}

/* Toolbar Dividers */
.toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 4px;
}

.toolbar-divider-small {
    width: 1px;
    height: 18px;
    background: #ddd;
    margin: 0 4px;
}

/* Undo/Redo Buttons */
#undo-btn,
#redo-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#undo-btn.disabled,
#redo-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Annotation Set Picker */
#annotation-set-picker {
    display: none;
    height: 32px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0 10px;
    background: #f5f5f5;
    font-size: 12px;
    cursor: pointer;
    max-width: 120px;
}

/* Import Button */
#import-btn {
    display: none;
    height: 28px;
    border: none;
    border-radius: 14px;
    background: #4caf50;
    cursor: pointer;
    padding: 0 12px;
    font-size: 11px;
    color: #fff;
}

#import-btn:hover {
    background: #43a047;
}

/* Toolbar Action Buttons */
.toolbar-btn-small {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #e8e8e8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
}

.toolbar-btn-small:hover {
    background: #ddd;
}

.toolbar-share-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #2196f3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-share-btn:hover {
    background: #1976d2;
}

.toolbar-done-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-done-btn:hover {
    background: #555;
}

/* ========== Notification Toast ========== */
#notification {
    display: none;
    position: fixed;
    bottom: 60px;
    right: 20px;
    background: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10001;
}

#notification.visible {
    display: block;
}

.quickfix-panel {
    margin-bottom: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    font-size: 14px;
}

.quickfix-header {
    background: #f5f5f5;
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quickfix-header h3 {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.quickfix-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    padding: 0 4px;
}

.quickfix-list {
    max-height: 250px;
    overflow-y: auto;
}

.quickfix-item {
    padding: 6px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.1s;
}

.quickfix-item:last-child {
    border-bottom: none;
}

.quickfix-item:hover {
    background: #f9f9f9;
}

.quickfix-item.active {
    background: #ffe0b2;
    /* Darker orange */
    border-left: 4px solid #f57c00;
    /* Stronger border */
    padding-left: 8px;
    /* Compensate for border */
    font-weight: 600;
}

.quickfix-item.done {
    opacity: 0.6;
    background: #f5f5f5;
}

.quickfix-item.done .quickfix-label {
    text-decoration: line-through;
    color: #888;
}

.quickfix-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.quickfix-label {
    flex: 1;
}

.quickfix-label small {
    color: #666;
    margin-left: 4px;
}
