/* ============================================
   DISTILL.PUB FAITHFUL REPRODUCTION
   ============================================ */

/* CSS Variables */
:root {
    /* Layout widths */
    --l-page: 1280px;
    /* Distill's actual color palette - very muted */
    --color-bg: #fff;
    --color-text: #000;
    --color-text-light: #333;
    --color-gray: #666;
    --color-gray-light: #999;
    --color-border: #ddd;
    --color-link: #004276;
    --color-link-hover: #002244;

    /* Semantic colors */
    --color-orange: #e07b39;
    --color-orange-dark: #c35a00;
    --color-orange-bg: #fff3e0;
    --color-blue: #4a90a4;
    --color-blue-dark: #1565c0;
    --color-blue-bg: #e3f2fd;
    --color-purple: #7b68a6;
    --color-green: #5a9f68;
    --color-green-dark: #2e7d32;
    --color-green-bg: #e8f5e9;
    --color-red: #c62828;
    --color-red-light: #ef5350;

    /* Typography - Inter + JetBrains Mono */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, Monaco, 'Andale Mono', monospace;

    /* Layout */
    --content-width: 760px;
    --toc-width: 180px;
    --page-margin: 32px;
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-text: #f1f5f9;
    --color-text-light: #cbd5e1;
    --color-gray: #94a3b8;
    --color-gray-light: #64748b;
    --color-border: #1e293b;
    --color-surface: #1e293b;
    --color-surface-border: #334155;
    --color-link: #60a5fa;
    --color-link-hover: #93c5fd;
    --color-orange-bg: #1c1008;
    --color-blue-bg: #0c1a2e;
    --color-green-bg: #0a1f0f;
}

[data-theme="dark"] body {
    background: var(--color-bg);
    color: var(--color-text);
}

[data-theme="dark"] .site-header {
    background: var(--color-bg);
    border-bottom-color: var(--color-surface);
}


[data-theme="dark"] .d-byline {
    border-color: var(--color-border);
}

[data-theme="dark"] .d-toc a {
    color: var(--color-gray);
}

[data-theme="dark"] .d-toc a:hover,
[data-theme="dark"] .d-toc a.active {
    color: var(--color-text);
}

[data-theme="dark"] code,
[data-theme="dark"] pre {
    background: var(--color-surface);
    color: #e2e8f0;
}

[data-theme="dark"] blockquote {
    border-left-color: var(--color-surface-border);
    color: var(--color-gray);
}

[data-theme="dark"] .d-note {
    background: var(--color-surface);
    border-color: var(--color-surface-border);
}

[data-theme="dark"] .d-callout {
    background: var(--color-surface);
    border-color: var(--color-surface-border);
}

[data-theme="dark"] .post-preview {
    background: #0f172a;
    border-color: var(--color-surface);
}

[data-theme="dark"] .post-preview:hover {
    border-color: var(--color-surface-border);
}

[data-theme="dark"] .post-title,
[data-theme="dark"] .post-abstract {
    color: var(--color-text-light);
}

[data-theme="dark"] .column-header h2 {
    color: var(--color-text);
}

[data-theme="dark"] .column-desc {
    color: var(--color-gray);
}

[data-theme="dark"] .bio-hero,
[data-theme="dark"] .bio-timeline {
    color: var(--color-text);
}

[data-theme="dark"] .timeline-role,
[data-theme="dark"] .timeline-company {
    color: var(--color-text-light);
}

[data-theme="dark"] .thumbnail-placeholder {
    background: var(--color-surface);
}

[data-theme="dark"] .logo {
    color: var(--color-text);
}

[data-theme="dark"] .logo-icon {
    filter: invert(1);
}

[data-theme="dark"] .bio-btn-icon {
    background: var(--color-surface);
    color: #f1f5f9;
}

[data-theme="dark"] .bio-btn-primary {
    background: #f1f5f9;
    color: #0f172a;
}

[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }

