/* ========== DESIGN TOKENS (shared with measure editor) ========== */
@import url('tokens.css');

/* ========== CROSS-BROWSER COMPATIBILITY RESET ========== */
* {
    margin: 0;
    padding: 0;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

*::before,
*::after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

body {
    font-family: var(--font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
    background: var(--bg-primary, #f5f5f7);
    color: var(--text-primary, #1d1d1f);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: relative;
    overflow: hidden;
}

/* ========== TOOLBAR — Glass morphism header ========== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-4, 16px);
    height: 52px;
    background: var(--bg-glass-thick, rgba(255, 255, 255, 0.85));
    backdrop-filter: blur(var(--blur-md, 20px)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--blur-md, 20px)) saturate(180%);
    border-bottom: 1px solid var(--border-color, #e5e5e7);
    z-index: var(--z-sticky, 200);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.06));
    position: relative;
    transition: background var(--dur, 0.25s) var(--ease-smooth, ease),
                box-shadow var(--dur, 0.25s) var(--ease-smooth, ease);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
}

.toolbar-right {
    justify-content: flex-end;
}

.toolbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.divider {
    width: 1px;
    height: 20px;
    background: var(--border-color-strong);
    margin: 0 var(--space-2);
    opacity: 0.6;
    transition: opacity var(--dur-fast) var(--ease-smooth);
}

.score-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    letter-spacing: var(--tracking-tight);
    transition: color var(--dur-fast) var(--ease-smooth);
}

.page-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-tertiary);
    padding: var(--space-1);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color-subtle);
}

.page-info-container {
    position: relative;
}

.page-info {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: center;
    cursor: pointer;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius);
    transition: all var(--dur-fast) var(--ease-smooth);
}

.page-info:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}

/* Page navigator: solid background only (no glass/blur — reduces GPU load) */
.page-navigator {
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--bg-elevated);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-height: 320px;
    width: 220px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* GPU-friendly: only opacity + transform; visibility toggled without transition to avoid lag */
    transition: opacity var(--dur-fast) var(--ease-apple),
                transform var(--dur-fast) var(--ease-apple);
    z-index: var(--z-dropdown);
}

.page-navigator.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* Keep visible during close transition so opacity/transform can animate; removed in JS on transitionend */
.page-navigator.animating-out {
    visibility: visible;
    pointer-events: none;
}

.page-navigator-content {
    max-height: 300px;
    overflow-y: auto;
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.page-navigator-content::-webkit-scrollbar {
    width: 8px;
}

.page-navigator-content::-webkit-scrollbar-track {
    background: transparent;
}

.page-navigator-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-sm);
}

.page-navigator-content::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.page-number-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 500;
    text-align: center;
    /* Lightweight transition to reduce lag with many buttons */
    transition: background var(--dur-instant) var(--ease-smooth),
                color var(--dur-instant) var(--ease-smooth);
    font-variant-numeric: tabular-nums;
}

.page-number-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.page-number-btn.active {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
    font-weight: 600;
    box-shadow: var(--shadow-accent);
}

.page-number-btn.current-view {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
}

.zoom-level {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 48px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    transition: color var(--dur-fast) var(--ease-smooth);
}

/* ========== ICON BUTTONS — Micro-interactions ========== */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-fast) var(--ease-smooth);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

/* Ripple effect base */
.btn-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, var(--accent-subtle) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0);
    transition: transform var(--dur-normal) var(--ease-out),
                opacity var(--dur-fast) var(--ease-out);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-icon:hover::after {
    opacity: 0.5;
    transform: scale(2);
}

.btn-icon:active {
    background: var(--border-color);
    transform: translateY(0) scale(0.95);
    transition-duration: var(--dur-instant);
}

.btn-icon:active::after {
    opacity: 1;
    transform: scale(2.5);
}

.btn-icon:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

#fullscreenBtn {
    transition: all var(--dur-fast) var(--ease-smooth);
}

#fullscreenBtn:hover {
    background: var(--accent-subtle);
    color: var(--accent);
}

#fullscreenBtn.active {
    background: var(--accent);
    color: var(--text-inverse);
    box-shadow: var(--shadow-accent);
}

.btn-icon.btn-small {
    padding: var(--space-1);
}

.btn-icon:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon:disabled::after {
    display: none;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-primary);
}

/* ========== LIBRARY SIDEBAR — Slide-in with glass effect ========== */
.library-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 340px;
    height: 100%;
    background: var(--bg-glass-thick);
    backdrop-filter: blur(var(--blur-lg)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(180%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--dur-slow) var(--ease-apple),
                box-shadow var(--dur-slow) var(--ease-apple);
    z-index: var(--z-dropdown);
    box-shadow: var(--shadow-xl);
    will-change: transform;
}

/* ── Sliver state — 16px strip peeks out; content stays visible so the
   panel appears to slide behind the screen edge, not fade away ── */
.library-sidebar.hidden {
    transform: translateX(calc(-100% + 16px));
    box-shadow: none;
    transition: transform 0.4s var(--ease-apple) 0.2s,
                box-shadow 0.4s var(--ease-apple) 0.2s;
}

/* Block clicks through the sliver — no opacity change so content is visible */
.library-sidebar.hidden > * {
    pointer-events: none;
}

/* iOS-style accent pill — signals the sliver is interactive */
.library-sidebar.hidden::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 4px;
    width: 3px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius-full);
    opacity: 0.4;
    transform: translateY(-50%);
    transition: opacity 0.2s var(--ease), height 0.2s var(--ease);
    pointer-events: none;
}

/* Invisible zone widens the hover target beyond the visible sliver */
.library-sidebar.hidden::before {
    content: '';
    position: absolute;
    top: 0;
    right: -12px;
    width: 28px;
    height: 100%;
    z-index: 1;
}

/* ── Hover peek — full expansion on hover ── */
.library-sidebar.hidden:hover:not(.library-peek-suppressed) {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
    transition: transform 0.35s var(--ease-apple),
                box-shadow 0.35s var(--ease-apple);
}

