/* ====================================
   Thinking with Comics - Website Styles
   Academic + Comic Style Design (Full Version)
   ==================================== */

:root {
    /* Color Palette - Comic inspired */
    --primary: #FF6B6B;
    --primary-dark: #EE5A5A;
    --secondary: #4ECDC4;
    --accent: #FFE66D;
    --dark: #2C3E50;
    --darker: #1a252f;
    --light: #F7F9FC;
    --white: #FFFFFF;
    --gray: #95A5A6;
    --gray-light: #ECF0F1;
    
    /* Comic colors */
    --comic-yellow: #FFF9C4;
    --comic-blue: #E3F2FD;
    --comic-pink: #FCE4EC;
    --comic-green: #E8F5E9;
    --comic-border: #2C3E50;
    
    /* Gradients */
    --gradient-hero: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-card: linear-gradient(145deg, #ffffff 0%, #f5f7fa 100%);
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-comic: 4px 4px 0px var(--comic-border);
    
    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-comic: 'Comic Neue', cursive;
    --font-display: 'Bangers', cursive;
    
    /* Spacing */
    --section-padding: 100px 0;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    line-height: 1.7;
    color: var(--dark);
    background: var(--light);
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Comic Decorations */
.comic-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.speech-bubble, .pow-bubble, .zap-bubble {
    position: absolute;
    font-size: 2rem;
    opacity: 0.15;
    animation: float 6s ease-in-out infinite;
}

.pow-bubble, .zap-bubble {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--primary);
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.floating:nth-child(2) { animation-delay: -1.5s; }
.floating:nth-child(3) { animation-delay: -3s; }
.floating:nth-child(4) { animation-delay: -4.5s; }

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 15px 0;
    border-bottom: 3px solid var(--comic-border);
    box-shadow: var(--shadow-sm);
}

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

.nav-logo {
    text-decoration: none;
}

.comic-text {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--dark);
    letter-spacing: 1px;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 30px;
}