/* ── claude-code-leak post ── */
[data-theme="dark"] .lk-stat {
    background: var(--color-surface);
    border-color: var(--color-surface-border);
}
[data-theme="dark"] .lk-stat-val { color: #f1f5f9; }
[data-theme="dark"] .lk-card {
    background: var(--color-surface);
    border-color: var(--color-surface-border);
}
[data-theme="dark"] .lk-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
[data-theme="dark"] .lk-card h3 { color: #f1f5f9; }
[data-theme="dark"] .lk-card p  { color: #94a3b8; }
[data-theme="dark"] .lt-desc    { color: #94a3b8; }
[data-theme="dark"] .react-loop { border-color: var(--color-surface-border); }
[data-theme="dark"] .rl-phase   { border-bottom-color: var(--color-surface); }
[data-theme="dark"] .rl-num     { background: var(--color-surface); border-right-color: var(--color-surface-border); color: #64748b; }
[data-theme="dark"] .rl-num span { color: #f1f5f9; }
[data-theme="dark"] .rl-body strong { color: #f1f5f9; }
[data-theme="dark"] .rl-body p  { color: #94a3b8; }
[data-theme="dark"] .rs-1 { background: #2d0f10; color: #fca5a5; }
[data-theme="dark"] .rs-2 { background: #2d1a08; color: #fdba74; }
[data-theme="dark"] .rs-3 { background: #2a1f05; color: #fde68a; }
[data-theme="dark"] .rs-4 { background: #052e16; color: #86efac; }
[data-theme="dark"] .rs-5 { background: #0c1a2e; color: #93c5fd; }
[data-theme="dark"] .rs-6 { background: #1e1040; color: #c4b5fd; }
[data-theme="dark"] .rs-7 { background: #2d0a3a; color: #e879f9; }
[data-theme="dark"] .eng-card {
    background: var(--color-surface);
    border-color: var(--color-surface-border);
}
[data-theme="dark"] .eng-card h4 { color: #f1f5f9; }
[data-theme="dark"] .eng-card p  { color: #94a3b8; }
[data-theme="dark"] .flag-table th {
    background: var(--color-surface);
    color: #cbd5e1;
    border-bottom-color: var(--color-surface-border);
}
[data-theme="dark"] .flag-table td { border-bottom-color: var(--color-surface); color: #94a3b8; }
[data-theme="dark"] .flag-table td:first-child { color: #60a5fa; }
[data-theme="dark"] .section-marker-label { color: var(--color-text-light); }
[data-theme="dark"] .section-marker-line  { background: var(--color-surface); }
[data-theme="dark"] .tag-agent    { background: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .tag-security { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .tag-memory   { background: #052e16; color: #6ee7b7; }
[data-theme="dark"] .tag-ux       { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .tag-infra    { background: #431407; color: #fdba74; }
[data-theme="dark"] .tag-arch     { background: #0c2a4a; color: #7dd3fc; }

/* ── agent-engineering-roadmap post ── */
[data-theme="dark"] .rm-box.b  { background: #0c1a2e; border-color: #3b82f6; }
[data-theme="dark"] .rm-box.b:hover { background: #0f2a4a; }
[data-theme="dark"] .rm-box.g  { background: #052e16; border-color: #16a34a; }
[data-theme="dark"] .rm-box.g:hover { background: #073d1e; }
[data-theme="dark"] .rm-title span { background: var(--color-surface); }
[data-theme="dark"] .rm-box    { color: #f1f5f9; }
[data-theme="dark"] .rm-panel  { background: #0f172a; color: #e2e8f0; }

/* ── general post components (d-note, d-callout, tables, code) ── */
[data-theme="dark"] table th { background: var(--color-surface); color: #cbd5e1; border-color: var(--color-surface-border); }
[data-theme="dark"] table td { border-color: var(--color-surface); color: #94a3b8; }
[data-theme="dark"] .timeline-section-title { color: #94a3b8; }

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text-light);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11"; /* Inter stylistic sets */
}

/* ============================================
   DISTILL HEADER (Title + Byline)
   ============================================ */
.d-title-section {
    max-width: 1280px;
    margin: 0 auto;
    padding: 48px var(--page-margin) 0;
    display: flex;
    justify-content: center;
}
.d-title-inner {
    width: calc(var(--toc-width) + var(--content-width) + 24px);
    max-width: 100%;
}

.d-title {
    font-family: var(--font-heading);
    font-size: 42px;
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 12px 0;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.d-subtitle {
    font-family: var(--font-body);
    font-size: 18px;
    font-weight: 400;
    line-height: 1.6;
    margin: 0 0 24px 0;
    color: var(--color-gray);
}

/* Byline grid: AUTHORS | AFFILIATIONS | PUBLISHED | DOI */
.d-byline {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 24px 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 32px;
}

.d-byline-column {
    font-family: var(--font-heading);
    font-size: 12px;
}

.d-byline-heading {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-light);
    margin-bottom: 8px;
    font-weight: 400;
}

.d-byline-content {
    color: var(--color-text-light);
    line-height: 1.5;
}

.d-byline-content a {
    color: var(--color-link);
    text-decoration: none;
}

.d-byline-content a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .d-byline {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .d-byline {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   MAIN LAYOUT (TOC + Content)
   ============================================ */
.d-article-container {
    display: flex;
    justify-content: center;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--page-margin);
}

/* Table of Contents - Left side */
.d-toc {
    width: var(--toc-width);
    flex-shrink: 0;
    padding-right: 24px;
}

.d-toc-sticky {
    position: sticky;
    top: 24px;
}

.d-toc-title {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 16px 0;
}

.d-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.d-toc-list li {
    margin-bottom: 8px;
}

.d-toc-list a {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-gray);
    text-decoration: none;
    line-height: 1.4;
    display: block;
}

.d-toc-list a:hover {
    color: var(--color-text);
}

.d-toc-list a.active {
    color: var(--color-text);
    font-weight: 500;
}

.d-toc-list .toc-indent {
    padding-left: 12px;
    font-size: 12px;
}

@media (max-width: 900px) {
    .d-toc {
        display: none;
    }
}

/* Main Content */
.d-article {
    flex: 1;
    max-width: var(--content-width);
    min-width: 0;
}

/* ============================================
   COMPANION/INTRO NOTE (Italic style)
   ============================================ */
.d-note {
    font-style: italic;
    color: var(--color-gray);
    margin-bottom: 32px;
}

.d-note a {
    color: var(--color-link);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
.d-article h2 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
    margin: 48px 0 16px 0;
    color: var(--color-text);
}

.d-article h2:first-of-type {
    margin-top: 0;
}

.d-article h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
    margin: 32px 0 12px 0;
    color: var(--color-text);
}

.d-article h4 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    margin: 24px 0 8px 0;
    color: var(--color-text);
}

.d-article p {
    margin: 0 0 16px 0;
}

.d-article strong {
    font-weight: 700;
    color: var(--color-text);
}

.d-article em {
    font-style: italic;
}

.d-article a {
    color: var(--color-link);
    text-decoration: none;
}

.d-article a:hover {
    text-decoration: underline;
}

/* ============================================
   LISTS
   ============================================ */
.d-article ul,
.d-article ol {
    margin: 0 0 16px 0;
    padding-left: 24px;
}

.d-article li {
    margin-bottom: 8px;
}

.d-article li::marker {
    color: var(--color-gray);
}

/* ============================================
   FIGURES & CAPTIONS
   ============================================ */
.d-figure {
    margin: 32px 0;
}

.d-figure-content {
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    padding: 24px;
    display: flex;
    justify-content: center;
}

.d-figure-caption {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-gray);
    margin-top: 12px;
    line-height: 1.5;
}

/* ============================================
   DIAGRAMS - Sequential Flow
   ============================================ */
.diagram-flow {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
}

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

.flow-label {
    width: 60px;
    color: var(--color-gray);
    text-align: right;
    flex-shrink: 0;
}

.flow-items {
    display: flex;
    align-items: center;
    gap: 4px;
}

.flow-item {
    padding: 6px 12px;
    background: white;
    border: 1px solid #ccc;
}

.flow-item.highlight {
    background: var(--color-orange-bg);
    border-color: var(--color-orange);
    color: var(--color-orange-dark);
}

.flow-arrow {
    color: #999;
    font-size: 12px;
}

.flow-annotation {
    margin-left: 70px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--color-gray);
}

/* ============================================
   ATTENTION VISUALIZATION
   ============================================ */
.attn-viz {
    font-family: var(--font-heading);
    font-size: 14px;
}

.attn-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.attn-label {
    width: 50px;
    font-weight: 600;
    color: var(--color-text);
    flex-shrink: 0;
}

.attn-label.c-query { color: var(--color-orange); }
.attn-label.c-key { color: var(--color-blue); }
.attn-label.c-value { color: var(--color-purple); }

.attn-desc {
    font-style: italic;
    color: var(--color-gray);
    font-size: 13px;
}

.attn-items {
    display: flex;
    gap: 8px;
}

.attn-item {
    padding: 6px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
}

.attn-item.highlight {
    background: #ede7f6;
    border-color: var(--color-purple);
    font-weight: 600;
}

.attn-scores {
    display: flex;
    gap: 6px;
}

.attn-score {
    padding: 4px 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    border-radius: 2px;
}

.attn-score.high {
    background: var(--color-orange);
    color: white;
    font-weight: 600;
}

.attn-score.low {
    background: #f5f5f5;
    color: #999;
}

.attn-output {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed #ddd;
}

.attn-output-eq {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--color-gray);
}

.attn-output-eq strong {
    color: var(--color-purple);
}

/* ============================================
   EQUATIONS (KaTeX)
   ============================================ */
.d-math {
    margin: 24px 0;
    overflow-x: auto;
}

.d-math-block {
    text-align: center;
    padding: 16px 0;
}

/* Equation Panel (with legend) */
.d-equation-panel {
    margin: 32px 0;
    padding: 24px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
}

.d-equation-title {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-gray-light);
    margin-bottom: 16px;
}

.d-equation-main {
    text-align: center;
    margin-bottom: 16px;
}

.d-equation-legend {
    border-top: 1px solid #e0e0e0;
    padding-top: 16px;
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-gray);
}

.d-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.d-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.d-legend-dot.query { background: var(--color-orange); }
.d-legend-dot.key { background: var(--color-blue); }
.d-legend-dot.value { background: var(--color-purple); }
.d-legend-dot.param { background: var(--color-green); }

/* ============================================
   TABLES
   ============================================ */
.d-table-wrapper {
    overflow-x: auto;
    margin: 24px 0;
}

.d-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-heading);
    font-size: 14px;
}

.d-table th,
.d-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.d-table th {
    font-weight: 600;
    color: var(--color-gray);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.d-table tbody tr:hover {
    background: #fafafa;
}

.d-table .highlight-row {
    background: #f5f5f5;
}

.d-table .good {
    color: var(--color-green-dark);
}

.d-table .bad {
    color: var(--color-red);
}

/* ============================================
   CALLOUTS (Distill style - very minimal)
   ============================================ */
.d-callout {
    margin: 24px 0;
    padding: 16px 20px;
    background: #f7f7f7;
    font-size: 15px;
}

.d-callout strong {
    color: var(--color-text);
}

.d-callout.warning {
    background: #fff8e1;
}

/* ============================================
   ARCHITECTURE DIAGRAM
   ============================================ */
.arch-diagram {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    padding: 20px;
    font-family: var(--font-heading);
    font-size: 12px;
}

.arch-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.arch-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-text);
    margin-bottom: 8px;
}

.arch-stack {
    border: 2px solid #333;
    padding: 12px;
    position: relative;
}

.arch-layer {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.arch-component {
    padding: 8px 16px;
    text-align: center;
    font-size: 11px;
    line-height: 1.3;
}

.arch-component.attn {
    background: var(--color-orange-bg);
    border: 1px solid var(--color-orange);
}

.arch-component.attn-cross {
    background: var(--color-blue-bg);
    border: 1px solid var(--color-blue);
}

.arch-component.attn-masked {
    background: #ffebee;
    border: 1px solid var(--color-red);
}

.arch-component.ffn {
    background: var(--color-green-bg);
    border: 1px solid var(--color-green);
}

.arch-norm {
    font-size: 10px;
    color: var(--color-gray);
    text-align: center;
}

.arch-repeat {
    position: absolute;
    right: -28px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: var(--color-gray);
}

.arch-embed {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.arch-embed-box {
    padding: 6px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    font-size: 10px;
}

.arch-embed-box.pos {
    background: #ede7f6;
    border-color: #b39ddb;
}

.arch-input-label {
    font-size: 11px;
    color: var(--color-gray);
    margin-top: 8px;
}

.arch-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: center;
    margin-top: 60px;
}

.arch-arrow svg {
    width: 50px;
    height: 20px;
}

.arch-arrow-label {
    font-size: 10px;
    color: var(--color-gray);
}

/* ============================================
   POSITIONAL ENCODING VIZ
   ============================================ */
.pos-viz {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pos-grid {
    display: grid;
    grid-template-columns: repeat(32, 1fr);
    gap: 1px;
    background: #ddd;
}

.pos-cell {
    aspect-ratio: 1;
}

.pos-axis-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-heading);
    font-size: 11px;
    color: var(--color-gray);
}

/* ============================================
   INTERACTIVE POSITIONAL ENCODING
   ============================================ */
.pe-interactive-wrapper {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 24px;
    margin: 24px 0;
}

.pe-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.pe-slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pe-slider-group label {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.pe-slider-group label span {
    display: inline-block;
    min-width: 24px;
    text-align: center;
    color: var(--color-orange);
    font-weight: 700;
}

.pe-slider-group input[type="range"] {
    width: 200px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

.pe-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-orange);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pe-slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-orange);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pe-info {
    display: flex;
    gap: 16px;
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-gray);
}

.pe-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pe-dot {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.pe-dot.pe-sin {
    background: var(--color-orange);
}

.pe-dot.pe-cos {
    background: var(--color-blue);
}

.pe-main {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.pe-grid-container {
    flex: 1;
    min-width: 280px;
}

.pe-grid-label,
.pe-wave-label {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pe-wave-label span {
    color: var(--color-orange);
    font-weight: 700;
}

.pe-grid {
    display: grid;
    gap: 1px;
    background: #ccc;
    border-radius: 4px;
    overflow: hidden;
}

.pe-cell {
    aspect-ratio: 1;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.pe-cell:hover {
    transform: scale(1.5);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.pe-cell-selected {
    outline: 2px solid var(--color-orange);
    outline-offset: -1px;
    z-index: 5;
}

.pe-grid-axes,
.pe-wave-axes {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-heading);
    font-size: 10px;
    color: var(--color-gray-light);
    margin-top: 6px;
}

.pe-wave-container {
    flex: 1;
    min-width: 280px;
}

#pe-wave-canvas {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 4px;
}

.pe-values {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.pe-values-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.pe-value-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    min-width: 80px;
}

.pe-value-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-gray);
    margin-bottom: 4px;
}

.pe-value-num {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
}

.pe-val-sin .pe-value-num {
    color: var(--color-orange);
}

.pe-val-cos .pe-value-num {
    color: var(--color-blue);
}

/* ============================================
   FOOTER & REFERENCES
   ============================================ */
.d-bibliography {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.d-bibliography h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.d-bibliography ol {
    font-size: 14px;
    padding-left: 20px;
}

.d-bibliography li {
    margin-bottom: 12px;
    color: var(--color-gray);
}

.d-bibliography a {
    color: var(--color-link);
}

.d-appendix {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-gray);
}

.d-appendix a {
    color: var(--color-link);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 700px) {
    .d-title {
        font-size: 28px;
    }
    
    .d-subtitle {
        font-size: 16px;
    }
    
    .d-article h2 {
        font-size: 20px;
    }
    
    .arch-diagram {
        flex-direction: column;
        gap: 24px;
    }
    
    .arch-arrow {
        transform: rotate(90deg);
        margin: 0;
    }
}

/* ============================================
   CODE & MONO
   ============================================ */
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: #f5f5f5;
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

pre {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: #f5f5f5;
    padding: 16px;
    overflow-x: auto;
    border-radius: 4px;
    line-height: 1.5;
}

pre code {
    background: none;
    padding: 0;
}

/* ============================================
   KATEX
   ============================================ */
.katex {
    font-size: 1.1em;
}

.katex-display {
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

/* ============================================
   SITE HEADER (for all pages)
   ============================================ */
.site-header {
    border-bottom: 1px solid #e0e0e0;
    padding: 16px 0;
    margin-bottom: 32px;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--color-gray);
    display: flex;
    align-items: center;
    transition: border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
    border-color: var(--color-gray);
    color: var(--color-text);
}

.theme-icon-sun  { display: block; }
.theme-icon-moon { display: none; }

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.l-page {
    max-width: var(--l-page);
    margin: 0 auto;
    padding: 0 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.logo:hover {
    color: var(--color-text);
}

.logo-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* ============================================
   HOMEPAGE - POSTS LIST
   ============================================ */
.homepage {
    background: var(--color-bg);
}

/* Three-column index layout */
.index-columns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 36px;
    padding-top: 32px;
    padding-bottom: 64px;
    max-width: 1280px;
}

.index-column {
    min-width: 0;
}

.column-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--color-border);
}

.column-header h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--color-text);
}

.ml-column .column-header {
    border-bottom-color: #1565c0;
}

.dev-column .column-header {
    border-bottom-color: #e65100;
}

.business-column .column-header {
    border-bottom-color: #7b1fa2;
}

.column-desc {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-gray);
    margin: 0;
}

.empty-column {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-gray-light);
    font-style: italic;
}

/* Two-column post cards - more compact */
.index-column .post-preview {
    margin-bottom: 32px;
}

.index-column .post-link {
    flex-direction: column;
    gap: 12px;
}

.index-column .post-thumbnail {
    width: 100%;
    height: 140px;
}

.index-column .post-title {
    font-size: 17px;
}

.index-column .post-authors {
    font-size: 13px;
}

.index-column .post-abstract {
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Responsive: stack columns on tablet/mobile */
@media (max-width: 960px) {
    .index-columns {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }
}

@media (max-width: 640px) {
    .index-columns {
        grid-template-columns: 1fr;
        gap: 48px;
    }
}

.posts-list {
    padding-top: 16px;
    padding-bottom: 64px;
}

.post-preview {
    margin-bottom: 48px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.post-date {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-gray);
}

.post-tags {
    display: flex;
    gap: 8px;
}

.tag {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--tag-bg);
    color: var(--tag-color);
}

.tag.explainer { --tag-bg: var(--color-blue-bg); --tag-color: var(--color-blue-dark); }
.tag.peer-reviewed { --tag-bg: var(--color-green-bg); --tag-color: var(--color-green-dark); }
.tag.editorial { --tag-bg: var(--color-orange-bg); --tag-color: #e65100; }
.tag.thread { --tag-bg: #f3e5f5; --tag-color: #7b1fa2; }

.post-link {
    display: flex;
    gap: 24px;
    text-decoration: none;
    color: inherit;
}

.post-link:hover .post-title {
    color: var(--color-link);
}

.post-thumbnail {
    flex-shrink: 0;
    width: 200px;
    height: 120px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
}

.thumbnail-svg {
    width: 100%;
    height: 100%;
}

.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-content {
    flex: 1;
    min-width: 0;
}

.post-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 8px 0;
    color: var(--color-text);
    transition: color 0.15s;
}

.post-authors {
    font-family: var(--font-heading);
    font-size: 14px;
    color: var(--color-gray);
    margin: 0 0 8px 0;
}

.post-abstract {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-gray);
    margin: 0;
}

/* Responsive posts */
@media (max-width: 600px) {
    .post-link {
        flex-direction: column;
    }
    
    .post-thumbnail {
        width: 100%;
        height: 160px;
    }
}

/* ============================================
   SITE FOOTER
   ============================================ */
.site-footer {
    border-top: 1px solid #e0e0e0;
    padding: 32px 24px;
    text-align: center;
}

.site-footer p {
    font-family: var(--font-heading);
    font-size: 14px;
    color: var(--color-gray);
    margin: 0 0 16px 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.footer-links a {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-gray);
    text-decoration: none;
}

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

/* ============================================
   BIO / PORTFOLIO PAGE
   ============================================ */

/* Hero */
.bio-hero {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    padding-top: 32px;
    max-width: calc(var(--toc-width) + var(--content-width) + 24px);
    margin-left: auto;
    margin-right: auto;
}

.bio-avatar-wrap {
    flex-shrink: 0;
    width: 108px;
    height: 108px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    background: #f7f7f7;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.bio-avatar {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bio-info {
    flex: 1;
    min-width: 0;
    padding-top: 6px;
}

.bio-name {
    font-family: var(--font-heading);
    font-size: 30px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 2px 0;
    letter-spacing: -0.02em;
}

.bio-tagline {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--color-gray);
    margin: 0 0 10px 0;
}

.bio-desc {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text-light);
    margin: 0 0 18px 0;
    max-width: 520px;
}

/* Bio action buttons */
.bio-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bio-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    transition: opacity 0.15s;
}

.bio-btn:hover {
    opacity: 0.72;
}

.bio-btn-primary {
    background: var(--color-text);
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
}

.bio-btn-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 9px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 600;
    min-width: 17px;
    height: 17px;
}

.bio-btn-icon {
    width: 36px;
    height: 36px;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 6px;
    color: var(--color-text);
}

/* Timeline */
.bio-timeline {
    border-top: 1px solid var(--color-border);
    padding-top: 40px;
    padding-bottom: 64px;
    margin-top: 36px;
    max-width: calc(var(--toc-width) + var(--content-width) + 24px);
    margin-left: auto;
    margin-right: auto;
}

.timeline-entry {
    display: grid;
    grid-template-columns: 48px 16px 1fr;
    gap: 0 18px;
}

.timeline-left {
    text-align: right;
    padding-top: 3px;
}

.timeline-year {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-gray);
}

.timeline-mid {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.timeline-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--color-text);
    flex-shrink: 0;
    margin-top: 2px;
}

.timeline-line {
    width: 1px;
    flex: 1;
    background: var(--color-border);
    min-height: 24px;
}

.timeline-entry:last-child .timeline-line {
    display: none;
}

.timeline-content {
    padding-bottom: 36px;
}

.timeline-entry:last-child .timeline-content {
    padding-bottom: 0;
}

/* Company badge + role */
.timeline-header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.timeline-badge {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--color-border);
}

/* Section headings (Experience / Education) */
.timeline-section-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 20px 0;
}

/* Education degree line */
.timeline-edu-degree {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-light);
    margin: 2px 0 0 0;
}

/* Skill tags */
.timeline-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    margin-left: 54px;
}

.timeline-skill-tag {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-gray);
    background: #f4f4f4;
    border: 1px solid var(--color-border);
    padding: 3px 10px;
    border-radius: 14px;
}

.timeline-role {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 2px 0;
}

.timeline-company {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-gray);
    margin: 0;
}

/* Achievements list */
.timeline-desc {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text-light);
    margin: 0;
    margin-left: 54px;
}

.timeline-achievements {
    list-style: none;
    margin: 0;
    padding: 0;
    margin-left: 54px;
}

.timeline-achievements li {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text-light);
    margin-bottom: 6px;
    padding-left: 14px;
    position: relative;
}

.timeline-achievements li::before {
    content: '·';
    position: absolute;
    left: 0;
    color: var(--color-gray-light);
    font-weight: 700;
}

/* Bio responsive */
@media (max-width: 600px) {
    .bio-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .bio-desc {
        max-width: none;
    }

    .bio-links {
        justify-content: center;
    }

    .timeline-entry {
        grid-template-columns: 1fr;
        gap: 4px 0;
    }

    .timeline-left {
        text-align: left;
    }

    .timeline-mid {
        display: none;
    }

    .timeline-achievements,
    .timeline-desc,
    .timeline-skills {
        margin-left: 0;
    }
}

/* ============================================
   WORKFLOW LOOP DIAGRAM (claude-code post)
   ============================================ */
.wf-loop {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    padding: 20px 8px 8px;
    width: 100%;
}

.wf-phase {
    flex: 1;
    max-width: 170px;
    min-width: 0;
}

.wf-phase-header {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 7px 10px;
    text-align: center;
    border-radius: 4px 4px 0 0;
}

.wf-phase.wf-plan .wf-phase-header {
    background: var(--color-orange-bg);
    color: var(--color-orange-dark);
    border: 1px solid var(--color-orange);
    border-bottom: none;
}

.wf-phase.wf-execute .wf-phase-header {
    background: var(--color-blue-bg);
    color: var(--color-blue-dark);
    border: 1px solid var(--color-blue);
    border-bottom: none;
}

.wf-phase.wf-verify .wf-phase-header {
    background: var(--color-green-bg);
    color: var(--color-green-dark);
    border: 1px solid #4caf50;
    border-bottom: none;
}

.wf-phase-body {
    padding: 10px 12px;
    border-radius: 0 0 4px 4px;
}

.wf-phase.wf-plan .wf-phase-body {
    border: 1px solid var(--color-orange);
    background: #fffbf5;
}

.wf-phase.wf-execute .wf-phase-body {
    border: 1px solid var(--color-blue);
    background: #f0f8ff;
}

.wf-phase.wf-verify .wf-phase-body {
    border: 1px solid #4caf50;
    background: #f2faf2;
}

.wf-step {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-text-light);
    padding: 5px 0;
    line-height: 1.4;
}

.wf-step + .wf-step {
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.wf-arrow {
    font-size: 18px;
    color: var(--color-gray);
    align-self: center;
    padding-top: 28px;
    flex-shrink: 0;
}

.wf-feedback {
    text-align: center;
    margin-top: 10px;
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-gray-light);
    font-style: italic;
}

/* ============================================
   BERT-SPECIFIC STYLES
   ============================================ */

/* Example box */
.d-example-box {
    background: #f8f9fa;
    border-left: 3px solid var(--color-gray);
    padding: 16px 20px;
    margin: 20px 0;
    font-style: italic;
    font-size: 16px;
}

/* BERT Masking Visualization */
.bert-masking-viz {
    padding: 20px;
}

.masking-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.masking-label {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    width: 70px;
    color: var(--color-gray);
}

.masking-tokens {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.masking-tokens .token {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 6px 10px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.masking-tokens .token.masked {
    background: var(--color-orange-bg);
    border-color: var(--color-orange);
    color: var(--color-orange);
    font-weight: 600;
}

.masking-tokens .token.random {
    background: #fce4ec;
    border-color: #c2185b;
    color: #c2185b;
}

.masking-tokens .token.unchanged {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #388e3c;
}

.masking-tokens .token.target {
    background: var(--color-blue-bg);
    border-color: var(--color-blue);
    color: var(--color-blue);
    font-weight: 500;
}

.masking-legend {
    display: flex;
    gap: 20px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-gray);
}

.legend-box {
    width: 14px;
    height: 14px;
    min-width: 14px;
    min-height: 14px;
    border-radius: 3px;
    border: 2px solid #ccc;
    display: inline-block;
    flex-shrink: 0;
}

.legend-box.masked {
    background: #ffe0b2;
    border-color: var(--color-orange);
}

.legend-box.random {
    background: #f8bbd9;
    border-color: #c2185b;
}

.legend-box.unchanged {
    background: #c8e6c9;
    border-color: #4caf50;
}

.legend-box.special {
    background: #e1bee7;
    border-color: #7b1fa2;
}

.legend-box.segment-a {
    background: #bbdefb;
    border-color: #1976d2;
}

.legend-box.segment-b {
    background: #ffe082;
    border-color: #ffa000;
}

/* BERT Input Visualization */
.bert-input-viz {
    padding: 20px;
}

.input-sequence {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.input-sequence .token {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 4px;
}

.input-sequence .token.special {
    background: #f3e5f5;
    border: 1px solid #7b1fa2;
    color: #7b1fa2;
    font-weight: 600;
}

.input-sequence .token.segment-a {
    background: #e3f2fd;
    border: 1px solid #1976d2;
    color: #1565c0;
}

.input-sequence .token.segment-b {
    background: #fff8e1;
    border: 1px solid #ffa000;
    color: #e65100;
}

.input-legend {
    display: flex;
    gap: 20px;
}

/* BERT Embedding Visualization */
.bert-embedding-viz {
    padding: 16px;
    overflow-x: auto;
}

.embed-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.embed-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    width: 60px;
    flex-shrink: 0;
}

.embed-label.c-query { color: var(--color-query); }
.embed-label.c-key { color: var(--color-key); }
.embed-label.c-value { color: var(--color-value); }

.embed-tokens {
    display: flex;
    gap: 4px;
}

.embed-tokens .token {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 4px 6px;
    background: #f5f5f5;
    border-radius: 3px;
    min-width: 36px;
    text-align: center;
}

.embed-box {
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 4px 6px;
    border-radius: 3px;
    min-width: 36px;
    text-align: center;
    border: 1px solid;
}

.embed-box.query {
    background: var(--color-orange-bg);
    border-color: var(--color-orange);
    color: #c66a2f;
}

.embed-box.key {
    background: var(--color-blue-bg);
    border-color: var(--color-blue);
    color: #3d7a8c;
}

.embed-box.key-b {
    background: #fff8e1;
    border-color: #ffa000;
    color: #e65100;
}

.embed-box.value {
    background: #f3e5f5;
    border-color: #7b68a4;
    color: #5e4a7a;
}

/* Fine-tuning Grid */
.finetuning-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 16px;
}

@media (max-width: 700px) {
    .finetuning-grid {
        grid-template-columns: 1fr;
    }
}

.finetune-task {
    text-align: center;
    padding: 16px;
    background: #fafafa;
    border-radius: 8px;
}

.finetune-title {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.finetune-example {
    font-size: 11px;
    color: var(--color-gray);
    margin-bottom: 16px;
}

.finetune-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.finetune-output {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 6px 12px;
    background: var(--color-green-bg);
    border: 1px solid #4caf50;
    border-radius: 4px;
    color: var(--color-green-dark);
}

.finetune-output-multi {
    display: flex;
    gap: 4px;
}

.finetune-output-multi span {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 4px 8px;
    background: var(--color-green-bg);
    border: 1px solid #4caf50;
    border-radius: 4px;
    color: var(--color-green-dark);
}

.finetune-arrow {
    font-size: 14px;
    color: var(--color-gray);
}

.finetune-bert {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--color-blue-bg) 0%, #bbdefb 100%);
    border: 1px solid #64b5f6;
    border-radius: 6px;
    color: var(--color-blue-dark);
}

.finetune-input {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.finetune-input .token {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 4px 6px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
}

.finetune-input .token.special {
    background: #f3e5f5;
    border-color: #7b1fa2;
    color: #7b1fa2;
}

/* ============================================
   VIT REGISTERS - Artifact Location Viz
   ============================================ */
.artifact-location-viz {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background: #fafafa;
    border-radius: 8px;
}

.location-row {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
}

.location-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text-light);
}

