/* ═══════════════════════════════════════════════════════════════════════
   AI Research Intelligence System — Dark Editorial Dashboard
   Bloomberg Terminal meets research journal aesthetic
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Reset & Variables ─────────────────────────────────────────────── */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #1a1a24;
    --bg-card: #14141e;
    --border: #2a2a3a;
    --border-subtle: #1e1e2e;

    --text-primary: #e8e8ef;
    --text-secondary: #9898a8;
    --text-muted: #5a5a6e;

    --accent: #f5a623;
    --accent-dim: #c48a1c;
    --accent-glow: rgba(245, 166, 35, 0.15);

    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'DM Mono', 'Fira Code', monospace;

    --sidebar-width: 280px;
    --content-max: 900px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.65;
    min-height: 100vh;
}

/* ── Layout ────────────────────────────────────────────────────────── */

.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    padding: 2rem 1.5rem;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 2rem;
    line-height: 1;
}

.logo-text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-glow);
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

.sidebar-section-title {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.sidebar-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-item {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.stat-number {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--accent);
    line-height: 1;
}

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

.sidebar-dates {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.date-link {
    display: block;
    padding: 0.4rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.date-link:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

/* ── Main Content ──────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 3rem 4rem;
    max-width: calc(var(--content-max) + var(--sidebar-width) + 8rem);
}

.report-container {
    max-width: var(--content-max);
}

.report-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.report-date {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
}

.report-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    font-weight: 400;
}

/* ── Brief Stats Bar ───────────────────────────────────────────────── */

.brief-stats-bar {
    display: flex;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    margin-bottom: 2.5rem;
}

.brief-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.brief-stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--accent);
    line-height: 1;
}

.brief-stat-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

/* ── Report Body (generated HTML) ──────────────────────────────────── */

/*
 * The report HTML is LLM-generated. Server-side sanitization strips
 * inline styles and <style> blocks before saving. These rules enforce
 * the dark theme on every possible element the LLM might produce.
 */

.report-body {
    counter-reset: report-section;
    color: var(--text-secondary);
    background: transparent;
}

/* Hide any <style> block that slips past sanitization */
.report-body style { display: none; }

/* ── h1 (LLM sometimes adds a report title) ── */
.report-body h1 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    background: none;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border: none;
    border-bottom: 2px solid var(--accent);
    letter-spacing: -0.02em;
}

/* ── Article wrapper ── */
.report-body article {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    background: none;
}

/* ── Section cards ── */
.report-body section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 1.75rem 2rem;
    position: relative;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.report-body section:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(245, 166, 35, 0.06);
}

/* Section number badge */
.report-body > article > section::before,
.report-body > section::before {
    counter-increment: report-section;
    content: counter(report-section, decimal-leading-zero);
    position: absolute;
    top: -0.65rem;
    left: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--bg-card);
    padding: 0.1rem 0.6rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* First section — executive brief — special treatment */
.report-body > article > section:first-child,
.report-body > section:first-child {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(245, 166, 35, 0.06) 0%, var(--bg-card) 60%);
}

.report-body > article > section:first-child::before,
.report-body > section:first-child::before {
    content: "BRIEF";
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
    font-weight: 600;
}

/* ── Headings ── */
.report-body h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    background: none;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    letter-spacing: -0.01em;
}

.report-body h3 {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    background: none;
    margin-bottom: 0.5rem;
    margin-top: 1.25rem;
}

.report-body h4 {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    background: none;
    margin-bottom: 0.4rem;
    margin-top: 1rem;
}

/* ── Paragraphs ── */
.report-body p {
    color: var(--text-secondary);
    background: none;
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.report-body > article > section:first-child p,
.report-body > section:first-child p {
    font-size: 1.05rem;
    color: var(--text-primary);
    line-height: 1.85;
}

/* ── Lists ── */
.report-body ul,
.report-body ol {
    padding-left: 1.25rem;
    color: var(--text-secondary);
    background: none;
    margin-bottom: 0.75rem;
}

.report-body ul {
    list-style: none;
    padding-left: 0;
}

.report-body ul li {
    position: relative;
    padding-left: 1.25rem;
    margin-bottom: 0.6rem;
    line-height: 1.7;
    color: var(--text-secondary);
    background: none;
}

.report-body ul li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1em;
}

.report-body ol {
    padding-left: 1.5rem;
}

.report-body ol li {
    margin-bottom: 0.6rem;
    line-height: 1.7;
    padding-left: 0.25rem;
    color: var(--text-secondary);
    background: none;
}