.nav-menu a {
    text-decoration: none;
    color: var(--dark);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.3s ease;
    position: relative;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.nav-menu a:hover {
    color: var(--primary);
}

.nav-menu a:hover::after {
    width: 100%;
}

/* Mobile Navigation Toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--dark);
    padding: 5px;
    z-index: 1002;
}

.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 120px 24px 60px;
    background: linear-gradient(180deg, var(--comic-yellow) 0%, var(--light) 100%);
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 80%, var(--comic-pink) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, var(--comic-blue) 0%, transparent 50%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 900px;
}

.comic-panel {
    background: var(--white);
    border: 4px solid var(--comic-border);
    border-radius: 8px;
    padding: 50px 60px;
    position: relative;
    box-shadow: 8px 8px 0px var(--comic-border);
}

.panel-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--comic-border);
}

.panel-corner.tl { top: -4px; left: -4px; border-radius: 8px 0 8px 0; }
.panel-corner.tr { top: -4px; right: -4px; border-radius: 0 8px 0 8px; }
.panel-corner.bl { bottom: -4px; left: -4px; border-radius: 8px 0 8px 0; }
.panel-corner.br { bottom: -4px; right: -4px; border-radius: 0 8px 0 8px; }

.venue-badge {
    display: inline-block;
    background: var(--primary);
    color: var(--white);
    padding: 8px 20px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 20px;
    letter-spacing: 2px;
    box-shadow: var(--shadow-comic);
    border: 2px solid var(--comic-border);
}

.hero-title {
    font-family: var(--font-display);
    font-size: 2.8rem;
    margin-bottom: 20px;
    line-height: 1.2;
    letter-spacing: 2px;
}

.hero-title .comic-word {
    background: linear-gradient(135deg, var(--primary) 0%, #FF8E53 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.author-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.author {
    font-size: 1.05rem;
    font-weight: 500;
}

.affiliation-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.equal-contrib {
    font-style: italic;
}

.hero-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 60px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 3px solid var(--comic-border);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 4px 4px 0px var(--comic-border);
}

.btn-primary:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px var(--comic-border);
}

.btn-secondary {
    background: var(--white);
    color: var(--dark);
    box-shadow: 4px 4px 0px var(--comic-border);
}

.btn-secondary:hover {
    background: var(--light);
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px var(--comic-border);
}

/* Hero Benchmark Figure */
.hero-benchmark {
    margin-top: 50px;
    max-width: 1100px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.hero-benchmark img {
    width: 100%;
    height: auto;
    border: 4px solid var(--comic-border);
    border-radius: 12px;
    box-shadow: 10px 10px 0px var(--comic-border);
    background: var(--white);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero-benchmark img:hover {
    transform: translate(-3px, -3px);
    box-shadow: 13px 13px 0px var(--comic-border);
}

/* TL;DR Section */
.tldr-section {
    padding: 60px 0;
    background: var(--white);
    border-top: 4px solid var(--comic-border);
    border-bottom: 4px solid var(--comic-border);
}

.tldr-card {
    background: linear-gradient(135deg, var(--comic-blue) 0%, var(--comic-green) 100%);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    box-shadow: 6px 6px 0px var(--comic-border);
}

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

.tldr-card h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.tldr-card p {
    font-size: 1.15rem;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

.tldr-card .highlight {
    background: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* TL;DR Examples Showcase */
.tldr-examples {
    margin-top: 50px;
    padding-top: 50px;
    border-top: 2px dashed var(--gray-light);
}

/* TL;DR Tabs - 与 Gallery tabs 完全一致 */
.tldr-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 40px;
}

.tldr-tab-btn {
    padding: 12px 25px;
    background: var(--light);
    border: 3px solid var(--comic-border);
    border-radius: 8px;
    font-family: var(--font-comic);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 3px 3px 0px var(--comic-border);
}

.tldr-tab-btn:hover {
    background: var(--comic-yellow);
}

.tldr-tab-btn.active {
    background: var(--primary);
    color: var(--white);
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--comic-border);
}

/* TL;DR Examples Content */
.tldr-examples-content {
    min-height: 400px;
}

.tldr-examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.tldr-examples-grid.hidden {
    display: none;
}

/* TL;DR items 使用与 Gallery 相同的样式 */
.tldr-example-item {
    transition: transform 0.3s ease;
}

.tldr-example-item:hover {
    transform: translateY(-5px);
}

.tldr-example-caption {
    margin-top: 15px;
    text-align: center;
    color: var(--gray);
    font-size: 0.95rem;
}

/* TL;DR Translation: side-by-side before/after with arrow */
.translation-pair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px;
}

/* Slightly thinner outer frame for the translation pair */
.translation-pair-wrapper {
    border-width: 3px;
    box-shadow: 4px 4px 0px var(--comic-border);
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.comic-frame-wrapper .translation-pair img {
    width: 0;
    flex: 1 1 0;
    height: clamp(280px, 68vw, 360px);
    object-fit: contain;
    background: var(--white);
    border-radius: 4px;
}

.translation-arrow {
    flex: 0 0 auto;
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 4vw, 3.2rem);
    color: var(--dark);
    opacity: 0.8;
    line-height: 1;
}

/* Section Styles */
.section {
    padding: var(--section-padding);
    position: relative;
}

.section-header {
    text-align: center;
    margin-bottom: 60px;
}

.comic-caption {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--primary);
    letter-spacing: 3px;
    margin-bottom: 10px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--dark);
    letter-spacing: 2px;
}

.section-desc {
    color: var(--gray);
    font-size: 1.1rem;
    margin-top: 10px;
}

/* Abstract Section */
.abstract-section {
    background: var(--light);
}

.abstract-content {
    max-width: 1050px;
    margin: 0 auto;
}

.comic-frame {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 6px 6px 0px var(--comic-border);
}

.comic-frame p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    text-align: justify;
}

.comic-frame p:last-child {
    margin-bottom: 0;
}

.highlight-box {
    background: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Findings Section */
.findings-section {
    background: linear-gradient(180deg, var(--white) 0%, var(--comic-yellow) 100%);
    padding: var(--section-padding);
}

.findings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 25px;
}

.finding-card {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    box-shadow: 5px 5px 0px var(--comic-border);
    transition: transform 0.3s ease;
}

.finding-card:hover {
    transform: translateY(-5px);
}

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

.finding-card h3 {
    font-family: var(--font-comic);
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--dark);
}

.finding-card p {
    color: var(--gray);
    font-size: 0.95rem;
}

