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

/* ========================================
   OFFLINE FONTS
   ======================================== */

@font-face {
    font-family: "JetBrains Mono";
    src: url("/webfonts/JetBrainsMono-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("/webfonts/JetBrainsMono-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("/webfonts/JetBrainsMono-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("/webfonts/JetBrainsMono-Italic.woff2") format("woff2");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}








:root {
    /* scroll-behavior: smooth;  <-- REMOVED to prevent scroll-fighting during drag interactions */
    /* Colors */
    --bg-primary: #fdfdfd;
    --bg-secondary: #f4f4f5;
    --bg-tertiary: #e9e9ed;
    --bg-hover: #e0e0e6;
    --text-primary: #333333;
    --text-secondary: #777777;
    --border-color: #e0e0e0;
    --accent-color: #3B82F6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.08);
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --danger-shadow: rgba(239, 68, 68, 0.2);
    --success-color: #81c784;
    --warning-color: #f59e0b;
    --warning-light: #ffd54f;
    --btn-dark: #1a1a1a;
    --btn-dark-hover: #333333;
    --gray-300: #bdbdbd;
    --gray-400: #9e9e9e;

    /* Typography - Font Families */
    --font-sans: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Source Code Pro", monospace;

    /* Typography - Font Weights */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;


    /* Typography - Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
}

/* ========================================
   BUTTONS - Standardized Components
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 0.5rem;
    text-decoration: none;
    line-height: normal;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* Base subtle shadow */
}

/* TACTILE FEEDBACK - Universal Press State */
/* Target all container-level interactive items. 
   We Avoid classes like .btn-text or .label to prevent "double scaling" (dilation) of text. */
button:active,
.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-danger:active,
.btn-success:active,
.btn-outline:active,
.btn-accent:active,
.nav-link:active,
.nav-item:active,
.sidebar-footer a:active,
.sidebar-footer button:active,
.sheet-option:active,
.icon-only-btn:active,
.sabo-input-modal-submit:active,
.sabo-input-modal-cancel:active,
.sabo-input-modal-close:active,
.action-sheet-close:active,
.section-action-btn:active,
.deck-card:active,
.deck-item:active,
.recent-deck-card:active,
.note-item:active,
.recent-note-card:active,
.recent-card:active,
.recent-card-empty:active,
.doc-card:active,
.folder-card:active,
.folder-header:active,
.mobile-action-btn:active,
.mobile-menu-btn:active,
.view-mode-btn:active,
.clickable:active,
.activity-filter:active,
.search-result-item:active,
.sidebar-search-item:active,
.sidebar-search-more:active,
.file-item:active,
.close-btn:active,
.toolbar-btn:active,
.icon-btn:active,
.back-link-btn:active,
[role="button"]:active {
    transform: none !important;
}

/* Prevent row shrink when clicking checkboxes */
.checkbox-wrapper:active {
    transform: translateY(-50%) !important;
}

.note-table-row:has(.checkbox-wrapper:active) {
    transform: none !important;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    border-color: transparent;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.btn-primary:active {
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: #c0c0c0;
    /* Strengthened outline */
    font-weight: 600;
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-secondary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.btn-secondary:active {
    box-shadow: none;
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-color: transparent;
}


.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
    border-color: transparent;
}

.btn-success:hover {
    filter: brightness(0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

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



/* ========================================
   SMOOTH SCROLL - Buttery navigation
   ======================================== */
html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bright, #fff);
    color: var(--text-primary);
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    /* Disable double-tap zoom on mobile but allow pinch */
    touch-action: manipulation;
    /* Disable pull-to-refresh on all pages */
    overscroll-behavior-y: none;
}

/* Standalone pages must use normal document scroll (not app-shell body locking).
   When html keeps default overflow:visible, body's overflow propagates to the
   viewport per CSS spec — giving us a single scroll container with no
   overscroll-behavior-y:none chaining issues. */
body:has(.search-page-container),
body:has(.about-container),
body:has(.legal-container) {
    display: block !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    min-height: 100% !important;
    touch-action: auto !important;
    overscroll-behavior-y: auto !important;
}

/* Global anti-selection for interactive elements */
button,
.btn,
.folder-menu-item,
.nav-item,
.clickable,
.note-table-row,
.folder-card,
.deck-card,
[role="button"] {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Global Transitions */
button,
.btn,
.nav-link,
.card,
.deck-card,
.deck-item,
.folder-card,
.folder-header,
.note-item,
.note-table-row,
.recent-card,
.recent-deck-card,
.doc-card,
.clickable,
input,
select,
textarea {
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

/* Ensure inputs remain selectable */
input,
textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Consistent Focus States */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.14);
}

/* ========================================
   PAGE TRANSITIONS - Native-feeling navigation
   ======================================== */

/* Fade in on page load */
.main {
    animation: pageEnter 0.25s ease-out;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered Entry Utility */
.stagger-item {
    opacity: 0;
    animation: staggerEnter 0.4s ease-out forwards;
}

@keyframes staggerEnter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stagger-1 {
    animation-delay: 50ms;
}

.stagger-2 {
    animation-delay: 100ms;
}

.stagger-3 {
    animation-delay: 150ms;
}

.stagger-4 {
    animation-delay: 200ms;
}

.stagger-5 {
    animation-delay: 250ms;
}

.stagger-6 {
    animation-delay: 300ms;
}

.stagger-7 {
    animation-delay: 350ms;
}

.stagger-8 {
    animation-delay: 400ms;
}

.stagger-9 {
    animation-delay: 450ms;
}

.stagger-10 {
    animation-delay: 500ms;
}

/* Fade out before navigation */
body.page-transitioning .main {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.15s ease-in, transform 0.15s ease-in;
}

/* Keep sidebar stable during transitions */
body.page-transitioning .sidebar {
    transition: none;
}

/* ========================================
   CONTENT SWITCHING - Note/Deck transitions
   ======================================== */

/* Editor and preview content should transition smoothly */
.editor-container,
.preview,
.editor textarea {
    transition: opacity 0.12s ease;
}

/* Ensure Editor has matching bottom padding */
.editor textarea {
    padding-bottom: 72px;
    /* ~3/4 inch */
    scroll-padding-bottom: 72px;
    /* Keep cursor above this zone */
}

/* Utility class for JS to trigger content fade */
.content-switching {
    opacity: 0.3;
    pointer-events: none;
}

/* Quick fade animation for content changes */
@keyframes contentFadeIn {
    from {
        opacity: 0.5;
    }

    to {
        opacity: 1;
    }
}

.content-refreshed {
    animation: contentFadeIn 0.15s ease-out;
}

.container {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
    margin-left: 250px;
    transition: margin-left 0.2s ease;
}

@media (max-width: 800px) {
    .container {
        margin-left: 0 !important;
    }
}

.container.sidebar-collapsed {
    margin-left: 0 !important;
}

.container.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

/* Sidebar Styles */
.sidebar {
    width: 250px;
    flex: none;
    height: 100vh;
    /* Use dvh for mobile browsers */
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2001;
    /* CRITICAL: Must be above EVERYTHING on mobile */
    background-color: #ffffff;
    border-right: 1px solid var(--border-color);
    /* Add safe-area padding */
    padding: 10px 10px max(10px, env(safe-area-inset-bottom)) 10px;
    box-sizing: border-box;
    /* allow overflow for search popup */
    overflow: visible;
    user-select: none;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
    /* GPU acceleration for slide animations */
    will-change: transform;
    backface-visibility: hidden;
    contain: layout style paint;
    /* Isolate repaints for better performance */
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 0 0 10px;
    margin-top: 12px;
}

.dashboard-header {
    margin-bottom: 30px;
    padding-left: 8px;
    /* Scoot greetings */
}

/* Sidebar Search */
.sidebar-search {
    padding: 0;
    margin-bottom: 16px;
}

.sidebar-search-input {
    width: 100%;
    height: 42px;
    /* Exact match to .nav-link */
    padding: 0 12px 0 42px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
    font-size: 15px;
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    transition: all 0.15s;
    box-sizing: border-box;
}

.sidebar-search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.14);
}

.sidebar-search-input::placeholder {
    color: var(--text-secondary);
}

.sidebar-search-wrapper {
    position: relative;
}

.sidebar-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0.7;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.sabo-logo-wordmark {
    width: 170px;
    height: 48px;
    -webkit-mask: url('/assets/img/sabo_logo.png') no-repeat left center/contain;
    mask: url('/assets/img/sabo_logo.png') no-repeat left center/contain;
    background-color: #3b82f6;
    margin-left: -4px;
}

.app-icon {
    width: 32px;
    height: 32px;
    background-color: var(--accent-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.app-name {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin-top: 6px;
}

/* Sidebar Lists & Labels */
.sidebar-section-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 8px;
    margin-bottom: 8px;
    margin-top: 16px;
}

.sidebar-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 24px 12px 8px 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-section-actions {
    display: flex;
    gap: 4px;
}

.sidebar-section-actions button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 24px;
    height: 24px;
}

.sidebar-section-actions button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}


.sidebar-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 16px 8px;
}

/* Sidebar Footer (User) */


.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: 2px solid var(--gray-300);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.user-avatar i {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin: 0 !important;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    padding-left: 6px;
}

.user-plan {
    font-size: 0.65rem;
    background: #FEF3C7;
    color: #92400E;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    width: fit-content;
    margin-top: 2px;
}

.footer-actions {
    display: flex;
    gap: 4px;
}

.icon-only-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.icon-only-btn i {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin: 0 !important;
}

.icon-only-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.icon-only-btn:active {
    transform: none;
}

.sidebar .search-container {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.sidebar input#searchNotes {
    width: 100%;
    padding: 8px 8px 8px 30px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    box-sizing: border-box;
    height: 38px;
}

.sidebar .search-container .fa-magnifying-glass {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}


#sidebarDeckList {
    flex: 1;
    overflow-y: auto;
    margin: 1rem 0;
    padding-right: 4px;
}

.sidebar-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

#sortBtn {
    padding: 8px 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    height: 38px;
    width: 40px;
}

/* Main Area Styles */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    position: relative;
    /* Added for absolute positioning of children if needed */
    height: 100vh;
    height: 100dvh;
    /* Match sidebar height */
}

/* --- SIDEBAR PIXEL-PERFECT RESET --- */

/* Navigation Links Container */
.nav-links {
    margin-top: 12px;
    padding-top: 0;
    border-top: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Reset inherited styles */
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
    box-sizing: border-box;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    /* Below sidebar (2001) but above everything else */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* Critical for iOS: use display:none to fully remove from touch path */
    display: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}


/* Footer Container */
.sidebar-footer {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    /* Break out of sidebar padding for full-width border */
    margin-left: -10px;
    margin-right: -10px;
    margin-bottom: 0;
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 0px;
    box-sizing: border-box;
}

