/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light mode colors (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #fbfbfd;
    --bg-elevated: #f9f9f9;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #515154;
    --text-link: #0066cc;
    --border-color: #d2d2d7;
    --border-light: #f0f0f2;
    --border: #e0e0e0;
    --primary: #ff4444;
    --primary-dark: #dd3333;
    --sidebar-width: 140px;
    --header-height: 48px;
    --shadow-sm: 0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 12px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --bg-elevated: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-tertiary: #999999;
    --text-link: #4da6ff;
    --border-color: #333333;
    --border-light: #2a2a2a;
    --border: #303030;
    --primary: #ff5555;
    --primary-dark: #ff6666;
    --shadow-sm: 0 0 0 0.5px rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 0 0 0.5px rgba(255, 255, 255, 0.05), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 0 0 0.5px rgba(255, 255, 255, 0.05), 0 12px 24px rgba(0, 0, 0, 0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Lato', 'Helvetica', 'Arial', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text-primary);
    background: var(--bg-primary); /* Dynamic background based on theme */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--border-color);
    z-index: 1000;
}

.header-container {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 22px;
    max-width: 1440px;
    margin: 0 auto;
}

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

.menu-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-primary);
    display: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 20px;
    font-weight: 400;
    opacity: 0.8;
}

.logo-text {
    font-family: Georgia, serif;
    font-size: 19px;
    font-weight: 500;
    letter-spacing: 0;
}

/* Search */
.search-container {
    flex: 1;
    max-width: 440px;
    margin: 0 auto;
}

.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: auto;
    width: 16px;
    height: 16px;
    cursor: pointer;
    transition: color 0.2s;
}

.search-icon:hover {
    color: var(--text-primary);
}

.search-input {
    width: 100%;
    padding: 4px 12px 4px 36px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s;
    height: 30px;
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

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

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
}

.header-icons {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.icon-button:hover {
    color: var(--text-primary);
}

.icon-button svg {
    width: 20px;
    height: 20px;
}

/* Font size control buttons */
.font-size-button {
    width: 24px;
    height: 24px;
    transition: all 0.2s;
    margin: 0 2px;
}

.font-size-button:hover {
    color: var(--primary);
}

.font-size-icon {
    font-weight: 500;
    user-select: none;
    display: inline-block;
    line-height: 1;
}

.font-size-icon.small {
    font-size: 12px;
}

.font-size-icon.medium {
    font-size: 15px;
}

.font-size-icon.large {
    font-size: 18px;
}

.font-size-button.active {
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-radius: 4px;
}

/* Theme toggle button */
.theme-toggle {
    margin-left: 8px;
}

.theme-toggle .theme-icon {
    transition: transform 0.3s ease;
}

.theme-toggle:hover .theme-icon {
    transform: rotate(20deg);
}

/* Mobile Menu Styles */
.mobile-only {
    display: none;
}

.desktop-only {
    display: flex;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    position: relative;
    top: -2px; /* Adjust vertical alignment */
}

.mobile-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 12px;
    margin-top: 8px;
    min-width: 200px;
    z-index: 1000;
}

.mobile-dropdown.show {
    display: block;
}

.dropdown-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.dropdown-section:last-child {
    border-bottom: none;
}

.dropdown-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.font-size-options {
    display: flex;
    gap: 8px;
}

.dropdown-button {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.font-option {
    flex: 1;
    font-weight: 600;
}

.font-option[data-size="small"] {
    font-size: 12px;
}

.font-option[data-size="medium"] {
    font-size: 15px;
}

.font-option[data-size="large"] {
    font-size: 18px;
}

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

.dropdown-button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.theme-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Main Container */
.main-container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    max-width: 1680px;
    margin-left: auto;
    margin-right: auto;
    background: var(--bg-primary);
}

/* Sidebar */
.sidebar {
    width: 160px;
    background: transparent;
    padding: 32px 8px 32px 8px;
    margin-left: 30px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

/* Content */
.content {
    flex: 1;
    padding: 10px 20px 32px 20px;
    max-width: none;
    background: var(--bg-primary);
    min-width: 0;
    width: 100%;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.nav-section {
    margin-bottom: 40px;
}

.nav-section:first-child {
    margin-bottom: 12px;
}

/* Ensure Contents section is always visible */
#contents-section {
    display: block !important;
    background: transparent;
    padding: 10px;
    border-radius: 8px;
    margin-top: 20px;
}

#contents-section .nav-title {
    color: var(--text-primary);
    margin-bottom: 10px;
}

#contents-list {
    display: block !important;
}

.nav-title {
    font-size: 14px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.nav-list {
    list-style: none;
}

.nav-link {
    display: block;
    padding: 3px 0;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.5;
    transition: color 0.2s;
    font-weight: 400;
    letter-spacing: 0;
}

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

.nav-link.active {
    color: var(--text-primary);
    font-weight: 500;
}

.nav-subsection {
    margin-left: 20px;
}

.nav-subsection .nav-link {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}


/* Learning Mode Toggle */
.learning-mode-toggle {
    display: inline-flex;
    gap: 0;
    margin-top: 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    overflow: hidden;
    vertical-align: middle;
}

.mode-btn {
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

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

.mode-btn.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 600;
}

/* Express mode expand button */
.express-expand-btn {
    transition: all 0.2s ease;
}

.express-expand-btn:hover {
    background: var(--bg-tertiary) !important;
    border-color: var(--text-tertiary) !important;
    transform: translateY(-1px);
}

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

.section-summary {
    margin-bottom: 2em;
    padding-bottom: 1.5em;
    border-bottom: 1px solid var(--border-color);
}

.section-summary:last-child {
    border-bottom: none;
}

.express-full-content {
    margin-top: 1em;
}

.express-full-content h2,
.express-full-content h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
}