.finding-card strong {
    color: var(--primary);
}

/* Method Section */
.method-section {
    background: var(--white);
}

.method-intro {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 40px;
}

.paths-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
}

.path-card {
    background: var(--light);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 5px 5px 0px var(--comic-border);
}

.path-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.path-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: var(--white);
    font-family: var(--font-display);
    font-size: 1.5rem;
    border-radius: 50%;
    border: 3px solid var(--comic-border);
}

.path-header h3 {
    font-family: var(--font-comic);
    font-size: 1.2rem;
}

.path-diagram {
    background: var(--white);
    border: 2px dashed var(--gray);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.diagram-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.flow-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    background: var(--comic-blue);
    border: 2px solid var(--comic-border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
}

.flow-item.highlight {
    background: var(--accent);
}

.flow-item i {
    font-size: 1.3rem;
}

.flow-arrow {
    font-size: 1.5rem;
    color: var(--gray);
    font-weight: bold;
}

.path-desc {
    color: var(--gray);
    font-size: 0.95rem;
    text-align: center;
}

.path-desc em {
    color: var(--primary);
    font-weight: 600;
}

/* Styles Section */
.styles-section {
    margin-top: 40px;
}

.subsection-title {
    font-family: var(--font-comic);
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 15px;
}

.styles-intro {
    text-align: center;
    color: var(--gray);
    margin-bottom: 30px;
}

.styles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.style-card {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    box-shadow: 4px 4px 0px var(--comic-border);
    transition: transform 0.3s ease;
}

.style-card:hover {
    transform: translateY(-3px);
}

.style-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.style-card h4 {
    font-family: var(--font-comic);
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.style-card p {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.style-boost {
    display: inline-block;
    background: var(--comic-green);
    color: var(--dark);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--comic-border);
}

/* Results Section */
.results-section {
    background: var(--light);
}

.results-tables {
    display: grid;
    gap: 40px;
    margin-bottom: 60px;
}

.table-container {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 5px 5px 0px var(--comic-border);
    overflow-x: auto;
}

.table-container h3 {
    font-family: var(--font-comic);
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-align: center;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.results-table th,
.results-table td {
    padding: 14px 20px;
    text-align: center;
    border-bottom: 2px solid var(--gray-light);
}

.results-table th {
    background: var(--comic-blue);
    font-weight: 600;
    border-bottom: 3px solid var(--comic-border);
}

.results-table td:first-child {
    text-align: left;
    font-weight: 500;
}

/* Column alignment overrides (keep scope narrow via table ids) */
#main-results-table th:nth-child(1),
#main-results-table td:nth-child(1),
#main-results-table th:nth-child(2),
#main-results-table td:nth-child(2),
#style-alignment-table th:nth-child(1),
#style-alignment-table td:nth-child(1) {
    text-align: center;
    vertical-align: middle;
}

/* Appendix empirical tables: center specified columns (Metric/Dataset; Benchmark/Method) */
#appendix-a1-table td:first-child,
#appendix-a2-table td:first-child {
    text-align: center;
    vertical-align: middle;
}

.results-table .highlight-row {
    background: var(--comic-yellow);
}

.results-table .highlight-row.best {
    background: var(--comic-green);
}

.results-table strong {
    color: var(--primary);
}

.results-table u {
    text-decoration: none;
    border-bottom: 2px solid var(--secondary);
}

/* Analysis Section */
.analysis-section {
    margin-top: 60px;
    text-align: center;
}

.analysis-section h3 {
    font-family: var(--font-primary);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 25px;
    color: var(--dark);
}

/* Academic Chart Container */
.chart-container {
    max-width: 700px;
    margin: 0 auto 20px;
}

.chart-container.academic-chart {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 5px 5px 0px var(--comic-border);
    height: 350px;
}

/* Figure 4: give extra room so chart labels don't get clipped */
#distribution-chart-container {
    max-width: 720px;
    height: 390px;
}

.figure-caption {
    max-width: 800px;
    margin: 15px auto 0;
    font-size: 0.9rem;
    color: var(--gray);
    text-align: justify;
    line-height: 1.6;
}

