/* ── Mobile Responsive Layer ──
   Pure additive — everything inside @media queries.
   Desktop layout is completely untouched.

   Base font context: html { font-size: 63.5% } = 10px
   So 1rem = 10px, 1.4rem = 14px, etc.
   At 375px with 0.7rem padding each side → ~361px content width */

/* ── Utility classes (always active) ── */
.mobile-only { display: none !important; }

/* ══════════════════════════════════════════════════════════
   MOBILE  (≤1024px)
   Covers phones, tablets, iPads (portrait + landscape)
   Two-mode layout: list view OR network view
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {

    /* ────────────────────────────────────────────────────
       MOBILE TOP-BAR + FLOATING SUPPORT (added 2026-05-07)
       Pull the back-to-sociologix link and mail button out of the
       header into a fixed-top mini bar above the title. Float the
       support button bottom-right (replaces the old BMC corner).
       ──────────────────────────────────────────────────── */
    .net-topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 40px;
        z-index: 300;
        display: flex !important;
        align-items: center;
        gap: 6px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        padding: 0 12px;
    }
    .net-topbar .back-to-sociologix {
        flex-shrink: 0;
        border: 0 !important;
        background: transparent !important;
        padding: 0 !important;
        margin-right: auto;
    }
    .net-topbar .mail-btn {
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        border: 0;
        background: transparent;
        color: #5ddbe8;
    }