.location-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.location-icon.high-similarity {
    background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
    border: 1px solid #ccc;
}

.location-icon.low-similarity {
    background: linear-gradient(135deg, #4a90a4 0%, #e07b39 50%, #7cb342 100%);
    border: 1px solid #888;
}

.location-icon.high-norm {
    background: #ef5350;
    border: 2px solid #c62828;
    box-shadow: 0 0 8px rgba(239, 83, 80, 0.5);
}

.location-icon.normal {
    background: #66bb6a;
    border: 1px solid #43a047;
}

.location-arrow {
    font-size: 20px;
    color: var(--color-gray);
}

/* ============================================
   VIT REGISTERS - Info Comparison Bars
   ============================================ */
.info-comparison {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px;
}

.info-bar-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.info-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-bar {
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 500;
    color: white;
    min-width: 120px;
}

.info-bar.normal {
    background: linear-gradient(90deg, #66bb6a 0%, #43a047 100%);
}

.info-bar.outlier {
    background: linear-gradient(90deg, #ef5350 0%, #c62828 100%);
}

/* ============================================
   VIT REGISTERS - Register Diagram
   ============================================ */
.register-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: #fafafa;
    border-radius: 8px;
}

.register-stage {
    text-align: center;
}

.stage-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.token-sequence {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.register-diagram .token {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid;
}

.register-diagram .token.cls {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

.register-diagram .token.reg {
    background: #fff3e0;
    border-color: #ff9800;
    color: #e65100;
}

.register-diagram .token.patch {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1565c0;
}

.register-diagram .token.discarded {
    opacity: 0.4;
    text-decoration: line-through;
}

.register-diagram .token.used {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.register-arrow {
    font-size: 14px;
    color: var(--color-gray);
    padding: 8px 0;
}

.register-legend {
    display: flex;
    gap: 24px;
    margin-top: 8px;
}

.register-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-gray);
}

.register-legend .box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #ccc;
}

.register-legend .box.used {
    background: #e3f2fd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.register-legend .box.discarded {
    background: #f5f5f5;
    opacity: 0.5;
}

/* ============================================
   VIT REGISTERS - Norm Distribution Interactive
   ============================================ */
.norm-explorer-wrapper {
    background: #fafafa;
    border-radius: 8px;
    padding: 20px;
}

#norm-distribution-interactive {
    width: 100%;
}

.norm-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.norm-slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.norm-slider-group label {
    font-size: 13px;
    color: var(--color-text-light);
}

.norm-slider-group input[type="range"] {
    width: 200px;
}

.norm-threshold-value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--color-red);
    min-width: 40px;
}

