/* Dashboard navigation becomes a separate screen on phones. */
@media (max-width: 759px) {
    body.mobile-dashboard-active {
        --mobile-dashboard-header-height: calc(58px + env(safe-area-inset-top, 0px));
        overflow: hidden;
    }

    body.mobile-dashboard-active .app-shell,
    body.mobile-dashboard-active .app-shell .main {
        width: 100% !important;
        height: 100dvh !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    body.mobile-dashboard-active .app-shell .main {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        grid-template-rows: var(--mobile-dashboard-header-height) minmax(0, 1fr) !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: var(--bg) !important;
    }

    body.mobile-dashboard-active .main::after { display: none !important; }

    body.mobile-dashboard-active:has(#dashboardWorkspace:not([hidden])) .main > .topbar {
        position: relative !important;
        inset: auto !important;
        z-index: 61;
        display: flex !important;
        flex-wrap: nowrap !important;
        grid-column: 1 / -1 !important;
        grid-row: 1 !important;
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
        min-height: 0;
        height: var(--mobile-dashboard-header-height);
        gap: 4px;
        padding: env(safe-area-inset-top, 0px) 8px 0;
        border-bottom: 1px solid var(--border);
        border-radius: 0;
        background: var(--surface);
    }

    body.mobile-dashboard-active .topbar-left {
        display: flex !important;
        flex: 1 1 auto !important;
        align-items: center;
        width: auto !important;
        min-width: 0;
        gap: 6px !important;
    }

    body.mobile-dashboard-active .topbar .sidebar-toggle-button {
        order: -1;
        display: grid !important;
        flex: 0 0 40px;
        place-items: center;
        width: 40px !important;
        min-width: 40px !important;
        height: 44px;
        margin: 0 !important;
        padding: 9px;
        color: var(--text);
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    body.mobile-dashboard-active .topbar #globalHomeButton {
        display: flex !important;
        flex: 0 1 auto;
        align-items: center;
        justify-content: flex-start;
        width: auto !important;
        min-width: 0 !important;
        min-height: 44px;
        margin: 0 !important;
        padding: 0;
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: none !important;
    }

    body.mobile-dashboard-active .topbar .topbar-brand-logo {
        width: auto !important;
        max-width: 116px !important;
        height: 32px !important;
    }
    body.mobile-dashboard-active .topbar .prep-atlas-brand { gap: 6px; color: var(--text); }
    body.mobile-dashboard-active .topbar .prep-atlas-brand__mascot-frame { width: 28px; height: 28px; flex-basis: 28px; }
    body.mobile-dashboard-active .topbar .prep-atlas-brand__name { font-size: 20px; }
    body.mobile-dashboard-active .topbar .page-title,
    body.mobile-dashboard-active .topbar .topbar-stats,
    body.mobile-dashboard-active .topbar #themeToggle { display: none !important; }

    body.mobile-dashboard-active .topbar .topbar-search-button {
        flex: 0 0 36px !important;
        width: 36px !important;
        min-width: 36px !important;
        height: 40px;
        margin: 0 !important;
        padding: 8px;
    }
    body.mobile-dashboard-active .topbar .topbar-search-button > span { display: none; }
    /* Desktop dashboard rules (33px high, 13.5px side padding) squeezed the icon off-centre; make it an even square with a centred icon. */
    body.mobile-dashboard-active:has(#dashboardWorkspace:not([hidden])) .topbar .topbar-search-button { height: 36px; min-height: 36px; padding: 0; gap: 0; justify-content: center; }
    body.mobile-dashboard-active .topbar .topbar-actions {
        display: flex !important;
        flex: 0 0 auto !important;
        align-items: center;
        width: auto !important;
        margin: 0 !important;
        gap: 4px;
    }
    body.mobile-dashboard-active .topbar .account-trigger { min-width: 36px; max-width: 76px; min-height: 40px; padding: 4px; gap: 3px; }
    body.mobile-dashboard-active .topbar .account-trigger-avatar { width: 30px; height: 30px; flex-basis: 30px; }
    body.mobile-dashboard-active .topbar #accountButtonLabel { font-size: 11px; }
    body.mobile-dashboard-active .topbar .topbar-settings-button { width: 36px; min-width: 36px; height: 40px; padding: 8px; }

    body.mobile-dashboard-active #dashboardWorkspace { display: none !important; }
    body.mobile-dashboard-active.mobile-dashboard-nav-open:has(#dashboardWorkspace:not([hidden])) .app-shell .main > #dashboardWorkspace:is(#dashboardWorkspace) {
        position: relative !important;
        inset: auto !important;
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        z-index: 60;
        display: block !important;
        box-sizing: border-box;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        min-width: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        background: var(--surface);
        visibility: visible !important;
        pointer-events: auto;
    }

    /* Navigation and the home overview form one scrolling main screen. */
    body.mobile-dashboard-active.mobile-dashboard-nav-open .app-shell .main {
        grid-template-rows: var(--mobile-dashboard-header-height) max-content max-content !important;
        align-content: start;
        overflow-y: auto !important;
        overscroll-behavior-y: contain;
    }
    body.mobile-dashboard-active.mobile-dashboard-nav-open .main > .topbar {
        position: sticky !important;
        top: 0 !important;
    }

    body.mobile-dashboard-active #dashboardWorkspace .dashboard-inner {
        display: flex !important;
        flex-direction: column;
        box-sizing: border-box;
        width: 100% !important;
        max-width: 520px;
        height: auto !important;
        min-height: 0;
        margin: 0 auto;
        padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px)) !important;
        gap: 12px;
        border: 0;
        border-radius: 0;
        overflow: visible !important;
        backdrop-filter: none;
    }
    body.mobile-dashboard-active #dashboardSidebarBrand { display: none !important; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-columns { display: flex !important; flex-direction: column; width: 100%; gap: 4px; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-header,
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-header-actions { display: contents; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-subject-selector { position: relative; inset: auto; width: 100%; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-subject-trigger { width: 100%; min-height: 44px; transform: none; }
    body.mobile-dashboard-active #dashboardWorkspace .sidebar-section-label { margin: 16px 8px 6px; padding: 0 8px; color: #767676; font-family: var(--font-ui); font-size: 12px; font-weight: 600; line-height: 16px; letter-spacing: normal; text-transform: uppercase; }
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-tools, .dashboard-tool-cluster) { display: block; width: 100%; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 8px 12px; }
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-home-button, .sidebar-nav-button, .quick-chat-button),
    body.mobile-dashboard-active #dashboardWorkspace .atlas-launcher__items button { display: flex; flex: 0 0 auto; align-items: center; width: 100%; height: auto; min-height: 44px; padding: 8px 12px; gap: 9px; font-family: Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 20px; }
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-home-button-icon, .quick-chat-button-icon, .sidebar-nav-icon) { flex: 0 0 18px !important; width: 18px; height: 18px; }
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-home-button-icon, .quick-chat-button-icon) svg { width: 18px; height: 18px; }
    body.mobile-dashboard-active #dashboardWorkspace #homeNewChatButton { padding-left: 12px; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool { display: flex; flex: none; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 140px; min-height: 140px; padding: 8px; gap: 4px; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool__visual { position: relative; flex: 0 0 64px !important; width: 88px; height: 64px; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .react-folder-mount { position: absolute; top: 50%; left: 50%; width: 100px; height: 80px; transform: translate(-50%, -50%) scale(1.3, 1.06) !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool-label { width: 100%; color: var(--text) !important; font-family: var(--font-ui) !important; font-size: 14px !important; font-weight: 500 !important; line-height: 20px !important; text-align: center; }
    body.mobile-dashboard-active #dashboardWorkspace .mobile-dashboard-folder-art { display: block; position: relative; flex: 0 0 94px; width: 140px; height: 94px; transform: scale(1.2); }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool:has(.mobile-dashboard-folder-art) > .folder-tool__visual { display: none !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .mobile-dashboard-folder-art .folder { transform: none !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .mobile-dashboard-folder-art .paper { transform: translate(-50%, 10%) !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .mobile-dashboard-folder-art .folder__front { transform: none !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool.is-mobile-folder-pressed .mobile-dashboard-folder-art .folder { transform: translateY(-5px) !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool.is-mobile-folder-pressed .mobile-dashboard-folder-art .paper { transform: translate(-50%, 0%) !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool.is-mobile-folder-pressed .mobile-dashboard-folder-art .folder__front { transform: skew(15deg) scaleY(.6) !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool.is-mobile-folder-pressed .mobile-dashboard-folder-art .folder__front.right { transform: skew(-15deg) scaleY(.6) !important; }
    /* On phones a tap opens the section; the folder itself stays closed and does not play its flap animation. */
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .react-folder-mount { pointer-events: none; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .react-folder-component :is(.folder, .paper, .folder__front) { transition: none !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .react-folder-component .folder { transform: none !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .react-folder-component .paper { transform: translate(-50%, 10%) !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .react-folder-component .folder__front { transform: none !important; }

    body.mobile-dashboard-active .main > section:not(#dashboardWorkspace):not(.global-search):not([hidden]) {
        position: relative !important;
        inset: auto !important;
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        box-sizing: border-box;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
    }
    body.mobile-dashboard-active.mobile-dashboard-nav-open .main > section:not(#dashboardWorkspace):not(.global-search):not([hidden]) { visibility: hidden; pointer-events: none; }
    body.mobile-dashboard-active #appHomeWorkspace { padding: 24px 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
    body.mobile-dashboard-active #appHomeWorkspace .app-home-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px 16px;
        align-items: start;
    }
    body.mobile-dashboard-active #appHomeWorkspace .app-home-header > div:first-child { display: contents; }
    body.mobile-dashboard-active #appHomeWorkspace .app-home-eyebrow { grid-column: 1; grid-row: 1; margin: 0; }
    body.mobile-dashboard-active #appHomeWorkspace #appHomeTitle { grid-column: 1 / -1; grid-row: 2; min-width: 0; overflow-wrap: anywhere; }
    body.mobile-dashboard-active #appHomeWorkspace .home-exam-countdown { grid-column: 2; grid-row: 1; justify-self: end; text-align: right; max-width: 180px; }
    body.mobile-dashboard-active #appHomeWorkspace .home-exam-clock { justify-content: flex-end; gap: 4px; }
    body.mobile-dashboard-active #appHomeWorkspace .home-exam-clock > div { min-width: 36px; padding: 6px; }
    body.mobile-dashboard-active #appHomeWorkspace .home-exam-clock strong { font-size: 19px; }
    body.mobile-dashboard-active #appHomeWorkspace .home-exam-dialog { left: auto; right: 0; top: calc(100% + 8px); width: min(300px, calc(100vw - 32px)); box-sizing: border-box; text-align: left; }
    body.mobile-dashboard-active .home-columns,
    body.mobile-dashboard-active .home-side-column,
    body.mobile-dashboard-active .home-side-bottom { grid-template-columns: minmax(0, 1fr); }
    body.mobile-dashboard-active .home-history-card,
    body.mobile-dashboard-active .home-friends-panel { width: 100% !important; max-width: 100%; }
    body.mobile-dashboard-active .home-paper-progress-card { width: 100%; height: auto !important; min-height: 0 !important; }
    body.mobile-dashboard-active .home-progress-scroll { flex: 0 0 auto; height: auto !important; max-height: none; overflow: visible !important; }
    body.mobile-dashboard-active .home-paper-progress-card .paper-progress-chart { height: auto; }
    body.mobile-dashboard-active .home-question-donuts .insight-legend li:not(:has(i)) { display: block; }

    body.mobile-dashboard-active #dashboardWorkspace .mobile-settings-row svg.mobile-row-chevron { flex: 0 0 16px; width: 16px; height: 16px; margin-left: auto; fill: none; stroke: var(--menu-icon); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    body.mobile-dashboard-active.mobile-dashboard-nav-open:has(#dashboardWorkspace:not([hidden])) .app-shell .main > #appHomeWorkspace:is(#appHomeWorkspace):not([hidden]) {
        grid-row: 3 !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        visibility: visible !important;
        pointer-events: auto;
        border-top: 1px solid var(--border) !important;
    }

    /* ---- Phone menu, copied from the RevisionDojo mobile menu: white header with logo, search and close; soft grey selector; compact rows; Settings on its own fixed white panel ---- */
    body.mobile-dashboard-active { --menu-font: Manrope, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; --menu-text: #808080; --menu-icon: #ababab; --menu-soft: #f5f5f5; --menu-blue: #e1eefb; --menu-blue-ink: #2d78bd; --menu-footer-h: 108px; }

    /* Header: logo and name on the left, search, then the close (X) on the far right. No divider line under it. */
    body.mobile-dashboard-active:has(#dashboardWorkspace:not([hidden])) .main > .topbar { padding: env(safe-area-inset-top, 0px) 14px 0 14px; background: #fff; }
    /* The divider line is removed only on the open menu page; every other phone page keeps it. */
    body.mobile-dashboard-active.mobile-dashboard-nav-open:has(#dashboardWorkspace:not([hidden])) .main > .topbar { border-bottom: 0 !important; box-shadow: none !important; }
    body.mobile-dashboard-active .topbar .topbar-left { display: contents !important; }
    body.mobile-dashboard-active .topbar #globalHomeButton { order: 1; margin-right: auto !important; }
    body.mobile-dashboard-active .topbar .topbar-search-button { order: 2; }
    body.mobile-dashboard-active .topbar .topbar-actions { order: 3; }
    body.mobile-dashboard-active .topbar .sidebar-toggle-button { order: 4; margin-left: 4px !important; }
    body.mobile-dashboard-active .topbar .prep-atlas-brand { gap: 8px; }
    body.mobile-dashboard-active .topbar .prep-atlas-brand__mascot-frame { width: 30px; height: 30px; flex-basis: 30px; }
    body.mobile-dashboard-active .topbar .prep-atlas-brand__name { color: #111; font: 600 22px/1 var(--menu-font); letter-spacing: -.02em; }
    body.mobile-dashboard-active:has(#dashboardWorkspace:not([hidden])) .topbar .topbar-search-button { background: var(--menu-soft); border-radius: 12px; color: #ababab; }
    body.mobile-dashboard-active .topbar .sidebar-toggle-button svg { width: 26px; height: 26px; color: #ababab; }
    /* While the menu is open the profile and gear leave the header; Settings moves to the bottom panel. */
    body.mobile-dashboard-active.mobile-dashboard-nav-open .topbar :is(.account-trigger, .topbar-settings-button) { display: none !important; }
    body.mobile-dashboard-active.mobile-dashboard-nav-open .topbar .topbar-settings-menu { position: fixed; top: auto; right: 12px; bottom: calc((100lvh - 100svh) / 1.05 + var(--menu-footer-h) + 8px); left: 12px; width: auto; max-width: 360px; margin-left: auto; z-index: 120; }

    /* Subject selector: soft grey bar with the current subject in a white pill. */
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-subject-trigger { display: flex; align-items: center; gap: 4px; width: 100%; height: 40px; min-height: 0; padding: 4px; border: 0; border-radius: 14px; background: var(--menu-soft); box-shadow: none; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-subject-selector-label { position: relative; display: flex; flex: 1 1 auto; align-items: center; justify-content: center; min-width: 0; height: 100%; padding: 0 30px; overflow: hidden; border: 0; border-radius: 11px; background: #fff; box-shadow: none; color: #111; font: 600 15px/1 var(--menu-font); white-space: nowrap; text-overflow: ellipsis; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-subject-selector-label::after { position: absolute; top: 50%; right: 13px; width: 6px; height: 6px; border-right: 1.8px solid #ababab; border-bottom: 1.8px solid #ababab; transform: translateY(-70%) rotate(45deg); content: ""; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-subject-plan { flex: 0 0 auto; margin: 0 8px 0 4px; padding: 2px 7px; border: 0; border-radius: 8px; background: #fff; color: #7a7a7a; font: 700 10.5px/14px var(--menu-font); }

    /* Tight layout. */
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-inner { padding: 6px 12px calc(var(--menu-footer-h) + 16px) !important; gap: 6px; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-columns { gap: 0; }
    body.mobile-dashboard-active #dashboardWorkspace .sidebar-section-label { margin: 12px 10px 3px; padding: 0; color: #767676; font: 700 11px/16px var(--menu-font); letter-spacing: .05em; text-transform: uppercase; }
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-columns > .sidebar-section-label:first-child { margin-top: 6px; margin-bottom: 0; }

    /* Rows: 30px tall, soft grey icons, medium dark text; the active row is light blue with blue text and icon. */
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-home-button, .sidebar-nav-button, .quick-chat-button, .mobile-settings-row),
    body.mobile-dashboard-active #dashboardWorkspace .atlas-launcher__items button { min-height: 29px; padding: 3px 10px; border-radius: 13px; gap: 12px; }
    body.mobile-dashboard-active #dashboardWorkspace #homeNewChatButton { padding-left: 10px; }
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-home-button-label, .quick-chat-button-label, .sidebar-nav-button > span, .atlas-launcher__items button > span) { color: var(--menu-text) !important; font: 600 15.5px/1.2 var(--menu-font) !important; letter-spacing: normal !important; }
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-home-button, .sidebar-nav-button, .quick-chat-button, .atlas-launcher__items button):is(:hover, :focus-visible) { background: #f7f7f7; }
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-home-button, .sidebar-nav-button, .quick-chat-button, .atlas-launcher__items button).is-active { background: var(--menu-blue); }
    body.mobile-dashboard-active #dashboardWorkspace :is(.dashboard-home-button, .sidebar-nav-button, .quick-chat-button, .atlas-launcher__items button).is-active :is(.dashboard-home-button-label, .quick-chat-button-label, span) { color: var(--menu-blue-ink) !important; }
    body.mobile-dashboard-active #dashboardWorkspace #dashboardLauncherHomeButton.is-active .dashboard-home-button-icon { content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='%232d78bd'%3E%3Cpath d='M32 10Q34 10 36 11.500L52 25Q54 27 54 30V52Q54 58 48 58H38V45A6 6 0 0 0 26 45V58H16Q10 58 10 52V30Q10 27 12 25L28 11.500Q30 10 32 10Z'/%3E%3C/svg%3E"); }
    body.mobile-dashboard-active #dashboardWorkspace #homeNewChatButton .dashboard-chat-mascot { color: var(--menu-icon); }

    /* Settings: its own fixed white panel at the bottom, outside the scrolling list; the list fades out above it. */
    /* The panel is placed from the visible-viewport height (svh), so it stays above Safari's floating toolbar instead of hiding behind it. */
    body.mobile-dashboard-active.mobile-dashboard-nav-open .mobile-menu-footer { position: fixed; right: 0; left: 0; z-index: 70; display: block; box-sizing: border-box; height: var(--menu-footer-h); padding: 6px 12px; background: #fff; top: calc(100vh / 1.05 - var(--menu-footer-h)); top: calc(100svh / 1.05 - var(--menu-footer-h)); }
    body.mobile-dashboard-active.mobile-dashboard-nav-open .mobile-menu-footer::before { position: absolute; right: 0; bottom: 100%; left: 0; height: 28px; background: linear-gradient(to top, #fff, rgba(255, 255, 255, 0)); pointer-events: none; content: ""; }
    body.mobile-dashboard-active #dashboardWorkspace .mobile-settings-row { display: flex; align-items: center; width: 100%; margin: 0; border: 0; background: transparent; color: var(--menu-text); font: 600 15.5px/1.2 var(--menu-font); text-align: left; }
    body.mobile-dashboard-active #dashboardWorkspace .mobile-settings-row:is(:hover, :focus-visible) { background: #f7f7f7; }
    body.mobile-dashboard-active #dashboardWorkspace .mobile-settings-row svg { flex: 0 0 18px; width: 18px; height: 18px; fill: var(--menu-icon); stroke: var(--menu-icon); stroke-width: 1.2; stroke-linejoin: round; }
    body.mobile-dashboard-active.mobile-dashboard-nav-open:has(#dashboardWorkspace:not([hidden])) .app-shell .main > #appHomeWorkspace:is(#appHomeWorkspace):not([hidden]) { border-top: 0 !important; padding-bottom: calc(var(--menu-footer-h) + 16px); }

    /* Folders sit close together and right under their title; the labels use the menu font. */
    body.mobile-dashboard-active #dashboardWorkspace .folder-group { grid-template-columns: repeat(2, 132px); justify-content: center; gap: 0 6px; padding: 0; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool { height: 88px; min-height: 88px; padding: 2px 4px; gap: 2px; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool__visual { flex: 0 0 58px !important; height: 58px; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool .folder { filter: none !important; box-shadow: none !important; }
    body.mobile-dashboard-active #dashboardWorkspace .folder-tool-label { color: #767676 !important; font: 600 14px/18px var(--menu-font) !important; transform: translateY(4px); }

    /* Section titles end in an arrow that opens the list of every button in that section; each row ends in an unpin icon. */
    body.mobile-dashboard-active #dashboardWorkspace .sidebar-section-label[role="button"] { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
    body.mobile-dashboard-active #dashboardWorkspace .menu-section-chevron { display: block; flex: 0 0 16px; width: 16px; height: 16px; margin-right: 0; fill: none; stroke: var(--menu-icon); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    /* Rows and section titles run as wide as the subject bar, so the arrows and pins sit on one column near the right edge. */
    body.mobile-dashboard-active #dashboardWorkspace .dashboard-columns { margin-right: 0; margin-left: 0; padding-right: 0; padding-left: 0; }
    body.mobile-dashboard-active #dashboardWorkspace .menu-pin { position: relative; display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 34px; height: 29px; margin: -29px 0 0 auto; padding: 0; border: 0; background: transparent; cursor: pointer; }
    body.mobile-dashboard-active #dashboardWorkspace .menu-pin svg, .mobile-menu-drawer svg.drawer-pin-icon { width: 18px; height: 18px; }
    body.mobile-dashboard-active #dashboardWorkspace .is-menu-unpinned { display: none !important; }
    body.mobile-dashboard-active #dashboardWorkspace :is(.sidebar-nav-button, .dashboard-home-button, .quick-chat-button, .atlas-launcher__items button):has(+ .menu-pin) { padding-right: 40px; }

    body .mobile-menu-drawer { position: fixed; top: 0; right: 0; left: 0; z-index: 140; display: flex; height: 100vh; height: calc(100svh / 1.05); }
    body .mobile-menu-drawer[hidden] { display: none; }
    .mobile-menu-drawer-scrim { order: 2; flex: 1 1 auto; border: 0; background: rgba(0, 0, 0, .78); cursor: pointer; animation: menu-drawer-fade .2s ease-out both; }
    .mobile-menu-drawer-panel { order: 1; flex: 0 0 58%; max-width: 270px; box-sizing: border-box; padding: calc(env(safe-area-inset-top, 0px) + 22px) 12px 16px; overflow-y: auto; background: #fff; font-family: var(--menu-font); animation: menu-drawer-slide .2s cubic-bezier(.16, .84, .3, 1) both; }
    /* Close (X) button: a white rounded square just right of the list, like the reference. */
    .mobile-menu-drawer-close { position: absolute; z-index: 2; top: calc(env(safe-area-inset-top, 0px) + 14px); left: calc(min(58%, 270px) + 10px); display: flex; align-items: center; justify-content: center; width: 42px; height: 40px; padding: 0; border: 0; border-radius: 14px; background: #fff; cursor: pointer; animation: menu-drawer-x .2s cubic-bezier(.16, .84, .3, 1) both; }
    .mobile-menu-drawer.is-closing .mobile-menu-drawer-scrim { animation: menu-drawer-fade-out .2s ease-out both; pointer-events: none; }
    .mobile-menu-drawer.is-closing .mobile-menu-drawer-panel { animation: menu-drawer-slide-out .2s cubic-bezier(.16, .84, .3, 1) both; pointer-events: none; }
    .mobile-menu-drawer.is-closing .mobile-menu-drawer-close { animation: menu-drawer-x-out .2s cubic-bezier(.16, .84, .3, 1) both; pointer-events: none; }
    .mobile-menu-drawer-close svg { width: 22px; height: 22px; fill: none; stroke: #8a8a8a; stroke-width: 1.9; stroke-linecap: round; }
    .mobile-menu-drawer h3 { margin: 0 8px 6px; color: #767676; font: 700 11px/16px var(--menu-font); letter-spacing: .05em; text-transform: uppercase; }
    .mobile-menu-drawer .drawer-row { display: flex; align-items: center; }
    .mobile-menu-drawer .drawer-open { display: flex; flex: 1 1 auto; align-items: center; gap: 12px; min-width: 0; min-height: 38px; padding: 3px 8px; border: 0; border-radius: 13px; background: transparent; color: #808080; font: 600 15.5px/1.2 var(--menu-font); text-align: left; cursor: pointer; }
    .mobile-menu-drawer .drawer-row:is(:hover, :focus-within) { border-radius: 13px; background: #f7f7f7; }
    .mobile-menu-drawer .drawer-open > :is(img, svg) { flex: 0 0 18px !important; width: 18px !important; height: 18px !important; margin: 0 !important; color: var(--menu-icon); }
    .mobile-menu-drawer .drawer-open > svg.drawer-folder { flex-basis: 20px; width: 20px; height: 20px; }
    .mobile-menu-drawer .drawer-pin { flex: 0 0 34px; width: 34px; height: 34px; padding: 0; border: 0; background: transparent; cursor: pointer; }
    .mobile-menu-drawer .drawer-pin svg { width: 18px; height: 18px; }

    /* Unpin toast: white pill with a black check and an Undo button, floating up above the bottom panel. */
    body .mobile-menu-toast { position: fixed; right: 12px; left: 12px; z-index: 150; box-sizing: border-box; display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 9px 0 16px; border: 2px solid #e6e6e6; border-radius: 22px; background: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .08); font-family: var(--menu-font); opacity: 0; transform: translateY(24px); visibility: hidden; pointer-events: none; top: calc(100vh / 1.05 - var(--menu-footer-h) - 66px); top: calc(100svh / 1.05 - var(--menu-footer-h) - 66px); transition: opacity .14s ease, transform .2s cubic-bezier(.2, .9, .3, 1.2), visibility 0s .2s; }
    body .mobile-menu-toast.is-visible { opacity: 1; transform: translateY(0); visibility: visible; pointer-events: auto; transition: opacity .14s ease, transform .2s cubic-bezier(.2, .9, .3, 1.2); }
    body:not(.mobile-dashboard-nav-open) .mobile-menu-toast { display: none; }
    .mobile-menu-toast > svg { flex: 0 0 24px; width: 24px; height: 24px; fill: #6e6e6e; }
    .mobile-menu-toast > svg path { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
    .mobile-menu-toast .toast-text { flex: 1 1 auto; min-width: 0; overflow: hidden; color: #777; font: 600 15.5px/1.2 var(--menu-font); text-overflow: ellipsis; white-space: nowrap; }
    .mobile-menu-toast .toast-undo { flex: 0 0 auto; height: 38px; padding: 0 18px; border: 0; border-radius: 12px; background: #6e6e6e; color: #fff; font: 600 15px/1 var(--menu-font); cursor: pointer; }
}

/* Desktop sidebar: the same section arrows and unpin icons; the list opens right of the sidebar under the top bar, the toast floats at the bottom middle of the main page. */
@media (min-width: 760px) {
    #dashboardWorkspace .sidebar-section-label[role="button"] { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
    #dashboardWorkspace .menu-section-chevron { display: block; flex: 0 0 14px; width: 14px; height: 14px; margin-right: 8px; fill: none; stroke: #ababab; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    #dashboardWorkspace .menu-pin { position: relative; display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 30px; height: 30px; margin: -30px 0 0 auto; padding: 0; cursor: pointer; }
    #dashboardWorkspace .menu-pin svg { width: 16px; height: 16px; }
    /* Sidebar pins show only on the row being hovered and on the open page (the same rows that get the grey highlight). Hovering the pin keeps the highlight. */
    #dashboardWorkspace .menu-pin { opacity: 0; }
    #dashboardWorkspace :is(.sidebar-nav-button, .dashboard-home-button, .quick-chat-button, .atlas-launcher__items button):is(:hover, :focus-visible, .is-active) + .menu-pin, #dashboardWorkspace :is(.sidebar-nav-button, .dashboard-home-button, .quick-chat-button, .atlas-launcher__items button):has(+ .menu-pin:is(:hover, :focus-visible)) + .menu-pin, #dashboardWorkspace .menu-pin:is(:hover, :focus-visible) { opacity: 1; }
    #dashboardWorkspace :is(.sidebar-nav-button, .dashboard-home-button, .quick-chat-button, .atlas-launcher__items button):has(+ .menu-pin:hover) { background: #f3f4f6; }
    #dashboardWorkspace .is-menu-unpinned { display: none !important; }
    #dashboardWorkspace :is(.sidebar-nav-button, .dashboard-home-button, .quick-chat-button, .atlas-launcher__items button):has(+ .menu-pin) { padding-right: 22px; }
    #dashboardWorkspace :is(.sidebar-nav-button, .dashboard-home-button, .quick-chat-button, .atlas-launcher__items button):has(+ .menu-pin) > :is(span, .quick-chat-button-label) { white-space: nowrap; }

    /* The list opens on hover, flush against the sidebar and top bar walls (it starts just past them, never over them), with no dimming and no animation. */
    body .mobile-menu-drawer { position: fixed; top: calc(var(--tb-bottom, 48px) + 2px); right: auto; bottom: 0; left: calc(var(--sb-right, 0px) + 2px); z-index: 5; display: block; width: 270px; height: auto; pointer-events: none; overflow: hidden; }
    body .mobile-menu-drawer[hidden] { display: none; }
    .mobile-menu-drawer-scrim { display: none; }
    .mobile-menu-drawer-panel { box-sizing: border-box; height: 100%; padding: 18px 10px 16px; overflow-y: auto; border-right: 1px solid #d9dde3; border-top-left-radius: 12px; background: #fff; pointer-events: auto; animation: menu-drawer-slide .18s cubic-bezier(.16, .84, .3, 1) both; }
    .mobile-menu-drawer-close { position: absolute; top: 12px; left: 228px; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 9px; background: transparent; cursor: pointer; pointer-events: auto; animation: menu-drawer-x-desk .18s cubic-bezier(.16, .84, .3, 1) both; }
    .mobile-menu-drawer.is-closing .mobile-menu-drawer-panel { animation-name: menu-drawer-slide-out; animation-duration: .18s; }
    .mobile-menu-drawer.is-closing .mobile-menu-drawer-close { animation: menu-drawer-x-desk-out .18s cubic-bezier(.16, .84, .3, 1) both; pointer-events: none; }
    .mobile-menu-drawer-close:is(:hover, :focus-visible) { background: #f5f5f5; }
    .mobile-menu-drawer-close svg { width: 16px; height: 16px; fill: none; stroke: #8a8a8a; stroke-width: 1.9; stroke-linecap: round; }
    .mobile-menu-drawer h3 { margin: 0 8px 6px; color: #767676; font: 700 11px/16px Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; letter-spacing: .05em; text-transform: uppercase; }
    .mobile-menu-drawer .drawer-row { display: flex; align-items: center; }
    .mobile-menu-drawer .drawer-open { display: flex; flex: 1 1 auto; align-items: center; gap: 12px; min-width: 0; min-height: 34px; padding: 3px 8px; border: 0; border-radius: 10px; background: transparent; color: #808080; font: 500 14px/1.2 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; text-align: left; cursor: pointer; }
    .mobile-menu-drawer .drawer-row:is(:hover, :focus-within) { border-radius: 10px; background: #f5f5f5; }
    .mobile-menu-drawer .drawer-open > :is(img, svg) { flex: 0 0 18px !important; width: 18px !important; height: 18px !important; margin: 0 !important; color: #ababab; }
    .mobile-menu-drawer .drawer-pin { flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border: 0; background: transparent; cursor: pointer; }
    .mobile-menu-drawer .drawer-pin svg { width: 16px; height: 16px; }

    body .mobile-menu-toast { position: fixed; bottom: 28px; left: calc(var(--sb-right, 0px) + (100vw / 1.05 - var(--sb-right, 0px)) / 2 - 190px); z-index: 150; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 380px; height: 54px; padding: 0 8px 0 16px; border: 2px solid #e6e6e6; border-radius: 20px; background: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .08); opacity: 0; transform: translateY(24px); visibility: hidden; pointer-events: none; transition: opacity .14s ease, transform .2s cubic-bezier(.2, .9, .3, 1.2), visibility 0s .2s; }
    body .mobile-menu-toast.is-visible { opacity: 1; transform: translateY(0); visibility: visible; pointer-events: auto; transition: opacity .14s ease, transform .2s cubic-bezier(.2, .9, .3, 1.2); }
    .mobile-menu-toast > svg { flex: 0 0 22px; width: 22px; height: 22px; fill: #6e6e6e; }
    .mobile-menu-toast > svg path { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
    .mobile-menu-toast .toast-text { flex: 1 1 auto; min-width: 0; overflow: hidden; color: #777; font: 600 14.5px/1.2 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-menu-toast .toast-undo { flex: 0 0 auto; height: 36px; padding: 0 16px; border: 0; border-radius: 11px; background: #6e6e6e; color: #fff; font: 600 14px/1 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; cursor: pointer; }
}

@keyframes menu-drawer-slide { from { transform: translateX(-100%); } }
@keyframes menu-drawer-fade { from { opacity: 0; } }
/* The X travels with the panel edge: phone panel slides 0 to 58% width, so the X's left moves from 10px to its own resting place; desktop panel slides 270px, so the X moves from -42px (228px - 270px). */
@keyframes menu-drawer-x { from { left: 10px; } }
@keyframes menu-drawer-x-out { to { left: 10px; } }
@keyframes menu-drawer-x-desk { from { left: -42px; } }
@keyframes menu-drawer-x-desk-out { to { left: -42px; } }
@keyframes menu-drawer-slide-out { to { transform: translateX(-100%); } }
@keyframes menu-drawer-fade-out { to { opacity: 0; } }

/* The phone-only Settings row, section arrows, unpin icons and list drawer stay hidden everywhere else. */
.mobile-settings-row, .mobile-menu-footer, .menu-pin, .menu-section-chevron, .mobile-menu-drawer, .mobile-menu-toast { display: none; }
.menu-pin svg, .drawer-pin svg { fill: #ababab; stroke: none; }
.menu-pin svg .slash, .drawer-pin svg .slash { fill: none; stroke: #ababab; stroke-width: 2.2; stroke-linecap: round; }

@media (prefers-reduced-motion: reduce) {
    .mobile-menu-drawer-panel, .mobile-menu-drawer-scrim, .mobile-menu-drawer-close { animation: none !important; }
}

@media (max-width: 759px) and (prefers-reduced-motion: reduce) {
    body.mobile-dashboard-active #dashboardWorkspace .mobile-dashboard-folder-art :is(.folder, .paper, .folder__front) { transition: none !important; }
}