/* Appendix captions: match full table/figure width (avoid narrow 800px cap) */
.figure-caption.appendix-caption-wide {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.figure-caption strong {
    color: var(--dark);
}

.figure-caption em {
    font-style: italic;
}

.analysis-intro {
    color: var(--gray);
    margin-bottom: 25px;
}

.analysis-caption {
    max-width: 900px;
    margin: 20px auto 0;
    color: var(--gray);
    font-size: 0.95rem;
    line-height: 1.7;
    text-align: center;
}

/* Appendix: Qualitative Comparison heading */
.appendix-section .qualitative-comparison-title {
    text-align: center;
    margin-bottom: 20px;
    color: var(--dark);
    font-size: 1.35rem;
    font-weight: 700;
}

/* Table Enhancements */
.table-container.full-width {
    overflow-x: auto;
}

.table-container.compact {
    max-width: 600px;
    margin: 0 auto;
}

.table-note {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 15px;
    font-style: italic;
}

.results-table .separator-row td {
    border-top: 2px solid var(--comic-border);
}

.results-table .positive {
    color: #27ae60;
    font-weight: 600;
}

.results-table .negative {
    color: var(--primary);
    font-weight: 600;
}

/* Scaling Chart */
.scaling-chart-container {
    max-width: 600px;
    margin: 0 auto 20px;
}

.scaling-chart {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 5px 5px 0px var(--comic-border);
}

.chart-bars {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 200px;
    padding: 20px 0;
}

.bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
}

.bar-group .bar {
    width: 40px;
    background: var(--secondary);
    border: 2px solid var(--comic-border);
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: all 0.3s ease;
}

.bar-group .bar::before {
    content: attr(data-value);
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dark);
}

.bar-group.pareto .bar {
    background: var(--comic-green);
    border-color: #27ae60;
}

.bar-label {
    margin-top: 10px;
    font-size: 0.85rem;
    font-weight: 500;
}

.chart-legend {
    margin-top: 15px;
    text-align: center;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gray);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: var(--secondary);
    border: 2px solid var(--comic-border);
}

.legend-color.pareto {
    background: var(--comic-green);
    border-color: #27ae60;
}

/* Panel Distribution */
.distribution-grid {
    display: grid;
    gap: 15px;
    max-width: 700px;
    margin: 0 auto;
}

.distribution-item {
    display: grid;
    grid-template-columns: 140px 1fr 200px;
    align-items: center;
    gap: 15px;
    background: var(--white);
    border: 2px solid var(--comic-border);
    border-radius: 8px;
    padding: 15px;
}

.task-name {
    font-weight: 600;
    font-family: var(--font-comic);
}

.distribution-bar {
    display: flex;
    height: 30px;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid var(--comic-border);
}

.distribution-bar .segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--white);
    background: var(--gray);
}

.distribution-bar .segment.highlight {
    background: var(--secondary);
}

.distribution-bar .segment.extended {
    background: var(--primary);
}

.task-desc {
    font-size: 0.8rem;
    color: var(--gray);
}

/* Temporal Analysis */
.temporal-analysis {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.perturbation-card {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    box-shadow: 4px 4px 0px var(--comic-border);
    min-width: 180px;
}

.perturbation-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.perturbation-card h4 {
    font-family: var(--font-comic);
    font-size: 1rem;
    margin-bottom: 15px;
}

.perturbation-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.perturbation-result .from,
.perturbation-result .to {
    font-weight: 600;
    font-size: 1.1rem;
}

.perturbation-result .arrow {
    color: var(--gray);
}

.perturbation-card .delta {
    font-weight: 700;
    font-size: 0.9rem;
}

.perturbation-card .delta.negative {
    color: var(--primary);
}

/* Ablation Comparison */
.ablation-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    max-width: 900px;
    margin: 0 auto 20px;
}

.ablation-group {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 4px 4px 0px var(--comic-border);
}

.ablation-group h4 {
    font-family: var(--font-comic);
    font-size: 1rem;
    margin-bottom: 15px;
    text-align: center;
}

.ablation-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ablation-bar {
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--white);
}

.ablation-bar.pure-visual {
    background: var(--gray);
}

.ablation-bar.with-text {
    background: var(--secondary);
}

.ablation-group .gain {
    display: block;
    text-align: center;
    margin-top: 10px;
    font-weight: 700;
    color: #27ae60;
}

