@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-dark: #07090e;
    --bg-panel: #0d111a;
    --card-bg: rgba(13, 17, 26, 0.82);
    --card-border: rgba(255, 255, 255, 0.09);
    --border-hover: rgba(59, 130, 246, 0.45);
    
    --accent-purple: #3b82f6;
    --accent-purple-hover: #2563eb;
    --accent-purple-glow: rgba(59, 130, 246, 0.28);
    
    --accent-teal: #10b981;
    --accent-teal-glow: rgba(16, 185, 129, 0.2);
    
    --accent-yellow: #f59e0b;
    --accent-red: #f43f5e;
    
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --font-outfit: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-inter: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);

    /* Apple Fluid Physics Spring Curves */
    --spring-snappy: cubic-bezier(0.16, 1, 0.3, 1);
    --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-smooth: cubic-bezier(0.32, 0.72, 0, 1);

    /* Apple Specular Translucent Materials */
    --apple-glass-dark: rgba(13, 17, 26, 0.82);
    --apple-glass-border: rgba(255, 255, 255, 0.09);
    --apple-specular-edge: inset 0 1px 0 0 rgba(255, 255, 255, 0.16);
    --apple-ambient-shadow: 0 16px 40px -4px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);

    /* Obsidian Sapphire Academic Palette */
    --deep-space: #07090e;
    --glass-panel: rgba(13, 17, 26, 0.85);
    --academic-blue: #38bdf8;
    --violet-pulse: #60a5fa;
    --emerald-verified: #10b981;
    --amber-review: #f59e0b;
}

:root.light-mode {
    --bg-dark: #f8fafc;
    --bg-panel: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.88);
    --card-border: #e2e8f0;
    --border-hover: rgba(37, 99, 235, 0.4);
    
    --accent-purple: #2563eb;
    --accent-purple-hover: #1d4ed8;
    --accent-purple-glow: rgba(37, 99, 235, 0.15);
    
    --accent-teal: #10b981;
    --accent-teal-glow: rgba(16, 185, 129, 0.15);
    
    --accent-yellow: #d97706;
    --accent-red: #e11d48;
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    /* Apple Specular Translucent Materials - Light Mode */
    --apple-glass-dark: rgba(255, 255, 255, 0.92);
    --apple-glass-border: rgba(0, 0, 0, 0.08);
    --apple-specular-edge: inset 0 1px 0 0 rgba(255, 255, 255, 0.9);
    --apple-ambient-shadow: 0 10px 30px -4px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);

    /* Academic Lab Palette - Light Mode */
    --deep-space: #f8fafc;
    --glass-panel: rgba(255, 255, 255, 0.95);
    --academic-blue: #0284c7;
    --violet-pulse: #2563eb;
    --emerald-verified: #10b981;
    --amber-review: #d97706;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background: #08090f;
    background-image: 
        radial-gradient(ellipse 70% 45% at 50% -15%, rgba(99, 102, 241, 0.22), transparent 70%),
        radial-gradient(ellipse 50% 35% at 85% 15%, rgba(59, 130, 246, 0.18), transparent 70%),
        radial-gradient(ellipse 50% 35% at 15% 20%, rgba(147, 51, 234, 0.16), transparent 70%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-inter);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    padding-top: var(--header-offset, 80px);
}

/* Ambient backdrop: seamless Linear-style deep indigo-violet & sapphire atmospheric aura */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(60% 45% at 50% -5%, rgba(99, 102, 241, 0.2), transparent 75%),
        radial-gradient(40% 35% at 10% 25%, rgba(168, 85, 247, 0.15), transparent 70%),
        radial-gradient(45% 35% at 90% 20%, rgba(59, 130, 246, 0.18), transparent 70%);
    filter: blur(50px);
    animation: ambientDrift 20s ease-in-out infinite alternate;
}

/* Subtle, refined hairline grid */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(70% 55% at 50% 25%, #000 0%, transparent 100%);
    -webkit-mask-image: radial-gradient(70% 55% at 50% 25%, #000 0%, transparent 100%);
}

@keyframes ambientDrift {
    from { transform: translate3d(-1.5%, 0, 0) scale(1); }
    to   { transform: translate3d(1.5%, 2%, 0) scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
    body::before { animation: none; }
}

:root.light-mode body::before {
    background:
        radial-gradient(55% 42% at 50% 0%, rgba(99, 102, 241, 0.1), transparent 70%),
        radial-gradient(40% 32% at 85% 15%, rgba(37, 99, 235, 0.08), transparent 70%);
}

:root.light-mode body::after { display: none; }

/* Content sits above the backdrop layers. The fixed header, toasts and modals
   already carry higher z-indexes of their own. */
main {
    position: relative;
    z-index: 1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: #27272a;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #3f3f46;
}

/* Backend Offline Banner */
.backend-offline-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 2.5rem;
    background: rgba(239, 68, 68, 0.1);
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 0.9rem;
    animation: slide-down 0.3s ease-out forwards;
}

.backend-offline-banner strong {
    color: #fef2f2;
}

/* Why the check failed. Distinguishes a slow host from a request that never
   left the browser, which is the difference between waiting and debugging. */
.backend-offline-reason {
    opacity: 0.75;
    font-size: 0.82em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Navigation Header */
header {
    width: 100%;
    height: 76px;
    padding: 0 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: transparent;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.logo-text {
    font-family: var(--font-outfit);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.1em;
    background: linear-gradient(135deg, #ffffff 30%, #a1a1aa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Page Layout Containers */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    /* Top padding is lighter than the sides: the fixed header already provides
       80px of clearance above this, so a full 2rem on top read as dead space
       between the header rule and the hero headline. */
    padding: 0.75rem 2rem 2rem;
}

.panel {
    display: none;
    width: 100%;
    animation: fade-in 0.4s ease-out forwards;
}

.panel.active {
    display: block;
}

/* Landing Panel (Search View) */
#landing-panel {
    max-width: 850px;
    text-align: center;
    margin: auto 0;
    padding-bottom: 5rem;
}

.rm-hero-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.hero-title {
    font-family: var(--font-outfit);
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.18;
    margin-bottom: 0.85rem;
    color: #ffffff;
    text-wrap: balance;
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

.hero-accent {
    background: linear-gradient(135deg, #a78bfa 0%, #60a5fa 50%, #38bdf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.canvas-text-target {
    display: inline-block;
    position: relative;
    vertical-align: top;
    text-decoration: none;
    line-height: inherit;
}

.canvas-text-canvas {
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
    font-weight: 400;
    line-height: 1.55;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
    text-wrap: balance;
}

/* Social Proof & Scale Metric Bento Showcase */
.rm-metrics-showcase {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    max-width: 680px;
    margin: 0 auto 1.6rem auto;
}

.rm-metric-card {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.08) 0%,
        rgba(255, 255, 255, 0.02) 40%,
        rgba(99, 102, 241, 0.06) 100%
    );
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 0.95rem 1.15rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: 
        inset 0 1.5px 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -1px 1px 0 rgba(0, 0, 0, 0.4),
        inset 0 0 20px rgba(255, 255, 255, 0.02),
        0 16px 36px -6px rgba(0, 0, 0, 0.6),
        0 3px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

/* Liquid specular reflection sweep across top */
.rm-metric-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 90% 60% at 50% -20%,
        rgba(255, 255, 255, 0.16) 0%,
        rgba(168, 85, 247, 0.12) 40%,
        transparent 80%
    );
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.3s ease;
}

/* Liquid chromatic rim light on bottom corner */
.rm-metric-card::after {
    content: "";
    position: absolute;
    bottom: -25px;
    right: -25px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.2), transparent 70%);
    pointer-events: none;
    z-index: 0;
    filter: blur(10px);
}

.rm-metric-card:hover {
    transform: translateY(-3px) scale(1.015);
    border-color: rgba(255, 255, 255, 0.28);
    border-top-color: rgba(255, 255, 255, 0.55);
    box-shadow: 
        inset 0 2px 2px 0 rgba(255, 255, 255, 0.55),
        inset 0 -1.5px 1px 0 rgba(0, 0, 0, 0.5),
        0 22px 44px -8px rgba(0, 0, 0, 0.75),
        0 0 24px rgba(129, 140, 248, 0.3);
}

.metric-giant-val {
    font-family: var(--font-outfit);
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    color: #ffffff;
    background: linear-gradient(135deg, #ffffff 40%, #c4b5fd 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
    z-index: 1;
    text-shadow: 0 4px 16px rgba(196, 181, 253, 0.25);
}

.metric-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #ffffff;
    margin-top: 0.1rem;
    position: relative;
    z-index: 1;
    letter-spacing: -0.01em;
}

.metric-subtext {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.3;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .rm-metrics-showcase {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

.search-box-container {
    background: rgba(13, 17, 26, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}

.search-box-container:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6, 0 20px 50px rgba(37, 99, 235, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.search-box-container:hover {
    border-color: rgba(59, 130, 246, 0.4);
}

.search-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-inter);
    font-size: 1.1rem;
    resize: none;
    height: 80px;
}

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

.search-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.chips-container {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chip {
    padding: 0.4rem 0.85rem;
    border-radius: 50px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.chip:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.chip.active {
    background-color: var(--accent-purple-glow);
    border-color: var(--accent-purple);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    outline: none;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-family: var(--font-outfit);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

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

/* Plan Approval Panel */
#approval-panel {
    max-width: 900px;
}

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

#approval-panel .section-title {
    font-size: 1.5rem;
    margin-bottom: 0;
    text-align: left;
}

#approval-panel .original-query-banner {
    padding: 0.7rem 1.1rem;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

#approval-panel .approval-grid {
    gap: 0.6rem;
}

#approval-panel .card {
    padding: 0.75rem 1rem;
}

#approval-panel .card-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    gap: 0.5rem;
}

#approval-panel .card-title {
    font-size: 1.05rem;
}

#approval-panel .card-icon {
    width: 18px !important;
    height: 18px !important;
}

#approval-panel .problem-statement-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