.library-sidebar.hidden:hover:not(.library-peek-suppressed) > * {
    pointer-events: auto;
}

/* Fade out pill when peek-expanding */
.library-sidebar.hidden:hover:not(.library-peek-suppressed)::after {
    opacity: 0;
    height: 0;
}

/* Keep ::before buffer alive during hover — it prevents flicker by
   extending the hover zone 12px past the sidebar's visible right edge.
   Only remove pseudo-elements when the sidebar is fully open (pinned). */
.library-sidebar:not(.hidden)::before,
.library-sidebar:not(.hidden)::after {
    display: none;
}

/* ========== RIGHT SIDEBAR — Menu panel ========== */
.right-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    background: var(--bg-glass-thick);
    backdrop-filter: blur(var(--blur-lg)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(180%);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--dur-slow) var(--ease-apple),
                box-shadow var(--dur-slow) var(--ease-apple);
    z-index: var(--z-dropdown);
    box-shadow: var(--shadow-xl);
    transform: translateX(100%);
    will-change: transform;
}

.right-sidebar.visible {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.sidebar-header h3 {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: var(--tracking-tight);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) 0;
}

.sidebar-section {
    margin-bottom: var(--space-6);
}

.sidebar-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 var(--space-5) var(--space-2);
    margin-bottom: var(--space-1);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-5);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-smooth);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
    position: relative;
}

.sidebar-item::before {
    content: '';
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: height var(--dur-fast) var(--ease-spring);
}

.sidebar-item:hover {
    background: var(--accent-subtle);
    color: var(--accent);
}

.sidebar-item:hover::before {
    height: 60%;
}

.sidebar-item:active {
    transform: scale(0.98);
}

.sidebar-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: color var(--dur-fast) var(--ease-smooth),
                transform var(--dur-fast) var(--ease-smooth);
}

.sidebar-item:hover svg {
    color: var(--accent);
    transform: scale(1.1);
}

.sidebar-item span {
    flex: 1;
}

.sidebar-item-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-base);
    color: var(--text-primary);
}

.sidebar-item-toggle span:first-child {
    flex: 1;
}

/* ========== TOGGLE SWITCH — Apple-style with spring animation ========== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color-strong);
    transition: background-color var(--dur-normal) var(--ease-smooth);
    border-radius: var(--radius-full);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: transform var(--dur-normal) var(--ease-spring);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--success);
}

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

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: var(--focus-ring);
}

/* Hover effect */
.toggle-switch:hover .toggle-slider:before {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* Dark mode — variables live in tokens.css. Page-specific overrides here. */

body.dark-mode .score-viewer {
    background: var(--bg-secondary);
}

body.dark-mode .score-page {
    background: var(--bg-secondary);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.40);
}

body.dark-mode .score-container::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
}
body.dark-mode .score-container::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

body.dark-mode .toolbar,
body.dark-mode .library-sidebar,
body.dark-mode .right-sidebar {
    background: var(--bg-glass-thick);
}

body.dark-mode .modal-content,
body.dark-mode .processing-modal-content,
body.dark-mode .process-modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

/* Ensure modal backdrop is always visible in dark mode */
body.dark-mode .modal {
    background: var(--bg-overlay);
}

body.dark-mode .modal.active {
    opacity: 1;
}

body.dark-mode .processing-modal-header {
    background: linear-gradient(135deg, rgba(41, 151, 255, 0.12) 0%, rgba(41, 151, 255, 0.04) 100%);
}

body.dark-mode .processing-modal-footer,
body.dark-mode .process-modal-footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

body.dark-mode .nav-arrow {
    background: var(--bg-glass-thick);
    color: var(--text-primary);
}

body.dark-mode .skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        rgba(255, 255, 255, 0.05) 20%,
        rgba(255, 255, 255, 0.08) 40%,
        rgba(255, 255, 255, 0.05) 60%,
        var(--bg-tertiary) 80%,
        var(--bg-tertiary) 100%
    );
}

/* Reduced motion mode */
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    height: 64px;
    background: var(--bg-glass);
}

.library-header h2 {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
}

.library-actions {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.combine-images-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.combine-images-dialog-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.combine-images-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.combine-images-dialog-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.combine-images-dialog-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.combine-images-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.combine-image-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    border: 1px solid var(--border-color);
}

.combine-image-item:hover {
    background: var(--bg-tertiary);
}

.combine-image-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

.combine-image-title {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.combine-image-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.combine-image-order {
    display: none;
    min-width: 24px;
    width: 24px;
    height: 24px;
    text-align: center;
    font-weight: 600;
    color: var(--accent);
    background: rgba(0, 113, 227, 0.1);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
}

.delete-original-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    user-select: none;
}

.delete-original-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
    margin-right: 8px;
}

.combine-images-dialog-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background: var(--border-color);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== PRIMARY BUTTON — Vibrant with glow ========== */
.btn-primary {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: var(--text-inverse);
    border: none;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    justify-content: center;
    transition: all var(--dur-fast) var(--ease-smooth);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    opacity: 1;
    transition: opacity var(--dur-fast) var(--ease-smooth);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-accent), 
                0 2px 4px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring-offset);
}

.library-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2);
}

.library-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.library-footer .btn-secondary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

/* ========== LIBRARY ITEMS — Card-style with hover effects ========== */
.library-item {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-smooth);
    margin-bottom: var(--space-1);
    display: flex;
    flex-direction: row;
    gap: var(--space-3);
    align-items: center;
    position: relative;
    border: 1px solid transparent;
    background: transparent;
}

.library-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-smooth);
    z-index: -1;
}

.library-item:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.library-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.library-item.drag-over-top::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

.library-item.drag-over-bottom::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

.library-item-drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.library-item:hover .library-item-drag-handle {
    opacity: 1;
    color: var(--text-primary);
}

.library-item-drag-handle:active {
    cursor: grabbing;
}

.library-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.library-item.active {
    background: var(--accent-subtle);
    border-color: var(--accent);
    box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--accent-subtle);
}