/* Express mode content styling */
.express-content {
    font-size: 1.05em;
    line-height: 1.7;
    color: var(--text-primary);
}

.express-content .section-summary {
    margin-bottom: 1.5em;
    padding: 1em;
    background: var(--bg-secondary);
    border-radius: 8px;
}

/* Article */
.article {
    background: var(--bg-elevated);
    border-radius: 18px;
    padding: 32px 120px 64px 50px; /* From working backup */
    box-shadow: var(--shadow-md);
    max-width: 1600px;
    border: 1px solid var(--border-light);
    margin: 0 auto;
    position: relative;
}


/* Responsive adjustments for desktop sizes with floating infobox (above 1200px) */
@media (min-width: 1501px) and (max-width: 1600px) {
    .article {
        padding-right: 200px;
    }
}

@media (min-width: 1441px) and (max-width: 1500px) {
    .article {
        padding-right: 250px;
    }
}

@media (min-width: 1351px) and (max-width: 1440px) {
    .article {
        padding-right: 300px;
    }
}

@media (min-width: 1301px) and (max-width: 1350px) {
    .article {
        padding-right: 320px;
    }
}

@media (min-width: 1251px) and (max-width: 1300px) {
    .article {
        padding-right: 340px;
    }
}

@media (min-width: 1201px) and (max-width: 1250px) {
    .article {
        padding-right: 350px;
    }
}

.article-header {
    margin-bottom: 20px;
}

.article-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 32px;
    font-weight: normal;
    line-height: 1.1;
    letter-spacing: 0;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.article-meta {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.4;
    margin-top: 8px;
}

.article-lead {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 24px;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-radius: 0;
    border: 1px solid var(--border-light);
}

.article-lead p {
    margin: 0;
}

.article-section {
    margin-bottom: 48px;
    position: relative;
}

/* First section with infobox needs full width for proper text flow */
.article-section:first-child {
    width: 100%;
}

/* Other sections have limited width for optimal reading - but NOT references */
.article-section:not(:first-child):not(.references-section) {
    max-width: 850px;
}

.section-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 20px;
    font-weight: normal;
    line-height: 1.125;
    letter-spacing: 0;
    margin-bottom: 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 4px;
}

.subsection-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.article-section p {
    font-size: 15px;
    line-height: 1.8;
    letter-spacing: 0;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Lato', 'Helvetica', 'Arial', sans-serif;
}

/* First section paragraphs need to use available width */
.article-section:first-child p {
    max-width: none;
    width: auto;
}

.intro-paragraph {
    margin-bottom: 24px !important;
}

.article-section h3 {
    font-size: 21px;
    font-weight: normal;
    line-height: 1.2;
    letter-spacing: 0;
    margin-top: 32px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.article-section a {
    color: var(--text-link);
    text-decoration: none;
    transition: opacity 0.2s;
}

.article-section a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Infobox - from working backup */
.infobox-wrapper {
    float: right;
    width: 280px;
    margin: 0 -280px 20px 30px; /* From working backup - full width negative margin */
    position: relative;
}

/* Gradual infobox adjustments for intermediate sizes */
@media (max-width: 1400px) {
    .infobox-wrapper {
        margin-right: -240px;
    }
}

@media (max-width: 1300px) {
    .infobox-wrapper {
        margin-right: -220px;
        width: 270px;
    }
}


.infobox {
    width: 100%;
    background: var(--bg-tertiary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    display: block;
}

.infobox-header {
    display: none;
}

.infobox-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Lato', 'Helvetica', 'Arial', sans-serif;
    font-size: 18px;
    font-weight: bold;
    margin: 0;
    letter-spacing: 0;
}

.infobox-image {
    padding: 8px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
}

.infobox-summary {
    padding: 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-light);
    font-size: 1rem;
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.4;
}

.infobox-summary p {
    margin: 0;
    font-size: 1rem !important;
}

.image-placeholder {
    width: 100%;
    height: 240px;
    background: var(--bg-secondary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.infobox-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    object-fit: cover;
}

.image-placeholder svg {
    opacity: 0.3;
}

.image-caption {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 12px 16px;
    text-align: center;
    background: var(--bg-primary);
}

.image-source {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
}

.image-source a {
    color: var(--text-link);
    text-decoration: none;
}

.image-source a:hover {
    text-decoration: underline;
}

.license-info {
    margin-bottom: 4px;
    font-weight: 500;
}

.artist-info {
    margin-bottom: 4px;
    font-style: italic;
}

.image-placeholder {
    padding: 40px 20px;
    background: var(--bg-secondary);
    text-align: center;
    color: var(--text-tertiary);
}

.placeholder-icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
}

.placeholder-text {
    font-size: 13px;
    font-style: italic;
}

.infobox-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.infobox-table th,
.infobox-table td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.infobox-table tr:first-child th,
.infobox-table tr:first-child td {
    padding-top: 16px;
}

.infobox-table th {
    font-weight: 600;
    color: var(--text-secondary);
    width: 35%;
    font-size: 12px;
}