#approval-panel .subtasks-list {
    gap: 0.35rem;
}

#approval-panel .subtask-item {
    padding: 0.4rem 0.6rem;
    gap: 0.6rem;
}

#approval-panel .subtask-number {
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
}

#approval-panel .subtask-content {
    font-size: 0.9rem;
}

#approval-panel .feedback-textarea {
    padding: 0.6rem;
    font-size: 0.9rem;
    min-height: 54px;
}

#approval-panel .feedback-controls {
    margin-top: 0.6rem;
    gap: 0.6rem;
}

#approval-panel .btn-secondary,
#approval-panel .btn-primary {
    padding: 0.45rem 1.1rem;
    font-size: 0.85rem;
}

.section-title {
    font-family: var(--font-outfit);
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.original-query-banner {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.original-query-banner strong {
    color: var(--text-primary);
}

.approval-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: rgba(59, 130, 246, 0.35);
    box-shadow: 0 16px 40px -4px rgba(0, 0, 0, 0.7), 0 0 20px rgba(59, 130, 246, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
}

.card-icon {
    color: var(--accent-purple);
}

.card-title {
    font-family: var(--font-outfit);
    font-size: 1.15rem;
    font-weight: 600;
}

/* Problem Statement Box */
.problem-statement-text {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Model text is rendered as markdown (see renderMarkdownSafe in app.js), so
   reset the block elements marked emits inside these compact fields. Without
   this, default <p>/<ul> margins double the spacing inside small cards. */
.problem-statement-text > p:first-child,
.subtask-content > p:first-child {
    margin-top: 0;
}
.problem-statement-text > p:last-child,
.subtask-content > p:last-child {
    margin-bottom: 0;
}
.problem-statement-text > ul,
.problem-statement-text > ol,
.subtask-content > ul,
.subtask-content > ol {
    margin: 0.4rem 0;
    padding-left: 1.25rem;
}
.problem-statement-text > ul:last-child,
.problem-statement-text > ol:last-child,
.subtask-content > ul:last-child,
.subtask-content > ol:last-child {
    margin-bottom: 0;
}

/* Model output regularly opens a section with a markdown "# Heading" line
   (e.g. literature review snippets restating their own title). Rendered
   through marked with no reset, that hit the browser's native h1/h2 UA
   styles — 2rem+, bold, full text-primary white — inside a compact card
   sized for 1rem body text, blowing out the checkpoint panel's layout.
   Scale headings down to sit just above the body copy instead of a
   separate oversized block, keeping them the bright/white shade rather
   than the paragraph's dimmer secondary gray so they still read as a
   heading, just not a page-title-sized one. */
.problem-statement-text h1,
.problem-statement-text h2,
.problem-statement-text h3,
.problem-statement-text h4,
.problem-statement-text h5,
.problem-statement-text h6,
.subtask-content h1,
.subtask-content h2,
.subtask-content h3,
.subtask-content h4,
.subtask-content h5,
.subtask-content h6 {
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}
.problem-statement-text > h1:first-child,
.problem-statement-text > h2:first-child,
.problem-statement-text > h3:first-child,
.subtask-content > h1:first-child,
.subtask-content > h2:first-child,
.subtask-content > h3:first-child {
    margin-top: 0;
}

/* Subtasks List */
.subtasks-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.subtask-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 1rem;
    transition: var(--transition-fast);
}

.subtask-item:hover {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
}

.subtask-number {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-purple);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.subtask-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Feedback Input Box */
.feedback-textarea {
    width: 100%;
    background: rgba(9, 9, 11, 0.4);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    color: var(--text-primary);
    font-family: var(--font-inter);
    font-size: 0.95rem;
    resize: vertical;
    min-height: 100px;
    outline: none;
    transition: var(--transition-fast);
}

.feedback-textarea:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 1px var(--accent-purple);
}

.feedback-controls {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-family: var(--font-outfit);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-new-research {
    padding: 0.45rem 1rem;
    font-size: 0.8rem;
    gap: 0.4rem;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: rgba(255,255,255,0.03);
}

/* GitHub Star Button in Header */
.btn-github {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: 36px;
    padding: 0 0.75rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-family: var(--font-inter);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.btn-github:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

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

/* Inline brand marks (GitHub, LinkedIn). They inherit colour from the link or
   button they sit in, so they follow both themes with no separate rules. */
.brand-mark {
    flex-shrink: 0;
    color: inherit;
    fill: currentColor;
}

.footer-brand-mark {
    vertical-align: middle;
    margin-right: 4px;
}

.github-star-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.github-star-icon {
    color: #eab308;
    fill: #eab308;
}

.github-star-count {
    color: var(--text-secondary);
    font-family: var(--font-mono, monospace);
    letter-spacing: -0.02em;
}

.btn-github:hover .github-star-count {
    color: var(--text-primary);
}

/* Settings Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 0.2s ease-out;
}

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    width: 480px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: slide-up 0.25s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
}

.modal-title {
    font-family: var(--font-outfit);
    font-size: 1.1rem;
    font-weight: 600;
}

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

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

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-family: var(--font-outfit);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input {
    width: 100%;
    background: rgba(9,9,11,0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem;
    color: var(--text-primary);
    font-family: var(--font-inter);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-fast);
}

.form-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 1px var(--accent-purple);
}

.form-hint {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--accent-purple);
    text-decoration: none;
}

.form-hint:hover {
    text-decoration: underline;
}

.save-status {
    font-size: 0.85rem;
    color: var(--accent-teal);
}

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

/* Workspace Panel (Active Execution) */
#workspace-panel {
    display: none;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    width: 100%;
    align-items: start;
}

#workspace-panel.active {
    display: grid;
}

/* Left Pane: Workers Panel */
.workers-sidebar {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: calc(100vh - 120px);
    position: sticky;
    top: 100px;
    overflow-y: auto;
}

.sidebar-title {
    font-family: var(--font-outfit);
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sidebar Timer container */
.sidebar-timer-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-inter);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.timer-label {
    color: var(--text-secondary);
}

.timer-value {
    color: var(--accent-purple);
    font-family: monospace;
    font-size: 1rem;
    font-weight: 600;
    margin-left: auto;
    letter-spacing: 0.05em;
}

.workers-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.worker-card {
    background: rgba(9, 9, 11, 0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.worker-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--text-muted);
}

.worker-card.pending::before {
    background: var(--text-muted);
}

.worker-card.running {
    border-color: var(--accent-purple);
    box-shadow: 0 4px 15px var(--accent-purple-glow);
}

.worker-card.running::before {
    background: var(--accent-purple);
}

.worker-card.completed {
    border-color: rgba(16, 185, 129, 0.3);
}

.worker-card.completed::before {
    background: var(--accent-teal);
}

.worker-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.worker-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
}

.worker-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.worker-status-icon.running {
    color: var(--accent-purple);
    animation: rotate 2s linear infinite;
}

.worker-status-icon.completed {
    color: var(--accent-teal);
}

.worker-status-icon.pending {
    color: var(--text-muted);
}

.worker-details {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.worker-search-count {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.worker-card-toggle {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--accent-purple);
    cursor: pointer;
    user-select: none;
    display: none;
    align-items: center;
    gap: 0.25rem;
}

.worker-card-toggle:hover {
    text-decoration: underline;
}

.worker-card.completed .worker-card-toggle {
    display: flex;
}

.worker-preview-content {
    display: none;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.03);
    margin-top: 0.5rem;
    white-space: pre-wrap;
    max-height: 250px;
    overflow-y: auto;
    animation: slide-down 0.2s ease-out forwards;
}

.worker-preview-content.expanded {
    display: block;
}

/* Right Pane: Report Workspace */
.report-workspace {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.aggregator-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
    display: none;
}

.aggregator-progress-bar.active {
    display: block;
}

.aggregator-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-teal));
    width: 50%;
    animation: loading-bar 2s ease-in-out infinite alternate;
}

.report-workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.report-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    min-height: calc(100vh - 180px);
    overflow-y: auto;
    position: relative;
}

.streaming-loader {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 2rem;
}

.streaming-dots {
    display: flex;
    gap: 0.25rem;
}

.streaming-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
    animation: loading-dots 1.4s infinite ease-in-out both;
}

.streaming-dots span:nth-child(1) { animation-delay: -0.32s; }
.streaming-dots span:nth-child(2) { animation-delay: -0.16s; }

/* Markdown Styling in Report Output */
.report-content {
    line-height: 1.7;
    font-size: 1.05rem;
    color: #e4e4e7;
}

.report-content h1, 
.report-content h2, 
.report-content h3 {
    font-family: var(--font-outfit);
    color: #ffffff;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.report-content h1 {
    font-size: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.report-content h2 {
    font-size: 1.45rem;
}

.report-content h3 {
    font-size: 1.15rem;
}

.report-content p {
    margin-bottom: 1.25rem;
}

.report-content ul, 
.report-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1.25rem;
}

.report-content li {
    margin-bottom: 0.5rem;
}