.library-item.active::before {
    opacity: 0.05;
}

.library-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0; /* Allow flex children to shrink */
}

.library-item-title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}

/* Annotated score badge */
.annotated-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(34, 197, 94, 0.2);
}

.annotated-badge svg {
    stroke: white;
    flex-shrink: 0;
}

.library-item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}

.library-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.15s ease;
    position: relative;
    z-index: 10;
}

.library-item:hover .library-item-actions {
    opacity: 1;
}

/* Baked/Annotated score items - always show actions for easy deletion */
.library-item.baked-score-item {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), rgba(22, 163, 74, 0.05));
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.library-item.baked-score-item:hover {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(22, 163, 74, 0.1));
    border-color: rgba(34, 197, 94, 0.3);
}

.library-item.baked-score-item .library-item-actions {
    opacity: 1 !important;
}

/* Ensure buttons in library-item-actions are always clickable */
.library-item-actions button,
.library-item-actions .btn-icon,
.library-item-actions .btn-icon-small,
.delete-score-btn,
.hidden-delete-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 100;
    -webkit-tap-highlight-color: transparent;
}

/* Make sure action buttons container doesn't block clicks */
.library-item-actions {
    pointer-events: auto !important;
}

/* Ensure action buttons are visible and clickable even when item is not hovered */
.library-item .library-item-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Delete button specific styling for visibility */
.delete-score-btn,
.hidden-delete-btn {
    color: var(--text-secondary);
    transition: color 0.15s ease, transform 0.15s ease;
}

.delete-score-btn:hover,
.hidden-delete-btn:hover {
    color: #ef4444 !important;
}

/* Overlay Library Items */
.library-item.overlay-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.03), rgba(217, 119, 6, 0.03));
    border: 1px solid rgba(245, 158, 11, 0.15);
    padding: 12px 14px;
}

.library-item.overlay-item:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(217, 119, 6, 0.08));
    border-color: rgba(245, 158, 11, 0.3);
}

.library-item.overlay-item .library-item-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.library-item.overlay-item .library-item-actions {
    opacity: 0.5;
}

.library-item.overlay-item:hover .library-item-actions {
    opacity: 1;
}

/* Reference overlay (backend model - blue theme) */
.library-item.overlay-item.reference-overlay {
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.03), rgba(0, 80, 200, 0.03));
    border: 1px solid rgba(0, 102, 255, 0.15);
}

.library-item.overlay-item.reference-overlay:hover {
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.08), rgba(0, 80, 200, 0.08));
    border-color: rgba(0, 102, 255, 0.3);
}

/* Editable overlay (editor - orange/amber theme) */
.library-item.overlay-item.editable-overlay {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.03), rgba(217, 119, 6, 0.03));
    border: 1px solid rgba(245, 158, 11, 0.15);
}

.library-item.overlay-item.editable-overlay:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(217, 119, 6, 0.08));
    border-color: rgba(245, 158, 11, 0.3);
}

.library-section-header {
    position: sticky;
    top: 0;
    z-index: 5;
}

.overlay-badge-small {
    flex-shrink: 0;
}

.btn-icon-small {
    padding: 4px 8px;
    font-size: 12px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.btn-icon-small:hover {
    background: var(--border-color);
}

/* ========== SCORE VIEWER — Main canvas area ========== */
.score-viewer {
    flex: 1;
    position: relative;
    overflow: hidden;
    overflow-x: hidden; /* No horizontal scrollbar during page transitions */
    min-width: 0; /* Flex: allow shrinking so content cannot force horizontal overflow */
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    opacity: 1;
    visibility: visible;
    z-index: 1;
    transition: background var(--dur-slow) var(--ease-smooth);
}

.score-viewer.fullscreen-mode {
    padding: 0;
    background: #1d1d1f;
}

.score-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden !important; /* Never show horizontal scrollbar during page animation */
    overflow-y: auto;
    position: relative;
    min-width: 0; /* Flex: allow clipping so translateX animation never causes scrollbar */
    /* Removed transition to prevent displacement of overlays */
    padding: 0;
    box-sizing: border-box;
}

.score-container.page-mode {
    overflow: hidden;
    flex-direction: column;
    position: relative;
}

.score-container.page-mode.fullscreen-mode {
    overflow-x: hidden;
    overflow-y: auto;
    align-items: flex-start !important;
    justify-content: flex-start !important;
}

.score-container.fullscreen-mode .score-page {
    min-height: auto;
    height: auto;
    margin: 0 !important;
    padding: 0 !important;
    top: 0 !important;
    left: 0 !important;
}

.score-container.fullscreen-mode {
    padding: 0;
}

.score-container.fullscreen-mode .score-page {
    padding: 0 !important;
    margin: 0 !important;
}

.score-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.score-container::-webkit-scrollbar-track {
    background: transparent;
}

.score-container::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
}

.score-container::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Completely hide horizontal scrollbar (page transition must never show it) */
.score-container::-webkit-scrollbar:horizontal {
    height: 0;
    display: none;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state svg {
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
}

.score-page {
    background: var(--bg-secondary);
    margin: 0;
    box-shadow: 0 4px 20px var(--shadow-strong);
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: visible;
    opacity: 1;
    will-change: transform, opacity;
}

.score-page.active {
    display: flex;
    position: relative;
}

/*
 * Page transitions — lightweight opacity + subtle translate.
 * Uses GPU-composited properties only (opacity, transform) so overlays
 * stay perfectly positioned and performance stays crisp.
 */

/* Initial state: invisible, slightly offset in travel direction */
.score-page.page-initial-next,
.double-page-container.page-initial-next {
    opacity: 0;
    transform: translateX(8px);
    will-change: opacity, transform;
}

.score-page.page-initial-prev,
.double-page-container.page-initial-prev {
    opacity: 0;
    transform: translateX(-8px);
    will-change: opacity, transform;
}

/* Exit: fade out + slight shift opposite to travel */
.score-page.page-exit-next,
.double-page-container.page-exit-next {
    animation: pageExitNext var(--dur-fast) var(--ease-in) forwards;
}

.score-page.page-exit-prev,
.double-page-container.page-exit-prev {
    animation: pageExitPrev var(--dur-fast) var(--ease-in) forwards;
}

@keyframes pageExitNext {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-8px); }
}