/* Shared Item Styles (Reset everything) */
.nav-link,
.sidebar-footer a,
.sidebar-footer button {
    /* Box Model */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    width: 100%;
    height: 42px;
    /* Slightly taller for better touch targets */
    padding: 0 12px;
    /* More horizontal padding */
    margin: 0;
    border: none;
    border-radius: 8px;
    /* Rounded corners */
    outline: none;

    /* Typography */
    font-family: inherit;
    /* Inherits Poppins */
    font-size: 15px;
    /* Slightly smaller for refinement */
    font-weight: var(--font-weight-medium);
    /* Constant weight */
    line-height: 1;
    /* normalize line height */
    text-align: left;
    text-decoration: none;
    color: var(--text-secondary);

    /* Background */
    background: transparent;
    cursor: pointer;
    /* Enhanced transitions for smooth app switching */
    transition: background-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

/* Icon Styles */
.nav-link i {
    width: 22px;
    /* Fixed icon container width */
    text-align: center;
    margin-right: 12px;
    /* Fixed gap */
    font-size: 18px;
    /* Icon size */
    display: inline-block;
    color: var(--text-secondary);
    /* Smooth icon color transition */
    transition: color 0.12s ease;
}

.sidebar-footer i {
    font-size: 18px;
    color: var(--text-secondary);
    transition: color 0.12s ease;
}

/* Hover States */
.nav-link:hover,
.sidebar-footer a:hover,
.sidebar-footer button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link:hover i,
.sidebar-footer a:hover i,
.sidebar-footer button:hover i {
    color: var(--text-primary);
}

/* Press State - tactile feedback handled globally */

/* Active State - Modern with ring */
.nav-link.active {
    background-color: var(--accent-light, #eff6ff);
    color: var(--accent-color);
    font-weight: var(--font-weight-semibold);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.nav-link.active i {
    color: var(--accent-color);
}

/* About Modal Styles */
/* About Modal Styles */
#aboutModal .modal-content {
    background-color: var(--bg-primary);
    margin: auto;
    padding: 0;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease;
    overflow: hidden;
}

#sabo-settings-modal .settings-modal-content {
    background-color: var(--bg-primary);
    margin: auto;
    padding: 0;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 400px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: none;
    overflow: hidden;
}

.settings-modal-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Preview Pane */
/* Editor Pane */
#noteContent {
    background: var(--bright, #fff);
    border: none;
    outline: none;
    resize: none;
    width: 100%;
    height: 100%;
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    box-sizing: border-box;

    /* Padding 20px (User Request) */
    /* Padding 20px (User Request) */
    padding: 20px;
    /* Reset base padding */
    box-sizing: border-box;
    /* Ensure padding doesn't break width */
    overscroll-behavior: none;
    /* Prevent scroll chaining to parent */
    /* Sufficient overscroll but not 50vh which causes issues */
    scroll-padding-bottom: 100px;
    padding-bottom: 40vh;
    /* Massive padding to allow scrolling text to vertical center */
}

/* Preview Pane */
/* Preview Pane */
#preview {
    flex: 1;
    overflow-y: auto;
    contain: content;
    /* Padding Reverted */
    padding: 4px 20px 20px;
    /* Define "safe area" for auto-scroll so elements don't snap to the absolute edge */
    scroll-padding-block: 100px;
    /* Reduced from 50vh to prevent browser over-scrolling during selection */
    /* Allow scrolling past the last line for comfortable editing */
    padding-bottom: 100px;

    /* Hide Scrollbar */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */

    /* Full page feel */
    background-color: var(--bright, #fff);
    /* Ensure white background */
    width: 100%;
}

#preview::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.preview-content {
    max-width: 800px;
    margin-inline: auto;
    width: 100%;
    /* Ensure long words/math don't break layout */
    overflow-wrap: break-word;
    word-wrap: break-word;
    /* Resolution for Issue #128: Stabilize selection */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    /* overflow-x: auto; */
    /* Let parent handle scroll or inner elements handle it */
}

[data-source-line] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

#aboutModal h3,
#sabo-settings-modal h3 {
    margin: 0;
    font-size: var(--text-xl);
    color: var(--text-primary);
    font-weight: 600;
}

#sabo-settings-modal .settings-modal-header {
    padding: 15px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-primary);
    border-radius: 8px 8px 0 0;
}

#sabo-settings-modal .settings-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#sabo-settings-modal label {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

#sabo-settings-modal .settings-desc {
    margin: 0 0 5px 0;
    font-size: 0.9em;
    color: var(--text-secondary);
}

#sabo-settings-modal input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    box-sizing: border-box;
}

#sabo-settings-modal input:focus {
    box-shadow: none;
    border-color: var(--accent-color);
}

#sabo-settings-modal .settings-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: var(--bg-secondary);
}

/* Modal Overlay (Shared) */
.modal,
#sabo-settings-modal {
    display: none;
    position: fixed;
    z-index: 9999 !important;
    /* Must be higher than sidebar (2001) to cover entire page */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s;
}

.modal.show {
    opacity: 1 !important;
    visibility: visible !important;
}


/* Modal content slide-in */
.modal-content,
.settings-modal-content {

    /* GPU acceleration for smooth modal animations */
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Close Button (Shared) */
.close,
.close-btn {
    color: var(--text-secondary);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.close:hover,
.close-btn:hover {
    color: var(--text-primary);
}

/* Shared modal header: title left, close button right */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.modal-header h3 {
    margin: 0;
    flex: 1;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i {
    vertical-align: middle;
    margin-right: 8px;
}

.modal-header .close,
.modal-header .close-btn {
    flex-shrink: 0;
    line-height: 1;
    font-size: 1.9rem;
}

/* Button Styles for Modals */
.btn-primary {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.btn-primary:active {
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}



@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Button Danger */
.btn-danger {
    background-color: var(--danger-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    box-shadow: 0 2px 8px rgba(239, 83, 80, 0.2);
}

.btn-danger:active {
    box-shadow: none;
}

/* Section Action Buttons (Create Deck/Folder) */
.section-action-btn,
.section-action-btn .btn-text {
    font-weight: 600;
}

/* ========================================
   FOCUS GLOW - Accessibility + Polish
   ======================================== */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    box-shadow: none;
    border-color: var(--text-secondary) !important;
}

button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* All buttons get smooth transitions */
.btn,
.btn-primary,
.btn-secondary,
.btn-danger {
    transition: all 0.15s ease;
}

/* Input Modal (Shared) */
.sabo-input-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sabo-input-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);

}

.sabo-input-modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: 8px;
    width: min(380px, 90vw);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);

    overflow: hidden;
}

.sabo-input-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px 0 24px;
    background: var(--bg-primary);
    border-bottom: none;
}

.sabo-input-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sabo-input-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.sabo-input-modal-close:hover {
    color: var(--text-primary);
}

.sabo-input-modal-body {
    padding: 10px 24px;
}

.sabo-input-modal-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-sizing: border-box;
    font-family: inherit;
}

.sabo-input-modal-input:focus {
    outline: none;
    border-color: var(--text-secondary);
    box-shadow: none;
}

.sabo-input-modal-footer {
    display: flex;
    gap: 10px;
    padding: 0 24px 12px 24px;
    background: var(--bg-primary);
    border-top: none;
    justify-content: flex-end;
}

.sabo-input-modal-cancel {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
}

.sabo-input-modal-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sabo-input-modal-submit {
    padding: 6px 20px;
    border: none;
    background: var(--accent-color);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
}

.sabo-input-modal-submit:hover {
    background: var(--accent-hover);
}

/* Toast Notification (Shared) */
#sabo-toast-container {
    position: fixed;
    bottom: 50px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: max-content;
    max-width: 90vw;
    z-index: 20000;
    /* Higher than modal */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

/* Center toast relative to main screen to align with modals */
@media (min-width: 991px) {
    #sabo-toast-container {
        left: 0;
        /* Align with global viewport */
    }
}

.sabo-toast {
    padding: 12px 20px;
    background-color: var(--text-primary);
    color: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: var(--text-sm);
    pointer-events: auto;
    font-weight: 600;
    text-align: center;
}

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

/* Mobile-specific toast adjustments */
@media (max-width: 768px) {
    #sabo-toast-container {
        bottom: 24px;
    }

    .sabo-toast {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}

.sabo-with-sidebar {
    padding-left: 250px;
    box-sizing: border-box;
}

/* --- Pane Slide Animation --- */
#editorPane,
#preview {
    transition: transform 0.2s ease, opacity 0.2s ease, flex 0.2s ease;
}

#preview {
    overflow-y: auto;
    overflow-x: hidden;
}

#editorPane.pane-hidden {
    /* transform: translateX(-100%); <-- Removed, handled by flex */
    opacity: 0;
    flex: 0 0 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    pointer-events: none;
    /* display: none !important; <-- Removed for animation */
    overflow: hidden;
}

#preview.pane-hidden {
    /* transform: translateX(100%); <-- Removed, handled by flex */
    opacity: 0;
    flex: 0 0 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    pointer-events: none;
    /* display: none !important; <-- Removed for animation */
    overflow: hidden;
}