.norm-stats {
    display: flex;
    gap: 24px;
    font-size: 13px;
}

.norm-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.norm-stat .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.norm-stat .dot.normal {
    background: #66bb6a;
}

.norm-stat .dot.outlier {
    background: #ef5350;
}

.norm-chart-container {
    position: relative;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 10px;
}

#norm-chart-canvas {
    width: 100%;
    height: 200px;
}

/* Legend dots for equation panels */
.d-legend-dot.cls {
    background: #4caf50;
}

.d-legend-dot.register {
    background: #ff9800;
}

.d-legend-dot.patch {
    background: #2196f3;
}

/* ============================================
   FLASHATTENTION STYLES
   ============================================ */

/* Memory Flow Diagram */
.mem-flow-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 10px;
    flex-wrap: wrap;
}

.mem-flow-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.mem-flow-box {
    padding: 14px 20px;
    border-radius: 8px;
    text-align: center;
    min-width: 90px;
}

.mem-flow-box.hbm {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #2196f3;
}

.mem-flow-box.sram {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #4caf50;
}

.mem-flow-box.compute {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border: 2px solid #ff9800;
}

.mem-flow-label {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
}

.mem-flow-spec {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-gray);
}

.mem-flow-desc {
    font-size: 11px;
    color: var(--color-gray-light);
    text-align: center;
}