.report-content blockquote {
    border-left: 4px solid var(--accent-purple);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
    background-color: rgba(99, 102, 241, 0.03);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.report-content pre {
    background: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.report-content code {
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.report-content pre code {
    background: transparent;
    padding: 0;
}

/* Citations & Sources Panel */
.sources-section {
    margin-top: 3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 2rem;
}

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

.sources-title {
    font-family: var(--font-outfit);
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.source-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.source-card:hover {
    border-color: var(--accent-purple);
    background: rgba(99, 102, 241, 0.04);
}

.source-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-purple);
    flex-shrink: 0;
}

.source-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow: hidden;
}

.source-domain {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-url {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 100;
}

.toast {
    background: #18181b;
    border: 1px solid var(--card-border);
    border-left: 3px solid var(--text-secondary);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 450px;
    animation: slide-in-toast 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-icon {
    color: var(--accent-red);
    flex-shrink: 0;
}

.toast-message {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.4;
}

/* showToast() emits toast-info / toast-success / toast-warning / toast-error.
   Without these every notice rendered in the error colour. */
.toast-error   { border-left-color: var(--accent-red); }
.toast-warning { border-left-color: var(--accent-yellow); }
.toast-success { border-left-color: var(--accent-teal); }
.toast-info    { border-left-color: var(--accent-purple); }

.toast-error .toast-icon   { color: var(--accent-red); }
.toast-warning .toast-icon { color: var(--accent-yellow); }
.toast-success .toast-icon { color: var(--accent-teal); }
.toast-info .toast-icon    { color: var(--accent-purple); }

/* Revising state */
.card.revising {
    border-color: var(--accent-purple);
    box-shadow: 0 0 20px var(--accent-purple-glow);
    transition: var(--transition-smooth);
}

.revising-spinner {
    animation: rotate 1s linear infinite;
}

/* Spinning ring used by the Research Mode "Defining research scope..." button
   state (and any other in-app loader). Without these rules the .spinner-ring
   div rendered as an invisible empty box, so the loading label had no icon. */
.spinner-ring {
    display: inline-block;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid rgba(120, 130, 200, 0.35);
    border-top-color: var(--academic-blue, #6366f1);
    border-radius: 50%;
    animation: rotate 0.7s linear infinite;
    flex-shrink: 0;
}
.spinner-ring.sm {
    width: 0.95rem;
    height: 0.95rem;
    border-width: 2px;
}
.spinner-ring.lg {
    width: 1.6rem;
    height: 1.6rem;
    border-width: 3px;
}

/* Small "Defining research scope" loader shown in the workspace body while the
   start request is in flight, before Checkpoint 1 renders. Reuses the ai-wave
   dots already used elsewhere so it matches the rest of the UI. */
.rm-scope-loader {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1.1rem 1.4rem;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 12px);
}
.rm-scope-loader .scope-spinner {
    width: 1.4rem;
    height: 1.4rem;
    border: 3px solid rgba(120, 130, 200, 0.3);
    border-top-color: var(--academic-blue, #6366f1);
    border-radius: 50%;
    animation: rotate 0.7s linear infinite;
    flex-shrink: 0;
}
.rm-scope-loader .scope-text {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.rm-scope-loader .scope-title {
    font-family: var(--font-outfit, inherit);
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
}
.rm-scope-loader .scope-sub {
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
}

/* Animations */
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Skeleton shimmer for plan loading */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position: 600px 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.04) 25%,
        rgba(255,255,255,0.12) 50%,
        rgba(255,255,255,0.04) 75%
    );
    background-size: 600px 100%;
    animation: shimmer 1.6s infinite linear;
    border-radius: 6px;
    display: block;
}

/* The white shimmer above is invisible on light mode's white cards - same bars,
   dark-tinted instead. */
:root.light-mode .skeleton {
    background: linear-gradient(
        90deg,
        rgba(15,23,42,0.06) 25%,
        rgba(15,23,42,0.14) 50%,
        rgba(15,23,42,0.06) 75%
    );
    background-size: 600px 100%;
}

.skeleton-ps {
    width: 100%;
    height: 14px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.skeleton-ps:last-child { width: 60%; }

.skeleton-task {
    width: 100%;
    height: 40px;
    border-radius: 8px;
    margin-bottom: 10px;
}

/* Thinking indicator for DeepSeek */
.thinking-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--accent-purple);
    font-weight: 500;
    padding: 4px 10px;
    background: rgba(99,102,241,0.1);
    border-radius: 20px;
    border: 1px solid rgba(99,102,241,0.2);
    margin-bottom: 1rem;
}

.thinking-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-purple);
    animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.3; transform: scale(0.6); }
}

@keyframes pulse-glow {
    from {
        box-shadow: 0 0 4px var(--accent-purple-glow);
    }
    to {
        box-shadow: 0 0 15px var(--accent-purple);
    }
}

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

