/* ========================================
   THE ABYSS OF KNOWLEDGE - MAIN STYLESHEET
   Modern, Professional, Industry Standard
   ======================================== */

/* ============ CSS VARIABLES ============ */
:root {
    /* Light Mode Colors (Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #2c2c2c;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
    --accent-primary: #475569;
    --accent-hover: #334155;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #383838;
    --text-primary: #e4e4e4;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --border-color: #374151;
    --border-hover: #4b5563;
    --accent-primary: #64748b;
    --accent-hover: #94a3b8;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
}

/* ============ BASE STYLES ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

/* ============ HEADER & NAVIGATION ============ */
header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    margin-bottom: 40px;
    box-shadow: 0 1px 3px var(--shadow);
    transition: all 0.3s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

nav {
    display: flex;
    gap: 10px;
}

nav a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

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

/* ============ DARK MODE TOGGLE ============ */
.theme-toggle {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.theme-icon {
    font-size: 1.1rem;
}

/* ============ CONTENT AREA ============ */
.content {
    background-color: var(--bg-primary);
    min-height: 60vh;
    transition: background-color 0.3s ease;
}

/* ============ FOOTER ============ */
footer {
    text-align: center;
    padding: 30px;
    color: var(--text-tertiary);
    margin-top: 40px;
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* ============ HOME PAGE ============ */
.hero {
    text-align: center;
    margin-bottom: 50px;
    padding: 40px 0;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -1px;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* Compact hero for blog-first layout */
.hero-compact {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
}

.hero-compact h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -1px;
}

.hero-compact p {
    font-size: 1rem;
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 40px 0;
}

.stat-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    margin-top: 5px;
}

/* ============ CTA BUTTONS ============ */
.cta-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 30px 0;
}

.cta-button {
    display: inline-block;
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    padding: 12px 32px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid var(--accent-primary);
}

.cta-button:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.cta-button.secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.cta-button.secondary:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-hover);
}

/* ============ LEVEL CARDS ============ */
.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 40px 0;
}

.level-card {
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    display: block;
}