/* --- Mobile Sidebar Styles --- */
@media (max-width: 990px) {

    /* Hide sidebar by default */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out, visibility 0.3s step-end;
        width: 280px;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
        z-index: 2600;
        /* ABOVE overlay (z-2500) */
        visibility: hidden;
        /* Prevent touch events when hidden */
    }

    /* Show sidebar when active */
    /* Show sidebar when active - specific to override .container.sidebar-collapsed .sidebar */
    .container .sidebar.mobile-visible,
    .sidebar.mobile-visible {
        transform: translateX(0) !important;
        visibility: visible !important;
        transition: transform 0.3s ease-in-out, visibility 0s;
    }

    /* Reset content margin/padding */
    .container,
    .sabo-with-sidebar {
        margin-left: 0 !important;
        padding-left: 0 !important;
        transition: margin-left 0.3s ease-in-out, padding-left 0.3s ease-in-out;
    }

    /* Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 2500;
        /* Ensure overlay is above everything on mobile */
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        /* Critical for iOS: use display:none to fully remove from touch path */
        display: none;
        transition: opacity 0.3s ease-in-out, visibility 0.3s;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.visible {
        display: block;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Ensure header/toolbar scrolls if needed */
    .toolbar,
    .header {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    /* Make note title input wider on mobile */
    .note-title-editor {
        min-width: 300px;
    }
}



/* ========================================
   CLS PREVENTION - Icon Sizing
   Reserve space for icons before Font Awesome loads
   ======================================== */
.fa-solid,
.fa-regular,
.fa-brands {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

/* Button icons need explicit minimum sizing */
button i.fa-solid,
button i.fa-regular,
button i.fa-brands,
.btn i {
    min-width: 16px;
    min-height: 16px;
}

/* Sidebar icons - already have width but ensure height */
.nav-link i,
.sidebar-footer i {
    height: 18px;
    line-height: 18px;
}

/* ========================================
   SKELETON LOADERS - Perceived Performance
   ======================================== */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-tertiary) 0%,
            var(--bg-hover) 50%,
            var(--bg-tertiary) 100%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-pulse {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Skeleton variants for different content types */
.skeleton-text {
    height: 1em;
    margin: 0.5em 0;
}

.skeleton-title {
    height: 2rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-card {
    height: 80px;
    margin-bottom: 1rem;
    border-radius: 16px;
}

.skeleton-button {
    height: 44px;
    width: 120px;
    border-radius: 4px;
}

/* Hide skeleton when content loads */
.skeleton-container:has(> :not(.skeleton):not(:empty)) .skeleton {
    display: none;
}

/* ========================================
   iOS MOBILE FIXES
   ======================================== */

/* Prevent iOS zoom on input focus (requires 16px+ font-size) */
@supports (-webkit-touch-callout: none) {

    input,
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Smooth momentum scrolling on iOS */


    /* Prevent rubber-band overscroll on iOS */
    html,
    body {
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix iOS keyboard pushing content */
    body {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }

    html {
        height: -webkit-fill-available;
    }
}

/* Ensure inputs are never too small on any mobile */
@media (max-width: 990px) {

    input,
    textarea,
    select {
        font-size: max(16px, 1em);
        /* Prevent iOS zoom */
    }

    /* Larger touch targets for mobile */
    button,
    .btn,
    .nav-link {
        min-height: 44px;
        /* Apple HIG minimum */
    }

    /* Exception for editor toolbar to prevent height jump */
    .editor-toolbar button {
        min-height: auto;
    }

    /* Prevent text selection on interactive elements */
    button,
    .btn,
    .nav-link,
    .note-item,
    .deck-item {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* ========================================
   MOBILE HEADER COMPONENT (Shared)
   ======================================== */

.mobile-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    width: 40px;
    height: 40px;
    padding: 0;
    aspect-ratio: 1;
}

.mobile-menu-btn i {
    font-size: 1.25rem;
}

.mobile-menu-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mobile-header h1 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.mobile-header .mobile-menu-btn {
    position: static;
    margin-right: 15px;
    width: auto;
    height: auto;
    padding: 5px;
}

/* ========================================
   FOLDER CARD COMPONENT (Shared)
   ======================================== */

.folder-card {
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: all 0.2s;
}

.folder-card-tab {
    display: none;
    /* Hide the old tab SVG */
}

.folder-card-body {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: white;
    /* Match deck items */
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    transition: all 0.15s ease;
    box-shadow: none;
    /* Removed strange shadow */
}

.folder-card:hover .folder-card-body {
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

/* Folder icon */
.folder-card-body::before {
    content: "";
    /* Font Awesome folder icon */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--folder-icon-color, #3b82f6);
    flex-shrink: 0;
    /* Icon container background styling */
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background-color: var(--folder-bg-color, #dbeafe);
    /* Default to blue tint 100 */
    transition: background-color 0.15s ease;
}

.folder-card:hover .folder-card-body::before {
    background-color: transparent;
}

.folder-card-header {
    flex: 1;
    min-width: 0;
}

.folder-card-name {
    margin: 0 0 2px 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.folder-card-stats {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    font-weight: 600;
}

/* Modern Color Palette v163 */
.folder-card.color-blue {
    --folder-icon-color: #3b82f6;
    --folder-bg-color: #eff6ff;
}

.folder-card.color-violet,
.folder-card.color-purple {
    --folder-icon-color: #8B5CF6;
    --folder-bg-color: #f5f3ff;
}

.folder-card.color-teal,
.folder-card.color-emerald {
    --folder-icon-color: #10B981;
    --folder-bg-color: #ecfdf5;
}

.folder-card.color-amber,
.folder-card.color-yellow {
    --folder-icon-color: #F59E0B;
    --folder-bg-color: #fffbeb;
}

.folder-card.color-rose,
.folder-card.color-coral {
    --folder-icon-color: #F43F5E;
    --folder-bg-color: #fff1f2;
}

.folder-card.color-slate,
.folder-card.color-gray {
    --folder-icon-color: #64748B;
    --folder-bg-color: #f8fafc;
}

.folder-card.color-fuchsia,
.folder-card.color-pink {
    --folder-icon-color: #D946EF;
    --folder-bg-color: #fdf4ff;
}

.folder-card.color-cyan,
.folder-card.color-sky {
    --folder-icon-color: #06B6D4;
    --folder-bg-color: #ecfeff;
}

.folder-card.color-black {
    --folder-icon-color: #1e293b;
    --folder-bg-color: #f1f5f9;
}

/* Folders grid (Consolidated) */
.folders-grid {
    display: grid;
    /* Smart responsive grid - proportional folders */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 0.25rem;
    padding: 5px;
    box-sizing: border-box;
}

/* ========================================
   SIDEBAR SEARCH (Shared)
   ======================================== */

.sidebar-search {
    position: relative;
    /* Ensure dropdown positions relative to this */
    z-index: 100;
    margin-top: 24px;
    margin-bottom: 16px;
}

.sidebar-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 300px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 400px;
    overflow-y: auto;
    z-index: 3000;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-search-results.hidden {
    display: none;
}

.sidebar-search-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.sidebar-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s;
    cursor: pointer;
}

.sidebar-search-item:hover,
.sidebar-search-item.selected {
    background: var(--bg-hover);
}

.sidebar-search-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.sidebar-search-item-icon.note {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.sidebar-search-item-icon.deck {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.sidebar-search-item-icon.document {
    background: rgba(244, 63, 94, 0.1);
    color: #F43F5E;
}

.sidebar-search-item-content {
    flex: 1;
    min-width: 0;
}

.sidebar-search-item-title {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.sidebar-search-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
    font-weight: 600;
}

.sidebar-search-more {
    display: flex;
    padding: 8px 16px;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.sidebar-search-more:hover {
    background: var(--bg-hover);
}

/* Shared Context Menu Styles */
.folder-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    min-width: 180px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
    transform-origin: top right;
    z-index: 10000;
}

.folder-menu-dropdown.hidden {
    display: none;
}

.folder-menu-item {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
}

/* .folder-menu-item:first-child removed to rely on container overflow: hidden */

.folder-menu-item:hover {
    background: var(--bg-tertiary);
}

.folder-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    color: var(--text-tertiary);
}

.folder-menu-item.delete {
    color: var(--danger-color);
}

.folder-menu-item.delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

.folder-menu-item.delete i {
    color: var(--danger-color);
}

/* Toolbar Title Editor */
.note-title-editor {
    flex-grow: 1;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 4px 8px;
    margin: 0 8px;
    outline: none;
    transition: all 0.2s ease;
    min-width: 0;
    max-width: 500px;
}

.note-title-editor:hover {
    background: transparent;
    border: 1px solid var(--border-color);
}

.note-title-editor:focus {
    background: transparent;
    border-color: var(--border-color);
}

/* Magic Deck Button (Icon Stack) */
.magic-deck-btn .icon-stack {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.magic-deck-btn .overlay-sparkle {
    font-size: 0.6em;
    position: absolute;
    bottom: -4px;
    right: -4px;
    color: var(--accent-light);
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
    animation: pulse-sparkle 2s infinite ease-in-out;
}

@keyframes pulse-sparkle {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
    }


    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

#selectionFloatingBtn {
    width: 32px !important;
    height: 32px !important;
    min-width: unset !important;
    padding: 4px !important;
    display: none;
    /* hidden by default, shown via inline-flex */
    align-items: center;
    justify-content: center;
}

/* Format Toolbar (Second Row) */
#formatToolbar {
    width: 100%;
    background: var(--bg-secondary);
    /* Light gray as requested */
    border-bottom: 1px solid var(--border-color);
    padding: 4px 12px;
    min-height: 40px;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    /* Premium Animation */
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 50px;
    opacity: 1;
    transform: translateY(0);
    transform: translateY(0);
    /* Mobile Scroll Fix */
    overflow-y: hidden;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Needed for max-height animation */
}

#formatToolbar::-webkit-scrollbar {
    display: none;
}

#formatToolbar.hidden {
    /* display: none !important;  <-- Removed for animation */
    max-height: 0;
    min-height: 0;
    /* Fixes gap issue */
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    border-bottom-width: 0;
    pointer-events: none;
    visibility: hidden;
    /* Double safety */
    transform: translateY(-10px);
}

/* Toggle Buttons (Sidebar & Format Bar) */
#toggleFormatBarBtn,
#toggleAutoScrollBtn,
#toggleSidebarBtn {
    height: 32px;
    width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

#toggleFormatBarBtn:hover,
#toggleAutoScrollBtn:hover,
#toggleSidebarBtn:hover {
    background-color: var(--bg-hover);
}

#toggleFormatBarBtn.active,
#toggleAutoScrollBtn.active,
#toggleSidebarBtn.active {
    background: var(--bg-tertiary);
}

/* Force Toolbar White Background */
.toolbar {
    background-color: var(--bg-primary) !important;
}

/* Force Seamless White Background */
.main,
.editor-container,
#editorPane {
    background-color: var(--bg-primary) !important;
    border-left: none !important;
}

#preview {
    background-color: var(--bright, #fff) !important;
    border-left: none !important;
}

/* Right-aligned toolbar actions */
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    /* Pushes to the right */
}

/* Compact Format Toolbar Buttons */
#formatToolbar button {
    padding: 4px 8px;
    height: 32px;
    /* Ensure buttons fit in compact bar */
}

/* ========================================
   DEBUG CONSOLE (Global)
   ======================================== */
.debug-history {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.debug-history.hidden {
    display: none;
}

.debug-history .debug-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

.debug-panel {
    position: relative;
    width: min(600px, 92vw);
    max-height: min(80vh, 640px);
    background: var(--bg-primary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    animation: modalSlideIn 0.2s ease-out;
}

.debug-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.debug-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.debug-header .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    border: none !important;
    background: transparent !important;
    color: var(--text-secondary);
    box-shadow: none !important;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.debug-header .icon-btn:hover {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

.debug-body {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.8rem;
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}

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

#sabo-settings-modal .settings-section {
    margin-bottom: 12px;
}

#sabo-settings-modal .settings-section.settings-section-compact {
    margin-bottom: 6px;
}

#sabo-settings-modal .settings-about-link {
    margin-top: 2px;
    margin-bottom: 0;
    text-align: center;
}

#sabo-settings-modal .settings-inline-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

#sabo-settings-modal .settings-inline-toggle-input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
    transform: none;
    flex-shrink: 0;
}

/* ========================================
   TABLE STYLES (Editor Preview)
   ======================================== */
.preview-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

/* Fix for empty cells being too small/hard to click */
.preview-content td:empty,
.preview-content th:empty {
    height: 2.5rem;
    /* Sufficient height for touch/click */
    min-width: 60px;
    background-color: rgba(0, 0, 0, 0.015);
    /* Subtle hint */
    cursor: text;
}

/* Tables inside blockquotes should have white background */
blockquote table,
.preview-content blockquote table {
    background-color: white;
}

/* ========================================
   DRAG & DROP - Unfolder Drop Zone
   ======================================== */
.section-header-left.drag-over-unfiled {
    background-color: rgba(37, 99, 235, 0.08);
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
    transition: all 0.15s ease;
    padding-right: 8px;
}

.section-header-left.drag-over-unfiled .section-title::after {
    content: "Move to Unfiled";
    display: inline-flex;
    align-items: center;
    margin-left: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(37, 99, 235, 0.24);
    background: rgba(37, 99, 235, 0.1);
    color: #1947a9;
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.2;
    vertical-align: middle;
}

/* ========================================
   SHORTCUTS MODAL (Shared)
   ======================================== */
.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.shortcut-keys kbd {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.9em;
    margin-left: 4px;
}

.shortcut-keys span {
    color: var(--text-secondary);
    margin: 0 4px;
}

/* Dashboard-specific countdown emphasis */
#event-countdown .countdown-number {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-right: 2px;
}

/* ========================================
   SHARED NOTES/DOCUMENTS RULES
   Auto-extracted from app CSS dedupe
   ======================================== */
:root {
    /* Flashcards specific variables */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(0, 0, 0, 0.08);
    --card-ratio: 1.6;
}



.notes-wrapper {
    align-items: stretch;
}

/* Notes/Documents library scroll container (desktop + mobile) */
#documents-app {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* Flashcards library/editor scroll container (desktop + mobile) */
#flashcards-app {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
}

#flashcards-app #library-deck-list,
#flashcards-app #deck-overview,
#flashcards-app #editor-section,
#flashcards-app .editor-card-list,
#flashcards-app .deck-item,
#flashcards-app .folder-card {
    touch-action: pan-y;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #333, #555);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    text-align: center;
}

.card {
    width: 100%;
    /* max-width: 800px; - Removed to allow wider layout */
    padding: 2rem;
    transition: transform 0.3s ease;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.folder-deck-grid.list-view {
    grid-template-columns: 1fr;
    gap: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    width: 100%;
}

.folder-deck-grid.list-view .deck-item {
    flex-direction: row;
    align-items: center;
    padding: 1.4rem 1.5rem 1.1rem;
    min-height: auto;
    gap: 1.5rem;
    /* Reduced from 3rem to give more space to progress bar */
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s, transform 0.2s;
    margin-bottom: 1.25rem !important;
    height: auto !important;
}

/* Keep Unfiled list cards aligned with folder-card outer radius */
.unfiled-section .folder-deck-grid.list-view .deck-item {
    border-radius: 8px;
}

.folder-deck-grid.list-view .deck-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.folder-deck-grid.list-view .deck-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
    min-width: 0;
}

.folder-deck-grid.list-view .deck-side-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-self: center;
    gap: 3rem;
    flex-shrink: 0;
    min-width: auto;
    /* Slight reduction to favor main content */
    justify-content: flex-end;
}