@keyframes slide-down {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-toast {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes loading-dots {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

@keyframes loading-bar {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

/* Responsive adjustments */
@media(max-width: 1024px) {
    #workspace-panel.active {
        grid-template-columns: 1fr;
    }
    .workers-sidebar {
        position: static;
        max-height: none;
    }
}

/* Backend Offline Banner */
.backend-offline-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background-color: rgba(239, 68, 68, 0.15);
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    font-size: 0.9rem;
    font-weight: 500;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slide-down 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.backend-offline-banner strong {
    color: #ef4444;
}

.config-warning-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 2.5rem;
    background: rgba(245, 158, 11, 0.1);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
    font-size: 0.9rem;
    animation: slide-down 0.3s ease-out forwards;
}

.config-warning-text {
    flex: 1;
}

.config-warning-text strong {
    color: #fef3c7;
    display: block;
    margin-bottom: 0.3rem;
}

.config-issues {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.85rem;
    color: #fcd34d;
}

.config-dismiss {
    background: none;
    border: none;
    color: #fbbf24;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    opacity: 0.7;
}

.config-dismiss:hover {
    opacity: 1;
}

/* Light Mode Overrides */
:root.light-mode body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

:root.light-mode header {
    background-color: rgba(255, 255, 255, 0.85);
    border-bottom-color: #e2e8f0;
}

:root.light-mode .mode-toggle-container {
    background: rgba(255, 255, 255, 0.65);
    border-color: #cbd5e1;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 4px 14px rgba(15, 23, 42, 0.08);
}

:root.light-mode .mode-tab {
    color: #475569;
}

:root.light-mode .mode-tab:hover {
    color: #0f172a;
}

:root.light-mode .mode-tab.active {
    color: #ffffff;
}

:root.light-mode .mode-time-estimate {
    color: #475569;
}

:root.light-mode .mode-time-estimate.is-active {
    color: #4338ca;
}

:root.light-mode .btn-github {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #475569;
}

:root.light-mode .btn-github:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

:root.light-mode .github-star-count {
    color: #475569;
}

:root.light-mode .btn-github:hover .github-star-count {
    color: #0f172a;
}

:root.light-mode .btn-icon {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #475569;
}

:root.light-mode .btn-icon:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

:root.light-mode .btn-secondary {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #475569;
}

:root.light-mode .btn-secondary:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

:root.light-mode .logo-text {
    background: linear-gradient(135deg, #111827 30%, #4b5563 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

:root.light-mode .hero-title {
    background: linear-gradient(135deg, #111827 40%, #4b5563 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

:root.light-mode .search-box-container {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

:root.light-mode .search-input {
    color: #0f172a;
}

:root.light-mode .search-input::placeholder {
    color: #94a3b8;
}

:root.light-mode .card {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

:root.light-mode .chip {
    background-color: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}

:root.light-mode .chip:hover {
    background-color: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

:root.light-mode .chip.active {
    background-color: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

:root.light-mode .feedback-textarea,
:root.light-mode .form-input,
:root.light-mode .rm-textarea,
:root.light-mode .rm-textarea-sm {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

:root.light-mode .feedback-textarea::placeholder,
:root.light-mode .form-input::placeholder,
:root.light-mode .rm-textarea::placeholder,
:root.light-mode .rm-textarea-sm::placeholder {
    color: #94a3b8;
}

:root.light-mode .feedback-textarea:focus,
:root.light-mode .form-input:focus,
:root.light-mode .rm-input-card:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 1px var(--accent-purple), 0 8px 32px var(--accent-purple-glow);
}

:root.light-mode .rm-input-card .rm-textarea:focus,
:root.light-mode .rm-input-card .rm-textarea-sm:focus {
    border-color: #cbd5e1;
    box-shadow: none;
}

:root.light-mode .rm-textarea:focus,
:root.light-mode .rm-textarea-sm:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 1px var(--accent-purple);
}

:root.light-mode .rm-advanced {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root.light-mode .rm-advanced-summary {
    color: #475569;
}

:root.light-mode .rm-advanced-summary:hover {
    color: #0284c7;
}

:root.light-mode .rm-advanced[open] .rm-advanced-summary {
    border-bottom-color: #e2e8f0;
    color: #0284c7;
}

:root.light-mode .rm-hint {
    color: #64748b;
}

:root.light-mode .hero-accent {
    background: linear-gradient(100deg, #2563eb 0%, #4f46e5 45%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

:root.light-mode .rm-metric-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 40%, rgba(99, 102, 241, 0.1) 100%);
    border-color: #cbd5e1;
    border-top-color: #ffffff;
    box-shadow: 
        inset 0 1.5px 1px 0 rgba(255, 255, 255, 1),
        inset 0 -1px 1px 0 rgba(203, 213, 225, 0.4),
        0 8px 24px -4px rgba(0, 0, 0, 0.08),
        0 3px 12px rgba(0, 0, 0, 0.04);
}

:root.light-mode .rm-metric-card:hover {
    border-color: #94a3b8;
    border-top-color: #ffffff;
    box-shadow: 
        inset 0 2px 2px 0 rgba(255, 255, 255, 1),
        inset 0 -1.5px 1px 0 rgba(148, 163, 184, 0.5),
        0 12px 28px -6px rgba(0, 0, 0, 0.12),
        0 0 20px rgba(99, 102, 241, 0.15);
}

:root.light-mode .metric-giant-val {
    color: #1e293b;
    background: linear-gradient(135deg, #0f172a 40%, #4f46e5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

:root.light-mode .metric-label {
    color: #334155;
}

:root.light-mode .metric-subtext {
    color: #64748b;
}

:root.light-mode .label-tag {
    background: rgba(2, 132, 199, 0.1);
    color: #0284c7;
}

:root.light-mode .local-privacy-banner {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
    color: #065f46;
}

:root.light-mode .pipeline-tracker-container {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

:root.light-mode .tracker-header {
    border-bottom-color: #f1f5f9;
}

:root.light-mode .tracker-title {
    color: #0f172a;
}

:root.light-mode .pipeline-step {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root.light-mode .pipeline-step.completed {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
}

:root.light-mode .pipeline-step.active {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--accent-purple);
}

:root.light-mode .pipeline-step.hitl {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.3);
}

:root.light-mode .step-label {
    color: #475569;
}

:root.light-mode .pipeline-step.completed .step-label,
:root.light-mode .pipeline-step.active .step-label {
    color: #0f172a;
}

:root.light-mode .rm-hitl-panel {
    background: #fffbeb;
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.08);
}

:root.light-mode .hitl-badge {
    background: #fef3c7;
    color: #b45309;
    border-color: #fcd34d;
}

:root.light-mode .worker-card {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root.light-mode .worker-title {
    color: #0f172a;
}

:root.light-mode .worker-details {
    color: #475569;
}

:root.light-mode .worker-search-logs {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

:root.light-mode .report-container {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

:root.light-mode .report-content {
    color: #1e293b;
}

:root.light-mode .report-content h1,
:root.light-mode .report-content h2,
:root.light-mode .report-content h3 {
    color: #0f172a;
}

:root.light-mode .report-content h1 {
    border-bottom-color: #e2e8f0;
}

:root.light-mode .report-content pre {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root.light-mode .report-content code {
    background: #f1f5f9;
    color: #0f172a;
}

:root.light-mode .subtask-item {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root.light-mode .subtask-item:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

:root.light-mode .subtask-content {
    color: #0f172a;
}

:root.light-mode .original-query-banner {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

:root.light-mode .original-query-banner strong {
    color: #0f172a;
}

:root.light-mode .problem-statement-text {
    color: #0f172a;
}

:root.light-mode .source-url {
    color: #0284c7;
}

:root.light-mode .source-card {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #475569;
}

:root.light-mode .modal {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
    color: #0f172a;
}

:root.light-mode .modal-header,
:root.light-mode .modal-footer {
    border-color: #f1f5f9;
}

:root.light-mode .modal-title {
    color: #0f172a;
}

:root.light-mode .modal-close {
    color: #64748b;
}

:root.light-mode .modal-close:hover {
    color: #0f172a;
}

:root.light-mode .toast {
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    border: 1px solid #e2e8f0;
    color: #0f172a;
}

:root.light-mode .workers-sidebar {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

:root.light-mode .sidebar-title {
    color: #0f172a;
}

:root.light-mode .sidebar-timer-container {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

:root.light-mode ::-webkit-scrollbar-track {
    background: #f1f5f9;
}

:root.light-mode ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

:root.light-mode ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

:root.light-mode .search-controls {
    border-top-color: #f1f5f9;
}

:root.light-mode .card-header {
    border-bottom-color: #f1f5f9;
}

:root.light-mode .card-title {
    color: #0f172a;
}

:root.light-mode .config-warning-banner {
    color: #92400e;
    background: rgba(245, 158, 11, 0.12);
    border-bottom-color: rgba(245, 158, 11, 0.25);
}

:root.light-mode .config-warning-text strong {
    color: #78350f;
}

:root.light-mode .config-issues {
    color: #92400e;
}

:root.light-mode .config-dismiss {
    color: #92400e;
}

:root.light-mode .backend-offline-banner {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.1);
    border-bottom-color: rgba(239, 68, 68, 0.2);
}

:root.light-mode .backend-offline-banner strong {
    color: #991b1b;
}

:root.light-mode .progress-map-card {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

:root.light-mode .progress-map-title {
    color: #0f172a;
    border-bottom-color: #f1f5f9;
}

/* Progress Map Styling */
.progress-map-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    animation: slide-up 0.3s ease-out;
}

.progress-map-title {
    font-family: var(--font-outfit);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.5rem;
}

.progress-nodes-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
}

.progress-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 90px;
    text-align: center;
    position: relative;
}

.node-icon-wrapper {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--text-muted);
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.node-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.node-sublabel {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.node-connector {
    flex: 1;
    height: 2px;
    background: var(--text-muted);
    margin-bottom: 1.25rem;
    transition: var(--transition-smooth);
}

/* Progress Map States */
.progress-node.pending .node-icon-wrapper {
    border-color: var(--text-muted);
    color: var(--text-muted);
}

.progress-node.active .node-icon-wrapper {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 10px var(--accent-purple-glow);
    animation: active-pulse 2s infinite alternate;
}

.progress-node.active .node-label {
    color: var(--accent-purple);
    font-weight: 600;
}

.progress-node.active .node-sublabel {
    color: var(--accent-purple);
}

.progress-node.completed .node-icon-wrapper {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
    background: rgba(16, 185, 129, 0.1);
}

.progress-node.completed .node-label {
    color: var(--text-primary);
}

.progress-node.completed .node-sublabel {
    color: var(--accent-teal);
}

.node-connector.completed {
    background: var(--accent-teal);
}

.node-connector.active {
    background: linear-gradient(90deg, var(--accent-teal), var(--accent-purple));
}

@keyframes active-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    100% {
        transform: scale(1.05);
        box-shadow: 0 0 10px 4px rgba(99, 102, 241, 0.2);
    }
}

/* Intermediate Search Logs inside Worker Cards */
.worker-search-logs {
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.03);
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.search-log-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: monospace;
    font-size: 0.7rem;
    line-height: 1.3;
}

.search-log-item.running {
    color: var(--accent-purple);
}

.search-log-item.completed {
    color: var(--text-secondary);
}

.search-log-item.running .log-icon {
    color: var(--accent-purple);
    animation: log-spin 1.5s linear infinite;
}

.search-log-item.completed .log-icon {
    color: var(--accent-teal);
}

@keyframes log-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Print CSS Stylesheet */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    header,
    .workers-sidebar,
    .aggregator-progress-bar,
    .streaming-loader,
    .report-actions,
    .toast-container,
    .progress-map-card,
    .feedback-controls,
    .theme-toggle,
    #settings-btn,
    #new-research-btn,
    .backend-offline-banner {
        display: none !important;
    }
    main {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    #workspace-panel {
        display: block !important;
        grid-template-columns: 1fr !important;
    }
    .report-workspace {
        margin-top: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .report-container {
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        min-height: auto !important;
    }
    .report-content {
        color: #000000 !important;
    }
    .report-content h1, 
    .report-content h2, 
    .report-content h3 {
        color: #000000 !important;
        border-bottom-color: #000000 !important;
    }
    .sources-section {
        border-top-color: #000000 !important;
    }
    .source-card {
        border-color: #e5e7eb !important;
        background: #f9fafb !important;
        color: #374151 !important;
    }
}

/* Report Markdown Images styling */
.report-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
    margin: 1.5rem auto;
    display: block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: var(--transition-smooth);
}

.report-content img:hover {
    transform: scale(1.01);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.15);
    border-color: var(--accent-purple);
}

/* ==========================================================================
   ACADEMIC LAB & RESEARCH MODE EXTENSIONS
   ========================================================================== */

/* Brand Tag */
.brand-text-group {
    display: flex;
    flex-direction: column;
}

.logo-tag {
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    font-weight: 700;
    color: var(--academic-blue);
    margin-top: -3px;
}

/* Mode Switcher Wrapper & Tabs */
.mode-switcher-wrapper {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    pointer-events: auto;
    z-index: 10;
}

.mode-toggle-container {
    position: relative;
    display: flex;
    padding: 4px;
    gap: 0;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.09);
    backdrop-filter: blur(20px) saturate(170%);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        inset 0 -1px 0 rgba(0, 0, 0, 0.25),
        0 6px 20px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    isolation: isolate;
}

/* One cell per tab, each the same width as the tab above it, so the two
   runtimes line up under the labels they belong to. */
.mode-time-row {
    display: flex;
    width: 100%;
    /* Matches .mode-toggle-container's padding so each half lines up with the
       tab above it rather than with the pill's outer edge. */
    padding: 0 4px;
    user-select: none;
}

.mode-time-estimate {
    flex: 1 1 0;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1;
    letter-spacing: 0.02em;
    transition: color var(--transition-fast), font-weight var(--transition-fast);
}

/* The selected mode's runtime is the one that applies right now, so it is the
   one that reads as foreground. */
.mode-time-estimate.is-active {
    color: var(--accent-purple);
    font-weight: 700;
}

/* The travelling pill. Both tabs are forced to equal width so a flat 100%
   translate always lands exactly on the second one. */
.mode-toggle-container::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    border-radius: 50px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow:
        0 2px 12px rgba(37, 99, 235, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 0;
}

.mode-toggle-container:has(#tab-researchmode.active)::before {
    transform: translateX(100%);
}

/* Specular sheen sweeping across the glass on hover. */
.mode-toggle-container::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50px;
    background: linear-gradient(
        105deg,
        transparent 35%,
        rgba(255, 255, 255, 0.16) 50%,
        transparent 65%
    );
    transform: translateX(-120%);
    pointer-events: none;
    z-index: 2;
}

.mode-toggle-container:hover::after {
    animation: glassSheen 0.9s ease-out;
}

@keyframes glassSheen {
    to { transform: translateX(120%); }
}

.mode-tab {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    min-width: 152px;
    justify-content: center;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.45rem 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: color 0.25s ease, transform 0.25s ease;
}

.mode-tab:hover {
    color: var(--text-primary);
}

.mode-tab:active {
    transform: scale(0.96);
}

/* The pill supplies the fill; the tab only changes its own text colour. */
.mode-tab.active {
    color: #ffffff;
}

.mode-tab i {
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mode-tab.active i {
    transform: scale(1.12);
}

@media (prefers-reduced-motion: reduce) {
    .mode-toggle-container::before,
    .mode-tab,
    .mode-tab i { transition: none; }
    .mode-toggle-container:hover::after { animation: none; }
}

/* Browsers without :has() get a static pill on the active tab instead of a
   sliding one - no motion, but the selection still reads correctly. */
@supports not selector(:has(*)) {
    .mode-toggle-container::before { display: none; }
    .mode-tab.active {
        background: linear-gradient(135deg, #6366f1, #4338ca);
        box-shadow: 0 2px 12px rgba(99, 102, 241, 0.45);
    }
}

/* Privacy Guarantee Banner */
.local-privacy-banner {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.25rem;
    margin: 1rem 1.5rem;
    color: #a7f3d0;
}

.local-privacy-banner.compact {
    margin: 0 0 1.25rem 0;
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
}

.privacy-notice-text {
    font-size: 0.85rem;
    line-height: 1.45;
}

/* Modal Extensions */
.modal-lg {
    width: 680px;
}

.modal-subtitle {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.form-section-title {
    font-family: var(--font-outfit);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--academic-blue);
    margin-bottom: 0.75rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.form-grid .full-width {
    grid-column: span 2;
}

/* Research Mode Inputs */
.rm-hero-header {
    text-align: center;
    max-width: 750px;
    margin: 0 auto 2rem auto;
}

/* Indexed-source strip. Marks are drawn inline rather than loaded as brand
   assets, so the row still renders with no network and nothing to hotlink. */
.index-strip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    margin-top: 1.75rem;
}

.index-strip-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.index-list {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.index-chip,
.index-chip:visited {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem 0.4rem 0.45rem;
    border-radius: 50px;
    text-decoration: none;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px) saturate(150%);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.index-chip:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
}

.index-mark {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    object-fit: contain;
}

/* The OpenAlex mark ships as solid black, which vanishes on the dark surface.
   Inverting it is the only change made to any of these brand assets. */
.index-mark-openalex {
    filter: invert(1);
}

:root.light-mode .index-mark-openalex {
    filter: none;
}

.index-footnote {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.6rem;
    margin-bottom: 0.25rem;
}

.rm-input-card {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.25rem;
    background: rgba(13, 17, 26, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    transition: var(--transition-smooth);
}

/* Live cumulative "papers synthesized" counter on the Research Mode landing. */
.rm-live-count {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 1rem auto 0;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: var(--font-inter);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: rmLiveCountPulse 3.5s ease-in-out infinite;
}

.rm-live-count i[data-lucide] {
    color: var(--academic-blue);
}

.rm-live-count strong {
    color: var(--text-primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@keyframes rmLiveCountPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.0); }
    50% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12); }
}

:root.light-mode .rm-live-count {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.3);
    color: var(--text-secondary);
}

/* Matches the DeepSearch search box: the panel carries the focus glow */
.rm-input-card:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6, 0 20px 50px rgba(37, 99, 235, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* The card already signals focus, so the textarea inside must not draw a second
   ring or border around itself - that double outline was the boxed-in look. */
.rm-input-card .rm-textarea,
.rm-input-card .rm-textarea-sm {
    width: 100%;
    background: transparent;
    border: none;
    outline: none !important;
    color: var(--text-primary);
    font-family: var(--font-inter);
    resize: none;
    box-shadow: none !important;
}

.rm-input-card .rm-textarea:focus,
.rm-input-card .rm-textarea:focus-visible,
.rm-input-card .rm-textarea-sm:focus,
.rm-input-card .rm-textarea-sm:focus-visible {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* The primary field mirrors .search-input's type scale (1.1rem) - the two
   are functionally the same control, just in different modes. */
.rm-textarea {
    min-height: 90px;
    font-size: 1.1rem;
}

.rm-textarea-sm {
    min-height: 60px;
}

.rm-hint {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.rm-advanced {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    background: rgba(9, 9, 11, 0.25);
}

.rm-advanced-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.9rem;
    cursor: pointer;
    font-family: var(--font-outfit);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    list-style: none;
    transition: var(--transition-fast);
}

.rm-advanced-summary::-webkit-details-marker {
    display: none;
}

.rm-advanced-summary:hover {
    color: var(--accent-purple);
}

.rm-advanced[open] .rm-advanced-summary {
    border-bottom: 1px solid var(--card-border);
    color: var(--accent-purple);
}

.rm-advanced-body {
    padding: 1rem 0.9rem 0.25rem;
}

.rm-advanced-body .rm-hint {
    margin: 0 0 1rem;
}

.label-tag {
    display: inline-block;
    margin-left: 0.45rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--academic-blue);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: middle;
}

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1.05rem;
}

/* Signature Element: Autonomous Academic Stepper */
.pipeline-stepper-card {
    background: rgba(13, 17, 26, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-md);
    padding: 1rem 1.35rem;
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    margin-bottom: 1.25rem;
    transition: var(--transition-smooth);
}

.stepper-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.stepper-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stepper-icon-ring {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stepper-headline {
    font-family: var(--font-outfit);
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
}

.stepper-live-sub {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.stepper-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--academic-blue);
    box-shadow: 0 0 8px var(--academic-blue);
    animation: pulseDot 1.4s ease-in-out infinite;
}

.stepper-meta-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.stepper-status-pill {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 50px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--academic-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.stepper-status-pill.review {
    background: rgba(245, 158, 11, 0.12);
    color: var(--amber-review);
    border-color: rgba(245, 158, 11, 0.35);
}

.stepper-status-pill.completed {
    background: rgba(16, 185, 129, 0.12);
    color: var(--emerald-verified);
    border-color: rgba(16, 185, 129, 0.35);
}

.rm-resume-banner {
    background: rgba(16, 23, 38, 0.75);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.1rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    margin-bottom: 1.25rem;
}

/* Super minimal Research Mode timer */
.rm-mini-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.55rem;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
    font-variant-numeric: tabular-nums;
    color: var(--academic-blue, #38bdf8);
    letter-spacing: 0.02em;
    user-select: none;
    line-height: 1.4;
    transition: var(--transition-smooth);
}

.rm-mini-timer.running {
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.18);
}

.rm-mini-timer.completed {
    background: rgba(52, 211, 153, 0.08);
    border-color: rgba(52, 211, 153, 0.3);
    color: var(--emerald-accent, #34d399);
}

.rm-mini-timer i {
    width: 12px;
    height: 12px;
    stroke-width: 2.2;
    flex-shrink: 0;
}

.light-theme .rm-mini-timer {
    background: rgba(2, 132, 199, 0.08);
    border-color: rgba(2, 132, 199, 0.25);
    color: #0284c7;
}

.light-theme .rm-mini-timer.completed {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
    color: #059669;
}

/* Was --text-muted on a near-transparent background - readable only on hover,
   invisible at rest. This is the toggle for the pipeline tracker and the
   Sources panel, so it needs to read as a button by default, not just on
   hover. */
.tracker-header-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(56, 189, 248, 0.08);
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    border: 1px solid rgba(56, 189, 248, 0.25);
    transition: var(--transition-smooth);
}

.tracker-header-controls:hover {
    background: rgba(56, 189, 248, 0.16);
    color: var(--text-primary);
    border-color: rgba(56, 189, 248, 0.45);
}

.tracker-chevron-icon {
    transition: transform 0.25s ease;
}

.pipeline-tracker-container[open] .tracker-chevron-icon {
    transform: rotate(180deg);
}

.tracker-collapsible-content {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Research Mode Corpus Stats Bar */
.rm-corpus-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.35rem;
    margin-top: 0.2rem;
    margin-bottom: 0.4rem;
    width: 100%;
}

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 0.2rem 0.45rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-width: 0;
    transition: var(--transition-fast);
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(56, 189, 248, 0.3);
}

.stat-num {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--academic-blue);
    font-variant-numeric: tabular-nums;
}

.stat-lbl {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: inline;
    white-space: nowrap;
}

:root.light-mode .stat-card {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root.light-mode .stat-card:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

:root.light-mode .stat-lbl {
    color: #64748b;
}

/* Compact step chips layout */
.pipeline-step {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    padding: 0.12rem 0.35rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    transition: var(--transition-smooth);
    line-height: 1.2;
}

.pipeline-step.completed {
    border-color: rgba(52, 211, 153, 0.35);
    background: rgba(52, 211, 153, 0.08);
}

.pipeline-step.active {
    border-color: var(--academic-blue);
    background: rgba(56, 189, 248, 0.15);
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.3);
    animation: active-step-pulse 2s infinite alternate;
}

.pipeline-step.hitl {
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.08);
}

.step-number {
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.pipeline-step.completed .step-number { color: var(--emerald-verified); }
.pipeline-step.active .step-number { color: var(--academic-blue); }
.pipeline-step.hitl .step-number { color: var(--amber-review); }

.step-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pipeline-step.completed .step-label { color: var(--text-primary); }
.pipeline-step.active .step-label { color: var(--text-primary); }

@keyframes active-step-pulse {
    0% { border-color: rgba(56, 189, 248, 0.4); }
    100% { border-color: var(--academic-blue); }
}

/* HITL Review Panel */
.rm-hitl-panel {
    border-color: rgba(251, 191, 36, 0.4);
    box-shadow: 0 0 25px rgba(251, 191, 36, 0.1);
    margin-bottom: 1.5rem;
}

.hitl-title-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.hitl-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.7rem;
    background: rgba(251, 191, 36, 0.15);
    color: var(--amber-review);
    border-radius: 50px;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.hitl-content-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
}

.hitl-btn-row {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 0.75rem;
}

.btn-emerald {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-emerald:hover {
    background: #10b981;
}

/* Paper Output Card */
.rm-paper-card {
    min-height: 500px;
    background: rgba(11, 15, 23, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-top: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: var(--radius-md);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 0 24px rgba(56, 189, 248, 0.06);
}

.paper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--card-border);
}

.paper-heading {
    font-family: var(--font-outfit);
    font-size: 1.35rem;
    font-weight: 600;
}

.paper-placeholder-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    gap: 1rem;
    color: var(--text-muted);
    text-align: center;
}

.btn-pdf {
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-pdf:hover {
    background: #3b82f6;
}

/* Export Dropdown Styling */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 6px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

.export-dropdown .dropdown-menu.show {
    display: block;
}

.export-dropdown .dropdown-item {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: #e2e8f0;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.export-dropdown .dropdown-item:hover {
    background: rgba(59, 130, 246, 0.3);
    color: #ffffff;
}

/* Keyboard focus ring for buttons, links, and chips. Text fields are excluded:
   they signal focus with their own border and glow, and the extra ring drew a
   hard rectangle inside the panel. */
*:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
    border-radius: 4px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.search-input:focus-visible,
.form-input:focus-visible,
.feedback-textarea:focus-visible {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   Responsive Mobile & Tablet Layout (1024px, 768px, 640px, 480px, 375px)
   ========================================================================== */

@media (max-width: 1024px) {
    main {
        padding: 1.5rem 1.25rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0 1.25rem;
    }

    .mode-tab {
        min-width: 120px;
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .full-width {
        grid-column: span 1;
    }

    .approval-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .paper-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .paper-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-start;
    }

    .rm-corpus-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Number-beside-label with a forced-nowrap label only works when the card
       is wide enough for both. Below 768px it isn't - the label text was
       overflowing its own card and visually bleeding into the neighboring
       one. Stack instead and let the label wrap if it genuinely needs to. */
    .stat-card {
        flex-direction: column;
        gap: 0.1rem;
        padding: 0.4rem 0.3rem;
    }

    .stat-lbl {
        white-space: normal;
        overflow-wrap: break-word;
        line-height: 1.15;
    }

    /* 44px is the smallest comfortably tappable target; below this width every
       control is being hit with a thumb rather than a cursor. */
    .btn-icon, .btn-secondary, .btn-github {
        min-height: 44px;
    }

    .btn-icon {
        min-width: 44px;
    }

    .mode-tab, .chip {
        min-height: 44px;
    }
}

@media (max-width: 640px) {
    /* Fallback only. The stacked header's real height depends on how its rows
       wrap, so a fixed number here drifts; syncHeaderOffset() overrides this
       with the measured value. */
    body {
        padding-top: var(--header-offset, 120px);
    }

    header {
        height: auto;
        min-height: 105px;
        padding: 0.65rem 1rem 0.55rem;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 0.35rem;
        background: var(--bg-dark);
        border-bottom: 1px solid var(--card-border);
    }

    :root.light-mode header {
        background: rgba(255, 255, 255, 0.96);
    }

    .logo-container {
        order: 1;
    }

    .header-actions {
        order: 2;
    }

    .mode-switcher-wrapper {
        order: 3;
        position: static;
        transform: none;
        width: 100%;
        margin-top: 0.25rem;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .mode-toggle-container {
        width: 100%;
        max-width: 320px;
    }

    .mode-tab {
        min-width: 0;
        flex: 1 1 50%;
        padding: 0.4rem 0.5rem;
        font-size: 0.78rem;
        gap: 0.3rem;
    }

    .hero-title {
        font-size: 1.85rem;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .search-box-container {
        padding: 1rem;
    }

    .search-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
        width: 100%;
    }

    .chips-container {
        width: 100%;
        gap: 0.35rem;
    }

    #plan-research-btn {
        width: 100%;
        justify-content: center;
    }

    .hitl-btn-row {
        flex-direction: column;
        gap: 0.6rem;
        width: 100%;
    }

    .hitl-btn-row .btn-primary,
    .hitl-btn-row .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .feedback-controls {
        flex-direction: column;
        gap: 0.6rem;
        width: 100%;
    }

    .feedback-controls button {
        width: 100%;
        justify-content: center;
    }

    .rm-input-card {
        padding: 1.25rem 1rem;
    }

    #rm-start-btn {
        width: 100%;
        white-space: normal;
        text-align: center;
        line-height: 1.35;
        padding: 0.85rem 1rem;
    }

    #rm-prisma-view img {
        max-width: 100%;
        height: auto;
        border-radius: var(--radius-sm);
    }

    #rm-evidence-matrix-view {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal {
        max-width: 95vw;
        max-height: 90vh;
        padding: 1.25rem 1rem;
    }

    .paper-modal-card {
        max-width: 96vw;
        max-height: 90vh;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .logo-tag {
        display: none;
    }

    .logo-text {
        font-size: 1.05rem;
    }

    .btn-github {
        padding: 0 0.5rem;
        font-size: 0.75rem;
    }

    .rm-corpus-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .index-list {
        flex-direction: column;
        align-items: stretch;
    }

    .index-chip {
        justify-content: center;
    }

    .tracker-title-group {
        gap: 0.4rem;
    }

    .tracker-title {
        font-size: 0.85rem;
    }
}

@media (max-width: 375px) {
    body {
        padding-top: var(--header-offset, 120px);
    }

    main {
        padding: 1rem 0.5rem;
    }

    .hero-title {
        font-size: 1.6rem;
    }

    .hero-subtitle {
        font-size: 0.85rem;
    }

    .mode-toggle-container {
        max-width: 100%;
    }

    .mode-tab {
        font-size: 0.72rem;
        padding: 0.35rem 0.35rem;
    }

    .mode-tab i {
        display: none; /* Keep text clean & unclipped on 375px */
    }

    .rm-input-card {
        padding: 1rem 0.75rem;
    }

    .card {
        padding: 1rem 0.75rem;
    }

    header {
        padding: 0.5rem 0.75rem;
    }
}

/* ==========================================================================
   Modern UI Animations & Micro-Interactions
   ========================================================================== */

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

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

@keyframes cursorBlink {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px #818cf8; }
    50% { opacity: 0; text-shadow: none; }
}

@keyframes wavePulse {
    0%, 100% { height: 4px; }
    50% { height: 16px; }
}

@keyframes nodeGlowPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(99, 102, 241, 0.35), inset 0 0 12px rgba(99, 102, 241, 0.2); border-color: rgba(99, 102, 241, 0.6); }
    50% { box-shadow: 0 0 25px rgba(99, 102, 241, 0.85), inset 0 0 20px rgba(99, 102, 241, 0.5); border-color: #6366f1; }
}

.orbital-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}
.orbital-ring {
    width: 52px;
    height: 52px;
    border: 3px solid rgba(99, 102, 241, 0.18);
    border-top-color: var(--accent-purple);
    border-right-color: #a855f7;
    border-radius: 50%;
    animation: orbitalRotate 2.2s linear infinite;
}
.skeleton-line {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(129,140,248,0.15) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    margin-bottom: 0.75rem;
}

:root.light-mode .skeleton-line {
    background: linear-gradient(90deg, rgba(15,23,42,0.05) 25%, rgba(99,102,241,0.25) 50%, rgba(15,23,42,0.05) 75%);
    background-size: 200% 100%;
}
.typing-cursor {
    display: inline-block;
    width: 9px;
    height: 1.1em;
    background: var(--accent-purple);
    margin-left: 3px;
    vertical-align: middle;
    border-radius: 2px;
    animation: cursorBlink 0.75s infinite;
}
.ai-wave-container {
    display: inline-flex;
    align-items: flex-end;
    gap: 3px;
    height: 18px;
    margin-left: 8px;
    vertical-align: middle;
}
.ai-wave-bar {
    width: 3px;
    background: var(--accent-purple);
    border-radius: 2px;
    animation: wavePulse 1s ease-in-out infinite;
}
.ai-wave-bar:nth-child(2) { animation-delay: 0.2s; }
.ai-wave-bar:nth-child(3) { animation-delay: 0.4s; }
.ai-wave-bar:nth-child(4) { animation-delay: 0.6s; }

.pipeline-step-item.active {
    animation: nodeGlowPulse 1.8s infinite ease-in-out !important;
}

/* ==========================================================================
   Sleek Minimalist Vercel / Linear Style Theme
   ========================================================================== */






/* ==========================================================================
   Worker cards, streaming tag and CDN-less markdown fallback
   ========================================================================== */

/* renderWorkers() emits .worker-status and .worker-task; neither had any rules,
   so the researcher sidebar rendered as unstyled text. */
.worker-status {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.12rem 0.5rem;
    border-radius: 50px;
    flex-shrink: 0;
    border: 1px solid transparent;
}

.worker-status.running {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--accent-purple);
}

.worker-status.completed {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--accent-teal);
}

.worker-task {
    margin-top: 0.4rem;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.worker-queries {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.worker-query {
    font-size: 0.72rem;
    color: var(--text-muted);
    padding-left: 0.75rem;
    border-left: 2px solid var(--card-border);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Pulses while token_stream events are arriving, so a slow node reads as busy
   rather than hung. */
.tracker-status-tag.streaming {
    animation: tagPulse 1.4s ease-in-out infinite;
}

@keyframes tagPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
    .tracker-status-tag.streaming { animation: none; }
}

/* Shown instead of rendered markdown when the marked.js CDN is unreachable. */
.markdown-fallback {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-secondary);
    margin: 0;
}

/* Accessibility: Skip Link */
.skip-link {
    position: absolute;
    top: -120px;
    left: 1rem;
    background: var(--accent-purple);
    color: #ffffff;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    z-index: 10000;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 1rem;
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

/* Semantic & SEO App Footer */
.app-footer {
    width: 100%;
    margin-top: 4rem;
    border-top: 1px solid var(--card-border);
    background: var(--bg-panel);
    color: var(--text-secondary);
    position: relative;
    z-index: 10;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem 2.25rem;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 2.5rem;
    align-items: start;
}

.footer-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-brand-col .footer-logo {
    height: 24px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.footer-brand-title {
    font-family: var(--font-outfit);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    line-height: 1;
}

.footer-brand-tag {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--academic-blue);
    border: 1px solid rgba(56, 189, 248, 0.25);
    line-height: 1.2;
}

.footer-desc {
    font-size: 0.84rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
    max-width: 320px;
}

.footer-tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.15rem;
}

.tech-tag {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
}

.footer-heading {
    font-family: var(--font-outfit);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin: 0;
    height: 24px;
    display: flex;
    align-items: center;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    font-size: 0.82rem;
    line-height: 1.4;
}

.footer-links li a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
}

.footer-links li a:hover {
    color: var(--accent-purple);
    transform: translateX(2px);
}

.footer-links li span {
    color: var(--text-muted);
}

.footer-author-note {
    font-weight: 500;
    color: var(--text-secondary) !important;
}

.footer-open-note {
    font-size: 0.76rem;
    color: var(--text-muted) !important;
}

.footer-bottom {
    border-top: 1px solid var(--card-border);
    padding: 1.25rem 1.5rem;
    background: rgba(0, 0, 0, 0.15);
}

.footer-bottom-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer-bottom p {
    margin: 0;
}

.footer-security-note {
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 1024px) {
    .footer-container {
        grid-template-columns: 1.3fr 1fr 1fr 1fr;
        gap: 2rem 1.5rem;
    }
}

@media (max-width: 900px) {
    .footer-container {
        grid-template-columns: 1fr 1fr;
        gap: 2.5rem 2rem;
    }
    .footer-desc {
        max-width: 100%;
    }
}

@media (max-width: 600px) {
    .footer-container {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2.25rem 1.25rem 1.75rem;
    }
    .footer-bottom-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

:root.light-mode .footer-bottom {
    background: rgba(0, 0, 0, 0.03);
}

:root.light-mode .tech-tag {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}

/* Source badges — reused brand marks for individual paper rows (checkpoint
   2 evidence strip, sources library panel). Smaller than the landing page's
   .index-mark since these sit inline next to a paper title. */
.source-badge {
    width: 14px;
    height: 14px;
    object-fit: contain;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Collapsed-by-default long-text blocks in checkpoint panels. */
.truncatable {
    max-height: 8.5em;
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}
.truncatable.expanded {
    max-height: none;
    mask-image: none;
    -webkit-mask-image: none;
}
.truncate-toggle {
    display: block;
    margin: 0.4rem 0 1rem 0;
    padding: 0;
    background: none;
    border: none;
    color: var(--accent-purple);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.truncate-toggle:hover {
    text-decoration: underline;
}

/* Checkpoint 2 evidence strip */
.evidence-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 220px;
    overflow-y: auto;
    margin-top: 0.5rem;
}
.evidence-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: var(--transition-fast);
}
.evidence-row:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}
.evidence-title {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.evidence-year {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.evidence-score {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--academic-blue);
    flex-shrink: 0;
    min-width: 32px;
    text-align: right;
}

/* Sources library panel */
/* Persistent side panel next to the paper, not a click-to-expand accordion -
   same pattern as DeepSearch's .workers-sidebar. min-width: 0 on the main
   column stops long unbreakable content (DOIs, URLs) from forcing the grid
   wider than the viewport. */
.rm-workspace-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
    width: 100%;
}

.rm-main-column {
    min-width: 0;
}

.rm-sources-sidebar {
    display: flex;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.rm-sources-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

.rm-sources-sidebar .rm-sources-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding: 0.75rem;
}

@media (max-width: 1024px) {
    .rm-workspace-grid {
        grid-template-columns: 1fr;
    }
    .rm-sources-sidebar {
        position: static;
        max-height: none;
    }
}

.rm-sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    padding: 1rem 1.5rem 1.5rem;
}
.source-card-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}
.source-card-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}
.source-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.source-card-score {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--academic-blue);
}
.source-card-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 0.35rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.source-card-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Inline citation links in paper view */
.citation-link {
    color: var(--academic-blue);
    text-decoration: none;
    border-bottom: 1px dotted var(--academic-blue);
}
.citation-link:hover {
    border-bottom-style: solid;
}