@keyframes pageExitPrev {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(8px); }
}

/* Enter: fade in + slide from offset to natural position */
.score-page.page-enter-next,
.double-page-container.page-enter-next {
    animation: pageEnterNext var(--dur-medium) var(--ease-apple) forwards;
    will-change: opacity, transform;
}

.score-page.page-enter-prev,
.double-page-container.page-enter-prev {
    animation: pageEnterPrev var(--dur-medium) var(--ease-apple) forwards;
    will-change: opacity, transform;
}

@keyframes pageEnterNext {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes pageEnterPrev {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .score-page.page-exit-next,
    .score-page.page-exit-prev,
    .double-page-container.page-exit-next,
    .double-page-container.page-exit-prev {
        animation: none;
        opacity: 0;
    }
    .score-page.page-enter-next,
    .score-page.page-enter-prev,
    .double-page-container.page-enter-next,
    .double-page-container.page-enter-prev {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

@keyframes pageExitNext {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-15%) scale(0.99);
    }
}

@keyframes pageExitPrev {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(15%) scale(0.99);
    }
}

@keyframes pageEnterNext {
    from {
        opacity: 0;
        transform: translateX(15%) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes pageEnterPrev {
    from {
        opacity: 0;
        transform: translateX(-15%) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Double page view */
.score-container.double-page {
    overflow: hidden;
}

.double-page-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.double-page-container .score-page {
    flex: 0 0 calc(50% - 10px);
    width: calc(50% - 10px);
    max-width: calc(50% - 10px);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

.double-page-container .score-page canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
    display: block;
}

.double-page-container .score-page img {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
    display: block;
}

.double-page-container .left-page {
    order: 0 !important;
    border-right: 1px solid var(--border-color);
}

.double-page-container .right-page {
    order: 1 !important;
    border-left: 1px solid var(--border-color);
}

.score-page img,
.score-page canvas {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    margin: 0;
    padding: 0;
}

/* ========== NAVIGATION ARROWS — Glass morphism with hover effects ========== */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-glass-thick);
    backdrop-filter: blur(var(--blur-md));
    -webkit-backdrop-filter: blur(var(--blur-md));
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--dur-normal) var(--ease-smooth);
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

.score-viewer:hover .nav-arrow {
    opacity: 1;
}

.nav-arrow:hover {
    background: var(--bg-secondary);
    transform: translateY(-50%) scale(1.1);
    box-shadow: var(--shadow-xl);
}

.nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
    transition-duration: var(--dur-instant);
}

.nav-arrow:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    transform: translateY(-50%);
}

.nav-arrow-left {
    left: var(--space-5);
}

.nav-arrow-left:hover {
    transform: translateY(-50%) scale(1.1) translateX(-2px);
}

.nav-arrow-right {
    right: var(--space-5);
}

.nav-arrow-right:hover {
    transform: translateY(-50%) scale(1.1) translateX(2px);
}

/* ========== MODAL — Apple-style with spring animations ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    display: none;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    z-index: var(--z-modal);
    /* IMPORTANT: No blur on base .modal — prevents stuck-blur if JS fails
       before .active is added. Blur is only on .modal.active below. */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    opacity: 0;
    transition: opacity var(--dur-normal) var(--ease-smooth);
}

@supports ((-webkit-backdrop-filter: blur(8px)) or (backdrop-filter: blur(8px))) {
    .modal.active {
        background: rgba(0, 0, 0, 0.35);
    }
    body.dark-mode .modal.active {
        background: rgba(0, 0, 0, 0.55);
    }
}

.modal.active {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    opacity: 1;
    -webkit-backdrop-filter: blur(var(--blur-sm));
    backdrop-filter: blur(var(--blur-sm));
    animation: modalBackdropIn var(--dur-normal) var(--ease-smooth) forwards;
}

@keyframes modalBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-2xl);
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    animation: modalContentIn var(--dur-slow) var(--ease-spring) forwards;
    animation-delay: 0.05s;
    border: 1px solid var(--border-color);
}

@keyframes modalContentIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.modal-header h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
}

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.modal-body p {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
    line-height: var(--leading-relaxed);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    margin-bottom: 12px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

/* ========== SECONDARY BUTTON ========== */
.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color-strong);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-smooth);
    position: relative;
    overflow: hidden;
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Settings Modal Styles */
.modal-large {
    max-width: 700px;
    width: 90%;
}

/* ========== PROCESSING MODAL STYLES ========== */
.process-modal-content {
    max-width: 560px;
    width: 90%;
    animation: processModalIn var(--dur-slow) var(--ease-spring) forwards;
}

@keyframes processModalIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.process-modal-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-6) var(--space-8);
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--accent-subtle) 0%, transparent 100%);
}

.process-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    flex-shrink: 0;
    animation: iconFloat 3s ease-in-out infinite;
    box-shadow: var(--shadow-accent);
}

@keyframes iconFloat {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-4px) scale(1.02);
    }
}

.process-modal-title-group {
    flex: 1;
}

.process-modal-title-group h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    letter-spacing: -0.5px;
}

.process-modal-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 400;
}

.btn-icon-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-icon-close:hover {
    background: var(--bg-tertiary);
    transform: rotate(90deg);
}

.process-modal-body {
    padding: 32px;
}

/* Processing Options Section */
.process-options-section {
    margin-bottom: 32px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.option-card {
    display: flex;
    flex-direction: column;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.option-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.1) 0%, rgba(0, 113, 227, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.option-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 113, 227, 0.15);
}

.option-card:hover::before {
    opacity: 1;
}

.option-checkbox:checked ~ .option-icon,
.option-checkbox:checked + .option-icon {
    color: var(--accent);
    transform: scale(1.1);
}