.folder-deck-grid.list-view .deck-name {
    font-size: 1.125rem;
    margin: 0;
    text-align: left;
}

.folder-deck-grid.list-view .deck-mastery {
    max-width: 100%;
    margin: 0;
    padding-right: 0;
}

.folder-deck-grid.list-view .deck-card-count {
    position: static;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    align-self: center;
    min-width: 70px;
    padding: 0 0.5rem 0 calc(0.5rem + 5px);
}

.folder-deck-grid.list-view .deck-item.document-item .deck-card-count {
    transform: translateY(0) !important;
}

#newDeckModal .btn-secondary {
    color: var(--text-secondary);
    font-weight: 600;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

#newDeckModal .btn-secondary:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--glass-border);
}

#newDeckModal .btn-secondary i {
    color: inherit;
    /* Ensure icon follows text color */
}

#newDeckModal .ai-gen-options,
#flashcardGenModal .ai-gen-options {
    margin-top: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--bg-primary);
}

#newDeckModal .ai-gen-options-heading,
#flashcardGenModal .ai-gen-options-heading {
    display: block;
    margin-top: 12px;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-primary);
}

#newDeckModal .ai-gen-options-title,
#flashcardGenModal .ai-gen-options-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-transform: none;
    letter-spacing: 0;
}

#newDeckModal .ai-gen-options-grid,
#flashcardGenModal .ai-gen-options-grid {
    display: grid;
    grid-template-columns: minmax(170px, max-content) 64px 64px;
    align-items: center;
    column-gap: 14px;
    justify-content: start;
    width: 100%;
}

#newDeckModal .ai-gen-options-grid-header+.ai-gen-options-grid,
#flashcardGenModal .ai-gen-options-grid-header+.ai-gen-options-grid {
    margin-top: 8px;
}

#newDeckModal .ai-gen-options-grid:not(.ai-gen-options-grid-header)+.ai-gen-options-grid,
#flashcardGenModal .ai-gen-options-grid:not(.ai-gen-options-grid-header)+.ai-gen-options-grid {
    margin-top: 10px;
}

#newDeckModal .ai-gen-options-grid-header,
#flashcardGenModal .ai-gen-options-grid-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

#newDeckModal .ai-gen-options-grid-header span:first-child,
#flashcardGenModal .ai-gen-options-grid-header span:first-child {
    text-align: left;
}

#newDeckModal .ai-gen-options-grid-header span:not(:first-child),
#flashcardGenModal .ai-gen-options-grid-header span:not(:first-child) {
    text-align: center;
}

#newDeckModal .ai-gen-options-label,
#flashcardGenModal .ai-gen-options-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
}

#newDeckModal .ai-gen-options-check,
#flashcardGenModal .ai-gen-options-check {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 26px;
    border-radius: 8px;
    cursor: pointer;
}

#newDeckModal .ai-gen-options-check input[type="checkbox"],
#flashcardGenModal .ai-gen-options-check input[type="checkbox"] {
    transform: scale(1.08);
    margin: 0;
}

#flashcardGenModal .ai-gen-options-heading {
    margin-bottom: 2px;
}

#flashcardGenModal .ai-gen-options {
    margin-top: 4px;
}

#newDeckModal #aiFrontPrompt,
#newDeckModal #aiBackPrompt,
#flashcardGenModal #fcGenPrompt {
    font-family: "SF Pro Text", "Avenir Next", "Helvetica Neue", "Segoe UI", Arial, sans-serif !important;
    line-height: 1.38;
}

#newDeckModal #aiFrontPrompt::placeholder,
#newDeckModal #aiBackPrompt::placeholder,
#flashcardGenModal #fcGenPrompt::placeholder {
    font-family: "SF Pro Text", "Avenir Next", "Helvetica Neue", "Segoe UI", Arial, sans-serif !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em;
    color: var(--text-secondary) !important;
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        /* Reduced gap between Title, Meta, Progress */
        padding: 1.5rem 1.5rem 1.25rem;
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-main-content {
        display: contents;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-name {
        order: 1;
        margin-bottom: 0;
        /* Remove extra margin, rely on parent gap */
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-side-content {
        order: 3;
        width: 100%;
        margin-top: 1rem;
        /* Add spacing from progress bar */
        display: flex;
        flex-direction: column;
        /* Stack items vertically if needed, or just let button fill */
        align-items: stretch;
        /* Full width button */
        padding: 0;
        border-top: none;
        min-width: 0;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-mastery {
        order: 2;
        max-width: none;
        width: 100%;
        margin-bottom: 0;
        margin-top: 1rem;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-side-content>div:not(:last-child)::after {
        display: none;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-card-count {
        display: none !important;
    }
}

@media (max-width: 710px) {
    .library-view-toggle {
        display: none !important;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid {
        display: flex !important;
        flex-direction: column !important;
    }
}

@media (max-width: 710px) {

    .folder-deck-grid.list-view .deck-card-count-number,
    .folder-deck-grid.list-view .deck-card-count-label,
    .folder-deck-grid.list-view .deck-meta-value {
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        color: var(--text-secondary) !important;
        line-height: 1 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: inline !important;
        vertical-align: middle !important;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-meta-item {
        display: inline-flex !important;
        flex-direction: row;
        align-items: center;
        vertical-align: middle;
        margin: 0 !important;
        padding: 0 !important;
    }
}

@media (max-width: 710px) {

    .folder-deck-grid.list-view .document-item .deck-meta-item,
    .folder-deck-grid.list-view .document-item .deck-card-count {
        display: inline-flex !important;
        /* Stack side by side */
        flex-direction: row !important;
        /* Force number and label side by side */
        align-items: center !important;
        gap: 0.3rem !important;
        /* Space between number and label */
        margin-bottom: 0 !important;
        padding: 0 !important;
        /* Remove the 13px left padding */
        color: var(--text-secondary);
        font-size: 0.85rem !important;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .document-item .deck-name {
        margin-bottom: 0.35rem !important;
        /* Add space between title and details */
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .document-item .deck-side-content {
        order: 2 !important;
        margin-top: 0 !important;
        margin-bottom: 0.5rem !important;
        flex-direction: row !important;
        /* Side by side */
        justify-content: flex-start !important;
        /* Left align */
        align-items: center !important;
        gap: 0 !important;
        /* Let bullets handle spacing */
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .document-item .deck-mastery {
        order: 3 !important;
        margin-top: 0 !important;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-item.document-item {
        padding-bottom: 1.2rem !important;
    }
}

@media (max-width: 710px) {
    .folder-deck-grid.list-view .deck-side-content>div:not(:last-child)::after {
        content: "•";
        margin: 0 0.5rem;
        color: var(--text-tertiary);
        opacity: 0.5;
        display: inline !important;
        vertical-align: middle !important;
        line-height: 1 !important;
        font-weight: 400 !important;
        /* Force normal weight */
        font-size: 0.8rem !important;
        /* Force consistent size */
        font-family: inherit !important;
    }
}

@media (max-width: 710px) {

    .folder-deck-grid.list-view .deck-card-count,
    .folder-deck-grid.list-view .deck-meta-item {
        font-weight: 400 !important;
        font-size: 0.8rem !important;
    }
}

@media (max-width: 710px) {
    .deck-grid.list-view .btn-study-outline {
        width: 100%;
    }
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    margin: 0 auto 2rem;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.score-circle .total {
    font-size: 1.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 5px;
}

.deck-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.instruction-panel {
    gap: 1rem;
    padding-top: 0;
}

.instruction-lede {
    color: var(--text-secondary);
    margin: 0;
}

.instruction-list {
    margin: 0;
    padding-left: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    color: var(--text-primary);
}

.instruction-list strong {
    color: var(--accent-color);
}

.instruction-list em {
    font-style: normal;
    color: inherit;
}

.instruction-footer {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

@media (max-width: 710px) {
    #library-section {
        padding-top: 0 !important;
    }
}

@media (max-width: 710px) {
    .instruction-panel {
        padding-top: 0 !important;
    }
}

@media (max-width: 710px) {
    .stat {
        padding: 0.5rem;
        /* Reduce padding to fit */
    }
}

@media (max-width: 710px) {
    .stat-label {
        font-size: 0.7rem;
        /* Smaller text */
        font-weight: 600;
    }
}

@media (max-width: 710px) {
    .stat-value {
        font-size: 1rem;
        line-height: 1.2;
    }
}

.folder-card-menu {
    border: none;
    background: transparent;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0;
    /* Hide by default */
    transition: all 0.2s ease;
}

.folder-card:hover .folder-card-menu,
.folder-card-menu.active,
.folder-card-menu:focus {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

.folder-menu-container {
    position: relative;
    z-index: 20;
    /* Ensure menu is above other things */
}

.folder-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    /* stronger shadow/outline effect */
    min-width: 180px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
    transform-origin: top right;
}

.stat {
    padding: 0.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: center;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0;
    margin-top: 1rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
}

.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);

    backdrop-filter: blur(2px);
    z-index: -1;
    /* Behind content but within modal container */
}

.settings-content {
    position: relative;
    width: min(320px, 90vw);
    background: var(--bg-primary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 0;
    /* Changed to allow full-width divider */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 10;
    display: flex;
    flex-direction: column;

    max-height: 85vh;
    height: auto;
    /* Ensure content clipping */
    clip-path: inset(0 round 16px);
    overflow: hidden;
    margin-bottom: 2rem;
    /* Add margin to lift it up */
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0;
    /* Prevent header from shrinking */
    z-index: 2;
}

.settings-body {
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
    /* Ensure bottom padding is visible when scrolled */
    padding-bottom: 2rem;
}

.settings-header .icon-btn {
    padding: 0;
    font-size: 1.6rem;
    background: none;
    border-radius: 0;
    width: 36px;
    height: 36px;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
}

.settings-header .icon-btn:hover {
    color: var(--text-primary);
    background: none;
}

.settings-header h3 {
    margin: 0;
    font-size: 1.4rem;
}

.settings-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Reduced to bring accordions closer */
    font-size: 0.9rem;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0;
}

.settings-group p {
    margin: 0.35rem 0 0.15rem 0;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.settings-group-inline label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    margin-top: 3rem;
    width: 100%;
}

.settings-action-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    /* Reduced gap from 0.5rem */
}

.settings-delete-btn {
    margin-top: 0.25rem;
    margin-bottom: 0;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(239, 83, 80, 0.5);
    color: var(--danger-color);
}

.btn-danger-outline:hover {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 83, 80, 0.2);
    border-color: var(--danger-color);
}

.settings-action-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.settings-action-group .btn {
    padding: 4px 8px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 4px;
}

.settings-content .btn {
    padding: 4px 8px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 4px;
    width: 180px;
    text-align: center;
}

.utility-action-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
}

.utility-action-group .btn {
    padding: 4px 8px;
    font-size: 0.8rem;
    text-align: center;
    border-radius: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.utility-action-group .btn:hover {
    background: var(--bg-tertiary);
}

.settings-accordion {
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    border-radius: 10px;
    /* overflow: hidden; Removed to allow focus rings/content to show */
    margin-bottom: 0.35rem;
    /* Reverted spacing between accordions */
    /* Add some spacing between accordions */
}

.settings-accordion-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    min-height: 40px;
    /* Ensure touch target size */
    background: var(--bg-secondary);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: background 0.2s;
    /* Ensure top corners are rounded if overflow: hidden fails */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border-bottom-left-radius: 8px;
    /* Default when closed */
    border-bottom-right-radius: 8px;
    /* Default when closed */
}

.settings-accordion-btn:hover {
    background: var(--bg-tertiary);
}

.settings-accordion-btn.active {
    background: var(--bg-tertiary);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.settings-accordion-btn .accordion-icon {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.settings-accordion-btn.active .accordion-icon {
    transform: rotate(180deg);
}

.settings-accordion-content {
    padding: 0.5rem 0.85rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--glass-border);
    overflow-y: visible;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.settings-accordion-content.hidden {
    display: none;
}

.debug-history {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 550;
}

.debug-history .debug-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.debug-panel {
    position: relative;
    width: min(600px, 92vw);
    max-height: min(80vh, 640px);
    background: var(--bg-primary);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.debug-header .icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.2rem;
    border: 1px solid var(--glass-border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: none;
}

.debug-body {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    font-family: "Fira Code", "Source Code Pro", monospace;
    font-size: 0.85rem;
    overflow: auto;
    flex: 1;
    min-height: 220px;
    white-space: pre-wrap;
    word-break: break-word;
}

.debug-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.debug-summary {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex: 1;
}

.debug-empty {
    margin: 0;
    padding: 1rem;
    text-align: center;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px dashed var(--glass-border);
    color: var(--text-secondary);
}

.deck-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.library-header-new {
    display: none;
    /* Show on desktop only */
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 1rem auto 0.75rem;
    /* Reduced from 1.5rem */
    max-width: 64rem;
    width: 100%;
    flex-wrap: wrap;
}

.library-header-new.no-folders {
    margin-top: 2rem;
    margin-bottom: 1.25rem;
    /* Reduced from 2.5rem */
}

@media (min-width: 991px) {
    .library-header-new {
        display: flex;
    }
}

.library-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.library-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    padding: 0.5rem 0 0.25rem 1px;
}

.library-actions {
    display: flex;
    gap: 12px;
    margin-left: 1.5rem;
    align-items: center;
    /* Ensure alignment */
}

.btn-primary-action,
.btn-secondary-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 36px;
    white-space: nowrap;
}

.btn-primary-action {
    background-color: var(--btn-dark);
    color: white;
    border: none;
}

.btn-primary-action:hover {
    background-color: var(--btn-dark-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary-action {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid #c0c0c0;
    /* Strengthened outline */
}

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

.library-header-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.85rem;
    background-color: rgba(37, 99, 235, 0.08);
    color: var(--accent-color);
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    height: 36px;
    box-sizing: border-box;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 0;
    /* Overrides global 44px on mobile */
}

.section-action-btn:hover {
    background-color: rgba(37, 99, 235, 0.15);
    color: var(--accent-hover);
}

.library-sort-dropdown .mobile-sort-icon {
    display: none;
    /* Hidden on desktop */
}

@media (max-width: 450px) {

    .library-sort-dropdown .sort-label,
    .library-sort-dropdown .sort-value,
    .library-sort-dropdown .fa-chevron-down {
        display: none;
    }
}

@media (max-width: 450px) {
    .library-sort-dropdown .mobile-sort-icon {
        display: block;
        font-size: 1rem;
    }
}

@media (max-width: 450px) {
    .library-sort-dropdown .sort-btn {
        width: 38px;
        height: 38px;
        padding: 0 !important;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 50%;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        min-width: 0;
        /* Override min-width */
    }
}

@media (max-width: 710px) {
    .section-action-btn .btn-text {
        display: none;
    }
}

@media (max-width: 710px) {
    .section-action-btn {
        width: 38px;
        height: 38px;
        padding: 0 !important;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 50%;
    }
}

@media (max-width: 710px) {
    .library-header-right {
        display: flex !important;
        /* Keep it visible */
    }
}

.library-sort-dropdown .sort-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.75rem;
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    height: 36px;
    box-sizing: border-box;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 0;
    /* Overrides global 44px on mobile */
}

.library-sort-dropdown .sort-btn:hover {
    border-color: var(--accent-color);
}

.library-sort-dropdown .sort-label {
    color: var(--text-secondary);
}

.library-sort-dropdown .sort-value {
    color: var(--text-primary);
}

.library-sort-dropdown i {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Shared UI utilities */
.hidden {
    display: none !important;
}

[data-action],
button,
.btn,
.icon-btn,
.sidebar-item,
.deck-item,
.folder-header {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Shared Docs + Flashcards library sort/menu styles */
#documents-app .library-sort-dropdown,
#flashcards-app .library-sort-dropdown {
    position: relative;
}

#documents-app .sort-btn,
#flashcards-app .sort-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
    justify-content: space-between;
}

#documents-app .sort-btn:hover,
#flashcards-app .sort-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
}

#documents-app .sort-label,
#flashcards-app .sort-label {
    color: var(--text-secondary);
}

#documents-app .sort-value,
#flashcards-app .sort-value {
    font-weight: 600;
}

@media (max-width: 450px) {

    #documents-app .sort-btn,
    #flashcards-app .sort-btn {
        width: 38px;
        min-width: 38px;
        height: 38px;
        padding: 0 !important;
        justify-content: center;
        border-radius: 50%;
    }
}

#documents-app .sort-menu,
#flashcards-app .sort-menu {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    width: 200px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#documents-app .sort-menu.hidden,
#flashcards-app .sort-menu.hidden {
    display: none;
}

#documents-app .sort-option,
#flashcards-app .sort-option {
    background: none;
    border: none;
    text-align: left;
    padding: 8px 12px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background 0.1s;
}

#documents-app .sort-option:hover,
#flashcards-app .sort-option:hover {
    background: var(--bg-hover);
}