/* Paper typography. .paper-render-container had zero rules before this —
   marked.parse() output rendered with bare browser UA defaults: no heading
   hierarchy, no paragraph rhythm, emphasis invisible against body weight. */
.paper-render-container {
    color: var(--text-primary);
    font-size: 0.98rem;
    line-height: 1.75;
    max-width: 780px;
    margin: 0 auto;
}
.paper-render-container h1 {
    font-family: var(--font-outfit);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 1.25rem 0;
    color: var(--text-primary);
}
.paper-render-container h2 {
    font-family: var(--font-outfit);
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 2rem 0 0.85rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-primary);
}
.paper-render-container h2:first-child {
    margin-top: 0;
}
.paper-render-container h3 {
    font-family: var(--font-outfit);
    font-size: 1.08rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 1.5rem 0 0.6rem 0;
    color: var(--text-primary);
}
.paper-render-container p {
    margin: 0 0 1rem 0;
}
.paper-render-container p:last-child {
    margin-bottom: 0;
}
.paper-render-container strong {
    font-weight: 700;
    color: var(--text-primary);
}
.paper-render-container em {
    font-style: italic;
}
.paper-render-container ul,
.paper-render-container ol {
    margin: 0 0 1rem 0;
    padding-left: 1.5rem;
}
.paper-render-container li {
    margin-bottom: 0.4rem;
    line-height: 1.65;
}
.paper-render-container li:last-child {
    margin-bottom: 0;
}
.paper-render-container a {
    color: var(--academic-blue);
}
.paper-render-container hr {
    border: none;
    border-top: 1px solid var(--card-border);
    margin: 1.75rem 0;
}