.mem-flow-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 4px;
}

.mem-flow-bw {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
}

.mem-flow-icon {
    font-size: 20px;
    line-height: 1;
}

.mem-flow-note {
    font-size: 10px;
}

.mem-flow-arrow.slow .mem-flow-bw,
.mem-flow-arrow.slow .mem-flow-icon {
    color: var(--color-red);
}

.mem-flow-arrow.slow .mem-flow-note {
    color: var(--color-red);
    font-weight: 600;
}

.mem-flow-arrow.fast .mem-flow-bw,
.mem-flow-arrow.fast .mem-flow-icon {
    color: var(--color-green-dark);
}

.mem-flow-arrow.fast .mem-flow-note {
    color: var(--color-green-dark);
}

@media (max-width: 500px) {
    .mem-flow-diagram {
        flex-direction: column;
    }
    .mem-flow-arrow {
        transform: rotate(90deg);
    }
}

/* Algorithm Steps */
.algo-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 20px 0;
}

.algo-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #e0e0e0;
}

.algo-step.bad {
    background: #fff5f5;
    border-left-color: #ef5350;
}

.step-num {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.algo-step.bad .step-num {
    background: #ffcdd2;
    color: var(--color-red);
}

.step-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.mem-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}

.mem-tag.hbm {
    background: #e8eaf6;
    color: #3949ab;
}