#documents-app .sort-option.active,
#flashcards-app .sort-option.active {
    background: var(--bg-tertiary);
    color: var(--accent-color);
    font-weight: 600;
}

#documents-app .deck-meta-item,
#flashcards-app .deck-meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    min-width: 75px;
    font-weight: 600;
}

#documents-app .deck-meta-value,
#flashcards-app .deck-meta-value {
    font-weight: 600;
    color: var(--text-secondary);
}

.library-view-toggle {
    display: flex;
    align-items: stretch;
    padding: 2px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    height: 36px;
    box-sizing: border-box;
    flex-shrink: 0;
    overflow: hidden;
}

.library-view-toggle .view-btn {
    padding: 0 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    flex: 1;
    min-width: 32px;
    margin: 0;
    min-height: 0;
    /* Overrides global 44px on mobile */
}

.library-view-toggle .view-btn:hover {
    color: var(--text-primary);
}

.library-view-toggle .view-btn.active {
    background: white;
    color: var(--accent-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.featured-deck-card {
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 1rem;
}

@media (min-width: 601px) {
    .featured-deck-card {
        flex-direction: row;
        gap: 1rem;
        align-items: center;
    }
}

.featured-deck-card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-color);
}

.featured-deck-icon {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

@media (max-width: 1199px) {
    .featured-deck-icon {
        display: none;
    }
}

.featured-deck-icon.color-green {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.featured-deck-icon.color-blue {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.featured-deck-icon.color-teal {
    background: rgba(20, 184, 166, 0.1);
    color: #14b8a6;
    border: 1px solid rgba(20, 184, 166, 0.2);
}

.featured-deck-icon.color-purple {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.featured-deck-icon.color-amber {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.doc-icon,
.featured-deck-icon.doc-icon,
.deck-item-icon.doc-icon {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: white !important;
    border: none !important;
}

.featured-deck-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.featured-deck-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
    width: fit-content;
    margin-bottom: 0.5rem;
}

.featured-deck-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    transition: color 0.15s;
    /* Handle long titles */
    word-break: break-word;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.featured-deck-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.featured-deck-stats .separator {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.5;
}

@media (min-width: 601px) and (max-width: 800px) {
    .featured-deck-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

@media (min-width: 601px) and (max-width: 800px) {
    .featured-deck-stats .separator {
        display: none;
    }
}

.featured-deck-progress {
    width: 100%;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (min-width: 601px) {
    .featured-deck-progress {
        width: 280px;
        padding-top: 0;
        padding-left: 1.5rem;
        border-top: none;
        border-left: 1px solid var(--glass-border);
    }
}

@media (min-width: 991px) {
    .featured-deck-progress {
        width: 340px;
        padding-left: 2rem;
    }
}

.featured-deck-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.featured-deck-progress-label {
    font-size: 0.85rem;
    /* Increased slightly */
    font-weight: 700;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
    /* text-transform: uppercase; Removed as requested */
}

.featured-deck-progress-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
}

.featured-deck-progress.is-complete .featured-deck-progress-value {
    color: #22c55e;
}

.featured-deck-progress-bar {
    width: 100%;
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.featured-deck-progress-bar .fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 5px;
    transition: width 0.3s ease;
}

.featured-deck-progress.is-complete .featured-deck-progress-bar .fill {
    background: #22c55e;
}

.featured-deck-resume-btn {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.15s;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.featured-deck-resume-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
}

.section-line {
    flex: 1;
    height: 1px;
    background: var(--glass-border);
}

.folders-section {
    width: 100%;
    max-width: 64rem;
    margin: 1.5rem auto 1rem;
}

.unfiled-section {
    width: 100%;
    max-width: 64rem;
    margin: 1.5rem auto 1rem;
}

.unfiled-section.my-decks-view {
    margin-top: 0.4rem;
}

@media (max-width: 990px) {
    .folders-section {
        margin-top: 1rem;
    }
}

@media (max-width: 990px) {
    .unfiled-section.my-decks-view {
        margin-top: 1.5rem;
    }
}

.section-header-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    /* Increased from 0.5rem as requested */
}

.section-header-toggle {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    flex: 1;
    /* Take up available space on the left for a massive hit target */
}

.section-header-toggle>* {
    pointer-events: none;
    /* Ensure clicks pass through to the div's onclick */
}

.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.flex-spacer {
    flex: 1;
}

.folder-header-icon {
    margin-right: 8px;
    color: var(--accent-color);
}

.recent-section {
    width: 100%;
    max-width: 64rem;
    margin: 1.5rem auto 0;
    /* Added space above */
}

.recent-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
    /* text-transform: uppercase; Removed as requested */
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recent-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recent-title i {
    font-size: 0.9rem;
}

.recent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 900px) {
    .recent-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .recent-grid {
        grid-template-columns: 1fr;
    }
}

.recent-deck-card {
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-deck-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.recent-deck-card:active {
    scale: 1;
    /* override if needed, but transform: scale is global */
}

.recent-deck-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-deck-card:hover .recent-deck-name {
    color: var(--accent-color);
}

.recent-deck-progress {
    height: 5px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.recent-deck-progress .progress-bar {
    height: 100%;
    background: var(--accent-color);
    border-radius: 3px;
}

.recent-deck-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recent-deck-stats .progress-percent {
    font-weight: 600;
    color: var(--accent-color);
}

.folder-section {
    width: 100%;
    margin-bottom: 1.5rem;
}

.folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

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

.folder-header.collapsed {
    border-radius: 0;
}

.folder-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.folder-chevron {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.folder-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.folder-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.folder-header::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--glass-border);
    margin-left: 0.5rem;
}

.folder-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.folder-header:hover .folder-actions {
    opacity: 1;
}

.folder-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.folder-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.folder-action-btn:last-child:hover {
    color: var(--danger-color);
}

.folder-content {
    padding: 1rem 0 0 0;
    transition: all 0.2s;
}

.folder-content.collapsed {
    display: none;
}

.folder-deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
    padding: 0;
    margin: 0;
    border-radius: 12px;
    transition: background 0.15s, border-color 0.15s;
    border: 2px dashed transparent;
    overflow: visible;
}

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

.folder-menu-dropdown {
    position: absolute;
    /* or fixed when creating dynamically */
    top: 100%;
    right: 0;
    width: 200px;
    /* Constrained width */
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    z-index: 100;
    overflow: hidden;
    padding: 0;
    /* Remove padding so hover hits edges */
    overflow: hidden;
    /* Ensure rounded corners clip children */
}

.folder-card-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.folder-card.drag-over {
    border-color: var(--glass-border) !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: scale(1.05) !important;
    z-index: 10;
}

.dragging-placeholder {
    opacity: 0.5;
    filter: grayscale(100%);
    background: var(--bg-secondary);
}

.folder-card.drag-over * {
    pointer-events: none;
}

.note-table-row.dragging {
    opacity: 0.5;
    background: var(--glass-bg);
}

.note-table-row.dragging-ghost {
    opacity: 0;
}

.sidebar-folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.sidebar-folder-item:hover {
    background: var(--bg-hover);
}

.sidebar-folder-item i {
    color: var(--accent-color);
    width: 16px;
}

.sidebar-folder-item span:first-of-type {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-badge {
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
}

.deck-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.deck-item[draggable="true"] {
    cursor: grab;
}

.deck-item[draggable="true"]:active {
    cursor: grabbing;
}

.folder-header.drag-over {
    background: rgba(37, 99, 235, 0.1) !important;
    border-radius: 8px;
}

.folder-header.drag-over .folder-name {
    color: var(--accent-color);
}

.folder-header.drag-over {
    transform: scale(1.05) !important;
}

.sidebar-folder-item.drag-over {
    background: var(--accent-color) !important;
    color: white !important;
    transform: scale(1.05) !important;
}

.sidebar-folder-item.drag-over i,
.sidebar-folder-item.drag-over span {
    color: white !important;
}

.deck-unseen {
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: 500;
}

.deck-item {
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
}

.deck-item .deck-card-count {
    display: none;
}

@media (max-width: 710px) {
    .deck-card-count {
        display: none !important;
    }
}

.deck-item:hover {
    transform: translateY(-2px) scale(1.005);
    box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.05), 0 6px 8px -3px rgba(0, 0, 0, 0.02);
    border-color: rgba(59, 130, 246, 0.3);
    z-index: 10;
    /* Subtle accent tint */
}

.deck-header {
    display: none;
}

.deck-icon-container {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.deck-icon-container.color-blue {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.15);
}

.deck-icon-container.color-teal {
    background: rgba(20, 184, 166, 0.1);
    color: #14b8a6;
    border: 1px solid rgba(20, 184, 166, 0.15);
}

.deck-icon-container.color-green {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.15);
}

.deck-icon-container.color-yellow {
    background: rgba(234, 179, 8, 0.1);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.15);
}

.deck-icon-container.color-orange {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.15);
}