.option-card:has(.option-checkbox:checked) {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.08) 0%, rgba(0, 113, 227, 0.03) 100%);
    box-shadow: 0 4px 16px rgba(0, 113, 227, 0.1);
}

.option-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.option-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.option-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.option-card:has(.option-checkbox:checked) .option-icon {
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent);
}

.option-card-content {
    flex: 1;
}

.option-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.option-description {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Endpoint Info Section */
.endpoint-info-section {
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.endpoint-header svg {
    color: var(--accent);
}

.endpoint-display {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.endpoint-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    cursor: not-allowed;
}

.endpoint-badge {
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    animation: badgeGlow 2s ease-in-out infinite;
}

@keyframes badgeGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(0, 113, 227, 0);
    }
}

.endpoint-note {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--accent);
    margin: 0;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.endpoint-note svg {
    flex-shrink: 0;
}

/* ========== MODEL PICKER STYLES ========== */
.model-picker {
    padding: 4px 0;
}

.model-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.model-picker-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-picker-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s ease;
}

.model-picker-status.connected {
    background: rgba(52, 199, 89, 0.1);
    color: #34c759;
}

.model-picker-status.connected .status-dot {
    background: #34c759;
    box-shadow: 0 0 6px #34c759;
}

.model-picker-status.error {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

.model-picker-status.error .status-dot {
    background: #ff3b30;
}

.model-picker-track {
    position: relative;
    display: flex;
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 6px;
    gap: 4px;
    margin-bottom: 20px;
}

.model-picker-slider {
    position: absolute;
    top: 6px;
    left: 6px;
    height: calc(100% - 12px);
    width: calc(25% - 5px);  /* 4 options instead of 3 */
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.model-option {
    flex: 1;
    position: relative;
    z-index: 1;
    cursor: pointer;
}

.model-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.model-option-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.model-option:hover .model-option-content {
    background: rgba(255, 255, 255, 0.03);
}

.model-option input:checked ~ .model-option-content {
    background: transparent;
}

.model-option-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.model-option-icon svg {
    width: 100%;
    height: 100%;
}

.model-option input:checked ~ .model-option-content .model-option-icon {
    color: var(--accent);
    transform: scale(1.1);
}

.model-option-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
    transition: color 0.3s ease;
}

.model-option input:checked ~ .model-option-content .model-option-name {
    color: var(--text-primary);
}

.model-option-desc {
    font-size: 11px;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.model-option input:checked ~ .model-option-content .model-option-desc {
    color: var(--text-secondary);
}

/* Model Details Card */
.model-details {
    position: relative;
}

.model-detail-card {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    animation: detailFadeIn 0.3s ease;
}

@keyframes detailFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.detail-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.detail-icon svg {
    width: 26px;
    height: 26px;
}

.baseline-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.solo-gradient {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.piano-gradient {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.symphony-gradient {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.detail-content {
    flex: 1;
    min-width: 0;
}

.detail-content h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px 0;
}

.detail-content p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.detail-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.detail-tag.solo-tag {
    background: rgba(17, 153, 142, 0.1);
    color: #11998e;
}

.detail-tag.piano-tag {
    background: rgba(245, 87, 108, 0.1);
    color: #f5576c;
}

/* Beta badge styling */
.beta-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-tag.symphony-tag {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

/* Responsive */
@media (max-width: 480px) {
    .model-option-content {
        padding: 12px 4px;
    }
    
    .model-option-icon {
        width: 28px;
        height: 28px;
    }
    
    .model-option-name {
        font-size: 12px;
    }
    
    .model-option-desc {
        font-size: 10px;
    }
    
    .model-detail-card {
        flex-direction: column;
        text-align: center;
    }
    
    .detail-icon {
        margin: 0 auto;
    }
}

/* ========== PROCESSING MODAL STYLES ========== */
.processing-modal-content {
    max-width: 480px;
    width: 90%;
    -webkit-animation: processingModalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    -moz-animation: processingModalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation: processingModalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    overflow: hidden;
    /* Safari fix for overflow and border-radius */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

@-webkit-keyframes processingModalSlideIn {
    from {
        opacity: 0;
        -webkit-transform: translateY(-20px) scale(0.95);
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0) scale(1);
        transform: translateY(0) scale(1);
    }
}

@-moz-keyframes processingModalSlideIn {
    from {
        opacity: 0;
        -moz-transform: translateY(-20px) scale(0.95);
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        -moz-transform: translateY(0) scale(1);
        transform: translateY(0) scale(1);
    }
}

@keyframes processingModalSlideIn {
    from {
        opacity: 0;
        -webkit-transform: translateY(-20px) scale(0.95);
        -moz-transform: translateY(-20px) scale(0.95);
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0) scale(1);
        -moz-transform: translateY(0) scale(1);
        transform: translateY(0) scale(1);
    }
}

.processing-modal-header {
    text-align: center;
    padding: 40px 32px 32px;
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.1) 0%, rgba(0, 113, 227, 0.05) 100%);
    border-bottom: 1px solid var(--border-color);
}

.processing-icon-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.processing-icon-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: processingIconPulse 2s ease-in-out infinite;
    box-shadow: 0 8px 24px rgba(0, 113, 227, 0.3);
}

@keyframes processingIconPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 24px rgba(0, 113, 227, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 32px rgba(0, 113, 227, 0.4);
    }
}

.processing-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
}

.processing-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.processing-content {
    padding: 32px;
}

.processing-status-section {
    margin-top: 0;
}

.processing-status-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.processing-status-text-group {
    flex: 1;
    text-align: center;
}

.processing-status-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.processing-time {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== APP LOADING OVERLAY — Elegant full-screen loader ========== */
.app-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    backdrop-filter: blur(var(--blur-lg));
    -webkit-backdrop-filter: blur(var(--blur-lg));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-max);
    color: var(--text-primary);
    animation: fadeIn var(--dur-normal) var(--ease-smooth);
}

.app-loading-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
}

.app-loading-content h3 {
    font-size: var(--text-xl);
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
}

.app-loading-content p {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin: 0;
}