.report-body ol li::marker {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85em;
}

/* ── Links ── */
.report-body a {
    color: var(--accent);
    background: none;
    text-decoration: none;
    border-bottom: 1px dashed var(--accent-dim);
    transition: border-color 0.15s ease, color 0.15s ease;
}

.report-body a:hover {
    border-bottom-style: solid;
    border-bottom-color: var(--accent);
}

/* ── Inline text ── */
.report-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.report-body strong.accent,
.report-body .accent {
    color: var(--accent);
    font-weight: 600;
}

.report-body em {
    color: var(--text-secondary);
    font-style: italic;
}

.report-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-tertiary);
    color: var(--accent);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

/* ── Tables ── */
.report-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.875rem;
    background: none;
}

.report-body thead th {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.report-body tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    background: none;
    line-height: 1.5;
}

.report-body tbody tr:hover td {
    background: rgba(245, 166, 35, 0.03);
}

.report-body tbody tr:last-child td {
    border-bottom: none;
}

/* ── Blockquotes ── */
.report-body blockquote {
    border: none;
    border-left: 3px solid var(--accent);
    background: var(--bg-tertiary);
    margin: 1rem 0;
    padding: 1rem 1.25rem;
    border-radius: 0 6px 6px 0;
    color: var(--text-primary);
    font-style: italic;
    line-height: 1.75;
}

.report-body blockquote p {
    color: var(--text-primary);
    margin-bottom: 0;
}

/* ── Code / Pre ── */
.report-body pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0.75rem 0;
}

/* ── Horizontal rules ── */
.report-body hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

/* ── Catch-all: any div/span/figure/etc the LLM might add ── */
.report-body div,
.report-body span,
.report-body figure,
.report-body figcaption,
.report-body header,
.report-body footer,
.report-body main,
.report-body aside,
.report-body nav,
.report-body details,
.report-body summary {
    background: none;
    color: inherit;
    border: none;
}

.accent-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent-dim);
}

.accent-link:hover {
    border-bottom-style: solid;
}

/* ── Empty State ───────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-graphic {
    margin-top: 2rem;
}

.big-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ── Archive Grid ──────────────────────────────────────────────────── */

.archive-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.archive-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.archive-card:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.archive-date {
    font-family: var(--font-mono);
    font-size: 0.95rem;
}

.archive-arrow {
    color: var(--accent);
    font-size: 1.25rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.archive-card:hover .archive-arrow {
    opacity: 1;
}

/* ── Graph Stats Grid ──────────────────────────────────────────────── */

.graph-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 3rem;
}

.graph-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    transition: border-color 0.15s ease;
}

.graph-stat-card:hover {
    border-color: var(--accent);
}

.graph-stat-number {
    display: block;
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 500;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.graph-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

/* ── Graph Info Section ────────────────────────────────────────────── */

.graph-info {
    padding: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.graph-info h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.graph-info h3 {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.graph-info p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.75;
}

.graph-info ul {
    padding-left: 1.25rem;
    color: var(--text-secondary);
}

.graph-info li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
}

/* ── Footer ────────────────────────────────────────────────────────── */

.footer {
    margin-left: var(--sidebar-width);
    padding: 1.5rem 4rem;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

/* ── Animated border for trending items ────────────────────────────── */

@keyframes pulse-border {
    0%, 100% { border-color: var(--accent); box-shadow: 0 0 20px rgba(245, 166, 35, 0.08); }
    50% { border-color: var(--accent-dim); box-shadow: 0 0 10px rgba(245, 166, 35, 0.03); }
}

.report-body section.trending {
    animation: pulse-border 2s ease-in-out infinite;
}

/* ── Subscribe / Form Styles ────────────────────────────────────────── */

.subscribe-intro {
    margin-bottom: 2rem;
    color: var(--text-secondary);
    line-height: 1.75;
    font-size: 1.05rem;
}

.subscribe-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.subscribe-card h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.subscribe-info {
    margin-top: 2rem;
    padding: 1.5rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.subscribe-info h3 {
    color: var(--accent);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.subscribe-info ul {
    padding-left: 1.25rem;
    color: var(--text-secondary);
}

.subscribe-info li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
}

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

.form-group label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-input {
    width: 100%;
    max-width: 340px;
    padding: 0.7rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    transition: border-color 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 160px;
}

.btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-dim);
}

.form-result {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-tertiary);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    color: var(--accent);
}

/* ── Graph Visualization ───────────────────────────────────────────── */