.deck-icon-container.color-coral {
    background: rgba(244, 63, 94, 0.1);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.15);
}

.deck-icon-container.color-purple {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.15);
}

.deck-icon-container.color-sky {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
    border: 1px solid rgba(14, 165, 233, 0.15);
}

.deck-icon-container {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    color: var(--accent-color);
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.deck-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deck-menu-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.deck-info {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Tighter spacing */
    flex: 1;
    text-align: left;
    /* Ensure left alignment */
}

.deck-name {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-primary);
    line-height: 1.3;
    word-break: break-word;
    transition: color 0.15s;
    margin: 0 0 0.25rem 0;
}

.deck-item:hover .deck-name {
    color: var(--text-primary);
}

.deck-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.8;
}

.deck-stats-separator {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.5;
}

.deck-main-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.deck-side-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

.deck-card-count {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.deck-card-count-number {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

.deck-card-count-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 2px;
}

.deck-grid:not(.list-view) .btn-study-outline {
    width: 100%;
}

.deck-mastery {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.deck-mastery-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.deck-mastery-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.deck-mastery-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-color);
}

.deck-mastery.is-complete .deck-mastery-value {
    color: #22c55e;
}

.deck-mastery-value.empty {
    color: var(--text-secondary);
}

.deck-progress {
    width: 100%;
    height: 8px;
    /* Slightly thicker */
    background: var(--bg-tertiary);
    border-radius: 999px;
    /* Pill shape */
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.folder-deck-grid.list-view .deck-progress {
    width: calc(100% - 10px);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    /* Gradient fill */
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.deck-mastery.is-complete .progress-bar {
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
}

.progress-bar.empty {
    background: var(--bg-secondary);
}

.deck-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.deck-btn {
    padding: 0.6rem 1rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-play {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    flex: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

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

.btn-study-outline {
    background: white;
    color: var(--text-primary);
    border: 1px solid #d1d5db;
    padding: 0.625rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    min-width: 100px;
    height: 46px;
    transform: translateY(2px);
}

.btn-study-outline:hover {
    background: #f9fafb;
    border-color: var(--accent-color);
}

.btn-restart-icon {
    background: var(--bg-secondary);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-restart-icon:hover {
    background: var(--bg-hover);
    color: var(--accent-color);
}

.btn-delete {
    background: rgba(239, 83, 80, 0.1);
    color: var(--danger-color);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-delete:hover {
    background: rgba(239, 83, 80, 0.2);
}

.upload-area {
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

.btn-sm {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    background: white;
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    border-color: var(--accent-color);
}

@keyframes cardSlideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.drag-preview {
    position: fixed;
    pointer-events: none;
    background: white;
    border-radius: 8px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 18px 40px rgba(37, 99, 235, 0.25);
    transform-origin: top left;
    z-index: 9999;
}

@keyframes dropDilation {
    100% {
        transform: scale(1);
        background-color: transparent;
    }
}

.drop-dilate {
    animation: dropDilation 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
    animation-delay: 0s !important;
    z-index: 10;
    position: relative;
    border-radius: 8px;
    /* Ensure highlight looks good */
}

.editor-footer {
    display: flex;
    justify-content: center;
    padding-top: 0.75rem;
}

.editor-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.editor-action-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    pointer-events: none;
}

.editor-action-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    transform: scale(1.1);
}

.editor-action-btn.delete:hover {
    background: rgba(239, 83, 80, 0.1);
    color: var(--danger-color);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.mobile-header {
    display: none;
    align-items: center;
    padding: 8px 20px;
    margin-bottom: 7px;
    background: #ffffff;
    /* Opaque background as requested */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.mobile-action-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(37, 99, 235, 0.1);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 1rem;
    padding: 0;
    flex-shrink: 0;
}

.mobile-action-btn i {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-action-btn:hover {
    background: rgba(37, 99, 235, 0.2);
}

@media (max-width: 990px) {

    html,
    body {
        overflow-x: hidden;
        overflow-y: hidden;
        height: 100vh;
        height: 100dvh;
        min-height: 100dvh;
    }

    .main {
        overflow-y: auto;
        overflow-x: hidden;
        height: 100%;
        min-height: 100dvh;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: none;
    }

}

@media (max-width: 990px) {

    /* Match flashcards mobile scrolling behavior for notes/documents libraries */
    #documents-app {
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 990px) {
    .mobile-header {
        display: flex;
    }

    .library-mobile-header {
        display: flex;
        /* Pull header out to edges to make border full width */
        width: calc(100% + 3rem) !important;
        margin-left: -1.5rem !important;
        margin-right: -1.5rem !important;
        /* Add padding back so text aligns with content */
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
        box-sizing: border-box;
    }
}

@media (max-width: 710px) {
    #library-section {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
}

@media (max-width: 710px) {
    #library-deck-list {
        padding-top: 0 !important;
    }
}

@media (max-width: 990px) {
    .settings-overlay {
        background: rgba(0, 0, 0, 0.5);
        /* Dim background */
        pointer-events: auto;
        z-index: -1;
    }
}

@media (max-width: 990px) {
    .settings-content {
        position: relative;
        /* Centered by parent flex */
        top: auto;
        right: auto;
        left: auto;
        bottom: auto;
        width: 100%;
        max-width: 320px;
        max-height: 85dvh;
        /* Safe height */
        margin: 20px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border-radius: 16px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }
}

@keyframes slideInTop {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 0.2rem;
    gap: 0.75rem;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    width: 36px;
    height: 20px;
    background: var(--gray-300);
    border-radius: 20px;
    position: relative;
    transition: background 0.3s;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

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

.toggle-label input:checked+.toggle-switch::after {
    transform: translateX(16px);
}

.menu-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 0;
}

.menu-btn {
    background: white;
    border: 1px solid var(--border-color);
    text-align: center;
    padding: 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
    width: 100%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-weight: 500;
}

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

.menu-btn.danger {
    color: var(--danger-color);
}

.menu-btn.danger:hover {
    background: rgba(239, 83, 80, 0.12);
}

@media (max-width: 710px) {

    html,
    body {
        overflow-y: hidden !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: none !important;
        touch-action: auto !important;
    }

    .main {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: none;
    }

}

@media (max-width: 710px) {
    .notes-wrapper {
        height: auto !important;
        min-height: 100% !important;
        /* Remove overflow: visible to allow textarea scrolling on iOS */
        display: flex;
        flex-direction: column;
        /* Enable touch scrolling for iOS */
        -webkit-overflow-scrolling: touch;
    }
}

.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.label {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.8rem;
    color: var(--text-secondary);

    /* Alignment with speaker icon & Font Fix */
    position: absolute;
    top: 20px;
    /* Aligns with speaker icon at top:12px + padding */
    left: 0;
    width: 100%;
    text-align: center;
    font-family: "Inter", sans-serif;
}

@media (max-width: 710px) {
    .label {
        top: 12px;
        /* Move label up on mobile */
        font-size: 0.7rem;
        /* Smaller text */
    }
}

@media (max-width: 710px) {
    .card-content {
        gap: 0.5rem;
        /* Reduce gap between text elements */
    }
}

@keyframes slideDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    background: rgba(37, 99, 235, 0.05);
    color: var(--text-primary);
}

.total {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-left: 5px;
}

.mistakes-container {
    width: 100%;
    background: rgba(239, 83, 80, 0.05);
    border: 1px solid rgba(239, 83, 80, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
}

.mistakes-container h3 {
    color: var(--danger-color);
    margin-bottom: 1rem;
}

.peek-container {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.peek-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 4rem;
    /* Prevent cut-off */

    /* Hide scrollbar */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.peek-list::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.mistake-count {
    color: var(--danger-color);
    font-weight: bold;
}

#newDeckBtn {
    background-color: var(--btn-dark);
    border: none;
    color: #fff;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 10px;
    width: 100%;
    font-size: 1em;
    user-select: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#newDeckBtn:hover {
    background-color: var(--text-primary);
}

.peek-drawer {
    position: fixed;
    right: 0;
    top: 0;
    width: 300px;
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--glass-border);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    /* Move completely off-screen */
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.peek-drawer.open {
    transform: translateX(0);
}

.peek-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.peek-header button {
    font-size: 2rem;
    padding: 0.2rem 0.6rem;
}

.peek-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.peek-item {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.peek-item .q {
    font-weight: 600;
    color: var(--text-primary);
}

.peek-item .a {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.toast {
    position: fixed;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: fit-content;
    max-width: 90%;

    z-index: 2000;
    pointer-events: auto;

    padding: 1rem 2rem;
    border-radius: 50px;
    background: rgba(30, 30, 30, 0.9);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    /* Soft shadow */
    max-width: 100%;
    /* Ensure it respects container */
    overflow: hidden;
    /* Hide overflow so we can detect it with scrollWidth */
    backdrop-filter: blur(10px);
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;

    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
    color: black;
}

#library-section {
    width: 100%;
    /*max-width: 1100px;*/
    margin: 0 auto;
    padding: 0;
    padding-bottom: 1.5rem;
    box-sizing: border-box;
}

#library-deck-list {
    padding: 0 clamp(1rem, 3vw, 2rem);
}

.progress-bar-container {
    display: none;
    flex: 1;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    margin: 0 1rem;
    overflow: hidden;
    max-width: 200px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

input[type="checkbox"] {
    accent-color: var(--accent-color);
    transform: scale(1.5);
    cursor: pointer;
}

body.stop-scrolling {
    overflow: hidden;
}

@keyframes shake {
    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

.settings-menu {
    padding: 8px;
    width: 240px;
    max-height: 80vh;
    overflow-y: auto;
    gap: 4px;
}

.menu-item {
    margin-bottom: 4px;
    padding: 4px 6px;
    min-height: 32px;
}

.menu-divider {
    margin: 0;
}

.font-sans {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
}

.font-serif {
    font-family: "Playfair Display", Georgia, serif;
}

.font-dyslexic {
    font-family: "Open-Dyslexic", sans-serif;
    line-height: 1.6;
}

.font-selector-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.font-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

.distractor-panel {
    grid-column: 1 / -1;
    /* Force full width on new row */
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-secondary);
    border: 1px solid rgba(226, 232, 240, 1);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    /* animation: fadeIn 0.2s ease-out; Remove animation to rule out issues */
}

.distractor-panel.hidden {
    display: none !important;
}

.distractor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.distractor-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.distractor-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 2px 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.distractor-tag button {
    border: none;
    background: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
}

.distractor-tag button:hover {
    color: var(--danger-hover);
    /* darker red */
}

.distractor-input-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.distractor-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    -webkit-user-select: text;
    user-select: text;
}

.distractor-header button.distractor-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.distractor-header button.distractor-tab:hover {
    color: var(--text-primary);
}

.distractor-header button.distractor-tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.modal {
    display: none;
    position: fixed;
    z-index: 2500;
    /* Higher than sidebar (2001), settings (500), and toasts (2000) */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;

}

.modal[style*="display: block"],
.modal[style*="display:block"] {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.modal[style*="display: flex"],
.modal[style*="display:flex"] {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.modal-content {
    background-color: #ffffff;
    margin: auto;
    padding: 20px 24px 20px;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2), 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 90%;
    animation: modalPopIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* Compact gap */
    text-align: center;
}

#confirmationMessage {
    margin: 24px 0 12px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

@keyframes modalPopIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.modal p {
    margin: 4px 0 0 0;
    margin-left: 8px;
    /* Scoot over */
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: center;
    /* Centered actions */
    gap: 10px;
    margin-top: 1rem;
}

#card-front-text,
#card-back-text {
    white-space: pre-wrap;
}

@media (max-width: 600px) {
    #newDeckModal .modal-content {
        margin: 1rem auto auto auto;
        max-height: calc(100dvh - 2rem);
        overflow-y: auto;
    }
}

.action-sheet {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    /* Centered modal by default (Desktop) */
    justify-content: center;
    padding: 20px;
}

.action-sheet-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    /* Premium feel */
    animation: fadeIn 0.2s ease;
}

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

.action-sheet-content {
    position: relative;
    background: var(--bg-primary);
    width: 90%;
    max-width: 440px;
    border-radius: 16px;
    /* Full radius for modal */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    animation: modalPopIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@media (max-width: 600px) {
    .action-sheet {
        align-items: flex-end;
        padding: 0;
    }
}

@media (max-width: 600px) {
    .action-sheet-content {
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        padding-bottom: env(safe-area-inset-bottom, 16px);
        animation: slideUp 0.25s ease;
    }
}

@keyframes slideUp {
    to {
        transform: translateY(0);
    }
}

.action-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 1rem;
}

.action-sheet-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.action-sheet-options {
    max-height: 50vh;
    overflow-y: auto;
}

.sheet-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.sheet-option:hover {
    background: var(--bg-hover);
}

.sheet-option:active {
    background: var(--bg-tertiary);
}

.sheet-option.active {
    color: var(--accent-color);
    font-weight: 500;
}

.sheet-option.active i {
    color: var(--accent-color);
}

.sheet-option i {
    color: var(--text-secondary);
    width: 20px;
    text-align: center;
}

.sheet-option.special {
    color: var(--accent-color);
    font-weight: 500;
}

.sheet-option.special i {
    color: var(--accent-color);
}

.sheet-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0;
    opacity: 0.5;
}

.speaking-highlight {
    border: 2px solid var(--accent-color) !important;
    background-color: var(--highlight-bg, rgba(var(--accent-rgb), 0.1)) !important;
    transform: scale(1.02);
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    min-height: 0;
    pointer-events: none;
}

.unfiled-section.collapsed .fa-chevron-down,
.folders-section.collapsed .fa-chevron-down {
    transform: rotate(-90deg);
}

.unfiled-section>.folder-deck-grid,
.unfiled-section>.notes-table-container,
.folders-section>.folders-grid {
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, visibility 0.3s;
    max-height: 50000px;
    opacity: 1;
    visibility: visible;
    overflow: hidden;
}

/* Shared fix for Documents + Flashcards: allow hover lift without clipping when expanded */
.unfiled-section:not(.collapsed)>.folder-deck-grid,
.unfiled-section:not(.collapsed)>.notes-table-container,
.folders-section:not(.collapsed)>.folders-grid {
    overflow: visible;
}

.unfiled-section.collapsed>.folder-deck-grid,
.unfiled-section.collapsed>.notes-table-container,
.folders-section.collapsed>.folders-grid {
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.collapse-btn i {
    transition: transform 0.2s ease;
    font-size: 1.3em;

}

.folder-view-section {
    width: 100%;
    max-width: 64rem;
    margin: 32px auto 0.5rem;
}

.notes-app .folder-view-section {
    margin-top: 48px;
}

@media (max-width: 768px) {
    .folder-view-section {
        margin-top: 16px;
    }
}

.folder-view-section .section-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.folder-view-section .back-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.folder-view-section .back-btn:hover {
    color: var(--text-primary);
}

.folder-deck-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.featured-deck-icon-img {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    object-fit: contain;
    flex-shrink: 0;
}

@media (max-width: 1199px) {
    .featured-deck-icon-img {
        display: none;
    }
}

@keyframes dragOverlayFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
    }
}

#pdf-drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    /* Let pointer events through so drag events hit the document continuously without flicker */
}

body.dragging-files #pdf-drop-overlay {
    display: flex;
    opacity: 1;
}