.mem-tag.compute {
    background: var(--color-green-bg);
    color: var(--color-green-dark);
}

/* Tiling Interactive */
#tiling-interactive {
    padding: 20px;
    background: #fafafa;
    border-radius: 8px;
}

.tiling-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tiling-slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tiling-slider-group label {
    font-size: 13px;
    color: var(--color-text-light);
}

.tiling-slider-group input[type="range"] {
    width: 200px;
}

.tiling-play-btn {
    padding: 6px 16px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 13px;
}

.tiling-play-btn:hover {
    background: #f0f0f0;
}

.tiling-step-label {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-link);
    min-width: 80px;
}

.tiling-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 600px) {
    .tiling-comparison {
        grid-template-columns: 1fr;
    }
}

.tiling-panel {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
}

.tiling-panel-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    text-align: center;
}

.tiling-panel-title.standard {
    color: var(--color-red);
}

.tiling-panel-title.flash {
    color: var(--color-green-dark);
}

.matrix-viz {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.matrix-grid {
    display: grid;
    gap: 2px;
}

.matrix-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    transition: background-color 0.15s, transform 0.15s;
}

.matrix-cell.empty {
    background: #f0f0f0;
}

.matrix-cell.computed {
    background: #ffcdd2;
}

.matrix-cell.in-hbm {
    background: #ef5350;
}