/* Text-size icon in the top sticky bar (matches mail-btn footprint) */
    .net-topbar .mobile-text-btn {
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: 0;
        color: #e8a96a;
        font-size: 1rem;
        cursor: pointer;
        padding: 0;
    }
    .net-topbar .mobile-text-btn:hover { color: var(--text-on-dark); }
    .net-topbar .theme-toggle {
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        background: transparent !important;
        border: 0 !important;
        color: #e8a96a;
        font-size: 1.1rem;
        padding: 0;
    }
    /* Support button in topbar: strip the circular wrapper so it reads
       as a clean icon next to the other utility icons. */
    .net-topbar .support-btn {
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0;
    }
    .net-topbar .support-btn:hover {
        background: transparent !important;
        box-shadow: none !important;
        transform: none;
    }
    .net-topbar .support-btn .support-btn-icon {
        width: 18px;
        height: auto;
    }

    /* Reserve space for the topbar by padding the app-header.
       Fixed topbar (z:300) overlays the header's top 40px region. */
    .app-header { padding-top: calc(40px + 0.5rem) !important; }
    /* ── Disable tap highlight ── */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* ────────────────────────────────────────────────────
       A. GLOBAL CONTAINMENT
       Desktop: body { overflow: hidden; height: 100vh }
       Problem: prevents scrolling, traps overflow
       ──────────────────────────────────────────────────── */
    html {
        /* Base mobile scale — overridden by user slider via JS var --mobile-scale */
        font-size: calc(var(--mobile-scale, 80) * 1%) !important;
    }
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    body {
        overflow-y: auto;
        height: 100vh;
        height: 100dvh;
    }
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* ────────────────────────────────────────────────────
       B. SHOW/HIDE + MODE TOGGLE
       ──────────────────────────────────────────────────── */
    .mobile-only { display: flex !important; }
    .desktop-only { display: none !important; }

    /* List mode: left panel fills screen, right panel fully hidden.
       Detail overlay on mobile is a separate element created by mobile.js. */
    body.mobile-mode-list .left-panel  { display: flex !important; }
    body.mobile-mode-list .right-panel { display: none !important; }

    /* Network mode: right panel fills screen, left panel hidden */
    body.mobile-mode-network .left-panel  { display: none !important; }
    body.mobile-mode-network .right-panel { display: block !important; }

    /* ────────────────────────────────────────────────────
       C. LEFT PANEL
       Desktop: overflow: hidden; border-right: 1px solid
       Problem: clips results list, border wastes space
       ──────────────────────────────────────────────────── */
    .left-panel {
        border-right: none;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        overflow-y: auto;   /* desktop has overflow:hidden — need scroll */
    }

    /* ────────────────────────────────────────────────────
       D. HEADER — stacked: title row, then full-width search
       Desktop: padding 1.2rem 2rem, gap 2rem, horizontal flex
       Problem: 40px horiz padding + 20px gap eats most of 375px
       ──────────────────────────────────────────────────── */
    .app-header {
        padding: 0.5rem 0.7rem;
        gap: 0;
        flex-wrap: wrap;
        position: sticky;
        top: 0;
        z-index: 200;
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }
    /* Title on its own row */
    .app-header .logo-area {
        flex: 1 1 100%;
        min-width: 0;
        margin-bottom: 0.3rem;
        display: flex;
        align-items: center;
        min-height: 2.2rem;
    }
    .app-header .logo-area h1 {
        font-size: clamp(1.2rem, 5vw, 1.9rem);
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .app-header .logo-area .subtitle,
    .app-header .logo-area .data-updated {
        display: none;
    }
    /* Hide stats, spacers */
    .stats-bar,
    .header-spacer {
        display: none !important;
    }
    /* Hide desktop BMC button — replaced by mobile mug */
    .bmc-btn {
        display: none !important;
    }
    /* Header banner image (replaces BMC on some networks) */
    .app-header img {
        display: none !important;
    }
    /* Search bar — own row, full width
       Desktop: flex:3, min-width:350px (wider than 375px viewport!)
       Fix: min-width:0, flex to fill row */
    .search-area {
        flex: 1 1 100%;
        min-width: 0 !important;
        max-width: 100%;
        order: 1;
    }
    /* Desktop input: padding 0.8rem 1.4rem 0.8rem 3.6rem, font-size 1.4rem
       Fix: tighter padding, 16px font prevents iOS zoom-on-focus */
    .search-area input {
        font-size: 14px;
        padding: 0.4rem 1rem 0.4rem 2.8rem;
        width: 100%;
    }
    .mobile-search-wrap {
        position: relative;
        flex: 1;
        min-width: 0;
    }
    .mobile-search-wrap .search-icon {
        position: absolute;
        left: 0.8rem;
        top: 50%;
        transform: translateY(-50%);
    }
    .mobile-search-wrap input {
        width: 100%;
    }
    /* Desktop: font-size 2.1rem, flex-shrink:0
       Fix: smaller icon */
    .about-btn {
        flex-shrink: 0;
        font-size: 1.6rem;
    }
    .synonym-pills {
        display: none !important;
    }
    /* Back breadcrumb — styled as a compact button below search */
    .prev-search-breadcrumb {
        flex: 1 1 100%;
        order: 2;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 0 !important;
        margin: -0.3rem 0 0.1rem;
    }
    .breadcrumb-item {
        color: var(--text-muted);
        cursor: pointer;
        font-weight: 500;
    }
    .breadcrumb-item:last-child {
        color: var(--core-teal);
        font-weight: 600;
    }
    .breadcrumb-item:active {
        opacity: 0.6;
        line-height: 1.2;
    }

    /* ────────────────────────────────────────────────────
       E. FILTERS — collapsible accordion
       Desktop: padding 0.8rem 1rem, filter-label 100px fixed
       Fix: no outer padding, labels stack above controls
       ──────────────────────────────────────────────────── */
    .filters-section {
        padding: 0;
        border-bottom: 1px solid var(--border-color);
        width: 100%;
        overflow: hidden;
    }
    /* Filters section hidden on mobile — content moved to slide panel */
    .filters-section {
        display: none !important;
    }
    /* Stack label above control instead of side-by-side
       Desktop: flex row, filter-label width:100px min-width:100px flex-shrink:0 */
    .filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.2rem;
        max-width: 100%;
        overflow: visible;  /* desktop has overflow:hidden (line 593) — need dropdowns visible */
    }
    .filter-label {
        font-size: 0.8rem;
        min-width: 0;
        width: auto;
        text-align: left;
        padding-right: 0;
        flex-shrink: 1;
    }
    .filter-row select,
    .doctype-dropdown-btn {
        width: 100%;
        max-width: 100%;
    }
    .year-range-container {
        width: 100%;
    }
    /* Desktop: white-space:nowrap, flex-shrink:0
       Fix: allow wrap + shrink */
    .year-display {
        white-space: normal;
        flex-shrink: 1;
        font-size: 0.85rem;
    }
    /* Network toggle full-width */
    .network-toggle {
        display: flex;
        width: 100%;
    }
    .network-toggle .toggle-btn {
        flex: 1;
        font-size: 0.85rem;
        padding: 0.5rem;
    }

    /* ────────────────────────────────────────────────────
       F. SCOPE TOGGLE
       Desktop: padding 0.5rem 1.4rem
       Fix: tighter padding, allow wrapping
       ──────────────────────────────────────────────────── */
    .scope-toggle {
        padding: 0.5rem 0.8rem;
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: wrap;
        font-size: 1rem;
    }
    .scope-toggle .scope-btn {
        font-size: 0.95rem;
        padding: 0.2rem 0.5rem;
    }

    /* ────────────────────────────────────────────────────
       G. RESULTS HEADER + SORT
       Desktop: padding 1rem 1.4rem
       BUG: sort-select had flex-shrink:0 causing cutoff
       ──────────────────────────────────────────────────── */
    /* Results header — just the count, compact */
    .results-header {
        padding: 0.2rem 0.8rem;
        border-bottom: none;
    }
    .results-header .sort-select {
        display: none;
    }
    .results-count {
        font-size: 0.8rem;
        color: var(--text-muted);
        text-align: center;
        width: 100%;
    }

    /* ── Filter & sort toolbar — hidden, merged into pills row ── */
    .mobile-toolbar {
        display: none !important;
    }
    .mobile-toolbar-btn {
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.4rem;
        cursor: pointer;
        padding: 0.4rem;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: opacity 0.15s;
    }
    .mobile-toolbar-btn:active {
        opacity: 0.6;
    }
    .mobile-toolbar-btn.active {
        opacity: 0.6;
    }
    .mobile-reset-btn {
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.2rem;
        cursor: pointer;
        padding: 0.4rem;
        margin-left: 0.6rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mobile-reset-btn:active {
        opacity: 0.5;
    }

    /* ── Slide-down panels (filter + sort) ── */
    .mobile-slide-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 300;
        max-height: 70vh;
        background: var(--bg-secondary);
        border-radius: 0 0 12px 12px;
        border-bottom: 2px solid var(--core-teal);
        box-shadow: none;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        visibility: hidden;
    }
    .mobile-slide-panel.visible {
        transform: translateY(0);
        box-shadow: 0 4px 20px rgba(0,0,0,0.4);
        visibility: visible;
    }
    .slide-panel-handle {
        display: none;
    }
    .slide-panel-close {
        position: absolute;
        top: 0.4rem;
        right: 0.8rem;
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.6rem;
        font-weight: 700;
        cursor: pointer;
        padding: 0.2rem 0.4rem;
        z-index: 1;
    }
    .slide-panel-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 2rem 1rem 0.8rem;
        -webkit-overflow-scrolling: touch;
    }
    /* Filter content inside panel */
    .mobile-filter-content .filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.2rem;
        max-width: 100%;
    }
    .mobile-filter-content .filter-label {
        font-size: 0.8rem;
        min-width: 0;
        width: auto;
        text-align: left;
        padding-right: 0;
    }
    .mobile-filter-content .filter-row select,
    /* Hide native select, show custom overlay on top */
    .mobile-dropdown-wrap {
        position: relative;
    }
    .mobile-select-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        padding: 0.35rem 2.2rem 0.35rem 0.6rem;
        background: var(--bg-panel);
        border: 1px solid var(--border-color);
        border-radius: 4px;
        color: var(--text-on-dark);
        font-family: var(--font-body);
        font-size: 1rem;
        cursor: pointer;
        z-index: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Custom picker — dropdown over filters */
    .mobile-picker-backdrop {
        position: fixed;
        inset: 0;
        z-index: 400;
    }
    .mobile-custom-picker-body {
        position: fixed;
        left: 1rem;
        right: 1rem;
        z-index: 401;
        max-height: 40vh;
        background: var(--bg-panel);
        border: 1px solid var(--border-color);
        border-radius: 0 0 6px 6px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    }
    .mobile-picker-option {
        padding: 0.6rem 0.8rem;
        font-size: 1rem;
        color: var(--text-on-dark);
        font-family: var(--font-body);
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
    }
    .mobile-picker-option:last-child {
        border-bottom: none;
    }
    .mobile-picker-option:active {
        background: var(--bg-hover);
    }
    .mobile-picker-option.selected {
        color: var(--core-teal);
        font-weight: 600;
    }
    .mobile-picker-option:first-child {
        background: rgba(255, 255, 255, 0.04);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .mobile-picker-option.disabled {
        color: var(--text-muted);
        opacity: 0.35;
        cursor: default;
    }
    /* Remove red focus outline on filter dropdowns */
    .mobile-filter-content select:focus,
    .mobile-filter-content .doctype-dropdown-btn:focus,
    .mobile-filter-content .doctype-dropdown-btn:hover {
        border-color: var(--border-color) !important;
        outline: none !important;
        box-shadow: none !important;
    }
    /* Match doctype button to native selects — vertically center text */
    .doctype-dropdown-btn {
        display: flex !important;
        align-items: center !important;
        font-size: 1.1rem !important;
    }
    /* Hide the CSS ::after arrow on doctype */
    .doctype-dropdown-btn::after {
        display: none !important;
    }
    /* Hide native select arrows, replace all with FA icon */
    .mobile-filter-content select,
    .mobile-filter-content .doctype-dropdown-btn {
        appearance: none !important;
        -webkit-appearance: none !important;
        background-image: none !important;
        position: relative;
    }
    /* Dropdown wrapper + centered arrow */
    .mobile-dropdown-wrap {
        position: relative;
        width: 100%;
    }
    .mobile-dropdown-wrap select,
    .mobile-dropdown-wrap .doctype-dropdown-btn {
        width: 100%;
        padding: 0.35rem 2.2rem 0.35rem 0.6rem !important;
        line-height: 1.3 !important;
    }
    .mobile-dropdown-arrow {
        position: absolute;
        right: 0.7rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-muted);
        font-size: 1rem;
        pointer-events: none;
        z-index: 2;
    }
    .mobile-filter-content .network-toggle {
        display: flex;
        width: 100%;
    }
    .mobile-filter-content .network-toggle .toggle-btn {
        flex: 1;
    }
    /* Sort options inside panel */
    .mobile-sort-option {
        padding: 0.8rem 1.2rem;
        font-size: 1rem;
        color: var(--text-on-dark);
        cursor: pointer;
        font-family: var(--font-body);
        border-bottom: 1px solid var(--border-color);
    }
    .mobile-sort-option:last-child {
        border-bottom: none;
    }
    .mobile-sort-option:active {
        background: var(--bg-hover);
    }
    .mobile-sort-option.active {
        color: var(--core-teal);
        font-weight: 600;
    }

    /* Help panel content styling (search + network) */
    #mobileAboutPanel .slide-panel-body,
    #mobileNetworkHelpPanel .slide-panel-body {
        font-size: 1.05rem;
        line-height: 1.7;
        color: var(--text-on-dark);
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        padding-bottom: 2rem;
    }
    /* No gradient — removed. Standard scrollbar only. */
    #mobileAboutPanel::after,
    #mobileNetworkHelpPanel::after {
        display: none !important;
    }
    #mobileAboutPanel h3,
    #mobileNetworkHelpPanel h3 {
        font-family: var(--font-heading);
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--core-teal);
        margin: 1.2rem 0 0.4rem;
        padding-bottom: 0.3rem;
        border-bottom: 1px solid var(--border-color);
    }
    #mobileAboutPanel h3:first-child,
    #mobileNetworkHelpPanel h3:first-child {
        margin-top: 0;
    }
    #mobileAboutPanel p,
    #mobileNetworkHelpPanel p {
        margin-bottom: 0.7rem;
        color: var(--text-on-dark);
    }
    #mobileAboutPanel strong,
    #mobileNetworkHelpPanel strong {
        color: var(--core-teal);
    }
    #mobileAboutPanel ul,
    #mobileNetworkHelpPanel ul {
        margin: 0.3rem 0 0.7rem 0;
        padding-left: 1.2rem;
    }
    #mobileAboutPanel li,
    #mobileNetworkHelpPanel li {
        margin-bottom: 0.4rem;
    }
    #mobileAboutPanel a,
    #mobileNetworkHelpPanel a {
        color: var(--core-teal);
    }

    /* ────────────────────────────────────────────────────
       H. PAPER CARDS — main overflow source
       Desktop: padding 1rem 1.2rem, no word-break
       Fix: constrain all content to card width
       ──────────────────────────────────────────────────── */
    .results-list {
        padding: 0.3rem;
    }
    .paper-card {
        padding: 0.7rem 0.8rem;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }
    /* Card text scale — change this one value to scale all card text.
       Base values = desktop sizes. 1.0 = same as desktop, 1.1 = 10% bigger.
       !important ensures these override the inline <style> rules. */
    .paper-card {
        --card-scale: 0.90;
    }
    .paper-title {
        font-size: calc(1.25rem * var(--card-scale)) !important;
        color: #ccc !important;
    }
    .paper-meta {
        font-size: calc(1.1rem * var(--card-scale)) !important;
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }
    .paper-meta .author-link {
        font-size: calc(1.15rem * var(--card-scale)) !important;
        color: #9a9a9a;
    }
    .author-expand {
        color: var(--core-teal);
        cursor: pointer;
        font-size: 0.85em;
        margin-left: 0.3rem;
        white-space: nowrap;
    }
    .author-expand i {
        font-size: 0.7em;
        margin-right: 0.15rem;
    }
    .paper-meta br {
        display: block;
        content: '';
        margin-top: 0.5rem;
    }
    .paper-keywords {
        max-width: 100%;
    }
    .keyword-tag {
        font-size: calc(1.0rem * var(--card-scale)) !important;
        max-width: calc(100vw - 4rem);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        background: rgba(232, 169, 106, 0.15);
        border-color: rgba(232, 169, 106, 0.3);
        color: var(--text-on-dark);
    }
    .paper-meta .journal {
        color: var(--text-on-dark);
        font-style: italic;
        font-size: calc(1.1rem * var(--card-scale)) !important;
    }
    .doc-type-badge {
        font-size: calc(0.95rem * var(--card-scale)) !important;
    }
    /* Fuzzy notice — desktop: padding 0.6rem 1.2rem
       Not previously overridden */
    .fuzzy-notice {
        padding: 0.4rem 0.8rem;
        font-size: 1rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* ────────────────────────────────────────────────────
       I. RIGHT PANEL (network view)
       ──────────────────────────────────────────────────── */
    .right-panel {
        min-height: 0;
        width: 100%;
        max-width: 100vw;
    }
    /* Hide desktop network info + node tooltip */
    .network-info {
        display: none !important;
    }
    .node-tooltip {
        display: none !important;
    }

    /* Node info drop-down panel */
    .mobile-node-panel {
        position: fixed;
        left: 0;
        right: 0;
        z-index: 180;
        background: var(--bg-secondary);
        border-bottom: 2px solid var(--core-teal);
        box-shadow: 0 4px 12px rgba(0,0,0,0.4);
        padding: 1.2rem 1rem 0.8rem;
        overflow: visible;
        transform: translateY(-100%);
        transition: transform 0.35s ease;
        visibility: hidden;
        display: flex;
        align-items: flex-start;
        gap: 0.8rem;
    }
    .mobile-node-panel.visible {
        transform: translateY(0);
        visibility: visible;
    }
    .mobile-node-panel .node-info-body {
        flex: 1;
        min-width: 0;
    }
    .mobile-node-panel .node-name {
        font-size: 1rem;
        font-weight: 600;
        color: var(--core-teal);
        margin-bottom: 0.2rem;
        min-height: 1.2em;
        word-wrap: break-word;
    }
    .mobile-node-panel .node-detail {
        font-size: 0.8rem;
        color: var(--text-muted);
        line-height: 1.5;
    }
    .mobile-node-panel .keyword-tag {
        font-size: 0.6rem !important;
        padding: 0.1rem 0.35rem !important;
        max-width: none;
        white-space: nowrap;
    }
    .mobile-node-panel .node-detail > div:last-child {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .mobile-node-panel .node-detail > div:last-child::-webkit-scrollbar {
        display: none;
    }
    .mobile-node-panel .node-close {
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.6rem;
        font-weight: 700;
        cursor: pointer;
        padding: 0;
        flex-shrink: 0;
        align-self: flex-end;
    }

    /* Active filter pills + controls — horizontal scroll */
    .mobile-active-filters {
        flex: 1 1 100%;
        display: flex;
        flex-wrap: nowrap;
        gap: 0.3rem;
        padding: 0.3rem 0;
        order: 2;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .mobile-active-filters::-webkit-scrollbar {
        display: none;
    }
    /* Sort button pushed to right end */
    .mobile-sort-btn-inline {
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.2rem;
        cursor: pointer;
        padding: 0.2rem 0.2rem 0.2rem 0.5rem;
        flex-shrink: 0;
        margin-left: auto;
        position: sticky;
        right: 0;
        z-index: 1;
        background: var(--bg-secondary);
    }
    /* Count in pills row */
    .mobile-pills-count {
        font-size: 0.75rem;
        color: var(--text-muted);
        white-space: nowrap;
        flex-shrink: 0;
    }
    .mobile-net-filter-btn {
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.2rem;
        cursor: pointer;
        padding: 0.2rem 0.5rem 0.2rem 0.2rem;
        flex-shrink: 0;
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--bg-secondary);
    }
    .mobile-filter-pill {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
        border-radius: 3px;
        background: rgba(232, 169, 106, 0.15);
        border: 1px solid rgba(232, 169, 106, 0.3);
        color: var(--text-on-dark);
        white-space: nowrap;
    }
    .degree-toggle {
        display: none !important;
    }

    /* Floating mini toggles — only in network mode */
    body.mobile-mode-list .mobile-float-toggles {
        display: none !important;
    }
    .mobile-float-toggles {
        position: fixed;
        bottom: 4.5rem;
        left: 0.8rem;
        z-index: 190;
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
    }
    .mobile-mini-toggle {
        position: relative;
        display: flex;
        width: 120px;
        border-radius: 4px;
        overflow: hidden;
        background: var(--bg-card);
    }
    .mobile-mini-toggle .toggle-slider {
        position: absolute;
        top: 0;
        bottom: 0;
        width: 50%;
        left: 0;
        background: #e8a96a;
        border-radius: 4px;
        transition: left 0.2s ease;
        pointer-events: none;
    }
    .mobile-mini-toggle .toggle-slider.right {
        left: 50%;
    }
    .mobile-mini-toggle button {
        flex: 1;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 0.7rem;
        font-family: var(--font-body);
        padding: 0.35rem 0;
        cursor: pointer;
        white-space: nowrap;
        transition: color 0.2s;
        position: relative;
        z-index: 1;
        text-align: center;
    }
    .mobile-mini-toggle button.active {
        color: #000;
        font-weight: 600;
    }
    .overlay-anchor-buttons {
        padding: 0 0.5rem 0.4rem;
    }
    .net-settings-toggle {
        width: 36px;
        height: 36px;
    }
    /* Desktop: min-width:240px — overflows on 375px
       Fix: remove min-width */
    .net-settings-panel {
        min-width: 0;
        max-width: calc(100vw - 2rem);
    }
    /* Hide desktop legend + settings panel — replaced by slide-up sheets */
    .network-legend {
        display: none !important;
    }
    .net-settings-panel {
        display: none !important;
    }
    .net-settings-toggle {
        display: none !important;
    }
    .share-btn {
        display: none !important;
    }
    /* Network bottom toolbar — only visible in network mode */
    body.mobile-mode-list .mobile-network-toolbar {
        display: none !important;
    }
    .mobile-network-toolbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 199;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.6rem 1rem 1rem;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
    }
    .mobile-net-btn {
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.3rem;
        cursor: pointer;
        padding: 0.4rem;
        display: flex;
        align-items: center;
        gap: 0.3rem;
    }
    .mobile-net-btn span {
        font-size: 0.75rem;
        color: var(--text-muted);
        font-family: var(--font-body);
    }
    /* Legend sheet content — colored pills */
    #mobileLegendSheet .legend-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        padding: 0.5rem 0;
    }
    .legend-pill {
        padding: 0.3rem 0.7rem;
        border-radius: 4px;
        font-size: 0.85rem;
        font-weight: 600;
        color: #fff;
        text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    }
    /* Settings sheet content */
    #mobileSettingsSheet .settings-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--border-color);
    }
    #mobileSettingsSheet .settings-row:last-child {
        border-bottom: none;
    }
    #mobileSettingsSheet .settings-row label {
        font-size: 0.9rem;
        color: var(--text-on-dark);
    }
    #mobileSettingsSheet .settings-row select {
        flex: 1;
        max-width: 60%;
        background: var(--bg-panel);
        color: var(--text-on-dark);
        border: 1px solid var(--border-color);
        border-radius: 4px;
        padding: 0.3rem 0.5rem;
        font-family: var(--font-body);
        font-size: 0.9rem;
    }
    #mobileSettingsSheet .settings-row input[type="range"] {
        flex: 1;
        max-width: 60%;
        accent-color: #e8a96a;
        -webkit-appearance: none;
        appearance: none;
        height: 4px;
        background: var(--border-color);
        border-radius: 2px;
        outline: none;
    }
    #mobileSettingsSheet .settings-row input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: #e8a96a;
        cursor: pointer;
    }
    /* Extra top padding so X doesn't overlap layout selector */
    #mobileSettingsSheet .sheet-body {
        padding-top: 2.5rem;
    }

    .network-metrics {
        font-size: 0.65rem;
        gap: 0.3rem;
        padding: 0.2rem 0.4rem;
        max-width: 100%;
        flex-wrap: wrap;
    }

    /* ────────────────────────────────────────────────────
       J. DETAIL OVERLAY — hidden on mobile
       Mobile uses #mobileDetailSheet instead (see end of file)
       ──────────────────────────────────────────────────── */
    /* ── Mobile detail sheet (created by mobile.js as #mobileDetailSheet) ── */
    #mobileDetailSheet {
        position: fixed;
        bottom: -1px;
        left: 0;
        right: 0;
        z-index: 300;
        max-height: 36vh;
        background: var(--bg-secondary);
        border-radius: 12px 12px 0 0;
        border-top: 2px solid var(--core-teal);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding-bottom: 0;
    }
    #mobileDetailSheet.visible {
        transform: translateY(0);
    }
    #mobileDetailSheet .sheet-handle {
        display: none;
    }
    #mobileDetailSheet .sheet-close {
        position: absolute;
        top: 0.2rem;
        right: 0.25rem;
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.4rem;
        font-weight: 700;
        cursor: pointer;
        padding: 0.15rem 0.25rem;
        line-height: 1;
        z-index: 2;
    }
    #mobileDetailSheet .sheet-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 1.5rem 1.4rem 1rem;
        -webkit-overflow-scrolling: touch;
        --card-scale: 0.90;
    }
    /* Sheet content — matches card sizing and colors */
    .sheet-title {
        font-size: calc(1.25rem * var(--card-scale));
        font-weight: 500;
        color: #ccc;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }
    .sheet-meta {
        font-size: calc(0.92rem * var(--card-scale));
        color: var(--text-muted);
        line-height: 1.5;
        margin-bottom: 0.4rem;
    }
    .sheet-journal {
        color: var(--text-on-dark);
        font-style: italic;
        font-size: calc(0.92rem * var(--card-scale));
    }
    .sheet-authors {
        font-size: calc(1.0rem * var(--card-scale));
        color: #9a9a9a;
        margin-bottom: 0.5rem;
    }
    .sheet-keywords {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        margin-bottom: 0.6rem;
    }
    .sheet-keywords .keyword-tag {
        font-size: calc(0.92rem * var(--card-scale)) !important;
    }
    .sheet-abstract {
        font-size: calc(1.1rem * var(--card-scale));
        color: var(--text-on-dark);
        line-height: 1.7;
        margin-top: 0.5rem;
        text-align: justify;
    }
    /* Sticky action bar at bottom of sheet (not scrollable) */
    .sheet-actions-bar {
        flex-shrink: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        /* Right padding reserved so the close X (~2rem) never overlaps buttons */
        padding: 1.1rem 2.6rem 0.6rem 0.6rem;
        border-bottom: none;
        background: var(--bg-secondary);
        justify-content: center;
        align-items: stretch;
    }
    /* Uniform styling for all action bar children (a, button) */
    .sheet-actions-bar > a,
    .sheet-actions-bar > button {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        font-family: inherit;
        font-size: 0.82rem;
        font-weight: 600;
        line-height: 1.1;
        padding: 0.5rem 0.65rem;
        border-radius: 4px !important;
        border: 1px solid var(--border-color) !important;
        background: var(--bg-card) !important;
        color: var(--text-on-dark) !important;
        text-decoration: none;
        white-space: nowrap;
        margin: 0;
    }
    .sheet-actions-bar > a:active,
    .sheet-actions-bar > button:active {
        background: var(--bg-hover) !important;
    }
    /* Highlight the Contacts button so it stands out slightly as the primary action */
    .sheet-actions-bar > .contact-pill {
        border-color: var(--core-teal) !important;
        color: var(--core-teal) !important;
    }

    /* ────────────────────────────────────────────────────
       K. ABOUT MODAL
       Desktop class is .about-content (NOT .about-modal-content)
       Desktop: padding 2.5rem 3rem, max-width 680px
       Fix: fit in mobile viewport
       ──────────────────────────────────────────────────── */
    .about-content {
        width: 95vw;
        max-width: 95vw;
        max-height: 85vh;
        margin: 2vh auto;
        padding: 1.2rem;
    }

    /* ────────────────────────────────────────────────────
       L. FLOATING MODE TOGGLE BUTTON
       ──────────────────────────────────────────────────── */
    .mobile-mode-toggle {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: var(--core-teal, #60D8D6);
        color: #000;
        border: none;
        font-size: 1.3rem;
        cursor: pointer;
        box-shadow: 0 3px 12px rgba(0,0,0,0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.15s, background 0.15s;
    }
    .mobile-mode-toggle:active {
        transform: scale(0.92);
    }
    /* Text size mini sheet */
    .mobile-text-sheet {
        position: fixed;
        bottom: 1.5rem;
        right: 5rem;
        z-index: 302;
        background: var(--bg-panel);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 0.6rem 1rem;
        box-shadow: 0 4px 16px rgba(0,0,0,0.4);
        display: none;
    }
    .mobile-text-sheet.visible {
        display: flex;
    }
    .text-sheet-body {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    .text-sheet-body label {
        font-size: 0.75rem;
        color: var(--text-muted);
        white-space: nowrap;
    }
    .text-sheet-body input[type="range"] {
        width: 100px;
        accent-color: #e8a96a;
        -webkit-appearance: none;
        appearance: none;
        height: 3px;
        background: var(--border-color);
        border-radius: 2px;
    }
    .text-sheet-body input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: #e8a96a;
        cursor: pointer;
    }
    .text-sheet-body .scale-val {
        font-size: 0.7rem;
        color: var(--text-muted);
        min-width: 2.5rem;
        text-align: center;
    }

    /* BMC button — inside FAB stack */
    .mobile-bmc-btn {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: #FFE57A;
        color: #000;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
        text-decoration: none;
    }
    .mobile-bmc-btn img {
        width: 16px;
        height: 16px;
    }
    .mobile-bmc-btn:active {
        transform: scale(0.92);
    }
    /* FAB stack — BMC positioned relative to FAB */
    .mobile-fab-stack {
        position: fixed;
        bottom: 1.5rem;
        right: 1rem;
        z-index: 301;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.8rem;
        pointer-events: none;
    }
    .mobile-fab-stack > * {
        pointer-events: auto;
    }
    body.mobile-mode-network .mobile-fab-stack {
        bottom: 4.8rem;
    }

    /* FAB animates with sheet — same 0.3s duration */
    .mobile-mode-toggle {
        transition: bottom 0.3s ease, transform 0.15s, background 0.15s;
    }
    /* In network mode, move FAB above the network toolbar */
    body.mobile-mode-network .mobile-mode-toggle {
        bottom: 3.5rem;
    }

    /* ────────────────────────────────────────────────────
       M. TOUCH TARGETS — 44px minimum (Apple HIG)
       ──────────────────────────────────────────────────── */
    .toggle-btn,
    .degree-btn,
    .reset-btn,
    .about-btn,
    .share-btn,
    .detail-toggle-btn {
        min-height: 44px;
    }
    /* Filter dropdowns — compact height */
    .mobile-filter-content select,
    .mobile-filter-content .doctype-dropdown-btn {
        min-height: 32px !important;
    }
    /* ── Slide-up sheets (network legend, settings) ── */
    .mobile-slide-up-sheet {
        position: fixed;
        bottom: 3.2rem;
        left: 0;
        right: 0;
        z-index: 300;
        max-height: 45vh;
        background: var(--bg-secondary);
        border-radius: 12px 12px 0 0;
        border-top: 2px solid var(--core-teal);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
        transform: translateY(100%);
        transition: transform 0.35s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        visibility: hidden;
    }
    .mobile-slide-up-sheet.visible {
        transform: translateY(0);
        visibility: visible;
    }
    .mobile-slide-up-sheet .sheet-close {
        position: absolute;
        top: 0.5rem;
        right: 0.8rem;
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.6rem;
        font-weight: 700;
        cursor: pointer;
        padding: 0.2rem 0.4rem;
        z-index: 1;
    }
    .mobile-slide-up-sheet .sheet-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 2.5rem 1.4rem 1rem;
        -webkit-overflow-scrolling: touch;
    }

    /* Stats sheet content */
    #mobileStatsSheet .stat-line:active {
        background: var(--bg-hover);
    }
    #mobileStatsSheet .stat-line {
        display: flex;
        justify-content: space-between;
        padding: 0.25rem 0;
        border-bottom: 1px solid var(--border-color);
    }
    #mobileStatsSheet .stat-line:last-child {
        border-bottom: none;
    }
    #mobileStatsSheet .stat-label {
        color: var(--text-muted);
        font-size: 0.9rem;
    }
    #mobileStatsSheet .stat-value {
        color: var(--core-teal);
        font-weight: 600;
        font-size: 0.9rem;
    }

    /* Stat explanation popup */
    .stat-explain-popup {
        position: fixed;
        inset: 0;
        z-index: 500;
        background: rgba(0,0,0,0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2rem;
    }
    .stat-explain-content {
        background: var(--bg-panel);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 1.2rem 1.4rem;
        max-width: 320px;
        color: var(--text-on-dark);
        font-size: 0.9rem;
        line-height: 1.6;
    }
    .stat-explain-content strong {
        color: var(--core-teal);
        font-size: 1rem;
        display: block;
        margin-bottom: 0.4rem;
    }
    .stat-explain-content p {
        margin: 0 0 0.8rem;
        color: var(--text-on-dark);
    }
    .stat-explain-content button {
        background: var(--core-teal);
        color: #000;
        border: none;
        border-radius: 4px;
        padding: 0.35rem 1rem;
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
    }

    /* Doc type dropdown — hide native, use custom picker via JS */
    .doctype-dropdown-list {
        display: none !important;
    }

    /* ────────────────────────────────────────────────────
       N. SEARCH HIGHLIGHTS — clean underline instead of busy bg
       ──────────────────────────────────────────────────── */
    mark.search-highlight {
        color: inherit;
        font-weight: inherit;
        background: rgba(255, 255, 255, 0.06);
        padding: 0.1rem 0.2rem;
        border-radius: 5px;
        box-shadow: 0 0 2px 1px rgba(255, 255, 255, 0.04);
    }

    /* ────────────────────────────────────────────────────
       O. TOOLTIPS / MISC
       ──────────────────────────────────────────────────── */
    .node-tooltip {
        max-width: 80vw;
    }
    .cluster-tip {
        max-width: 85vw;
    }

    /* ── Light mode overrides for mobile ── */
    [data-theme="light"] .paper-title {
        color: #222 !important;
    }
    [data-theme="light"] .paper-meta .author-link {
        color: #444 !important;
    }
    [data-theme="light"] .paper-meta .journal {
        color: #333 !important;
    }
    [data-theme="light"] .keyword-tag {
        color: #333 !important;
        background: rgba(232, 169, 106,0.08) !important;
        border-color: rgba(232, 169, 106,0.2) !important;
    }
    [data-theme="light"] mark.search-highlight {
        background: rgba(0,0,0,0.07) !important;
        box-shadow: 0 0 3px 1px rgba(0,0,0,0.04) !important;
    }
    [data-theme="light"] .sheet-title {
        color: #222 !important;
    }
    [data-theme="light"] .sheet-authors {
        color: #444 !important;
    }
    [data-theme="light"] .sheet-meta,
    [data-theme="light"] .sheet-journal {
        color: #555 !important;
    }
    [data-theme="light"] .sheet-abstract {
        color: #333 !important;
    }
}