.pdf-drop-overlay-content {
    background: #ffffff;
    border: 2.5px dashed var(--accent-color);
    border-radius: 16px;
    padding: 4rem 5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.4);
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s ease, border-color 0.15s ease;
    pointer-events: auto;
}

body.dragging-files .pdf-drop-overlay-content {
    animation: dragOverlayFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.pdf-drop-overlay-content i {
    font-size: 4rem;
    color: var(--accent-color);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.15s ease;
}

body.dragging-over-box .pdf-drop-overlay-content i {
    transform: translateY(-8px) scale(1.1);
    color: var(--accent-hover, var(--accent-color));
}

.pdf-drop-overlay-content span {
    font-size: 2.2rem;
    color: var(--accent-color);
    font-weight: 700;
    letter-spacing: -0.02em;
    transition: color 0.15s ease;
}

body.dragging-over-box .pdf-drop-overlay-content span {
    color: var(--accent-hover, var(--accent-color));
}

/* Hovering over the box — ready to accept */
body.dragging-over-box .pdf-drop-overlay-content {
    border-style: solid;
    border-color: var(--accent-hover);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.4), 0 0 0 6px rgba(var(--accent-rgb, 37, 99, 235), 0.2);
    transform: scale(1.03);
    /* Physical bump to feel more interactive */
}

/* Hovering outside the box — will cancel */
body.dragging-outside-box .pdf-drop-overlay-content {
    border-style: dashed;
    border-color: var(--accent-color);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.4);
    transform: scale(0.98);
    /* Slighly shrink to feel inactive */
}

.notes-table-view {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    margin-top: 0;
}

.notes-table-container {
    /* border: 1px solid var(--border-color); Removed for frameless look */
    border: none;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
    margin-top: 0;
}

.notes-table-header {
    display: grid;
    grid-template-columns: minmax(120px, 2fr) minmax(50px, 80px) minmax(50px, 80px) minmax(80px, 100px);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    /* Thin divider */
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    align-items: center;
    background: transparent;
    /* Transparent header */
}

.note-table-row {
    display: grid;
    grid-template-columns: minmax(120px, 2fr) minmax(50px, 80px) minmax(50px, 80px) minmax(80px, 100px);
    padding: 0.75rem 1rem;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.15s ease, opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease, padding 0.3s ease, border-width 0.3s ease;
    background: transparent;
    max-height: 420px;
    overflow: hidden;
}

.fade-out-row {
    opacity: 0 !important;
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-bottom-width: 0 !important;
    transform: translateX(20px);
    pointer-events: none;
}

.note-table-row:first-child {
    border-top: none;
}

.note-table-row:last-child {
    border-bottom: none;
}

.note-table-row:hover {
    background-color: var(--bg-tertiary);
    /* Gentle highlight */
}

.note-col-name {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.checkbox-wrapper {
    position: absolute;
    left: 0;
    top: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.note-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    transform: none !important;
}

.deck-grid.selection-mode .checkbox-wrapper {
    opacity: 1;
    pointer-events: auto;
}

.deck-grid.selection-mode .note-icon {
    opacity: 0;
}

.note-icon {
    color: var(--text-secondary);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: opacity 0.15s ease;
}

.note-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 1.5rem;
}

.note-rename-input {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: inherit;
    background: #fff;
    border: 1.5px solid var(--accent-color);
    border-radius: 6px;
    padding: 4px 8px;
    margin: 0;
    outline: none;
    width: min(100%, 280px);
    min-width: 0;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.12);
    line-height: inherit;
    box-sizing: border-box;
}

.note-col-lines {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.note-col-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: right;
}

.note-col-size {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.notes-table-header .col-date {
    text-align: right;
}

@media (max-width: 900px) {

    .notes-table-header,
    .note-table-row {
        grid-template-columns: 1fr 60px 80px;
    }
}

@media (max-width: 900px) {

    .col-size,
    .note-col-size {
        display: none !important;
    }
}

@media (max-width: 680px) {

    .notes-table-header,
    .note-table-row {
        grid-template-columns: 1fr 80px;
    }
}

@media (max-width: 680px) {

    .col-lines,
    .note-col-lines {
        display: none !important;
    }
}

@media (max-width: 680px) {

    .checkbox-wrapper,
    .note-icon {
        width: 22px;
        height: 22px;
    }

    .note-checkbox {
        width: 16px;
        height: 16px;
    }
}

.notes-table-header .sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notes-table-header .sortable.col-date {
    justify-content: flex-end;
}

.notes-table-header .sortable:hover {
    color: var(--text-primary);
}

.notes-table-header .sortable.active {
    color: var(--accent-color);
    font-weight: 700;
}

.notes-table-header .sortable i {
    margin-left: 4px;
    font-size: 0.8rem;
}

/* ========================================
   SAAS COMPACT OVERRIDE
   Notion-inspired density and polish
   ======================================== */
:root {
    --bg-primary: #f7f9fc;
    --bg-secondary: #f2f5f9;
    --bg-tertiary: #e7ecf4;
    --bg-hover: #dde4ef;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #d6dfeb;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: rgba(37, 99, 235, 0.1);
    --bright: #fff;
}

html,
body {
    font-size: 15px;
}

.main,
.stagger-item {
    animation: none !important;
}

.stagger-item {
    opacity: 1 !important;
}

button,
.btn,
.nav-link,
.card,
.deck-card,
.deck-item,
.folder-card,
.folder-header,
.note-item,
.note-table-row,
.recent-card,
.recent-deck-card,
.doc-card,
.clickable,
input,
select,
textarea {
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease !important;
}

.sidebar {
    width: 236px;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom)) 8px;
    background: #fff;
    border-right: 1px solid #dde4ef;
}

.container {
    margin-left: 236px;
}

.sidebar-header {
    margin-top: 8px;
    margin-bottom: 10px;
    padding-left: 8px;
}

.sidebar-search {
    margin-bottom: 10px;
}

.sidebar-search-input {
    height: 36px;
    border-radius: 6px;
    padding: 0 10px 0 34px;
    font-size: 14px;
}

.sidebar-search-icon {
    left: 12px;
    font-size: 0.82rem;
}

.nav-links {
    margin-top: 8px;
    gap: 1px;
}

.sidebar-section-label {
    margin: 14px 8px 6px 10px;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
}

.sidebar-divider {
    margin: 10px 6px;
}