.graph-canvas-container {
    position: relative;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

#graphSvg {
    display: block;
    width: 100%;
    background: var(--bg-card);
}

.graph-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-muted);
}

.graph-loading p {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.graph-controls {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.25rem;
    z-index: 5;
}

.graph-ctrl-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

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

.graph-back-btn {
    width: auto;
    padding: 0 0.75rem;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    gap: 0.3rem;
    background: var(--accent);
    color: #0a0a0f;
    border-color: var(--accent);
    font-weight: 600;
}

.graph-back-btn:hover {
    background: #e09400;
    border-color: #e09400;
}

/* AI Summary in detail panel */
.node-detail-summary {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
}

.node-summary-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.graph-legend {
    position: absolute;
    bottom: 0.75rem;
    left: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    z-index: 5;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(10, 10, 15, 0.8);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Graph Search ──────────────────────────────────────────────────── */

.graph-search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.graph-search-bar {
    display: flex;
    gap: 0.5rem;
}

.graph-search-input {
    flex: 1;
    max-width: none;
}

.graph-search-select {
    width: 160px;
    flex-shrink: 0;
}

.graph-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.search-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--border-subtle);
}

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

.search-result-item:hover {
    background: var(--accent-glow);
}

.search-result-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.search-result-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.search-result-text strong {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ── Node Detail Panel ─────────────────────────────────────────────── */

.node-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
}

.node-detail-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

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

.node-detail-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    margin-bottom: 0.4rem;
    padding-right: 2rem;
    word-break: break-word;
}

.node-detail-type {
    display: inline-block;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.node-detail-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.node-detail-neighbors {
    max-height: 240px;
    overflow-y: auto;
}

.neighbor-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: background 0.1s;
}

.neighbor-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ── Schema Columns ────────────────────────────────────────────────── */

.schema-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

/* ── Responsive — Mobile First ─────────────────────────────────────── */

/* Tablet (≤ 1024px) — narrower sidebar */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }

    .main-content {
        padding: 2rem 2rem;
    }

    .footer {
        padding: 1rem 2rem;
    }
}