/* ══════════════════════════════════════════════════════════
   SMALL PHONES  (≤375px)
   Aggressive tightening for iPhone SE / narrow viewports
   ══════════════════════════════════════════════════════════ */
@media (max-width: 375px) {
    html {
        font-size: calc((var(--mobile-scale, 80) - 8) * 1%) !important;
    }
    /* Header */
    .app-header {
        padding: 0.4rem 0.5rem;
    }
    .app-header .logo-area h1 {
        font-size: 1.7rem;
    }
    .search-area input {
        font-size: 13px;
        padding: 0.4rem 0.8rem 0.4rem 2.8rem;
    }
    .search-icon {
        left: 0.6rem;
    }

    /* Filters */
    .mobile-filter-body {
        padding: 0 0.5rem 0.4rem;
    }

    /* Results header */
    .results-header {
        padding: 0.4rem 0.5rem;
    }
    .results-count {
        font-size: 0.9rem;
    }
    .sort-select {
        font-size: 0.9rem;
    }

    /* Paper cards */
    .paper-card {
        padding: 0.5rem 0.6rem;
    }
    .paper-title {
        font-size: calc(1.25rem * var(--card-scale)) !important;
    }
    .paper-meta {
        font-size: 0.85rem;
    }
    .keyword-tag {
        font-size: 0.75rem;
        max-width: calc(100vw - 3rem);
    }

    /* Scope toggle */
    .scope-toggle {
        padding: 0.4rem 0.5rem;
    }
    .scope-toggle .scope-btn {
        font-size: 0.85rem;
        padding: 0.15rem 0.4rem;
    }

    /* Detail overlay */
    .detail-scroll {
        padding: 0.6rem 0.8rem;
    }
    .detail-actions-bar {
        padding: 0.4rem 0.8rem 0.6rem;
    }
    .detail-actions-bar a,
    .detail-actions-bar button {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }

    /* About modal */
    .about-content {
        padding: 1rem;
        width: 98vw;
        max-width: 98vw;
    }

    /* Mode toggle button */
    .mobile-mode-toggle {
        width: 46px;
        height: 46px;
        bottom: 0.7rem;
        right: 0.7rem;
    }
}