.loading-spinner-large {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    position: relative;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    animation: spinSmooth 0.9s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

/* Fallback for Safari < 12.1 without conic-gradient */
@supports not (background: conic-gradient(white, white)) {
    .loading-spinner-large {
        background: none;
        border: 4px solid rgba(255, 255, 255, 0.3);
        border-top-color: white;
        -webkit-mask: none;
        mask: none;
    }
}

/* Cross-browser spin animation */
@-webkit-keyframes spin {
    0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}

@-moz-keyframes spin {
    0% { -moz-transform: rotate(0deg); transform: rotate(0deg); }
    100% { -moz-transform: rotate(360deg); transform: rotate(360deg); }
}

@keyframes spin {
    0% { 
        -webkit-transform: rotate(0deg); 
        -moz-transform: rotate(0deg); 
        transform: rotate(0deg); 
    }
    100% { 
        -webkit-transform: rotate(360deg); 
        -moz-transform: rotate(360deg); 
        transform: rotate(360deg); 
    }
}

.progress-bar-wrapper {
    margin-top: 16px;
}

.processing-modal-footer {
    padding: var(--space-6) var(--space-8);
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    display: flex;
    justify-content: center;
    gap: var(--space-3);
}

.processing-modal-footer .btn-secondary,
.processing-modal-footer .btn-primary,
.process-modal-footer .btn-secondary,
.process-modal-footer .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    line-height: 1;
    vertical-align: middle;
}

.processing-modal-footer .btn-secondary svg,
.processing-modal-footer .btn-primary svg,
.process-modal-footer .btn-secondary svg,
.process-modal-footer .btn-primary svg {
    flex-shrink: 0;
    display: block;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-3);
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #5ac8fa 50%, var(--accent) 100%);
    background-size: 200% 100%;
    border-radius: var(--radius-full);
    width: 0%;
    transition: width var(--dur-normal) var(--ease-smooth);
    animation: progressShimmer 2s linear infinite;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: progressGlow 1.5s ease-in-out infinite;
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes progressGlow {
    0%, 100% { opacity: 0; transform: translateX(-100%); }
    50% { opacity: 1; transform: translateX(100%); }
}

.processing-details {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Process Modal Footer */
.process-modal-footer {
    padding: 24px 32px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-animated {
    position: relative;
    overflow: hidden;
    transition: transform var(--dur-fast) var(--ease-spring),
                box-shadow var(--dur-fast) var(--ease-smooth),
                background var(--dur-fast) var(--ease-smooth);
}

.btn-animated:hover {
    transform: translateY(-1px);
}

.btn-animated:active {
    transform: translateY(0) scale(0.97);
    transition-duration: var(--dur-instant);
}

/* Click-triggered radial ripple (added via JS) */
.btn-animated .btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: btnRippleExpand var(--dur-medium) var(--ease-out) forwards;
    pointer-events: none;
    z-index: 0;
}

@keyframes btnRippleExpand {
    0%   { transform: scale(0); opacity: 0.6; }
    100% { transform: scale(4); opacity: 0; }
}

.btn-animated span,
.btn-animated svg {
    position: relative;
    z-index: 1;
}

.btn-primary-glow {
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary-glow:hover {
    box-shadow: 0 6px 22px var(--accent-glow), 0 2px 6px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.btn-primary-glow:active {
    box-shadow: 0 2px 8px var(--accent-glow);
    transform: translateY(0) scale(0.97);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
    
    .process-modal-content {
        max-width: 95%;
    }
    
    .process-modal-header {
        padding: 20px 24px;
    }
    
    .process-modal-body {
        padding: 24px;
    }
}

/* ========== SUCCESS MODAL STYLES ========== */
.success-modal-content {
    max-width: 560px;
    width: 90%;
    animation: successModalIn var(--dur-slower) var(--ease-spring) forwards;
    overflow: hidden;
}

@keyframes successModalIn {
    from {
        opacity: 0;
        transform: translateY(-40px) scale(0.88);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.success-modal-header {
    text-align: center;
    padding: var(--space-10) var(--space-8) var(--space-8);
    background: linear-gradient(135deg, var(--success-muted) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-color);
}

.success-icon-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-5);
}

.success-icon-circle {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success) 0%, #00a844 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    position: relative;
    animation: successIconPop var(--dur-slower) var(--ease-spring);
    box-shadow: var(--shadow-success);
}

@keyframes successIconPop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.15) rotate(10deg);
    }
    80% {
        transform: scale(0.95) rotate(-5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.success-checkmark {
    animation: checkmarkDraw var(--dur-slower) var(--ease-out) 0.3s both;
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
}

@keyframes checkmarkDraw {
    to {
        stroke-dashoffset: 0;
    }
}

.success-ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    animation: rippleExpand 2s ease-out infinite;
}

@keyframes rippleExpand {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.success-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-2) 0;
    letter-spacing: var(--tracking-tight);
    animation: slideUp var(--dur-normal) var(--ease-apple) 0.2s both;
}

.success-message {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin: 0;
    line-height: var(--leading-relaxed);
    animation: slideUp var(--dur-normal) var(--ease-apple) 0.3s both;
}

.success-content {
    padding: 32px;
}

.success-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card-primary {
    border-color: rgba(0, 113, 227, 0.3);
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.05) 0%, rgba(0, 113, 227, 0.02) 100%);
}

.stat-card-secondary {
    border-color: rgba(0, 200, 83, 0.3);
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.05) 0%, rgba(0, 200, 83, 0.02) 100%);
}

.stat-card-tertiary {
    border-color: rgba(255, 165, 0, 0.3);
    background: linear-gradient(135deg, rgba(255, 165, 0, 0.05) 0%, rgba(255, 165, 0, 0.02) 100%);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.stat-card-primary .stat-icon {
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent);
}

.stat-card-secondary .stat-icon {
    background: rgba(0, 200, 83, 0.1);
    color: #00c853;
}

.stat-card-tertiary .stat-icon {
    background: rgba(255, 165, 0, 0.1);
    color: #ffa500;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.2;
}