/* Mobile (≤ 768px) — sidebar becomes top-collapsible + bottom nav */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        max-height: 0;
        overflow: hidden;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0 1rem;
        z-index: 100;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }

    .sidebar.open {
        max-height: 100vh;
        overflow-y: auto;
        padding: 1.25rem 1rem 1rem;
    }

    .sidebar-header {
        padding-bottom: 1rem;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        flex: 1 0 auto;
        text-align: center;
        border-radius: 20px;
    }

    .nav-link.active {
        border-left: none;
        border-bottom: 2px solid var(--accent);
    }

    .sidebar-stats {
        flex-direction: row;
        gap: 1.5rem;
        padding-top: 0.75rem;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    .sidebar-dates {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .date-link {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        background: var(--bg-tertiary);
        border-radius: 4px;
    }

    .main-content {
        margin-left: 0;
        padding: 1.25rem 1rem;
        /* Room for mobile header toggle */
        padding-top: 4rem;
    }

    .footer {
        margin-left: 0;
        padding: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .report-header {
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }

    .report-date {
        align-self: flex-start;
        font-size: 0.75rem;
    }

    .report-subtitle {
        font-size: 0.8rem;
    }

    .brief-stats-bar {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .brief-stat-value {
        font-size: 1.25rem;
    }

    .brief-stat-label {
        font-size: 0.6rem;
    }

    /* Report body */
    .report-body section {
        padding: 1.25rem 1rem;
        border-radius: 8px;
    }

    .report-body > article > section::before,
    .report-body > section::before {
        font-size: 0.55rem;
        top: -0.55rem;
        left: 1rem;
    }

    .report-body h1 {
        font-size: 1.25rem;
    }

    .report-body h2 {
        font-size: 1.15rem;
        margin-bottom: 1rem;
        padding-bottom: 0.6rem;
    }

    .report-body h3 {
        font-size: 0.9rem;
    }

    .report-body p,
    .report-body li {
        font-size: 0.9rem;
        line-height: 1.65;
    }

    .report-body > article > section:first-child p,
    .report-body > section:first-child p {
        font-size: 0.95rem;
    }

    .report-body table {
        font-size: 0.8rem;
        display: block;
        overflow-x: auto;
    }

    .report-body thead th,
    .report-body tbody td {
        padding: 0.4rem 0.5rem;
    }

    .report-body blockquote {
        padding: 0.75rem 1rem;
    }

    /* Graph stats grid */
    .graph-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .graph-stat-card {
        padding: 1rem;
    }

    .graph-stat-number {
        font-size: 1.75rem;
    }

    .graph-stat-label {
        font-size: 0.65rem;
    }

    /* Graph info */
    .graph-info {
        padding: 1.25rem;
    }

    /* Subscribe form */
    .subscribe-card {
        padding: 1.25rem;
    }

    .form-input {
        max-width: 100%;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group {
        min-width: 100%;
    }

    .btn {
        width: 100%;
        text-align: center;
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }

    /* Empty state */
    .empty-state {
        padding: 2rem 1rem;
    }

    .big-emoji {
        font-size: 3rem;
    }

    /* Archive cards — full width, bigger touch targets */
    .archive-card {
        padding: 1rem;
    }

    .archive-date {
        font-size: 0.85rem;
    }

    .archive-arrow {
        opacity: 1; /* Always visible on touch */
    }

    /* Graph visualization mobile */
    .graph-search-bar {
        flex-direction: column;
    }

    .graph-search-select {
        width: 100%;
    }

    .graph-search-input {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .graph-legend {
        font-size: 0.6rem;
        gap: 0.4rem;
        flex-wrap: wrap;
    }

    .node-detail-panel {
        padding: 1rem;
    }

    .node-detail-title {
        font-size: 1rem;
    }

    .node-detail-neighbors {
        max-height: 200px;
    }

    .schema-columns {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Small phones (≤ 400px) */
@media (max-width: 400px) {
    .main-content {
        padding: 1rem 0.75rem;
        padding-top: 3.5rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .graph-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .graph-stat-card {
        padding: 0.75rem;
    }

    .graph-stat-number {
        font-size: 1.4rem;
    }

    .sidebar-nav {
        flex-direction: column;
    }

    .nav-link {
        text-align: left;
    }
}

/* ── Mobile Header Toggle (hamburger) ──────────────────────────────── */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    z-index: 101;
}

.mobile-header .logo-text {
    font-size: 0.7rem;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

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

/* Desktop: hide mobile header */
@media (min-width: 769px) {
    .mobile-header {
        display: none !important;
    }
}

/* ── Safe area insets for notch phones ──────────────────────────────── */

@supports (padding: env(safe-area-inset-top)) {
    .mobile-header {
        padding-top: env(safe-area-inset-top);
        height: calc(3.5rem + env(safe-area-inset-top));
    }

    @media (max-width: 768px) {
        .main-content {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        }
    }
}

/* ── Touch optimizations ───────────────────────────────────────────── */

@media (hover: none) and (pointer: coarse) {
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .archive-card {
        min-height: 48px;
    }

    .archive-arrow {
        opacity: 1;
    }

    .btn {
        min-height: 48px;
    }

    .date-link {
        min-height: 36px;
        display: flex;
        align-items: center;
    }
}


/* ═══════════════════════════════════════════════════════════════════════
   Research Lab — Hybrid Diffusion Model Interface
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Tab Navigation ── */
.lab-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    padding-bottom: 0;
    overflow-x: auto;
}

.lab-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.lab-tab:hover { color: var(--text-primary); }
.lab-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Panels ── */
.lab-panel { display: none; }
.lab-panel.active { display: block; }

.lab-description {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.lab-description p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ── Buttons ── */
.lab-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.lab-btn:hover { border-color: var(--accent); color: var(--accent); }
.lab-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.lab-btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
    font-weight: 500;
}
.lab-btn-primary:hover {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
    color: var(--bg-primary);
}

/* ── Chat ── */
.chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    height: 500px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}
.chat-message.user { align-self: flex-end; }
.chat-message.assistant { align-self: flex-start; }

.chat-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.chat-message.user .chat-bubble {
    background: var(--accent);
    color: var(--bg-primary);
    border-bottom-right-radius: 4px;
}
.chat-message.assistant .chat-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 4px;
}

.chat-typing { font-style: italic; color: var(--text-muted); }

.chat-sources {
    margin-top: 0.4rem;
    padding-left: 0.5rem;
    font-size: 0.75rem;
}
.chat-source { margin-bottom: 0.2rem; }

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}
.chat-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
}
.chat-input:focus { border-color: var(--accent); outline: none; }

/* ── Generate ── */
.gen-controls { margin-bottom: 1rem; }

.gen-textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.75rem;
    box-sizing: border-box;
}
.gen-textarea:focus { border-color: var(--accent); outline: none; }

.gen-params {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.gen-param {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.gen-param-input {
    width: 80px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}
.gen-param-input:focus { border-color: var(--accent); outline: none; }

.gen-output {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.25rem;
    margin-top: 1rem;
}
.gen-output-title {
    margin: 0 0 0.75rem 0;
    color: var(--accent);
    font-size: 0.9rem;
    font-family: var(--font-mono);
}
.gen-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
}
.gen-stats {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

/* ── Semantic Search ── */
.search-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.search-query-input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
}
.search-query-input:focus { border-color: var(--accent); outline: none; }

.search-results-lab {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.search-result-card {
    display: flex;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem;
    transition: border-color 0.2s;
}
.search-result-card:hover { border-color: var(--accent); }

.search-result-score {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent);
    min-width: 50px;
    font-weight: 500;
}
.search-result-content h4 {
    margin: 0 0 0.3rem 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}
.search-result-content p {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.5;
}
.search-result-date {
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

/* ── Autocomplete ── */
.complete-textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.75rem;
    box-sizing: border-box;
}
.complete-textarea:focus { border-color: var(--accent); outline: none; }

.complete-output {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.25rem;
    margin-top: 0.75rem;
}
.complete-text {
    font-size: 0.95rem;
    line-height: 1.7;
}
.complete-original { color: var(--text-primary); }
.complete-suggestion { color: var(--accent); font-style: italic; }

/* ── About section ── */
.lab-about {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}
.lab-about h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.search-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════════════════════
   Podcast — Inline Player (on report pages)
   ═══════════════════════════════════════════════════════════════════════ */

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.podcast-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: var(--accent-glow);
    border: none;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
}

.podcast-pill:hover {
    background: rgba(245, 166, 35, 0.25);
}

.podcast-pill-icon {
    color: var(--accent);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.podcast-pill-label {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--accent);
    letter-spacing: 0.03em;
    font-weight: 400;
}

.podcast-inline {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--accent-dim);
    border-radius: 8px;
    margin: 1.5rem 0 2rem;
    color-scheme: dark;
}

.podcast-inline-left {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-shrink: 0;
}

.podcast-inline-icon {
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.85;
}

.podcast-inline-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.podcast-inline-title {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.podcast-inline-meta {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.podcast-inline-audio {
    flex: 1;
    min-width: 0;
    height: 36px;
    border-radius: 6px;
    outline: none;
    color-scheme: dark;
    filter: invert(0);
}

.podcast-inline-audio::-webkit-media-controls-panel {
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.podcast-inline-audio::-webkit-media-controls-current-time-display,
.podcast-inline-audio::-webkit-media-controls-time-remaining-display {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

/* ═══════════════════════════════════════════════════════════════════════
   Podcast Browse Page
   ═══════════════════════════════════════════════════════════════════════ */

.podcast-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.podcast-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--accent-dim);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.podcast-card:hover {
    border-color: var(--border);
    border-left-color: var(--accent);
    background: var(--bg-tertiary);
}

.podcast-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.podcast-card-date {
    font-family: var(--font-mono);
    font-size: 0.73rem;
    color: var(--accent);
    letter-spacing: 0.03em;
}

.podcast-card-duration {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
}

.podcast-card-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.35rem 0;
    line-height: 1.35;
}

.podcast-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 0.85rem 0;
}

.podcast-card .podcast-card-audio {
    width: 100%;
    height: 36px;
    border-radius: 6px;
    outline: none;
}

.podcast-card .podcast-card-audio::-webkit-media-controls-panel {
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.podcast-card .podcast-card-audio::-webkit-media-controls-current-time-display,
.podcast-card .podcast-card-audio::-webkit-media-controls-time-remaining-display {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .lab-tabs { gap: 0; }
    .lab-tab { padding: 0.6rem 0.75rem; font-size: 0.8rem; }
    .chat-container { height: 400px; }
    .chat-message { max-width: 90%; }
    .gen-params { gap: 0.5rem; }
    .gen-param-input { width: 65px; }
    .search-result-card { flex-direction: column; gap: 0.5rem; }
    .search-result-score { min-width: auto; }
    .podcast-inline { flex-direction: column; align-items: stretch; gap: 0.75rem; }
    .podcast-inline-title { max-width: 100%; }
    .podcast-inline-left { gap: 0.5rem; }
    .podcast-card { padding: 1rem; }
    .podcast-card-title { font-size: 1.05rem; }
    .podcast-card-header { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
    .header-right { gap: 0.5rem; }
    .podcast-pill-label { display: none; }
}