.infobox-table td {
    font-weight: 400;
    color: var(--text-primary);
}

.infobox-table tr:last-child th,
.infobox-table tr:last-child td {
    border-bottom: none;
}

/* Infobox list formatting */
.infobox-table td ul {
    margin: 0;
    padding-left: 20px;
    list-style: disc;
}

.infobox-table td ul li {
    margin: 4px 0;
    line-height: 1.4;
}

/* Multiline value formatting */
.infobox-table td br {
    line-height: 1.6;
}

/* Wikipedia source attribution */
.infobox-source {
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

/* Right Sidebar - Bias Analysis */
    width: 300px;
    padding: 32px 22px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    flex-shrink: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.right-sidebar::-webkit-scrollbar {
    width: 6px;
}

.right-sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.score-circle {
    position: relative;
    display: inline-block;
    margin-bottom: 16px;
}

.score-circle svg {
    width: 140px;
    height: 140px;
}

.score-circle circle {
    transition: stroke-dashoffset 0.5s ease;
}

.score-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Lato', 'Helvetica', 'Arial', sans-serif;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    font-weight: bold;
    color: #34c759;
    letter-spacing: 0;
}

.score-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Conspiracy Analysis Section */
    background: var(--bg-primary);
    border-radius: 18px;
    padding: 32px;
    margin-top: 24px;
    border: 1px solid rgba(255, 68, 68, 0.2);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.05);
}


/* Authoritative Deep Analysis Styles */
    margin-top: 48px;
    padding: 48px;
    background: linear-gradient(135deg, #1a1a1c 0%, #2d1b1b 100%);
    border-radius: 24px;
    color: #ffffff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.authoritative-analysis .section-title {
    color: #ffffff;
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 32px;
    letter-spacing: -0.02em;
}

/* Logic Tree Styles - Authoritative Version */
    margin-top: 32px;
    font-size: 14px;
}

/* Authoritative Tree Nodes */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.leaf-number {
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
    font-size: 20px;
    font-weight: 700;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.leaf-content {
    padding: 16px 20px;
    flex: 1;
}

.leaf-subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-weight: 400;
}

.node-icon {
    color: #ff4444;
    margin-right: 8px;
    transition: transform 0.2s;
}

.node-title {
    flex: 1;
}

.node-badge {
    background: #ff4444;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.leaf-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background: rgba(255, 68, 68, 0.1);
    color: #ff4444;
    text-align: center;
    line-height: 20px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    margin-right: 8px;
}

.leaf-title {
    color: var(--text-secondary);
}

/* Tree Content Display */
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-light);
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.content-number {
    display: inline-block;
    width: 24px;
    height: 24px;
    background: #ff4444;
    color: white;
    text-align: center;
    line-height: 24px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    margin-right: 8px;
}

.content-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.content-question {
    font-size: 13px;
    color: #ff4444;
    font-weight: 500;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(255, 68, 68, 0.05);
    border-radius: 8px;
    border-left: 3px solid #ff4444;
}

.content-response {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-height: 200px;
    overflow-y: auto;
    padding-right: 8px;
}

.content-response::-webkit-scrollbar {
    width: 4px;
}

.content-response::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Analysis Footer */
    margin-top: 48px;
    text-align: center;
    padding-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.full-analysis-link {
    display: inline-block;
    padding: 16px 32px;
    background: #ff4444;
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(255, 68, 68, 0.3);
}

.full-analysis-link:hover {
    background: #ff3333;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 68, 68, 0.4);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Responsive */
@media (max-width: 1200px) {
    .right-sidebar {
        position: relative;
        width: 100%;
        padding: 20px;
        height: auto;
        margin-top: 30px;
    }

    .main-container {
        flex-direction: column;
    }

    /* Don't override article padding - let our responsive rules handle it */
    .article {
        max-width: 100%;
        margin-bottom: 0;
    }

    /* Keep default behavior for screens between 980-1200px */
}

/* Mobile/Tablet intro paragraph styling */
.mobile-intro-paragraph {
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 24px !important;
    padding: 0 16px;
    color: var(--text-primary);
}

/* Tablet styles - includes 640px to 1200px (when layout switches to column) */
@media (min-width: 640px) and (max-width: 1200px) {
    /* Hide sidebar on tablet, show hamburger */
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        width: 250px;
        background: var(--bg-primary);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-lg);
        z-index: 999;
        margin-left: 0;
        padding: 24px 16px;
    }

    .sidebar.open {
        transform: translateX(0);
    }


    /* Content full width on tablet */
    .content {
        padding: 16px 24px;
        width: 100%;
        margin-left: 0;
    }

    /* Article adjustments for tablet */
    .article {
        padding: 32px 40px;
        max-width: 100%;
    }

    /* Keep infobox small and centered on tablet */
    .infobox-wrapper {
        float: none !important;
        width: 100% !important;
        max-width: 400px !important;
        margin: 0 auto 20px auto !important;
        position: static !important;
    }

    .infobox {
        width: 100%;
    }

}