.matrix-cell.in-sram {
    background: #66bb6a;
    transform: scale(1.1);
}

.matrix-cell.current {
    background: #26a69a;
    transform: scale(1.2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.tiling-stats {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-gray);
    text-align: center;
}

.tiling-stats .bad {
    color: var(--color-red);
}

.tiling-stats .good {
    color: var(--color-green-dark);
}

.tiling-description {
    margin-top: 16px;
    padding: 12px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--color-text-light);
    text-align: center;
}

/* Algorithm Box */
.algo-box {
    background: #f8f9fa;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.algo-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.algo-box ol {
    margin: 0;
    padding-left: 20px;
}

.algo-box li {
    margin-bottom: 8px;
    font-size: 14px;
}

/* Takeaways */
.takeaways {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 24px 0;
}

.takeaway {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: #f0f7ff;
    border-radius: 8px;
    border-left: 4px solid #1976d2;
}

.takeaway-num {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: #1976d2;
    flex-shrink: 0;
}

.takeaway-content {
    font-size: 14px;
    line-height: 1.6;
}

/* FlashAttention Algorithm Interactive */
#flash-algorithm-interactive {
    background: #fafafa;
    border-radius: 8px;
    padding: 20px;
}

.flash-algo-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.flash-algo-btn {
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    font-family: var(--font-heading);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.flash-algo-btn:hover {
    background: #f0f0f0;
}

.flash-algo-status {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-gray);
    padding: 4px 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.flash-algo-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flash-algo-hbm {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #2196f3;
    border-radius: 8px;
    padding: 12px;
}

.flash-algo-hbm-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    color: var(--color-blue-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.flash-algo-matrices {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.flash-algo-matrix-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.flash-algo-matrix-label {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
}

.flash-algo-matrix {
    display: flex;
    gap: 3px;
    padding: 6px;
    background: white;
    border-radius: 4px;
    border: 1px solid #90caf9;
}

.flash-algo-block {
    width: 28px;
    height: 28px;
    border-radius: 3px;
    background: #e0e0e0;
    border: 1px solid #bdbdbd;
    transition: all 0.2s;
}

.flash-algo-block.loading {
    background: #fff59d;
    border-color: #fbc02d;
    animation: pulse-yellow 0.5s ease-in-out;
}

.flash-algo-block.in-sram {
    background: #a5d6a7;
    border-color: #4caf50;
}

.flash-algo-block.active {
    background: #81c784;
    border-color: #388e3c;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

.flash-algo-block.computed {
    background: #90caf9;
    border-color: #1976d2;
}

@keyframes pulse-yellow {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.flash-algo-transfer {
    display: flex;
    justify-content: center;
    min-height: 30px;
}

.transfer-arrow {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 4px;
    animation: bounce 0.4s ease-in-out infinite alternate;
}

.transfer-arrow.down {
    color: #e65100;
    background: #fff3e0;
}

.transfer-arrow.up {
    color: #1565c0;
    background: #e3f2fd;
}

@keyframes bounce {
    0% { transform: translateY(-2px); }
    100% { transform: translateY(2px); }
}

.flash-algo-sram {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #4caf50;
    border-radius: 8px;
    padding: 12px;
}

.flash-algo-sram-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    color: var(--color-green-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.flash-algo-sram-content {
    display: flex;
    gap: 8px;
    justify-content: center;
    min-height: 40px;
    align-items: center;
    flex-wrap: wrap;
}

.sram-empty {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #81c784;
    font-style: italic;
}

.sram-block {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 4px;
    background: white;
    border: 2px solid #81c784;
    color: var(--color-green-dark);
}

.sram-block.loading {
    border-color: #fbc02d;
    background: #fffde7;
    color: #f57f17;
}

.sram-block.active {
    border-color: #388e3c;
    background: #e8f5e9;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.3);
}

.sram-block.fading {
    opacity: 0.6;
    border-style: dashed;
}

.flash-algo-compute {
    margin-top: 10px;
    min-height: 32px;
    display: flex;
    justify-content: center;
}

.compute-op {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 6px 12px;
    background: white;
    border-radius: 4px;
    border: 1px solid #81c784;
    display: flex;
    align-items: center;
    gap: 8px;
}

.compute-op.step2 {
    background: #f1f8e9;
}

.compute-op.done {
    color: var(--color-green-dark);
    border-color: #4caf50;
}

.compute-done {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--color-green-dark);
    font-weight: 600;
}

.compute-formula {
    color: var(--color-text);
}

.compute-arrow {
    color: #66bb6a;
}

.flash-algo-loops {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.flash-algo-loop {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
}

.flash-algo-loop.outer-loop {
    background: #fff3e0;
    border: 1px solid #ff9800;
}

.flash-algo-loop.inner-loop {
    background: #e8eaf6;
    border: 1px solid #5c6bc0;
}

.loop-label {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--color-text);
}

.loop-value {
    font-family: var(--font-mono);
    font-weight: 700;
}

.outer-loop .loop-value {
    color: #e65100;
}

.inner-loop .loop-value {
    color: #3949ab;
}

.loop-desc {
    color: var(--color-gray);
    font-size: 11px;
}

/* ============================================
   COMPENSATION CHARTS & INTERACTIVE
   ============================================ */

/* Static chart canvases */
.comp-chart-canvas {
    width: 100%;
    height: 280px;
    display: block;
}

.comp-chart-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 24px 0;
}

@media (max-width: 600px) {
    .comp-chart-pair {
        grid-template-columns: 1fr;
    }
}

.comp-chart-pair canvas {
    width: 100%;
    height: 240px;
}

.comp-chart-label {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
    color: var(--color-text);
}

/* Tier Explorer Interactive */
#comp-tier-explorer {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 24px;
    margin: 24px 0;
}

.comp-explorer-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.comp-select-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comp-select-group label {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.comp-select-group select {
    font-family: var(--font-heading);
    font-size: 13px;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

.comp-explorer-legend {
    display: flex;
    gap: 14px;
    margin-left: auto;
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-gray);
}

.comp-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.comp-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.comp-canvas-wrap {
    position: relative;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 16px;
}

.comp-canvas-wrap canvas {
    width: 100%;
    height: 280px;
    display: block;
}

.comp-tooltip {
    display: none;
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
}

.comp-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 500px) {
    .comp-stats-row {
        grid-template-columns: 1fr;
    }
}

.comp-stat-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 14px;
    text-align: center;
}

.comp-stat-tier {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.comp-stat-name {
    font-family: var(--font-heading);
    font-size: 11px;
    color: var(--color-gray);
    margin-bottom: 8px;
}

.comp-stat-median {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.comp-stat-range {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-gray);
    margin-bottom: 4px;
}

.comp-stat-count {
    font-family: var(--font-heading);
    font-size: 11px;
    color: var(--color-gray-light);
}

/* Comparison table for US vs Canada */
.comp-comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-heading);
    font-size: 14px;
    margin: 16px 0;
}

.comp-comparison-table th,
.comp-comparison-table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid #e0e0e0;
}