/* ══════════════════════════════════════════════════════════
   WIDE MOBILE / TABLET  (600px+)
   Larger screens get bigger text, taller sheets
   ══════════════════════════════════════════════════════════ */
@media (min-width: 600px) and (max-width: 1024px) {
    /* Card text scale up */
    .paper-card {
        --card-scale: 1.05;
    }
    .paper-title {
        font-size: calc(1.5rem * var(--card-scale)) !important;
    }
    /* Search bar */
    .search-area input {
        font-size: 14px;
        padding-left: 3rem !important;
    }
    /* Title */
    .app-header .logo-area h1 {
        font-size: 2.2rem;
    }
    /* Summary sheet — bigger and taller on tablets */
    #mobileDetailSheet {
        max-height: 55vh;
    }
    #mobileDetailSheet .sheet-body {
        --card-scale: 1.2;
        padding: 2rem 2.5rem 1.5rem;
    }
    #mobileDetailSheet .sheet-close {
        font-size: 1.8rem !important;
        top: 0.8rem;
        right: 1rem;
    }
    .sheet-title {
        font-size: calc(1.6rem * var(--card-scale));
        margin-bottom: 0.6rem;
    }
    .sheet-meta {
        font-size: calc(1.1rem * var(--card-scale));
    }
    .sheet-journal {
        font-size: calc(1.1rem * var(--card-scale));
    }
    .sheet-authors {
        font-size: calc(1.15rem * var(--card-scale));
        margin-bottom: 0.6rem;
    }
    .sheet-keywords .keyword-tag {
        font-size: calc(1.0rem * var(--card-scale)) !important;
        padding: 0.2rem 0.6rem !important;
    }
    .sheet-abstract {
        font-size: calc(1.1rem * var(--card-scale));
        line-height: 1.7;
    }
    .sheet-actions-bar {
        padding: 1rem 3rem 1rem 1rem;
    }
    .sheet-actions-bar > a,
    .sheet-actions-bar > button {
        font-size: 0.92rem;
        padding: 0.55rem 0.5rem;
    }
    /* Slide-up sheets — taller, higher above bigger toolbar */
    .mobile-slide-up-sheet {
        max-height: 55vh;
        bottom: 4rem;
    }
    .mobile-slide-up-sheet .sheet-body {
        padding: 3rem 2rem 1.5rem;
    }
    /* Stats sheet */
    #mobileStatsSheet .stat-line {
        padding: 0.4rem 0;
    }
    #mobileStatsSheet .stat-label {
        font-size: 1.05rem;
    }
    #mobileStatsSheet .stat-value {
        font-size: 1.05rem;
    }
    /* Settings sheet */
    #mobileSettingsSheet .settings-row label {
        font-size: 1.05rem;
    }
    #mobileSettingsSheet .settings-row select {
        font-size: 1rem;
    }
    /* Legend pills */
    .legend-pill {
        font-size: 1rem;
        padding: 0.35rem 0.8rem;
    }
    /* Help panels */
    #mobileAboutPanel .slide-panel-body,
    #mobileNetworkHelpPanel .slide-panel-body {
        font-size: 1.15rem;
    }
    /* Stat explanations */
    .stat-explain-content {
        max-width: 400px;
        font-size: 1rem;
    }
    /* Node panel */
    .mobile-node-panel {
        padding: 1.2rem 1.5rem 1rem;
    }
    .mobile-node-panel .node-name {
        font-size: 1.4rem;
    }
    .mobile-node-panel .node-detail {
        font-size: 1.05rem;
        line-height: 1.6;
    }
    .mobile-node-panel .keyword-tag {
        font-size: 0.8rem !important;
    }
    /* Network toggles — bigger on wide screens */
    .mobile-mini-toggle {
        width: 200px;
    }
    .mobile-mini-toggle button {
        font-size: 1rem;
        padding: 0.5rem 0;
    }
    /* Network toolbar — bigger icons and text */
    .mobile-network-toolbar {
        padding: 1rem 2rem 1.4rem;
    }
    .mobile-net-btn {
        font-size: 1.8rem;
    }
    .mobile-net-btn span {
        font-size: 1rem;
    }
    /* FAB bigger */
    .mobile-mode-toggle {
        width: 68px;
        height: 68px;
        font-size: 1.7rem;
    }
    /* BMC button bigger */
    .mobile-bmc-btn {
        width: 42px;
        height: 42px;
    }
    .mobile-bmc-btn img {
        width: 24px;
        height: 24px;
    }
    /* Float toggles position */
    .mobile-float-toggles {
        bottom: 6rem;
    }
    body.mobile-mode-network .mobile-fab-stack {
        bottom: 6rem;
    }
    /* Filter/sort/reset icons in pills row */
    .mobile-net-filter-btn {
        font-size: 1.6rem;
    }
    .mobile-sort-btn-inline {
        font-size: 1.6rem;
    }
    .mobile-reset-btn {
        font-size: 1.6rem;
    }
    /* Filter pills */
    .mobile-filter-pill {
        font-size: 1rem;
        padding: 0.3rem 0.8rem;
    }
    /* Keyword pills in cards */
    .keyword-tag {
        font-size: calc(1.05rem * var(--card-scale)) !important;
        padding: 0.15rem 0.6rem !important;
    }
    /* Doc type badge */
    .doc-type-badge {
        font-size: calc(1.0rem * var(--card-scale)) !important;
    }
    /* About/book button */
    .about-btn {
        font-size: 1.8rem !important;
    }
    /* Close buttons */
    .sheet-close,
    .slide-panel-close,
    .mobile-slide-up-sheet .sheet-close {
        font-size: 1.8rem !important;
    }
    /* Results count */
    .results-count {
        font-size: 1rem;
    }
    /* Back breadcrumb */
    .prev-search-breadcrumb {
        font-size: 0.95rem;
    }
}