/* Mobile styles - only apply below 640px */
@media (max-width: 639px) {
    /* Stack sidebar and content vertically */
    .main-container {
        display: block;
        padding: 0;
        width: 100%;
    }

    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }

    /* Single column references on mobile */
    .section-references,
    .references-subsections-container {
        column-count: 1;
        column-rule: none;
    }

    .menu-button {
        display: block;
    }

    /* Adjust header for tablet */
    .header-container {
        padding: 0 16px;
    }

    .search-container {
        max-width: 300px;
    }

    /* Hide sidebar on article pages - Wikipedia style */
    .sidebar {
        display: none;
    }

    /* Menu button not needed when sidebar is visible inline */
    .menu-button {
        display: none;
    }

    /* Content full width - Wikipedia style */
    .content {
        display: block;
        padding: 0;
        width: 100%;
        max-width: 100%;
    }

    /* Article - Wikipedia mobile style (no padding/borders) */
    .article {
        padding: 0;
        max-width: 100%;
        border-radius: 0;
        margin: 0;
        width: 100%;
        box-shadow: none;
        border: none;
        background: var(--bg-primary);
    }

    /* Article header - clean Wikipedia style */
    .article-header {
        padding: 16px;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-light);
        margin: 0;
    }

    .article-title {
        font-size: 24px;
        line-height: 1.3;
        font-family: Georgia, serif;
    }

    /* Article lead - Wikipedia style gray box */
    .article-lead {
        padding: 12px 16px;
        background: var(--bg-secondary);
        border: none;
        border-bottom: 1px solid var(--border-light);
        margin: 0;
        border-radius: 0;
    }

    /* Article sections - Wikipedia mobile style */
    .article-section {
        margin: 0;
        padding: 0;
        border-bottom: 1px solid var(--border-light);
    }

    /* Section titles - Wikipedia expandable style */
    .section-title {
        font-size: 18px;
        padding: 14px 16px;
        margin: 0;
        background: var(--bg-secondary);
        border: none;
        border-bottom: 1px solid var(--border-light);
        font-weight: normal;
        font-family: Georgia, serif;
    }

    /* Section content */
    .article-section p {
        padding: 0 16px;
        margin-top: 16px;
        margin-bottom: 16px;
        font-size: 16px;
        line-height: 1.65;
    }

    .article-section ul,
    .article-section ol {
        padding-left: 36px;
        padding-right: 16px;
        margin: 16px 0;
    }

    /* Infobox at top on mobile - Wikipedia style */
    .infobox-wrapper {
        float: none !important;
        width: 100% !important;
        margin: 0 0 16px 0 !important;
        order: -1; /* Show before other content */
    }

    .infobox {
        width: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
        border-left: none;
        border-right: none;
        box-shadow: none;
        border-bottom: 1px solid var(--border-light);
    }

    /* Infobox sections on mobile */
    .infobox-image {
        padding: 0;
        background: var(--bg-primary);
    }

    .infobox-table th,
    .infobox-table td {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Font controls responsive */
    .header-icons {
        gap: 8px;
    }

    .font-size-button {
        width: 20px;
        height: 20px;
        margin: 0 1px;
    }
}

@media (max-width: 640px) {
    /* Force single column layout */
    html, body {
        overflow-x: hidden !important;
        width: 100%;
    }

    /* Show mobile menu, hide desktop controls */
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    .mobile-menu-toggle {
        display: block !important;
    }



    /* Header mobile optimizations */
    .header-container {
        padding: 0 12px;
        gap: 8px;
    }

    .logo-text {
        font-size: 17px;
    }

    /* Search bar mobile */
    .search-container {
        flex: 1;
        max-width: none;
        margin: 0 8px;
    }

    .search-input {
        font-size: 14px;
        padding: 6px 8px 6px 32px;
    }

    /* Keep header controls visible but we'll move them to hamburger menu */

    /* Main container mobile */
    .main-container {
        min-height: calc(100vh - var(--header-height));
        flex-direction: column;
        width: 100%;
        overflow-x: hidden;
    }

    /* Sidebar - hidden off-screen like tablet, can slide in with burger button */
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        width: 250px;
        background: var(--bg-primary);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-lg);
        z-index: 999;
        margin-left: 0;
        padding: 24px 16px;
        display: block !important;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Content full width */
    .content {
        padding: 0;
        width: 100%;
    }

    /* Article - Wikipedia mobile style */
    .article {
        padding: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
        width: 100%;
        margin: 0;
        background: var(--bg-primary);
    }

    .article-header {
        margin-bottom: 16px;
    }

    .article-title {
        font-size: 24px;
        line-height: 1.3;
        margin-bottom: 8px;
    }

    .article-meta {
        font-size: 14px;
    }

    .article-lead {
        font-size: 13px;
        padding: 12px 16px;
        margin-bottom: 20px;
    }

    /* Section optimizations */
    .article-section {
        margin-bottom: 24px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Force all sections to be full width */
    .article-section:not(:first-child):not(.references-section) {
        max-width: 100%;
    }

    .section-title {
        font-size: 20px;
        margin-bottom: 12px;
        padding-bottom: 6px;
    }

    .subsection-title {
        font-size: 17px;
        margin-top: 20px;
        margin-bottom: 10px;
    }

    .article-section p {
        font-size: 15px;
        line-height: 1.7;
        margin-bottom: 16px;
    }

    /* Remove indent on mobile for better space usage */
    .article-section h3.subsection-title + p,
    .article-section h3.subsection-title + ul,
    .article-section h3.subsection-title + ol,
    .article-section h3.subsection-title + table,
    .article-section h3.subsection-title ~ p,
    .article-section h3.subsection-title ~ ul,
    .article-section h3.subsection-title ~ ol {
        margin-left: 0;
    }

    /* Lists mobile */
    .article-section ul,
    .article-section ol {
        padding-left: 20px;
        margin-bottom: 16px;
    }

    .article-section li {
        margin-bottom: 8px;
        font-size: 15px;
    }

    /* Tables responsive - allow scroll only for tables */
    .article-section table {
        font-size: 13px;
        display: block;
        overflow-x: auto;
        max-width: 100%;
        width: 100%;
    }

    /* Wrap table in scrollable container */
    table {
        min-width: 300px;
    }

    /* Infobox mobile full width */
    .infobox-wrapper {
        float: none !important;
        width: 100% !important;
        margin: 0 0 20px 0 !important;
        max-width: 100% !important;
    }

    .infobox {
        border-radius: 8px;
        margin-bottom: 20px;
        width: 100%;
        max-width: 100%;
    }

    .infobox-table th,
    .infobox-table td {
        padding: 10px 12px;
        font-size: 12px;
    }

    /* Deep analysis sections mobile */
    .authoritative-analysis {
        padding: 24px 16px;
        margin-top: 32px;
        border-radius: 12px;
    }

    .authoritative-analysis .section-title {
        font-size: 24px;
        margin-bottom: 20px;
    }

    /* References mobile */
    .references-section {
        font-size: 13px;
    }

    .reference-item {
        font-size: 13px;
        margin-bottom: 12px;
    }

    /* Homepage mobile */
    .homepage-hero {
        padding: 40px 20px;
    }

    .hero-title {
        font-size: 40px;
        letter-spacing: -1px;
    }

    .hero-subtitle {
        font-size: 18px;
    }

    .hero-description {
        font-size: 15px;
        padding: 0 16px;
    }

    .hero-features {
        flex-direction: column;
        gap: 12px;
    }

    /* Process grid mobile */
    .process-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    /* Article showcase mobile */
    .articles-showcase {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .article-showcase-card.featured {
        grid-column: span 1;
    }
}

/* Code Editor Analysis Styles */
    background: #1e1e1e;
    border-radius: 0;
    margin: 16px 0;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 12px;
    overflow: hidden;
    border: 1px solid #2d2d30;
}