.success-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-success-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    min-width: 140px;
    justify-content: center;
}

@media (max-width: 768px) {
    .success-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .success-actions {
        flex-direction: column;
    }
    
    .btn-success-action {
        width: 100%;
    }
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid var(--bg-tertiary);
}

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

.settings-item-label {
    flex: 1;
    margin-right: 24px;
}

.settings-item-label label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.settings-item-description {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.settings-item-control {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.settings-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-width: 200px;
    transition: border-color 0.2s;
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent);
}

.settings-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-width: 120px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Success Modal */
.success-modal {
    text-align: center;
    max-width: 400px;
    padding: 32px 24px;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.success-modal h3 {
    margin: 0 0 12px 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.success-modal p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.success-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

/* Error Modal */
.error-modal {
    text-align: center;
    max-width: 400px;
    padding: 32px 24px;
}

.error-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: scaleIn 0.3s ease;
}

.error-modal h3 {
    margin: 0 0 12px 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.error-modal p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    line-height: 1.6;
    text-align: left;
}

/* Delete Confirmation Modal */
.delete-modal-content {
    max-width: 440px;
    width: 90%;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px) scale(0.97);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    animation: none;
}

.modal.active .delete-modal-content {
    opacity: 1;
    transform: translateY(0) scale(1);
}


.delete-modal-header {
    text-align: center;
    padding: 32px 24px 24px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    border-bottom: 1px solid var(--border-color);
}

.delete-icon-wrapper {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: deleteIconPulse 0.5s ease;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

@keyframes deleteIconPulse {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.delete-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    letter-spacing: -0.3px;
}

.delete-modal-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
    font-weight: 500;
}

.delete-modal-body {
    padding: 24px;
    text-align: center;
}

.delete-warning {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.delete-modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    justify-content: flex-end;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
}

/* Download Options Modal */
.download-options-modal-content {
    max-width: 500px;
    width: 90%;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px) scale(0.97);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    animation: none;
}

.modal.active .download-options-modal-content {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.download-options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.download-options-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.3px;
}

.download-options-body {
    padding: 24px;
}

.download-options-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin: 0 0 20px 0;
    line-height: 1.5;
    font-weight: 500;
}

.download-options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.download-option-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.download-option-btn:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.1);
}

.download-option-btn:active {
    transform: translateY(0);
}

.download-option-primary {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.05) 0%, rgba(0, 113, 227, 0.02) 100%);
}

.download-option-primary:hover {
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.1) 0%, rgba(0, 113, 227, 0.05) 100%);
    box-shadow: 0 4px 16px rgba(0, 113, 227, 0.2);
}

.download-option-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 10px;
    color: var(--accent);
    flex-shrink: 0;
}

.download-option-primary .download-option-icon {
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.15) 0%, rgba(0, 113, 227, 0.1) 100%);
}

.download-option-content {
    flex: 1;
    min-width: 0;
}

.download-option-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    letter-spacing: -0.2px;
}

.download-option-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.download-option-arrow {
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.download-option-btn:hover .download-option-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

/* Download Loading Modal */
.download-loading-modal-content {
    max-width: 400px;
    width: 90%;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px) scale(0.97);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    animation: none;
}

.modal.active .download-loading-modal-content {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.download-loading-header {
    text-align: center;
    padding: 32px 24px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.download-loading-spinner {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.download-loading-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.3px;
}

.download-loading-body {
    padding: 24px;
    text-align: center;
}

.download-loading-status {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    line-height: 1.5;
}

.download-loading-progress {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.download-loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: 3px;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
    box-shadow: 0 0 10px rgba(0, 113, 227, 0.3);
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 12px;
}

/* ========== LOADING SPINNER — Smooth Apple-style ========== */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spinSmooth 0.8s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
    flex-shrink: 0;
}

@keyframes spinSmooth {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== SKELETON SCREENS — Smooth shimmer effect ========== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        rgba(255, 255, 255, 0.5) 20%,
        rgba(255, 255, 255, 0.8) 40%,
        rgba(255, 255, 255, 0.5) 60%,
        var(--bg-tertiary) 80%,
        var(--bg-tertiary) 100%
    );
    background-size: 400% 100%;
    animation: skeletonShimmer 1.8s ease-in-out infinite;
    border-radius: var(--radius);
}

@keyframes skeletonShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.skeleton-text {
    height: 1em;
    min-width: 40%;
}

.skeleton-text.short { min-width: 20%; }
.skeleton-text.long { min-width: 75%; }

.skeleton-block {
    height: 48px;
    width: 100%;
}

.skeleton-block.sm { height: 32px; }
.skeleton-block.lg { height: 80px; }
.skeleton-block.xl { height: 120px; }

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-app-bar {
    height: 52px;
    width: 100%;
}

.skeleton-library-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-library-item .skeleton-circle {
    flex-shrink: 0;
}

.skeleton-library-item .skeleton-text {
    flex: 1;
}