.comp-comparison-table th {
    font-weight: 600;
    color: var(--color-gray);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.comp-comparison-table th:first-child,
.comp-comparison-table td:first-child {
    text-align: left;
}

.comp-comparison-table .tier-label {
    font-weight: 600;
}

/* ============================================
   S&P 500 HISTORY CHARTS
   ============================================ */

.sp500-chart-wrap {
    position: relative;
    background: #fff;
    padding: 12px 8px 8px;
    border-radius: 4px;
    height: 420px;
}

.sp500-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 0 0 20px;
}

.sp500-stats-table th,
.sp500-stats-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.sp500-stats-table thead th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sp500-bull-header {
    color: #1b5e20;
    border-bottom: 3px solid #4caf50 !important;
}

.sp500-bear-header {
    color: #b71c1c;
    border-bottom: 3px solid #ef5350 !important;
}

.sp500-gain {
    color: #1b5e20;
    font-weight: 600;
}

.sp500-loss {
    color: #b71c1c;
    font-weight: 600;
}

@media (max-width: 600px) {
    .sp500-chart-wrap {
        height: 300px;
        padding: 8px 4px 4px;
    }

    .sp500-stats-table {
        font-size: 12px;
    }

    .sp500-stats-table th,
    .sp500-stats-table td {
        padding: 8px 8px;
    }
}