/* When inside infobox */
.westworld-analysis::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #00d4ff, transparent);
    animation: scan 3s linear infinite;
}

@keyframes scan {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

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

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

@keyframes fillProgress {
    0% { width: 0%; }
    100% { width: 100%; }
}

@keyframes glitch {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-1px, 1px); }
    40% { transform: translate(1px, -1px); }
    60% { transform: translate(-1px, 0); }
    80% { transform: translate(1px, 0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Code Editor Specific Styles */
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 35px;
}

.editor-tabs {
    display: flex;
    height: 100%;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    background: #1e1e1e;
    color: #cccccc;
    border-right: 1px solid #252526;
    cursor: pointer;
}

.tab.active {
    background: #1e1e1e;
    color: #ffffff;
}

.tab-icon {
    font-size: 14px;
}

.tab-close {
    opacity: 0;
    transition: opacity 0.2s;
}

.tab:hover .tab-close {
    opacity: 0.7;
}

.editor-actions {
    display: flex;
    gap: 8px;
    padding: 0 8px;
}

.editor-btn {
    background: none;
    border: none;
    color: #cccccc;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}

.editor-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.editor-body {
    display: flex;
    height: 300px;
}

.file-tree {
    width: 200px;
    background: #252526;
    border-right: 1px solid #3e3e42;
    overflow-y: auto;
}

.folder-icon, .file-icon {
    font-size: 14px;
}

.editor-content {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    overflow-y: auto;
}


/* WikiBased Style Narrative Analysis */
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 0;
    margin: 0;
    overflow: hidden;
}

/* Scrollbar styling for phase questions */
    width: 6px;
}

.question-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.question-item:hover {
    background: var(--bg-secondary);
}

.q-num {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.q-title {
    font-size: 11px;
    color: var(--text-secondary);
}

.question-detail {
    padding: 20px 24px;
    animation: fadeIn 0.3s ease;
    display: none;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin: 0 16px;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-link);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    margin-right: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    text-decoration: none;
}

.back-btn:hover {
    background: rgba(0, 122, 204, 0.1);
}

.detail-number {
    font-weight: 700;
    color: var(--text-secondary);
    background: #e5e5e5;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.detail-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    flex: 1;
}

.detail-question {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 20px;
    font-style: italic;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    line-height: 1.5;
}

.detail-answer {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    max-height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.detail-answer::-webkit-scrollbar {
    width: 8px;
}

.detail-answer::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.detail-answer::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.nav-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
}

.full-link {
    color: var(--text-link);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
}

.full-link:hover {
    text-decoration: underline;
}

/* Conspiracy Drill Summary Styles */
    background: var(--bg-primary);
    border: none;
    border-radius: 12px;
    padding: 40px;
    margin: 48px auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    animation: slideIn 0.3s ease;
    position: relative;
    max-width: 760px;
}

/* Question navigation buttons */
    display: flex;
    gap: 24px;
    margin: 0 -40px 32px -40px;
    padding: 24px 40px;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}

/* Conclusion section styles */
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.conclusion-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}


/* Conclusion summary special styling */
    border-left-width: 6px;
    border-left-color: #333;
    background: var(--bg-secondary);
}