/* Cost Formula */
.cost-formula {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    background: var(--comic-blue);
    padding: 8px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 2px solid var(--comic-border);
}

/* Analysis Panels Section (legacy) */
.analysis-panels-section {
    margin-top: 60px;
    text-align: center;
}

.analysis-panels-section h3 {
    font-family: var(--font-comic);
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.analysis-panels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-bottom: 25px;
}

.analysis-panel {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 5px 5px 0px var(--comic-border);
}

.analysis-panel img {
    width: 100%;
    height: auto;
    display: block;
}

.analysis-panels-caption {
    max-width: 900px;
    margin: 0 auto;
    color: var(--gray);
    font-size: 0.95rem;
    line-height: 1.7;
    text-align: justify;
}

/* Efficiency Section */
.efficiency-section {
    text-align: center;
    margin-top: 60px;
}

.efficiency-section h3 {
    font-family: var(--font-comic);
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.efficiency-comparison {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.efficiency-card {
    background: var(--white);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 30px 40px;
    box-shadow: 5px 5px 0px var(--comic-border);
    min-width: 200px;
}

.efficiency-card.comic {
    background: var(--comic-green);
}

.efficiency-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.efficiency-card h4 {
    font-family: var(--font-comic);
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.efficiency-stats {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
}

.stat-value.highlight {
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray);
}

.efficiency-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--primary);
}

.arrow-text {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.efficiency-arrow i {
    font-size: 2rem;
}

.efficiency-badge {
    margin-top: 15px;
    background: var(--accent);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 2px solid var(--comic-border);
}

/* Gallery Section */
.gallery-section {
    background: var(--white);
}

.gallery-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 40px;
}

.tab-btn {
    padding: 12px 25px;
    background: var(--light);
    border: 3px solid var(--comic-border);
    border-radius: 8px;
    font-family: var(--font-comic);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 3px 3px 0px var(--comic-border);
}

.tab-btn:hover {
    background: var(--comic-yellow);
}

.tab-btn.active {
    background: var(--primary);
    color: var(--white);
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--comic-border);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.gallery-grid.hidden {
    display: none;
}

.gallery-item {
    transition: transform 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
}

.comic-frame-wrapper {
    position: relative;
    border: 4px solid var(--comic-border);
    border-radius: 8px;
    /* Allow the dataset label to overlap the frame border */
    overflow: visible;
    box-shadow: 6px 6px 0px var(--comic-border);
    background: var(--white);
}

.comic-frame-wrapper img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    /* Match the inner radius (outer radius - border thickness) */
    border-radius: 4px;
}

.frame-overlay {
    position: absolute;
    /* Centered at the top; the border should pass through the label midline */
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    pointer-events: none;
}

.frame-label {
    background: var(--primary);
    color: var(--white);
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--comic-border);
    pointer-events: none;
}

.gallery-caption {
    margin-top: 15px;
    text-align: center;
    color: var(--gray);
    font-size: 0.95rem;
}

/* Citation Section */
.citation-section {
    background: var(--comic-blue);
    border-top: 4px solid var(--comic-border);
}

.citation-box {
    background: var(--darker);
    border: 3px solid var(--comic-border);
    border-radius: 12px;
    padding: 30px;
    position: relative;
    box-shadow: 6px 6px 0px var(--comic-border);
    max-width: 940px;
    margin: 0 auto;
}

.copy-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary);
    color: var(--white);
    border: 2px solid var(--white);
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: var(--primary-dark);
}

.citation-box pre {
    margin: 0;
    overflow-x: auto;
}