.level-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.level-badge {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.level-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.level-description {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin: 10px 0;
}

.level-count {
    font-size: 1.3rem;
    color: var(--accent-primary);
    font-weight: 600;
}

/* Colored borders for levels (keep for visual distinction) */
.level-0 { border-left: 4px solid #FF6B6B; }
.level-1 { border-left: 4px solid #4ECDC4; }
.level-2 { border-left: 4px solid #45B7D1; }
.level-3 { border-left: 4px solid #FFA07A; }
.level-4 { border-left: 4px solid #98D8C8; }

.center-title {
    text-align: center;
    margin: 40px 0 20px;
    font-size: 1.8rem;
    color: var(--text-primary);
    font-weight: 700;
}

/* ============ POST CARDS ============ */
.posts-section {
    margin-top: 60px;
}

.posts-section-featured {
    max-width: 1200px;
    margin: 0 auto 60px auto;
    padding: 0 20px;
}

.section-title {
    font-size: 2rem;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-weight: 700;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

.post-card-link {
    text-decoration: none;
    display: block;
}

.post-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 30px;
    transition: all 0.2s ease;
    cursor: pointer;
    height: 100%;
}

.post-card-link:hover .post-card {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.post-card h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.post-card-link:hover .post-card h3 {
    color: var(--accent-primary);
}

.post-meta {
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.post-excerpt {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 15px;
}

.read-more {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s ease;
    display: inline-block;
}

.post-card-link:hover .read-more {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ============ POST DETAIL PAGE ============ */
article {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.post-header {
    margin-bottom: 50px;
    padding: 30px;
    border-bottom: 1px solid var(--border-color);
}

.post-title {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.post-body {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.125rem;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 40px;
}

.post-body p {
    margin-bottom: 1.25em;
}

.post-body h1, .post-body h2, .post-body h3 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    margin-top: 1.75em;
    margin-bottom: 0.5em;
    font-weight: 700;
    line-height: 1.3;
}

.post-body h1 { font-size: 1.875rem; }
.post-body h2 { font-size: 1.5rem; }
.post-body h3 { font-size: 1.25rem; }

.post-body h1:first-child,
.post-body h2:first-child,
.post-body h3:first-child {
    margin-top: 0;
}

/* Images and media in post body */
.post-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2em auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.post-body img[src$=".gif"] {
    border: 1px solid var(--border-color);
}

.post-body figure {
    margin: 2em 0;
    text-align: center;
}

.post-body figcaption {
    margin-top: 0.5em;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Blockquotes */
.post-body blockquote {
    margin: 1.5em 0;
    padding: 1.25em 1.5em;
    border-left: 4px solid var(--accent-primary);
    background-color: var(--bg-secondary);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-secondary);
    position: relative;
}

.post-body blockquote::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 15px;
    font-size: 4rem;
    color: var(--accent-primary);
    opacity: 0.2;
    font-family: Georgia, serif;
    line-height: 1;
}

.post-body blockquote p {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.7;
}

.post-body blockquote p:not(:last-child) {
    margin-bottom: 0.75em;
}

/* Nested blockquotes (for citations/attributions) */
.post-body blockquote blockquote {
    margin: 1em 0 0 0;
    padding: 0;
    border-left: none;
    background: none;
    font-style: normal;
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

.post-body blockquote blockquote::before {
    display: none;
}

.post-body blockquote blockquote p {
    font-size: 0.9rem;
}

/* Dark mode adjustments for blockquotes */
[data-theme="dark"] .post-body blockquote {
    background-color: var(--bg-tertiary);
}

/* ============ REFERENCES SECTION ============ */
.references-section {
    margin: 60px 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.references-section .section-title {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.references-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: reference-counter;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.reference-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 24px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    counter-increment: reference-counter;
    position: relative;
    transition: all 0.25s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.reference-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 16px var(--shadow);
    transform: translateY(-2px);
}

.reference-item::before {
    content: "[" counter(reference-counter) "]";
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 0.9rem;
    min-width: 32px;
    flex-shrink: 0;
    padding-top: 2px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

.reference-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    flex-shrink: 0;
    height: fit-content;
    transition: transform 0.2s ease;
}

.reference-item:hover .reference-type-badge {
    transform: scale(1.05);
}

/* Type badge icons and colors */
.reference-book .reference-type-badge {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}
.reference-book .reference-type-badge::before { content: "📖"; }

.reference-article .reference-type-badge {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    border: 1px solid #90caf9;
}
.reference-article .reference-type-badge::before { content: "📄"; }

.reference-paper .reference-type-badge {
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%);
    color: #c2185b;
    border: 1px solid #f48fb1;
}
.reference-paper .reference-type-badge::before { content: "📝"; }

.reference-website .reference-type-badge {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: #ef6c00;
    border: 1px solid #ffcc80;
}
.reference-website .reference-type-badge::before { content: "🌐"; }

.reference-video .reference-type-badge {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    color: #7b1fa2;
    border: 1px solid #ce93d8;
}
.reference-video .reference-type-badge::before { content: "🎬"; }

.reference-podcast .reference-type-badge {
    background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
    color: #00838f;
    border: 1px solid #80deea;
}
.reference-podcast .reference-type-badge::before { content: "🎙️"; }

.reference-news .reference-type-badge {
    background: linear-gradient(135deg, #fffde7 0%, #fff9c4 100%);
    color: #f57f17;
    border: 1px solid #fff176;
}
.reference-news .reference-type-badge::before { content: "📰"; }

.reference-thesis .reference-type-badge {
    background: linear-gradient(135deg, #efebe9 0%, #d7ccc8 100%);
    color: #5d4037;
    border: 1px solid #bcaaa4;
}
.reference-thesis .reference-type-badge::before { content: "🎓"; }

.reference-report .reference-type-badge {
    background: linear-gradient(135deg, #eceff1 0%, #cfd8dc 100%);
    color: #455a64;
    border: 1px solid #b0bec5;
}
.reference-report .reference-type-badge::before { content: "📊"; }

.reference-other .reference-type-badge {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    color: #616161;
    border: 1px solid #bdbdbd;
}
.reference-other .reference-type-badge::before { content: "📌"; }

.reference-content {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-primary);
    min-width: 0;
}

.reference-content em {
    font-style: italic;
    color: var(--text-primary);
}

.reference-content a {
    color: var(--accent-primary);
    text-decoration: none;
    word-break: break-word;
    transition: color 0.2s ease;
}

.reference-content a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.reference-note {
    margin-top: 12px;
    padding: 12px 16px;
    background-color: var(--bg-primary);
    border-left: 3px solid var(--accent-primary);
    border-radius: 0 8px 8px 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.6;
}

/* Dark mode adjustments for reference badges */
[data-theme="dark"] .reference-book .reference-type-badge {
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.2) 0%, rgba(46, 125, 50, 0.3) 100%);
    border-color: rgba(46, 125, 50, 0.4);
}
[data-theme="dark"] .reference-article .reference-type-badge {
    background: linear-gradient(135deg, rgba(21, 101, 192, 0.2) 0%, rgba(21, 101, 192, 0.3) 100%);
    border-color: rgba(21, 101, 192, 0.4);
}
[data-theme="dark"] .reference-paper .reference-type-badge {
    background: linear-gradient(135deg, rgba(194, 24, 91, 0.2) 0%, rgba(194, 24, 91, 0.3) 100%);
    border-color: rgba(194, 24, 91, 0.4);
}
[data-theme="dark"] .reference-website .reference-type-badge {
    background: linear-gradient(135deg, rgba(239, 108, 0, 0.2) 0%, rgba(239, 108, 0, 0.3) 100%);
    border-color: rgba(239, 108, 0, 0.4);
}
[data-theme="dark"] .reference-video .reference-type-badge {
    background: linear-gradient(135deg, rgba(123, 31, 162, 0.2) 0%, rgba(123, 31, 162, 0.3) 100%);
    border-color: rgba(123, 31, 162, 0.4);
}
[data-theme="dark"] .reference-podcast .reference-type-badge {
    background: linear-gradient(135deg, rgba(0, 131, 143, 0.2) 0%, rgba(0, 131, 143, 0.3) 100%);
    border-color: rgba(0, 131, 143, 0.4);
}
[data-theme="dark"] .reference-news .reference-type-badge {
    background: linear-gradient(135deg, rgba(245, 127, 23, 0.2) 0%, rgba(245, 127, 23, 0.3) 100%);
    border-color: rgba(245, 127, 23, 0.4);
}
[data-theme="dark"] .reference-thesis .reference-type-badge {
    background: linear-gradient(135deg, rgba(93, 64, 55, 0.3) 0%, rgba(93, 64, 55, 0.4) 100%);
    border-color: rgba(93, 64, 55, 0.5);
}

/* ============ LINKED TRUTHS ============ */
.linked-truths {
    margin: 50px 0;
    padding: 30px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.linked-truths-description {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 1rem;
}

.truth-link-card {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.truth-link-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.role-badge {
    display: inline-block;
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    padding: 5px 15px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 10px;
    text-transform: uppercase;
}

/* Keep colorful role badges for clarity */
.role-badge.reinforce { background: #4ECDC4; color: white; }
.role-badge.reinterpret { background: #45B7D1; color: white; }
.role-badge.critique { background: #FF6B6B; color: white; }
.role-badge.summarize { background: #98D8C8; color: white; }
.role-badge.apply { background: #FFA07A; color: white; }
.role-badge.historize { background: #F9A825; color: white; }

.truth-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 10px 0;
}

.truth-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.truth-title a:hover {
    color: var(--accent-primary);
}

.truth-meta {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin: 5px 0;
}

.confidence-delta {
    font-weight: 600;
    margin-top: 10px;
}

.confidence-delta.positive { color: #4ECDC4; }
.confidence-delta.negative { color: #FF6B6B; }

.truth-note {
    margin-top: 10px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.95rem;
}

.back-link {
    display: inline-block;
    margin-top: 30px;
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
}

.back-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ============ TRUTH NODES LIST PAGE ============ */
.page-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 0 20px;
}

.page-title {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.filters {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    margin: 0 20px 40px 20px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-btn {
    padding: 10px 25px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    border-radius: 6px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

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

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

.nodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 25px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
}

.truth-node-card-link {
    text-decoration: none;
    display: block;
}

.truth-node-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 30px;
    transition: all 0.2s ease;
    cursor: pointer;
    height: 100%;
}

.truth-node-card-link:hover .truth-node-card {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
    border-color: var(--accent-primary);
}

.node-header {
    margin-bottom: 30px;
}

.node-header .level-badge {
    display: inline-block;
    margin-bottom: 12px;
}

.node-header .node-title {
    font-size: 2.2rem;
    margin-bottom: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.confidence-badge {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 5px 15px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
}

.node-title {
    font-size: 1.4rem;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.truth-node-card-link:hover .node-title {
    color: var(--accent-primary);
}

.node-meta {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

.node-description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 15px;
}

.node-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 15px 0;
}

.tag {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.empty-state {
    grid-column: 1/-1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.empty-state h3 {
    color: var(--text-tertiary);
    font-size: 2rem;
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-top: 20px;
}

/* ============ SECONDARY SECTION (Homepage Knowledge System) ============ */
.secondary-section {
    max-width: 1200px;
    margin: 80px auto 40px auto;
    padding: 40px 20px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
}

.explore-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin: 30px 0 40px 0;
}

.explore-card {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.explore-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: 0 8px 20px var(--shadow-hover);
}

.explore-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.explore-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.explore-count {
    font-size: 1.1rem;
    color: var(--accent-primary);
    font-weight: 600;
    margin-bottom: 15px;
}

.explore-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============ ACCORDION (Five Levels) ============ */
.levels-accordion {
    margin-top: 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
}

.levels-accordion summary {
    cursor: pointer;
    padding: 20px;
    list-style: none;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.levels-accordion summary::-webkit-details-marker {
    display: none;
}

.levels-accordion summary:hover {
    background-color: var(--bg-tertiary);
}

.levels-accordion summary h4 {
    font-size: 1.3rem;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

.accordion-icon {
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.levels-accordion[open] .accordion-icon {
    transform: rotate(180deg);
}

.levels-accordion .levels-grid {
    padding: 20px;
    padding-top: 10px;
}

/* ============ TRUTH NODE DETAIL PAGE ============ */
.truth-node-detail {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
}

.truth-node-detail .node-header {
    padding: 30px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 40px;
}

.node-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.meta-item {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 8px;
}

.meta-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 500;
}

.meta-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.node-description {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 40px;
}

.section {
    margin: 50px 0;
}

.relation-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.relation-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.relation-type {
    display: inline-block;
    color: white;
    padding: 5px 15px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 10px;
}

/* Keep colorful relation types for clarity */
.relation-type.contradicts { background: #FF6B6B; }
.relation-type.supports { background: #4ECDC4; }
.relation-type.derives_from { background: #45B7D1; }
.relation-type.interprets { background: #FFA07A; }
.relation-type.depends_on { background: #F9A825; }
.relation-type.analogous_to { background: #98D8C8; }

.relation-weight {
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.relation-node {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 10px 0;
}

.relation-node a {
    color: var(--text-primary);
    text-decoration: none;
}

.relation-node a:hover {
    color: var(--accent-primary);
}

.relation-level {
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

.relation-rationale {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 10px;
    padding-left: 20px;
    border-left: 3px solid var(--border-color);
}

.post-list {
    display: grid;
    gap: 20px;
}

.post-item-link {
    text-decoration: none;
    display: block;
}

.post-item {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.post-item-link:hover .post-item {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow-hover);
    transform: translateY(-2px);
}

.post-item h4 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.post-item-link:hover .post-item h4 {
    color: var(--accent-primary);
}

.post-date {
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* ============ GRAPH PAGE ============ */
.graph-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
}

.intro-text {
    margin-bottom: 30px;
    padding: 25px 30px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.intro-text h2 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.8rem;
}

.intro-text p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
}

.graph-container {
    position: relative;
    width: 100%;
    height: 700px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 30px var(--shadow);
}

#graph-canvas {
    width: 100%;
    height: 100%;
}

.graph-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow-hover);
    z-index: 10;
}

.graph-controls h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 600;
}

.control-button {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 10px 20px;
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.control-button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.node-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow-hover);
    z-index: 10;
    display: none;
}

.node-info.active {
    display: block;
}

.node-info h4 {
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
}

.node-info p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============ POSTS SIDEBAR ============ */
.posts-sidebar {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background-color: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 20px var(--shadow-hover);
    transition: right 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.posts-sidebar.open {
    right: 0;
}

.sidebar-header {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    padding: 25px;
    flex-shrink: 0;
}

.sidebar-close {
    float: right;
    background-color: rgba(0,0,0,0.2);
    border: none;
    color: var(--bg-primary);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: background 0.2s ease;
}

.sidebar-close:hover {
    background-color: rgba(0,0,0,0.3);
}

.sidebar-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    clear: both;
}

.sidebar-subtitle {
    opacity: 0.9;
    font-size: 0.95rem;
}

.sidebar-controls {
    padding: 20px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sort-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 10px;
    font-size: 0.95rem;
}

.sort-select {
    padding: 8px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.sort-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: var(--bg-primary);
}

.sidebar-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
    font-size: 1.1rem;
}

.sidebar-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.sidebar-empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.post-item-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.post-item-meta {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.post-item-excerpt {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.post-count {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    display: inline-block;
    margin-top: 5px;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 999;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

/* ============ RESPONSIVE LAYOUT (Public Site) ============ */
/* Prevent horizontal scroll on small screens */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Make long words/URLs wrap in content */
.post-body, .reference-content, .node-description {
    overflow-wrap: anywhere;
    word-break: normal;
}

/* --- Tablets and down --- */
@media (max-width: 1024px) {
    .header-content {
        padding: 0 16px;
    }

    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }

    .nodes-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }

    .graph-container {
        height: 65vh;
        min-height: 520px;
    }

    .posts-sidebar {
        width: 420px;
        right: -420px;
    }
}

/* --- Phones and small tablets --- */
@media (max-width: 768px) {
    header {
        padding: 14px 0;
        margin-bottom: 24px;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .header-left {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
    }

    h1 {
        font-size: 1.3rem;
        line-height: 1.25;
        width: 100%;
    }

    nav {
        display: flex;
        width: 100%;
        flex-wrap: nowrap;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    nav::-webkit-scrollbar {
        display: none; /* Chrome/Safari/Opera */
    }

    nav a {
        padding: 10px 16px;
        font-size: 0.9rem;
        white-space: nowrap;
        flex: 0 0 auto;
        min-height: 44px; /* iOS touch target */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background-color: var(--bg-tertiary);
        border-radius: 8px;
    }

    .header-right {
        width: 100%;
        justify-content: flex-start;
    }

    .theme-toggle {
        width: fit-content;
        padding: 10px 14px;
        min-height: 44px;
    }

    /* Home typography */
    .hero-compact {
        padding: 18px 16px;
        margin-bottom: 24px;
    }

    .hero-compact h2 {
        font-size: 1.6rem;
    }

    .hero-compact p {
        font-size: 0.98rem;
    }

    /* Cards and grids */
    .posts-section-featured {
        padding: 0 16px;
        margin-bottom: 40px;
    }

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

    .posts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .post-card {
        padding: 20px;
    }

    .post-card h3 {
        font-size: 1.15rem;
        line-height: 1.35;
    }

    .post-meta {
        font-size: 0.9rem;
        gap: 12px;
    }

    .post-excerpt {
        font-size: 0.95rem;
    }

    .secondary-section {
        margin: 40px 16px 24px 16px;
        padding: 24px 16px;
        border-radius: 10px;
    }

    .center-title {
        font-size: 1.5rem;
        margin: 24px 0 16px;
    }

    .explore-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .explore-card {
        padding: 20px;
    }

    .explore-icon {
        font-size: 2.5rem;
    }

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

    .levels-accordion summary {
        padding: 16px;
    }

    .levels-accordion summary h4 {
        font-size: 1.1rem;
    }

    .levels-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 16px 0;
        padding: 16px;
    }

    .level-card {
        padding: 18px;
    }

    .level-badge {
        font-size: 1.5rem;
    }

    .level-name {
        font-size: 1rem;
    }

    /* Post detail */
    article {
        padding: 0 16px;
    }

    .post-header {
        padding: 16px 0;
        margin-bottom: 24px;
    }

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

    .post-body {
        font-size: 1.02rem;
        line-height: 1.75;
    }

    .post-body h1 { font-size: 1.5rem; }
    .post-body h2 { font-size: 1.3rem; }
    .post-body h3 { font-size: 1.15rem; }

    .post-body img {
        margin: 1.25em auto;
        border-radius: 10px;
    }

    .post-body blockquote {
        padding: 1em 1.1em;
        margin: 1.25em 0;
    }

    .post-body blockquote::before {
        font-size: 3rem;
        top: -5px;
        left: 10px;
    }

    /* References - stack vertically on mobile */
    .references-section {
        margin: 40px 0;
    }

    .references-section .section-title {
        font-size: 1.3rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .reference-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }

    .reference-item::before {
        font-size: 0.85rem;
        min-width: auto;
    }

    .reference-type-badge {
        padding: 5px 10px;
        font-size: 0.65rem;
    }

    .reference-content {
        font-size: 0.9rem;
        line-height: 1.65;
    }

    .reference-note {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    /* Linked truths */
    .linked-truths {
        margin: 40px 0;
        padding: 20px;
    }

    .linked-truths .section-title {
        font-size: 1.2rem;
    }

    .linked-truths-description {
        font-size: 0.95rem;
    }

    .truth-link-card {
        padding: 16px;
    }

    .role-badge {
        font-size: 0.75rem;
        padding: 4px 12px;
    }

    .truth-title {
        font-size: 1.1rem;
    }

    .truth-meta {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .back-link {
        margin-top: 24px;
        padding: 12px 0;
        display: inline-block;
    }

    /* Truth nodes list page */
    .page-header {
        padding: 0 16px;
        margin-bottom: 24px;
    }

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

    .page-subtitle {
        font-size: 1rem;
    }

    .filters {
        padding: 16px;
        margin: 0 16px 24px 16px;
        border-radius: 10px;
    }

    .filter-buttons {
        gap: 8px;
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding-bottom: 4px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .filter-buttons::-webkit-scrollbar {
        display: none;
    }

    .filter-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
        white-space: nowrap;
        flex: 0 0 auto;
        min-height: 44px;
    }

    .nodes-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0 16px 30px 16px;
    }

    .truth-node-card {
        padding: 18px;
    }

    .truth-node-card .node-header {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        margin-bottom: 12px;
    }

    .truth-node-card .level-badge,
    .truth-node-card .confidence-badge {
        font-size: 0.8rem;
        padding: 4px 10px;
    }

    .truth-node-card .node-title {
        font-size: 1.2rem;
        line-height: 1.35;
    }

    .node-meta {
        font-size: 0.85rem;
        gap: 10px;
    }

    .node-description {
        font-size: 0.95rem;
    }

    .node-footer {
        padding-top: 12px;
    }

    .tags {
        gap: 6px;
    }

    .tag {
        font-size: 0.75rem;
        padding: 3px 10px;
    }

    /* Truth node detail page */
    .truth-node-detail {
        padding: 0 16px 30px 16px;
    }

    .truth-node-detail .node-header {
        padding: 20px;
        margin-bottom: 30px;
    }

    .truth-node-detail .node-header .level-badge {
        font-size: 0.85rem;
        padding: 5px 12px;
        margin-bottom: 10px;
    }

    .truth-node-detail .node-header .node-title {
        font-size: 1.6rem;
        line-height: 1.25;
        margin-bottom: 16px;
    }

    .node-meta-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .meta-item {
        padding: 10px 12px;
    }

    .meta-label {
        font-size: 0.65rem;
    }

    .meta-value {
        font-size: 1rem;
    }

    .section {
        margin: 35px 0;
    }

    .relation-card {
        padding: 16px;
    }

    .relation-type {
        font-size: 0.8rem;
        padding: 4px 12px;
    }

    .relation-weight {
        font-size: 0.85rem;
    }

    .relation-node {
        font-size: 1.1rem;
    }

    .relation-level {
        font-size: 0.85rem;
    }

    .relation-rationale {
        font-size: 0.9rem;
        padding-left: 16px;
    }

    .post-list {
        gap: 14px;
    }

    .post-item {
        padding: 18px;
    }

    .post-item h4 {
        font-size: 1.15rem;
    }

    /* Graph page */
    .graph-page {
        padding: 0 16px 30px 16px;
    }

    .intro-text {
        padding: 18px;
        margin-bottom: 20px;
    }

    .intro-text h2 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    .intro-text p {
        font-size: 1rem;
    }

    .graph-container {
        height: 60vh;
        min-height: 350px;
        border-radius: 12px;
    }

    /* Controls: move below graph on mobile */
    .graph-controls {
        position: static;
        margin: 16px 0 0 0;
        width: 100%;
        padding: 16px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .graph-controls h3 {
        width: 100%;
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .control-button {
        flex: 1 1 auto;
        min-width: 100px;
        padding: 12px 14px;
        font-size: 0.9rem;
        margin: 0;
        min-height: 44px;
    }

    /* Node info panel - bottom sheet style */
    .node-info {
        bottom: 10px;
        left: 10px;
        right: 10px;
        padding: 16px;
        border-radius: 12px;
    }

    .node-info h4 {
        font-size: 1.15rem;
        margin-bottom: 8px;
    }

    .node-info p {
        font-size: 0.9rem;
        white-space: pre-line;
    }

    /* Sidebar becomes full-width overlay */
    .posts-sidebar {
        width: 100%;
        right: -100%;
        border-left: none;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    }

    .posts-sidebar.open {
        right: 0;
    }

    .sidebar-header {
        padding: 20px;
    }

    .sidebar-title {
        font-size: 1.3rem;
    }

    .sidebar-subtitle {
        font-size: 0.9rem;
    }

    .sidebar-controls {
        padding: 14px 20px;
    }

    .sort-select {
        padding: 10px 14px;
        min-height: 44px;
    }

    .sidebar-content {
        padding: 16px;
    }

    .post-item-title {
        font-size: 1.05rem;
    }

    .post-item-meta {
        font-size: 0.8rem;
    }

    /* Footer */
    footer {
        padding: 24px 16px;
        font-size: 0.85rem;
    }
}

/* --- Small phones (iPhone SE, etc.) --- */
@media (max-width: 420px) {
    h1 {
        font-size: 1.2rem;
    }

    nav a {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-height: 40px;
    }

    .hero-compact h2 {
        font-size: 1.4rem;
    }

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

    .section-title {
        font-size: 1.3rem;
    }

    .post-card h3 {
        font-size: 1.1rem;
    }

    .reference-item {
        padding: 14px;
        gap: 10px;
    }

    .reference-item::before {
        min-width: auto;
        font-size: 0.8rem;
    }

    .reference-type-badge {
        padding: 4px 8px;
        font-size: 0.6rem;
    }

    .reference-content {
        font-size: 0.85rem;
    }

    .node-meta-grid {
        grid-template-columns: 1fr;
    }

    .truth-node-detail .node-header .node-title {
        font-size: 1.4rem;
    }

    .explore-title {
        font-size: 1.15rem;
    }

    .explore-count {
        font-size: 1rem;
    }

    .graph-container {
        height: 55vh;
        min-height: 300px;
    }

    .control-button {
        min-width: 80px;
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .filter-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .level-card {
        padding: 14px;
    }

    .level-badge {
        font-size: 1.3rem;
    }
}

/* --- Landscape phones --- */
@media (max-width: 768px) and (orientation: landscape) {
    .graph-container {
        height: 80vh;
        min-height: 280px;
    }

    .posts-sidebar {
        width: 50%;
        right: -50%;
    }

    .posts-sidebar.open {
        right: 0;
    }
}