/* ==========================================================================
   Research Mode Post-Checkpoint Transition Loading Placeholder
   ========================================================================== */

.rm-checkpoint-loader {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--glass-panel);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 0 20px rgba(56, 189, 248, 0.08);
    position: relative;
    overflow: hidden;
    animation: fade-in 0.35s ease-out forwards;
}

.rm-checkpoint-loader::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--academic-blue), var(--accent-purple), transparent);
    animation: loaderTopGlow 2.5s linear infinite;
}

@keyframes loaderTopGlow {
    0% { transform: translateX(0); }
    100% { transform: translateX(50%); }
}

.rm-loader-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rm-loader-badge-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.rm-loader-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--academic-blue);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.rm-loader-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--academic-blue);
    box-shadow: 0 0 8px var(--academic-blue);
    animation: pulseDot 1.6s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
}

.rm-loader-live-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--violet-pulse);
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid rgba(129, 140, 248, 0.2);
}

.rm-loader-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.rm-loader-hero {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.rm-loader-spinner-wrapper {
    position: relative;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rm-loader-spinner-wrapper .orbital-ring {
    position: absolute;
    inset: 0;
    width: 52px;
    height: 52px;
}

.rm-loader-core-icon {
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rm-loader-hero-text {
    flex: 1;
}

.rm-loader-title {
    font-family: var(--font-outfit);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.35rem 0;
    line-height: 1.35;
}

.rm-loader-subtitle {
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0;
}

.rm-loader-subtasks-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
}

.rm-loader-subtasks-heading {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.rm-loader-subtasks-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rm-loader-subtask-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.84rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.rm-loader-subtask-item.in-progress {
    color: var(--text-primary);
    font-weight: 500;
}

.rm-loader-subtask-status {
    width: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--academic-blue);
    box-shadow: 0 0 8px var(--academic-blue);
    animation: pulseDot 1.2s infinite ease-in-out;
}

.wait-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.4;
}

.rm-loader-subtask-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--academic-blue);
    opacity: 0.85;
}