.skeleton-viewer-placeholder {
    width: 100%;
    height: 100%;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.skeleton-score-page {
    aspect-ratio: 8.5 / 11;
    width: auto;
    height: 80%;
    max-height: 85vh;
    min-height: 200px;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
}

.score-viewer {
    position: relative;
}

.score-viewer-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.score-viewer-skeleton .skeleton-viewer-placeholder {
    min-height: 200px;
}

.app-loading-overlay.skeleton-overlay {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.app-loading-overlay.skeleton-overlay .app-loading-skeleton {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.app-loading-overlay.skeleton-overlay .skeleton-toolbar {
    height: 52px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.skeleton-toolbar-left,
.skeleton-toolbar-center,
.skeleton-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.skeleton-toolbar-center {
    justify-content: center;
    gap: 6px;
}

.skeleton-toolbar-right {
    justify-content: flex-end;
}

.skeleton-btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
}

.skeleton-btn-icon.sm {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.skeleton-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color-strong);
    opacity: 0.6;
    flex-shrink: 0;
    margin: 0 8px;
}

.app-loading-overlay.skeleton-overlay .skeleton-main {
    flex: 1;
    display: flex;
    min-height: 0;
}

.app-loading-overlay.skeleton-overlay .skeleton-sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.app-loading-overlay.skeleton-overlay .skeleton-library-sidebar {
    width: 340px;
    padding: 0;
    gap: 0;
}

.skeleton-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-library-actions {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.skeleton-library-list {
    flex: 1;
    padding: 8px;
    overflow: hidden;
}

.skeleton-library-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.skeleton-drag-dots {
    width: 12px;
    height: 14px;
    flex-shrink: 0;
    border-radius: 2px;
}

.skeleton-library-item-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.app-loading-overlay.skeleton-overlay .skeleton-library-sidebar .skeleton-library-item {
    border-bottom: none;
    padding: 12px 16px;
    border-radius: var(--radius-md);
}

.app-loading-overlay.skeleton-overlay .skeleton-content {
    flex: 1;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toolbar Dropdown (for edit measures) */
.toolbar-dropdown {
    position: relative;
    display: inline-flex;
}

.toolbar-dropdown .btn-icon.active {
    background: var(--accent);
    color: white;
}

.dropdown-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.dropdown-item:disabled svg,
.dropdown-item:disabled span {
    color: var(--text-secondary);
}

/* ========== DROPDOWN MENU — Glass morphism with smooth animations ========== */
.dropdown-menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    background: var(--bg-glass-thick);
    backdrop-filter: blur(var(--blur-md));
    -webkit-backdrop-filter: blur(var(--blur-md));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 240px;
    z-index: var(--z-dropdown);
    overflow: hidden;
    border: 1px solid var(--border-color);
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top right;
    transition: all var(--dur-normal) var(--ease-apple);
    pointer-events: none;
}

.dropdown-menu.show,
.dropdown-menu:not([style*="display: none"]) {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.dropdown-header {
    padding: var(--space-3) var(--space-4);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-glass);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-smooth);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
    position: relative;
}

.dropdown-item::before {
    content: '';
    position: absolute;
    left: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: height var(--dur-fast) var(--ease-spring);
}

.dropdown-item:hover {
    background: var(--accent-subtle);
    color: var(--accent);
}

.dropdown-item:hover::before {
    height: 50%;
}

.dropdown-item:active {
    background: var(--accent-subtle-hover);
}

.dropdown-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.dropdown-item.active::before {
    height: 50%;
}

.dropdown-item svg {
    flex-shrink: 0;
    transition: transform var(--dur-fast) var(--ease-smooth);
}

.dropdown-item:hover svg {
    transform: scale(1.1);
}

.dropdown-item span {
    flex: 1;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-1) 0;
}

.dropdown-info {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.measure-overlay {
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
}

.measure-overlay g {
    pointer-events: all;
}

.score-page {
    position: relative;
}

/* Scrollbar Styling */
.library-list::-webkit-scrollbar,
.score-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.library-list::-webkit-scrollbar-track,
.score-container::-webkit-scrollbar-track {
    background: transparent;
}

.library-list::-webkit-scrollbar-thumb,
.score-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.library-list::-webkit-scrollbar-thumb:hover,
.score-container::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.score-container::-webkit-scrollbar:horizontal {
    height: 0;
    display: none;
}

/* Processed Score Badge and Label */
.processed-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #34c759;
    color: white;
    flex-shrink: 0;
    margin-left: 6px;
    vertical-align: middle;
}

.processed-badge svg {
    width: 10px;
    height: 10px;
}

.library-item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
}

.library-item-meta > span {
    white-space: nowrap;
    flex-shrink: 0;
}

.processed-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(52, 199, 89, 0.1);
    color: #34c759;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.editable-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ========== PAGE EDITOR MODAL ========== */
.page-editor-modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

.page-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.page-editor-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-editor-header h3 svg {
    color: var(--accent-primary);
}

.page-editor-info {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-editor-score-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.page-editor-stats {
    font-size: 13px;
    color: var(--text-secondary);
}

.page-editor-stats span {
    color: var(--accent-primary);
    font-weight: 600;
}

.page-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.page-editor-toolbar .btn-small {
    padding: 6px 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-editor-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 8px;
}

.page-editor-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: auto;
}

.page-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 300px;
    max-height: 50vh;
}

.page-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.page-editor-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
}

.page-editor-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.page-editor-item.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.page-editor-item.excluded {
    opacity: 0.5;
    border-color: var(--text-tertiary);
}

.page-editor-item.excluded .page-editor-thumbnail {
    filter: grayscale(100%);
}

.page-editor-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: var(--bg-secondary);
    transition: filter 0.2s ease;
}

.page-editor-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-editor-item:hover .page-editor-item-overlay {
    opacity: 1;
}

.page-editor-item.excluded .page-editor-item-overlay {
    opacity: 1;
    background: rgba(0, 0, 0, 0.6);
}

.page-editor-check {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transform: scale(0);
    transition: transform 0.2s ease;
}

.page-editor-item.selected .page-editor-check {
    transform: scale(1);
}

.page-editor-exclude-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    display: none;
}

.page-editor-item.excluded .page-editor-exclude-icon {
    display: flex;
}

.page-editor-item.excluded .page-editor-check {
    display: none;
}

.page-editor-item-footer {
    padding: 8px 10px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-editor-page-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-editor-status {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.page-editor-item.selected .page-editor-status {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

.page-editor-item.excluded .page-editor-status {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.page-editor-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.page-editor-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.page-editor-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.page-editor-loading p {
    font-size: 14px;
}

/* Edit Pages button in library */
.edit-pages-btn {
    color: var(--accent-cyan) !important;
}

.edit-pages-btn:hover {
    background: rgba(6, 182, 212, 0.1) !important;
}

/* Pages selection indicator in library */
.pages-selection-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: help;
}

.score-id-display {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.editable-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.mask-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive adjustments for desktop focus */
@media (max-width: 1024px) {
    .library-sidebar {
        position: absolute;
        height: 100%;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
}