.citation-box code {
    color: #A8E6CF;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Footer */
.footer {
    background: var(--darker);
    color: var(--white);
    padding: 60px 0 30px;
    position: relative;
    border-top: 4px solid var(--comic-border);
}

.footer-content {
    text-align: center;
}

.footer-logo {
    margin-bottom: 20px;
}

.footer-logo .comic-text {
    color: var(--white);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.footer-links a {
    color: var(--gray);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

.footer-text {
    color: var(--gray);
    font-size: 0.9rem;
}

.footer-comic {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    opacity: 0.3;
}

.comic-panel-small {
    width: 60px;
    height: 8px;
    background: var(--primary);
    border-radius: 4px;
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal.visible {
    opacity: 1;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    z-index: 1;
}

.modal-content img {
    max-width: 100%;
    max-height: 85vh;
    border: 4px solid white;
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: var(--primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.modal-close:hover {
    transform: scale(1.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .nav-menu {
        position: fixed;
        top: 0;
        right: -300px;
        width: 280px;
        height: 100vh;
        background: var(--white);
        flex-direction: column;
        padding: 80px 30px 30px;
        gap: 20px;
        transition: right 0.3s ease;
        box-shadow: -5px 0 20px rgba(0,0,0,0.1);
        z-index: 1001;
    }
    
    .nav-menu.open {
        right: 0;
    }
    
    .nav-overlay.open {
        display: block;
    }
    
    .hero-title {
        font-size: 1.8rem;
    }
    
    .comic-panel {
        padding: 30px 20px;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .tldr-tabs {
        gap: 10px;
    }
    
    .tldr-tab-btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
    
    .tldr-examples-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .tldr-example-item {
        max-width: 100%;
    }
    
    .paths-container {
        grid-template-columns: 1fr;
    }
    
    .styles-grid {
        grid-template-columns: 1fr;
    }
    
    .analysis-panels-grid {
        grid-template-columns: 1fr;
    }
    
    .efficiency-comparison {
        flex-direction: column;
    }
    
    .efficiency-arrow {
        transform: rotate(90deg);
    }
    
    .gallery-tabs {
        gap: 10px;
    }
    
    .tab-btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-content {
    animation: fadeInUp 0.8s ease-out;
}

.finding-card:nth-child(1) { animation: fadeInUp 0.6s ease-out 0.1s both; }
.finding-card:nth-child(2) { animation: fadeInUp 0.6s ease-out 0.2s both; }
.finding-card:nth-child(3) { animation: fadeInUp 0.6s ease-out 0.3s both; }
.finding-card:nth-child(4) { animation: fadeInUp 0.6s ease-out 0.4s both; }

/* Scroll animations */
.section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ====================================
   Appendix Section Styles
   ==================================== */

.appendix-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.appendix-subsection {
    margin-top: 50px;
    padding: 30px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.appendix-subsection h3 {
    font-family: var(--font-primary);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--secondary);
}

/* Math Definition Box */
.math-definition {
    background: #eef2f6;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: none;
    padding: 18px 24px;
    margin: 18px auto 16px;
    max-width: 700px;
    text-align: center;
}

.math-definition > p {
    margin: 0 0 10px;
    color: var(--dark);
    font-weight: 600;
    letter-spacing: 0.2px;
}

.equation-block {
    margin: 0;
    padding: 2px 0 0;
    background: transparent;
    border: none;
}

.equation {
    display: grid;
    grid-template-columns: 50px 130px 190px;
    align-items: baseline;
    justify-content: center;
    column-gap: 12px;
    row-gap: 6px;
    padding: 8px 6px;
    font-family: 'Times New Roman', serif;
    font-size: 1.05rem;
}


.equation + .equation {
    margin-top: 4px;
}

.eq-label {
    font-weight: 600;
    color: var(--dark);
    letter-spacing: 0.2px;
    background: transparent;
    border: none;
    padding: 0;
    display: inline-block;
    text-align: left;
    min-width: 90px;
}

.eq-math {
    font-style: italic;
    color: #1f3b5b;
    font-size: 1.15rem;
    text-align: left;
}

.eq-note {
    color: #64748b;
    font-size: 0.88rem;
    font-style: normal;
    text-align: left;
}

/* Keep the efficiency chart border consistent with the cost function box */
#efficiency-chart-container {
    border-width: 2px;
    box-shadow: 4px 4px 0px var(--comic-border);
}

@media (max-width: 700px) {
    .math-definition {
        padding: 18px 18px;
        margin: 18px 0;
    }

    .equation {
        grid-template-columns: 1fr;
        padding: 10px 6px;
    }

    .eq-note {
        text-align: left;
    }
}

/* Theorem Box */
.theorem-box {
    background: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin: 20px 0;
    overflow: hidden;
}

.theorem-title {
    background: linear-gradient(135deg, #4472C4 0%, #3a5fa8 100%);
    color: white;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 1rem;
}

.theorem-content {
    padding: 20px;
}

.theorem-content p {
    margin-bottom: 12px;
    line-height: 1.7;
}

/* Math Block */
.math-block {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 15px 20px;
    margin: 15px 0;
    text-align: center;
    overflow-x: auto;
}

.math-formula {
    font-family: 'Times New Roman', 'STIX Two Math', serif;
    font-size: 1.2rem;
    font-style: italic;
    color: #2d3748;
    white-space: nowrap;
}

.math-formula .frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 5px;
}

.math-formula .frac .num {
    border-bottom: 1px solid #2d3748;
    padding-bottom: 2px;
}

.math-formula .frac .den {
    padding-top: 2px;
}

.math-formula .sum {
    font-size: 1.4rem;
    margin: 0 3px;
}

.math-note {
    font-size: 0.9rem;
    color: var(--gray);
    font-style: normal;
    margin-top: 10px;
}

/* Experiment Setup */
.experiment-setup {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.setup-item {
    flex: 1;
    min-width: 280px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px 20px;
    font-size: 0.95rem;
}

.setup-item strong {
    color: var(--dark);
}

/* Appendix Table */
.appendix-table {
    font-size: 0.95rem;
}

.appendix-table th {
    background: linear-gradient(135deg, #4472C4 0%, #3a5fa8 100%);
    color: white;
}

.appendix-table td.highlight {
    background: #e8f5e9;
    font-weight: 600;
}

.appendix-table .separator-row td {
    height: 8px;
    background: #f0f4f8;
    padding: 0;
}

.appendix-table .average-row {
    background: #fff8e1;
}

.appendix-table .positive {
    color: #2e7d32;
    font-weight: 600;
}

/* Insight Box */
.insight-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 1px solid #81c784;
    border-radius: 12px;
    padding: 25px;
    margin-top: 30px;
    text-align: center;
}

.insight-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

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

.insight-title {
    font-size: 1.15rem;
    color: #2e7d32;
    font-weight: 700;
    margin: 0;
}

.insight-text {
    color: #1b5e20;
    line-height: 1.6;
    margin: 0;
    max-width: 900px;
}

/* Metrics Highlight */
.metrics-highlight {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 30px auto 0;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    flex-wrap: wrap;
    max-width: 700px;
}

.metric-card {
    text-align: center;
    padding: 20px 30px;
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    min-width: 140px;
}

.metric-card.highlight {
    background: linear-gradient(135deg, #4472C4 0%, #3a5fa8 100%);
    color: white;
}

.metric-card.highlight .metric-value {
    color: white;
}

.metric-card.highlight .metric-label {
    color: rgba(255,255,255,0.9);
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
}

.metric-value.positive {
    color: #2e7d32;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 5px;
}

.metric-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #2e7d32;
}

.metric-delta {
    font-size: 0.95rem;
    font-weight: 700;
    color: #2e7d32;
    white-space: nowrap;
}

.metric-arrow-icon {
    position: relative;
    width: 120px;
    height: 18px;
    color: #2e7d32;
    /* Hide the literal arrow character; we draw our own */
    font-size: 0;
    line-height: 0;
}

.metric-arrow-icon::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: calc(100% - 16px);
    height: 5px;
    background: currentColor;
    border-radius: 999px;
}

.metric-arrow-icon::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    border-left: 16px solid currentColor;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
}

.metric-result {
    text-align: center;
    padding: 15px 25px;
    background: #e8f5e9;
    border-radius: 10px;
    border: 2px solid #81c784;
}

/* Responsive for Appendix */
@media (max-width: 768px) {
    .appendix-subsection {
        padding: 20px;
    }
    
    .theorem-box {
        margin: 15px -10px;
        border-radius: 0;
    }
    
    .math-block {
        padding: 10px;
    }
    
    .math-formula {
        font-size: 1rem;
    }
    
    .metrics-highlight {
        flex-direction: column;
        gap: 15px;
    }
    
    .metric-arrow-icon {
        transform: rotate(90deg);
    }
    
    .insight-box {
        flex-direction: column;
        text-align: center;
    }
    
    .experiment-setup {
        flex-direction: column;
    }
}