.rm-loader-subtask-label {
    line-height: 1.4;
}

.rm-loader-shimmer-preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0.25rem 0;
}

.rm-loader-footer-bar {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-bottom: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.rm-loader-footer-inner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.rm-loader-footer-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Light mode overrides for post-checkpoint loader */
:root.light-mode .rm-checkpoint-loader {
    background: #ffffff;
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
:root.light-mode .rm-loader-subtasks-container {
    background: #f8fafc;
    border-color: #e2e8f0;
}
:root.light-mode .rm-loader-header,
:root.light-mode .rm-loader-footer-bar {
    border-color: #e2e8f0;
}

/* ==========================================================================
   APPLE FLUID DESIGN & UI/UX PRO MAX UPGRADES
   ========================================================================== */

/* 1. Universal Tactile Spring Feedback */
button, 
.btn-primary, 
.btn-secondary, 
.chip, 
.mode-tab, 
.source-card-item, 
.source-filter-chip,
.stat-card,
.modal-close-btn,
.export-dropdown button {
    transition: transform 0.16s var(--spring-snappy), 
                box-shadow 0.2s ease, 
                background-color 0.2s ease, 
                border-color 0.2s ease;
}

button:active, 
.btn-primary:active, 
.btn-secondary:active {
    transform: scale(0.96) !important;
}

.chip:active, 
.source-filter-chip:active, 
.mode-tab:active {
    transform: scale(0.93) !important;
}

/* 2. Optical Typography & Number Tabulation */
.hero-title, 
.section-title, 
.paper-heading, 
.modal-title {
    letter-spacing: -0.025em;
}

.filter-label, 
.step-number, 
.phase-badge, 
.hitl-badge, 
.label-tag,
.tracker-toggle-lbl,
.outline-header {
    letter-spacing: 0.06em;
    font-weight: 700;
}

.timer-value, 
#rm-research-timer, 
.stat-num, 
#rm-log-count, 
#rm-sources-count-tag, 
.github-star-count,
.input-char-counter,
.paper-meta-chip {
    font-variant-numeric: tabular-nums;
}

/* 3. Input Meta Bars & Character Word Gauges */
.search-box-meta, 
.input-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.2rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.search-box-meta {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
}

.input-char-counter {
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.input-char-counter.has-content {
    color: var(--academic-blue);
}

.input-shortcut-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kbd-hint {
    display: inline-block;
    padding: 1px 5px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Mono", Monaco, monospace;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

:root.light-mode .kbd-hint {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

/* 4. Autonomous Academic Pipeline Tracker (Compact & High-Density) */
.pipeline-tracker-card {
    background: rgba(13, 17, 26, 0.82);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 0.65rem 0.95rem;
    box-shadow: 0 10px 28px -6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    margin-bottom: 0.85rem;
    transition: var(--transition-smooth);
}

.pipeline-tracker-card.active-execution {
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 12px 32px -6px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.12);
}

.tracker-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tracker-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stepper-icon-ring {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stepper-headline {
    font-size: 0.88rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
}

.stepper-live-sub {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.05rem;
}

.stepper-pulse-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--academic-blue);
    animation: pulseDot 1.4s ease-in-out infinite;
}

.tracker-meta-group {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.stepper-status-pill {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.09);
    padding: 0.18rem 0.55rem;
    border-radius: 50px;
}

.stepper-status-pill.review {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fef3c7;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.2);
}

.stepper-status-pill.completed {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.35);
    color: #6ee7b7;
}

.tracker-collapse-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 0.18rem 0.45rem;
    border-radius: 5px;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: var(--transition-fast);
}