.nav-link,
.sidebar-footer a,
.sidebar-footer button {
    height: 36px;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 13.5px;
    font-weight: 500;
}

.nav-link i {
    width: 18px;
    margin-right: 9px;
    font-size: 14px;
}

.sidebar-footer {
    padding-top: 6px;
}

.sidebar-footer i {
    font-size: 15px;
}

.icon-only-btn {
    width: 28px;
    height: 28px;
    border-radius: 5px;
}

.btn {
    border-radius: 6px;
    min-height: 34px;
    padding: 0.4rem 0.8rem;
    font-size: 0.84rem;
    box-shadow: none;
}

.btn-primary:hover {
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.2);
}

.btn-secondary:hover,
.btn-danger:hover,
.btn-success:hover {
    box-shadow: none;
}

.card,
.deck-item,
.doc-card,
.folder-card-body,
.recent-card,
.activity-card,
.storage-card,
.modal-content,
.settings-modal-content,
.sabo-input-modal-content {
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.folder-card:hover .folder-card-body,
.deck-item:hover,
.doc-card:hover,
.recent-card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.notes-table-header,
.note-table-row {
    padding-top: 0.58rem;
    padding-bottom: 0.58rem;
}

.note-table-row {
    max-height: 420px;
}

.modal,
#sabo-settings-modal {
    backdrop-filter: blur(1px);
}

@media (max-width: 990px) {
    .sidebar {
        width: 268px;
    }

    .container {
        margin-left: 0 !important;
    }
}

/* ========================================
   MODAL + MENU PRO OVERRIDE
   Focus: dialogs, sheets, context menus, color hierarchy
   ======================================== */
:root {
    --surface-1: #ffffff;
    --surface-2: #f8fbff;
    --surface-3: #f1f5fb;
    --surface-border: #d7e1ef;
    --surface-border-strong: #c8d5e8;
    --overlay-soft: rgba(15, 23, 42, 0.46);
    --overlay-hard: rgba(15, 23, 42, 0.58);
    --menu-shadow: 0 18px 38px -24px rgba(15, 23, 42, 0.45), 0 10px 18px -14px rgba(15, 23, 42, 0.32);
    --dialog-shadow: 0 32px 56px -30px rgba(15, 23, 42, 0.55), 0 20px 24px -20px rgba(15, 23, 42, 0.35);
}

.modal,
#sabo-settings-modal {
    align-items: flex-start;
    justify-content: center;
    padding: clamp(20px, 8vh, 72px) 18px 18px;
    background: linear-gradient(180deg, var(--overlay-soft), var(--overlay-hard));
    backdrop-filter: blur(8px) saturate(125%);
    -webkit-backdrop-filter: blur(8px) saturate(125%);
}

.modal-content,
.settings-modal-content,
.sabo-input-modal-content {
    background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-2) 100%);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    box-shadow: var(--dialog-shadow);
}

.modal-content {
    width: min(560px, calc(100vw - 36px));
    max-height: calc(100dvh - clamp(48px, 13vh, 120px));
    overflow: auto;
    padding: 18px 20px;
    gap: 0.75rem;
    text-align: left;
}

#aboutModal .modal-content {
    max-width: 560px;
}

#sabo-settings-modal .settings-modal-content {
    width: min(520px, calc(100vw - 36px));
    max-height: calc(100dvh - clamp(48px, 13vh, 120px));
    overflow: auto;
}

#sabo-settings-modal .settings-modal-header {
    padding: 14px 18px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--surface-border);
}

#sabo-settings-modal .settings-modal-body {
    padding: 14px 18px;
    gap: 8px;
}

#sabo-settings-modal .settings-modal-footer {
    padding: 12px 18px;
    background: var(--surface-3);
    border-top: 1px solid var(--surface-border);
}

.modal-header {
    margin-bottom: 0.35rem;
    gap: 0.6rem;
}

.modal-header h3,
.modal h3,
#sabo-settings-modal h3 {
    font-size: 1.08rem;
    line-height: 1.25;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.modal p,
#confirmationMessage {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
    text-align: left;
}

.modal-actions {
    justify-content: flex-end;
    gap: 8px;
    margin-top: 0.4rem;
}

.close,
.close-btn,
.modal-header .close,
.modal-header .close-btn,
.sabo-input-modal-close,
.action-sheet-close {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.12rem;
    color: #5b677d;
}

.close:hover,
.close-btn:hover,
.sabo-input-modal-close:hover,
.action-sheet-close:hover {
    background: #eaf0f8;
    color: #0f172a;
}

.sabo-input-modal-overlay {
    background: linear-gradient(180deg, var(--overlay-soft), var(--overlay-hard));
    backdrop-filter: blur(8px) saturate(125%);
    -webkit-backdrop-filter: blur(8px) saturate(125%);
}

.sabo-input-modal-content {
    width: min(430px, calc(100vw - 32px));
    max-height: calc(100dvh - clamp(48px, 13vh, 120px));
    background: var(--surface-1);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    box-shadow: var(--dialog-shadow);
    overflow: hidden;
}

.sabo-input-modal-header {
    padding: 12px 16px 6px;
    background: var(--surface-1);
    border-bottom: none;
}

.sabo-input-modal-body {
    padding: 8px 16px;
    background: var(--surface-1);
}

.sabo-input-modal-input,
#sabo-settings-modal input[type="password"] {
    border: 1px solid var(--surface-border-strong);
    border-radius: 8px;
    background: #fff;
    padding: 7px 10px;
    min-height: 34px;
    font-size: 0.9rem;
}

.sabo-input-modal-footer {
    padding: 8px 16px 12px;
    background: var(--surface-1);
    border-top: none;
    gap: 8px;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.sabo-input-modal-submit,
.sabo-input-modal-cancel {
    min-height: 34px;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 600;
}

.action-sheet {
    padding: 20px;
}

.action-sheet-overlay {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.42), rgba(15, 23, 42, 0.58));
    backdrop-filter: blur(8px) saturate(125%);
    -webkit-backdrop-filter: blur(8px) saturate(125%);
}

.action-sheet-content {
    width: min(520px, calc(100vw - 36px));
    border-radius: 12px;
    border: 1px solid var(--surface-border);
    background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-2) 100%);
    box-shadow: var(--dialog-shadow);
}

.action-sheet-header {
    padding: 12px 14px;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--surface-border);
}

.action-sheet-options {
    max-height: min(62vh, 560px);
}

.sheet-option {
    gap: 10px;
    padding: 10px 12px;
    font-size: 0.88rem;
}

.sheet-option i {
    width: 16px;
}

.sheet-divider,
.menu-divider {
    height: 1px;
    margin: 6px 2px;
    background: linear-gradient(90deg, transparent, #d4deec, transparent);
    opacity: 1;
}

.settings-menu,
#quiz-settings-menu,
.folder-menu-dropdown {
    background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-2) 100%);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    box-shadow: var(--menu-shadow);
}

.settings-menu {
    width: min(260px, calc(100vw - 24px));
    padding: 6px;
    gap: 2px;
}

#quiz-settings-menu {
    padding: 6px;
    gap: 2px;
}

.menu-item,
.folder-menu-item {
    min-height: 34px;
    padding: 7px 9px;
    margin: 0;
    border-radius: 7px;
    font-size: 0.84rem;
    color: var(--text-primary);
}

.menu-item:hover,
.folder-menu-item:hover,
#quiz-settings-menu .menu-item:hover {
    background: #eaf1fb;
}

.menu-item.active,
#quiz-settings-menu .menu-item.active {
    background: #dce9fb;
    color: #1947a9;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.2);
}

@media (max-width: 700px) {

    .modal,
    #sabo-settings-modal,
    .sabo-input-modal {
        padding: 10px 10px max(10px, env(safe-area-inset-bottom));
        align-items: flex-end;
    }

    .modal-content,
    .settings-modal-content,
    .sabo-input-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: min(86dvh, 760px);
        border-radius: 12px 12px 10px 10px;
    }

    .action-sheet {
        padding: 0;
        align-items: flex-end;
    }

    .action-sheet-content {
        width: 100%;
        max-width: 100%;
        border-radius: 12px 12px 0 0;
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }
}

/* ========================================
   CONTRAST REFINEMENT (Dashboard + Notes)
   ======================================== */
.dashboard-container {
    background: #f2f5fa;
}

.dashboard-container .recent-card,
.dashboard-container .activity-card,
.dashboard-container .storage-card {
    background: #ffffff;
    border: 1px solid #cbd7e7;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 18px -16px rgba(15, 23, 42, 0.4);
}

.dashboard-container .recent-card-label {
    background: #e8effa;
    color: #3a4a61;
    font-weight: 600;
}

.dashboard-container .recent-card-meta,
.dashboard-container #dashboard-subgreeting,
.dashboard-container #event-countdown,
.dashboard-container .storage-breakdown-label,
.dashboard-container .storage-breakdown-value {
    color: #41536b;
}

.dashboard-container .activity-filter {
    border-color: #c4d2e5;
    background: #ffffff;
    color: #243247;
}

.dashboard-container .heatmap-cell {
    background: #d8e1ef;
}

.dashboard-container .heatmap-cell.is-future {
    background: #edf2fa;
}

.dashboard-container .storage-bar {
    background: #e5ecf7;
}

.notes-app .notes-table-container {
    background: #ffffff;
    border: 1px solid #ccd8ea;
    border-radius: 8px;
    overflow: hidden;
}

.notes-app .unfiled-section:not(.collapsed)>.notes-table-container {
    overflow: hidden;
}

.notes-app .notes-table-view {
    border-radius: 0;
    overflow: visible;
}

.notes-app .notes-table-header {
    background: #f7faff;
    border-bottom: 1px solid #d7e2f0;
    border-radius: 0;
}

.notes-app .note-table-row {
    background: #ffffff;
    border-bottom: 1px solid #e2eaf5;
}

.notes-app .note-table-row:hover {
    background: #f4f8ff;
}

.notes-app .note-title {
    color: #0f172a;
    font-weight: 560;
}

.notes-app .note-col-lines,
.notes-app .note-col-size,
.notes-app .note-col-date,
.notes-app .note-icon {
    color: #4a5d77;
}

/* Context menu row fill: no pill corners, no inset whitespace */
.folder-menu-dropdown {
    padding: 0;
}

.folder-menu-dropdown .folder-menu-item {
    border-radius: 0;
    margin: 0;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.folder-menu-dropdown .folder-menu-item:hover {
    border-radius: 0;
    background: #eaf1fb !important;
}

.folder-menu-dropdown .folder-menu-item.delete:hover {
    border-radius: 0;
    background: #fde7eb !important;
}

.folder-menu-dropdown .menu-divider {
    margin: 0;
    height: 1px;
    background: #d7e2f0;
}

/* Flashcards button shape consistency */
#flashcards-app .btn,
#flashcards-app .library-view-toggle,
#flashcards-app .library-view-toggle .view-btn,
#flashcards-app .library-sort-dropdown .sort-btn,
#flashcards-app .section-action-btn {
    border-radius: 10px;
}

@media (max-width: 710px) {
    #flashcards-app .section-action-btn {
        border-radius: 50%;
    }
}

@media (max-width: 450px) {
    #flashcards-app .library-sort-dropdown .sort-btn {
        border-radius: 50%;
    }
}

/* Flashcards deck overview study CTA emphasis */
#flashcards-app .deck-study-btn,
#flashcards-app #start-study-btn,
#flashcards-app #study-missed-btn {
    border-radius: 10px !important;
    font-size: 1.06rem;
    font-weight: 500 !important;
}

/* Match Study Missed hover behavior to Study (without btn-sm translate lift). */
#flashcards-app #study-missed-btn:hover {
    transform: none;
}

:root:not(.sabo-dark-mode) #flashcards-app #study-missed-btn:hover {
    background-color: var(--accent-hover);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.2);
}