/* ── Author Contacts panel (mobile) ── */
@media (max-width: 1024px) {
    .contact-pill {
        display: inline-block;
        padding: 0.4rem 1rem;
        background: rgba(var(--accent-rgb), 0.15);
        border: 1px solid var(--core-teal);
        border-radius: 4px;
        color: var(--core-teal);
        font-size: 1.1rem;
        cursor: pointer;
        font-family: inherit;
    }
    .contact-panel {
        margin: 0.5rem 0 0.8rem;
        padding: 0.8rem;
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        font-size: 0.98rem;
    }
    [data-theme="light"] .contact-panel { background: rgba(0,0,0,0.03); }
    .contact-panel-header {
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
        margin-bottom: 0.5rem;
        padding-bottom: 0.4rem;
        border-bottom: 1px solid var(--border-color);
    }
    .contact-panel-title { font-size: 1rem; font-weight: 500; color: var(--text-on-dark); }
    .contact-copy-all {
        padding: 0.3rem 0.7rem;
        background: rgba(var(--accent-rgb), 0.1);
        border: 1px solid var(--core-teal);
        border-radius: 4px;
        color: var(--core-teal);
        font-size: 0.95rem;
        cursor: pointer;
        align-self: flex-start;
    }
    .contact-row { padding: 0.6rem 0; border-bottom: 1px solid rgba(255,255,255,0.07); }
    .contact-row:last-child { border-bottom: none; }
    [data-theme="light"] .contact-row { border-color: rgba(0,0,0,0.07); }
    .contact-row-head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
    .contact-name { font-weight: 500; color: var(--text-on-dark); font-size: 1rem; }
    .contact-badge {
        font-size: 0.72rem;
        padding: 0.1rem 0.4rem;
        border-radius: 10px;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }
    .contact-badge.role { background: rgba(255,255,255,0.1); color: var(--text-muted); }
    .contact-badge.conf-high { background: rgba(46, 160, 67, 0.25); color: #3fb950; }
    .contact-badge.conf-medium { background: rgba(210, 153, 34, 0.25); color: #d29922; }
    .contact-badge.conf-low { background: rgba(248, 81, 73, 0.25); color: #f85149; }
    .contact-badge.conf-none { background: rgba(110, 118, 129, 0.25); color: #8b949e; }
    .contact-badge.conf-edited { background: rgba(var(--accent-rgb), 0.2); color: var(--core-teal); }
    .contact-edit-input {
        flex: 1;
        min-width: 160px;
        padding: 0.3rem 0.4rem;
        background: var(--bg-primary);
        border: 1px solid var(--core-teal);
        border-radius: 4px;
        color: var(--text-on-dark);
        font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
        font-size: 0.95rem;
    }
    .contact-edit-input:focus { outline: none; border-color: var(--core-teal); box-shadow: 0 0 0 2px rgba(var(--accent-rgb),0.25); }
    .contact-row-body { margin-top: 0.3rem; font-size: 0.95rem; line-height: 1.5; color: var(--text-muted); }
    .contact-email-row { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
    .contact-row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.4rem; }
    .contact-email {
        font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
        color: var(--text-on-dark);
        font-size: 0.95rem;
        word-break: break-all;
        user-select: all;
    }
    .contact-row-action {
        background: transparent;
        border: 1px solid var(--border-color);
        color: var(--text-muted);
        border-radius: 4px;
        padding: 0.25rem 0.5rem;
        cursor: pointer;
        font-size: 0.9rem;
        text-decoration: none;
        display: inline-block;
        min-height: 28px;
        min-width: 28px;
    }
    .contact-row-action.verified-yes { color: #3fb950; border-color: #3fb950; background: rgba(46, 160, 67, 0.12); }
    .contact-row-action.verified-no { color: #f85149; border-color: #f85149; background: rgba(248, 81, 73, 0.12); }
    .contact-why {
        margin-top: 0.3rem;
        padding: 0.35rem 0.5rem;
        background: rgba(0, 0, 0, 0.25);
        border-left: 2px solid var(--border-color);
        font-size: 0.9rem;
        border-radius: 0 4px 4px 0;
    }
    [data-theme="light"] .contact-why { background: rgba(0,0,0,0.04); }
    .contact-why-label { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.1rem; }
    .contact-source-link { color: var(--core-teal); text-decoration: none; font-size: 0.88rem; }
    .contact-no-data-group { margin-top: 0.4rem; color: var(--text-muted); font-size: 0.9rem; font-style: italic; }
    .contact-no-data-toggle { cursor: pointer; color: var(--text-muted); background: none; border: none; padding: 0; font-size: 0.9rem; }
}

/* Mobile Author Contacts slide-up sheet — overlays the paper sheet */
@media (max-width: 1024px) {
    #mobileContactsSheet {
        position: fixed;
        bottom: -1px;
        left: 0;
        right: 0;
        z-index: 350;  /* above #mobileDetailSheet (300) */
        max-height: 90vh;
        height: 90vh;
        background: var(--bg-secondary);
        border-radius: 12px 12px 0 0;
        border-top: 2px solid var(--core-teal);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    #mobileContactsSheet.visible { transform: translateY(0); }
    #mobileContactsSheet .sheet-close {
        position: absolute;
        top: 0.5rem;
        right: 0.8rem;
        background: none;
        border: none;
        color: #e8a96a;
        font-size: 1.8rem;
        font-weight: 700;
        cursor: pointer;
        padding: 0.2rem 0.4rem;
        z-index: 1;
    }
    #mobileContactsSheet .sheet-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 2.6rem 1rem 1.5rem;
        -webkit-overflow-scrolling: touch;
    }
    /* Inside the slide-up sheet the panel should fill it, not be boxed */
    #mobileContactsSheet .contact-panel {
        margin-top: 0;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        max-height: none;
        overflow: visible;
    }
}