/* Phase grouping styles */
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Responsive adjustment for conspiracy drill summary */
/* Homepage Styles */
.homepage-hero {
    text-align: center;
    padding: 80px 0;
    background: var(--bg-secondary);
    margin: -40px -40px 60px -40px;
    border-bottom: 1px solid var(--border-color);
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 72px;
    font-weight: 300;
    margin: 0 0 16px 0;
    letter-spacing: -2px;
    color: var(--text-primary);
}

.hero-subtitle {
    font-size: 24px;
    font-weight: 400;
    color: var(--text-secondary);
    margin: 0 0 24px 0;
}

.hero-description {
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 40px 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-features {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 40px;
}

.feature {
    display: flex;
    align-items: center;
    gap: 8px;
}

.feature-icon {
    font-size: 24px;
}

.feature-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.homepage-section {
    margin-bottom: 80px;
}

.homepage-section h2 {
    font-size: 32px;
    font-weight: 400;
    margin-bottom: 40px;
    text-align: center;
    color: var(--text-primary);
}

/* Articles Showcase */
.articles-showcase {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.article-showcase-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 24px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.article-showcase-card:hover {
    border-color: #999;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.article-showcase-card.featured {
    grid-column: span 2;
    background: var(--bg-secondary);
    border-width: 2px;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: var(--text-primary);
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.word-count {
    color: var(--text-secondary);
}

.featured-label {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #0066cc;
    color: white;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* More Articles */
.more-articles {
    text-align: center;
    padding: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.more-articles h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.articles-list {
    font-size: 15px;
    line-height: 2;
}

.article-link {
    color: #0066cc;
    text-decoration: none;
    padding: 0 8px;
    white-space: nowrap;
}

.article-link:hover {
    text-decoration: underline;
}

/* Empty State */





/* Process Grid */
.process-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 32px;
}

.process-step {
    text-align: center;
}

.step-number {
    width: 48px;
    height: 48px;
    background: #111;
    color: white;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
}

.process-step h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.process-step p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 48px;
    }
    
    .hero-subtitle {
        font-size: 20px;
    }
    
    .hero-features {
        flex-direction: column;
        gap: 16px;
    }
    
    .article-showcase-card.featured {
        grid-column: span 1;
    }
    
    .articles-list {
        line-height: 2.5;
    }
    
    /* Single column for references on mobile */
    .references-subsections-container {
        column-count: 1;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    /* Two columns for tablets */
    .references-subsections-container {
        column-count: 2;
    }
}

/* Citation Styles - Updated for light gray */
.citation {
    color: #999999 !important;  /* Light gray instead of blue */
    text-decoration: none;
    font-size: 0.5em !important;  /* Half size */
    font-weight: normal;
    cursor: pointer;
    position: relative;
    padding: 0 2px;
}

.citation:hover {
    text-decoration: none !important;  /* No underline */
    color: #666666 !important;  /* Darker gray on hover */
    background-color: rgba(0, 0, 0, 0.05);
}

/* Dynamic reference tooltip - WikiBased style */
.reference-tooltip {
    position: absolute;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 40px rgba(255, 68, 68, 0.1);
    padding: 12px 16px;
    max-width: 450px;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    z-index: 10000;
    pointer-events: none;
    animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reference-tooltip::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(20, 20, 20, 0.95);
}

/* Superscript reference links - targeting actual citation class */
sup {
    font-size: 0.5em !important;  /* Half the normal font size */
    vertical-align: super;
    line-height: 0;
}

sup a.citation {
    color: #999999 !important;  /* Light gray */
    text-decoration: none !important;
    padding: 0 1px;
    font-weight: normal !important;
}

sup a.citation:hover {
    color: #666666 !important;  /* Slightly darker gray on hover */
    text-decoration: none !important;  /* No underline */
    background-color: rgba(0, 0, 0, 0.05) !important;  /* Very subtle background */
}

/* Also target any reference class if exists */
sup.reference {
    font-size: 0.5em !important;
    vertical-align: super;
    line-height: 0;
}

sup.reference a {
    color: #999999 !important;
    text-decoration: none !important;
    padding: 0 1px;
    font-weight: normal !important;
}

sup.reference a:hover {
    color: #666666 !important;
    text-decoration: none !important;
    background-color: rgba(0, 0, 0, 0.05) !important;
}


/* Indent content under subsections */
.article-section h3.subsection-title + p,
.article-section h3.subsection-title + ul,
.article-section h3.subsection-title + ol,
.article-section h3.subsection-title + table,
.article-section h3.subsection-title ~ p,
.article-section h3.subsection-title ~ ul,
.article-section h3.subsection-title ~ ol {
    margin-left: 20px;
}

/* Ensure proper paragraph spacing */
.article-section p {
    margin-bottom: 1.2em;
    line-height: 1.6;
    max-width: 100%;
}

/* Prevent extremely long unbroken lines */
.article-section {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* References section styling */
#references-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

#references-section h2 {
    font-size: 24px;
    margin-bottom: 20px;
}

#references-section span[id^="ref"] {
    display: block;
    margin-bottom: 12px;
    padding-left: 30px;
    text-indent: -30px;
    line-height: 1.6;
    font-size: 14px;
}

#references-section span[id^="ref"]:target {
    background: #ffffcc;
    padding: 8px;
    padding-left: 38px;
    border-radius: 4px;
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    from { background: #ffff99; }
    to { background: #ffffcc; }
}

/* References section styles */
.references-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e1e8ed;
}

.references-section h2 {
    font-size: 1.5em;
    margin-bottom: 1em;
}

.reference-list {
    padding-left: 2em;
    list-style: decimal;
}

.reference-item {
    margin-bottom: 1.2em;  /* Increased spacing between rows */
    font-size: 1em;  /* Same as content */
    line-height: 1.8;  /* Increased line height for better readability */
    color: var(--text-primary);
}

.reference-item .ref-number {
    font-weight: normal;  /* Same as content */
    color: var(--text-secondary);
    margin-right: 0.5em;
}

.reference-item:target {
    background-color: #fff3cd;
    padding: 5px;
    margin-left: -5px;
    border-radius: 3px;
    animation: reference-highlight 2s ease-out;
}

@keyframes reference-highlight {
    0% { background-color: #fff3cd; }
    100% { background-color: transparent; }
}


/* Section-organized references */
.references-section .subsection-title {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 2em;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid var(--border-light);
}

.references-section .subsection-title:first-of-type {
    margin-top: 1em;
}

.section-references {
    margin-bottom: 2em;
    font-size: 0.95em;
    line-height: 1.8;
    /* Single column for reference content */
}

/* Layout for the References section itself - subsections in two columns */
#references .article-section,
.article-section:has(.subsection-header) {
    /* Target the References main section */
}

/* Container for reference subsections */
.article-section#references,
.article-section.references-section {
    max-width: 100% !important;
    width: 100% !important;
}

/* Remove two-column from entire section */
.article-section:has(.ref-subsection-content) {
    /* Don't apply columns to the whole section */
}

/* Create a container for just the subsections to be in columns */
.references-subsections-container {
    margin-top: 1.5em;
    width: 100%;
}

/* Each subsection should not break across columns */
.subsection-header,
.ref-subsection-content {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 2.5em;  /* Increased spacing between subsections */
}

/* Each reference subsection */
.reference-subsection {
    margin-bottom: 3em;  /* Increased spacing between sections */
}

/* Reduce spacing specifically for reference subsections */
.references-subsections-container .subsection-header {
    margin-bottom: 0.5em;
}

.references-subsections-container .subsection-header h3 {
    font-weight: 400 !important;
}

.references-subsections-container .ref-subsection-content {
    margin-bottom: 0.8em;
}


/* Reference numbers same size as content */
.references-subsections-container .ref-number,
.ref-subsection-content .ref-number,
.reference-subsection .ref-number,
.references-subsections-container span.ref-number,
#references .ref-number {
    font-size: 1em !important;  /* Same as content */
}

.section-references .reference-item {
    display: flex;
    align-items: baseline;
    margin-bottom: 1.5em;  /* Increased spacing between reference items */
    /* Prevent items from breaking across columns */
    break-inside: avoid;
    page-break-inside: avoid;
}

.section-references .ref-number {
    flex-shrink: 0;
    font-weight: 500;
    color: var(--text-secondary);
    margin-right: 0.8em;
    min-width: 3em;
}

.section-references .ref-content {
    flex: 1;
    color: var(--text-primary);
    word-break: break-word;
}

/* FORCE all reference text to match content size */
.references-section {
    font-size: 12.7px; /* 10% larger than 11.55px */
    width: 100% !important;  /* Use full width */
    max-width: none !important;  /* Remove any max-width constraints */
}

/* Make References title match other section titles */
.references-section h2 {
    font-family: Georgia, 'Times New Roman', serif !important;
    font-size: 20px !important;  /* Same as .section-title */
    font-weight: normal !important;
    line-height: 1.125 !important;
    letter-spacing: 0 !important;
    margin-bottom: 1em !important;
}

/* Reference subsection titles - same as main section titles */
.references-section h3,
.references-subsections-container h3,
.references-subsections-container h3.subsection-title,
.article-section .references-subsections-container h3.subsection-title {
    font-family: Georgia, 'Times New Roman', serif !important;
    font-size: 20px !important;  /* Same as section titles */
    font-weight: normal !important;
    line-height: 1.125 !important;
    margin-bottom: 0.8em !important;
}

/* All reference content at normal reading size */
.reference-item {
    font-size: 12.7px !important;  /* 10% larger than 11.55px */
    line-height: 1.6 !important;  /* Adjusted for smaller text */
}

.ref-number {
    font-size: 12.7px !important;  /* 10% larger than 11.55px */
    font-weight: 500 !important;
}

/* ULTIMATE OVERRIDE - Force all reference subsection titles to be full size */
.references-subsections-container .subsection-header h3,
.references-subsections-container h3,
.ref-subsection-content h3,
.reference-subsection h3,
#references h3,
#references .subsection-title,
.article-section#references h3,
.article-section .references-subsections-container h3,
.article-section .references-subsections-container .subsection-header h3 {
    font-size: 20px !important;
    font-weight: 600 !important;
    line-height: 1.125 !important;
    margin-bottom: 0.8em !important;
    font-style: normal !important;
}

/* Force all text in reference subsections to be normal size */
.references-subsections-container,
.references-subsections-container *,
.ref-subsection-content,
.ref-subsection-content * {
    font-size: 12.7px !important;  /* 10% larger than 11.55px */
}

/* But keep the h3 titles at 20px */
.references-subsections-container h3 {
    font-size: 20px !important;
}

/* Reference Popup Styles */
.reference-popup {
    position: absolute;
    z-index: 10000;
    max-width: 400px;
    min-width: 250px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
    animation: fadeIn 0.2s ease-out;
    transition: opacity 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reference-popup::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--bg-secondary);
}

.reference-popup.below::after {
    bottom: auto;
    top: -6px;
    border-top: none;
    border-bottom: 6px solid var(--bg-secondary);
}

.reference-popup-content {
    padding: 12px 14px;
}

.reference-popup-number {
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reference-popup-text {
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.6;
}

.reference-popup-actions {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    margin-top: 8px;
}

.reference-popup-link {
    color: var(--link-color) !important;
    text-decoration: none !important;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.reference-popup-link:hover {
    color: var(--link-hover) !important;
    text-decoration: underline !important;
}

.reference-popup-url {
    color: var(--link-color) !important;
    text-decoration: none !important;
    font-size: 11px;
    margin-left: 8px;
    padding: 2px 6px;
    background: var(--bg-primary);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.reference-popup-url:hover {
    background: var(--link-color);
    color: white !important;
}

/* Enhanced reference link styling */
sup.reference a {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

sup.reference a:hover {
    color: var(--link-color) !important;
    background-color: var(--bg-secondary) !important;
    border-radius: 3px;
    padding: 1px 3px;
}


/* Dark mode specific adjustments */
[data-theme="dark"] .reference-popup {
    background: #1a1a1a;
    border-color: #333;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .reference-popup::after {
    border-top-color: #1a1a1a;
}

[data-theme="dark"] .reference-popup.below::after {
    border-bottom-color: #1a1a1a;
}

[data-theme="dark"] .reference-popup-number {
    color: #999;
}

[data-theme="dark"] .reference-popup-text {
    color: #e0e0e0;
}

[data-theme="dark"] .reference-popup-actions {
    border-top-color: #333;
}

[data-theme="dark"] .reference-popup-url {
    background: #0a0a0a;
}

[data-theme="dark"] .reference-popup-url:hover {
    background: #4a9eff;
}

/* Additional responsive improvements */
@media (max-width: 480px) {
    /* Ultra-small screens */
    .header {
        height: 44px;
    }

    :root {
        --header-height: 44px;
    }

    .logo-text {
        font-size: 16px;
    }

    .search-container {
        margin: 0 4px;
        max-width: calc(100% - 100px); /* Leave room for logo and menu */
    }

    .article {
        padding: 16px 12px;
        width: 100%;
        overflow-x: hidden;
    }

    .article-title {
        font-size: 20px;
        word-wrap: break-word;
    }

    .section-title {
        font-size: 18px;
    }

    .article-section p {
        font-size: 14px;
    }

    /* Stack everything vertically */
    .main-container,
    .article-section,
    .infobox-wrapper {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    /* Reset problematic margins on mobile */
    .infobox-wrapper,
    .article-section {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Allow normal paragraph margins */
    .article-section p,
    .article-section ul,
    .article-section ol {
        margin-bottom: 16px;
    }
}

/* Landscape mobile optimizations */
@media (max-width: 812px) and (orientation: landscape) {
    .header {
        height: 40px;
    }

    :root {
        --header-height: 40px;
    }

    .article {
        padding: 20px;
    }

    .sidebar {
        width: 240px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets for touch */
    .nav-link {
        padding: 8px 0;
    }

    .icon-button {
        width: 32px;
        height: 32px;
    }

    .search-input {
        height: 36px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Better scrolling on touch */
    .sidebar,
    .content,
    .article-section {
        -webkit-overflow-scrolling: touch;
    }
}

/* Container queries for better component-level responsiveness */
.article-section {
    container-type: inline-size;
}

@container (max-width: 500px) {
    .infobox-wrapper {
        float: none;
        width: 100%;
        margin: 0 0 20px 0;
    }
}

/* Flexible grid layouts */
.articles-showcase {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

/* Better text wrapping */
.article-section p,
.article-section li {
    hyphens: auto;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Prevent horizontal overflow globally */
* {
    box-sizing: border-box;
}

/* Limit max-width only for elements that need it */
img, video, iframe, table {
    max-width: 100%;
}

/* Ensure all images are responsive */
img, video, iframe {
    max-width: 100% !important;
    height: auto;
}

/* Responsive images */
.article-section img,
.infobox img {
    max-width: 100%;
    height: auto;
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .article,
    .infobox {
        border-width: 0.5px;
    }
}

/* Footer */
.footer {
    margin-top: 80px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
}

.footer-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 40px 20px 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section {
    color: var(--text-primary);
}

.footer-title {
    font-family: Georgia, serif;
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.footer-description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 300px;
}

.footer-heading {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--text-primary);
}

.footer-bottom {
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.footer-bottom p {
    font-size: 13px;
    color: var(--text-tertiary);
}

.footer-bottom a {
    color: var(--text-link);
    text-decoration: none;
}

.footer-bottom a:hover {
    text-decoration: underline;
}

/* Responsive footer */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .footer-container {
        padding: 30px 20px 15px;
    }

    .footer-description {
        max-width: 100%;
    }
}

/* Print styles */
@media print {
    .header,
    .sidebar,
    .right-sidebar,
    .footer,
    .icon-button,
    .theme-toggle {
        display: none !important;
    }

    .main-container {
        display: block;
        margin: 0;
    }

    .content {
        padding: 0;
        max-width: 100%;
    }

    .article {
        box-shadow: none;
        border: none;
        padding: 0;
        background: var(--bg-primary);
        color: var(--text-primary);
    }

    .article-section p {
        font-size: 11pt;
        line-height: 1.5;
    }
}