.tracker-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.tracker-expandable-content {
    margin-top: 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    animation: fadeIn 0.2s ease;
}

/* 5 Corpus Stats Cards (Ultra-Sleek Inline Strip) */
.rm-corpus-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
    width: 100%;
}

.stat-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: var(--transition-fast);
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.stat-num {
    font-family: var(--font-outfit);
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--academic-blue);
    line-height: 1;
}

.stat-lbl {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* 4-Phase Connected Real-Time Pipeline Matrix (Compressed Density) */
.pipeline-stages-container {
    width: 100%;
}

.pipeline-stages-matrix {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
}

.pipeline-phase-group {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: var(--transition-fast);
}

.pipeline-phase-group.phase-active {
    background: rgba(56, 189, 248, 0.03);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.06);
}

.pipeline-phase-group.phase-done {
    border-color: rgba(16, 185, 129, 0.15);
}

.phase-group-header {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.phase-num-pill {
    font-size: 0.56rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--academic-blue);
    background: rgba(56, 189, 248, 0.1);
    padding: 0.08rem 0.3rem;
    border-radius: 3px;
}

.phase-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.phase-stages-chips {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* 2-Column layout for Phase 4 so it stays flat and compact */
.pipeline-phase-group:nth-child(4) .phase-stages-chips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.2rem;
}

.stage-flow-chip {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.66rem;
    color: var(--text-muted);
    transition: var(--transition-fast);
    position: relative;
    line-height: 1.2;
}

.stage-flow-chip.completed {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.22);
    color: var(--text-primary);
}

.stage-flow-chip.active {
    background: rgba(56, 189, 248, 0.14);
    border-color: rgba(56, 189, 248, 0.4);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.stage-flow-chip.is-hitl-stage {
    border-left: 2px solid #f59e0b;
}

.stage-flow-chip.review.active {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.45);
    color: #fef3c7;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.stage-chip-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stage-chip-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stage-chip-live-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--academic-blue);
    box-shadow: 0 0 5px var(--academic-blue);
    animation: pulseDot 1.2s infinite ease-in-out;
}

@media (max-width: 960px) {
    .pipeline-stages-matrix {
        grid-template-columns: repeat(2, 1fr);
    }
    .rm-corpus-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .pipeline-stages-matrix {
        grid-template-columns: 1fr;
    }
    .rm-corpus-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Workspace Grid: Main Column & Sources Sidebar */
.rm-workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 1.5rem;
    align-items: start;
    width: 100%;
}

.rm-main-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.rm-sources-sidebar {
    position: sticky;
    top: calc(var(--header-offset, 80px) + 1rem);
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(13, 17, 26, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.rm-sources-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rm-sources-grid {
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: calc(100vh - 220px);
}

.sources-empty-state {
    padding: 2rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (max-width: 1100px) {
    .rm-workspace-grid {
        grid-template-columns: 1fr;
    }
    .rm-sources-sidebar {
        position: static;
        max-height: 500px;
    }
}

/* 5. Sticky Table of Contents Outline & Paper Workspace Layout */
.paper-layout-wrapper {
    display: flex;
    gap: 1.25rem;
    position: relative;
    align-items: flex-start;
}

.paper-outline-rail {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--header-offset, 80px) + 1rem);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    background: rgba(13, 17, 26, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    transition: all 0.25s var(--spring-snappy);
}

:root.light-mode .paper-outline-rail {
    background: rgba(248, 250, 252, 0.8);
    border-color: #e2e8f0;
}

.outline-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.outline-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
}

.outline-item {
    margin: 0;
    padding: 0;
}

.outline-link {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    line-height: 1.35;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.outline-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.outline-link.active {
    color: var(--academic-blue);
    background: rgba(56, 189, 248, 0.1);
    font-weight: 600;
}

.outline-link.level-3 {
    padding-left: 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.paper-stats-badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.75rem;
}

.paper-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    padding: 0.2rem 0.55rem;
    border-radius: 12px;
}

:root.light-mode .paper-meta-chip {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}

/* 6. Sources Sidebar Database Filters & Cards */
.sources-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.sources-filter-bar::-webkit-scrollbar {
    display: none;
}

.source-filter-chip {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 50px;
    cursor: pointer;
    white-space: nowrap;
}

.source-filter-chip:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.source-filter-chip.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--academic-blue);
    color: var(--academic-blue);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.12);
}

.source-card-item {
    cursor: pointer;
    position: relative;
    border-left: 3px solid transparent;
}

.source-card-item:hover {
    border-left-color: var(--academic-blue);
    transform: translateX(2px);
}

/* 7. Skeleton Shimmer Outline Preview */
.paper-skeleton-outline {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
    width: 100%;
    max-width: 480px;
}

.skeleton-pill, 
.skeleton-bar {
    height: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 100%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.8s infinite ease-in-out;
}

.skeleton-pill {
    height: 20px;
    border-radius: 20px;
}

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

/* 8. Origin-Anchored Spring Dropdown */
.export-dropdown {
    position: relative;
}

.export-dropdown .dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: rgba(18, 24, 38, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 190px;
    z-index: 100;
    transform-origin: top right;
    transform: scale(0.94) translateY(-6px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s var(--spring-snappy), opacity 0.18s ease;
}

.export-dropdown .dropdown-menu.show {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.dropdown-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.dropdown-item:hover {
    background: rgba(56, 189, 248, 0.15);
    color: var(--text-primary);
}

:root.light-mode .export-dropdown .dropdown-menu {
    background: rgba(255, 255, 255, 0.98);
    border-color: #cbd5e1;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

/* 9. WCAG 2.2 Accessible Focus Indicators */
button:focus-visible,
a:focus-visible,
summary:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-icon:focus-visible,
.mode-tab:focus-visible,
.chip:focus-visible,
.source-filter-chip:focus-visible,
.dropdown-item:focus-visible,
.index-chip:focus-visible {
    outline: 2px solid var(--academic-blue) !important;
    outline-offset: 2px !important;
}

/* Ensure inner textareas and inputs never get inner highlight outlines or double boxes */
textarea,
textarea:focus,
textarea:focus-visible,
input:focus,
input:focus-visible,
.search-input,
.search-input:focus,
.search-input:focus-visible,
.rm-textarea,
.rm-textarea:focus,
.rm-textarea:focus-visible,
.rm-textarea-sm,
.rm-textarea-sm:focus,
.rm-textarea-sm:focus-visible,
.feedback-textarea:focus,
.feedback-textarea:focus-visible,
.rm-hitl-feedback-input:focus,
.rm-hitl-feedback-input:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
}

/* 10. Safe Area Insets for Mobile */
body {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ==========================================================================
   PREMIUM APPLE LOADERS & INTERACTIVE BUTTON SPINNERS
   ========================================================================== */

.btn-loader-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    color: #ffffff;
    font-weight: 600;
}

.apple-spin-ring {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #ffffff;
    border-right-color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
    animation: appleSpin 0.75s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    flex-shrink: 0;
}

.apple-spin-ring.lg {
    width: 28px;
    height: 28px;
    border-width: 3px;
    border-color: rgba(56, 189, 248, 0.2);
    border-top-color: var(--academic-blue);
    border-right-color: var(--accent-purple);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}

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

.btn-loader-text {
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
}

.loading-dots {
    display: inline-flex;
    width: 14px;
    margin-left: 2px;
}

.loading-dots span {
    animation: dotBlink 1.4s infinite both;
    font-weight: 700;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBlink {
    0%, 20% { opacity: 0; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-1px); }
    100% { opacity: 0; transform: translateY(0); }
}

/* Button Loading Shimmer */
.btn-primary:disabled {
    opacity: 0.94;
    cursor: wait;
    position: relative;
    overflow: hidden;
}

.btn-primary:disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 150%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    animation: btnShimmer 1.8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes btnShimmer {
    0% { transform: translateX(0); }
    100% { transform: translateX(200%); }
}

/* Workspace Scope Loader Card */
.rm-scope-loader {
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--glass-panel);
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 20px rgba(56, 189, 248, 0.08);
    animation: fade-in 0.35s ease-out;
}

.rm-scope-loader-inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Apple Radar Spinner */
.apple-radar-spinner {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.radar-core {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--academic-blue), var(--accent-purple));
    box-shadow: 0 0 12px var(--academic-blue);
    z-index: 2;
}

.radar-wave {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1.5px solid var(--academic-blue);
    opacity: 0;
    animation: radarPulse 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.radar-wave-1 { animation-delay: 0s; }
.radar-wave-2 { animation-delay: 0.65s; }
.radar-wave-3 { animation-delay: 1.3s; }

@keyframes radarPulse {
    0% { transform: scale(0.3); opacity: 0.9; }
    50% { opacity: 0.45; }
    100% { transform: scale(1.3); opacity: 0; }
}

.scope-text-wrap {
    flex: 1;
    min-width: 0;
}

.scope-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.scope-title {
    font-family: var(--font-outfit);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.scope-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--academic-blue);
    padding: 0.15rem 0.55rem;
    border-radius: 50px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--academic-blue);
    box-shadow: 0 0 6px var(--academic-blue);
    animation: pulseDot 1.4s ease-in-out infinite;
}

.scope-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 0.6rem 0;
    line-height: 1.45;
}

.scope-progress-bar-track {
    height: 4px;
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.scope-progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, var(--academic-blue), var(--accent-purple));
    border-radius: 999px;
    animation: progressIndeterminate 1.8s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

@keyframes progressIndeterminate {
    0% { left: -40%; width: 30%; }
    50% { left: 35%; width: 45%; }
    100% { left: 100%; width: 30%; }
}



