:root {
    --bg: #050508;
    --surface: #0c0d14;
    --surface-card: #121420;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --champion: #10b981;
    --champion-glow: rgba(16, 185, 129, 0.1);
    --font-sans: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background-color: var(--bg); color: var(--text-primary); font-family: var(--font-sans); line-height: 1.7; -webkit-font-smoothing: antialiased; padding-bottom: 60px; }
#scroll-progress { position: fixed; top: 0; left: 0; height: 2px; background: var(--accent); z-index: 9999; transition: width 0.1s linear; width: 0%; }
.hero-section { max-width: 1200px; margin: 0 auto; padding: 80px 40px 40px 40px; position: relative; }
.hero-accent-blur { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 600px; height: 250px; background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, rgba(0,0,0,0) 70%); z-index: -1; pointer-events: none; }
.hero-meta { font-family: var(--font-mono); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 3px; color: var(--accent); margin-bottom: 20px; font-weight: 600; }
h1 { font-size: 3.5rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.04em; margin-bottom: 20px; max-width: 900px; background: linear-gradient(180deg, #ffffff 0%, #a5b4fc 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-subtitle { font-size: 1.25rem; color: var(--text-secondary); max-width: 700px; font-weight: 400; margin-bottom: 32px; }
.btn-group { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.btn-modern-primary { display: inline-flex; align-items: center; gap: 12px; background: var(--text-primary); color: var(--bg); padding: 16px 32px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 1.05rem; transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.btn-modern-primary i { font-size: 1.8rem; }
.btn-modern-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(255, 255, 255, 0.1); background: #ffffff; }
.main-layout { max-width: 1200px; margin: 0 auto; padding: 0 40px; }
.section { position: relative; padding: 50px 0; border-bottom: none; }
.section::after { content: ""; position: absolute; bottom: 0; left: 0; width: 0%; height: 1px; background: var(--border); transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.section.revealed::after { width: 100%; }
.section-collapsible { position: relative; display: block; }
.accordion-guide { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 30px 0 4px 0; padding: 14px 18px; border: 1px solid var(--border); border-radius: 18px; background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(255, 255, 255, 0.018) 42%, rgba(16, 185, 129, 0.05)); color: var(--text-secondary); overflow: hidden; }
.accordion-guide::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 16% 50%, rgba(99, 102, 241, 0.12), transparent 28%); pointer-events: none; }
.accordion-guide-main, .accordion-guide-hint { position: relative; z-index: 1; }
.accordion-guide-main { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-primary); }
.accordion-guide-main i { color: var(--accent); }
.accordion-guide-hint { font-size: 0.86rem; color: var(--text-secondary); }
.section-header { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 28px; cursor: pointer; user-select: none; padding: 18px 0 18px 24px; border-radius: 18px; isolation: isolate; transition: background 0.24s ease; }
.section-header::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 999px; background: linear-gradient(180deg, var(--accent), rgba(99, 102, 241, 0.18)); opacity: 0.72; box-shadow: 0 0 0 rgba(99, 102, 241, 0); transition: opacity 0.24s ease, box-shadow 0.24s ease; }
.section-header:hover, .section-header:focus-visible { background: linear-gradient(90deg, rgba(99, 102, 241, 0.075), rgba(255, 255, 255, 0.018) 62%, rgba(255, 255, 255, 0)); outline: none; }
.section-header:hover::before, .section-header:focus-visible::before, .section.expanded .section-header::before { opacity: 1; box-shadow: 0 0 28px rgba(99, 102, 241, 0.42); }
.section-header:hover .panel-header-content h2, .section-header:focus-visible .panel-header-content h2 { color: #ffffff; }
.section-header .chevron { position: relative; flex: 0 0 auto; width: 64px; height: 36px; display: inline-flex; align-items: center; justify-content: flex-start; padding: 3px; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 999px; background: rgba(255, 255, 255, 0.045); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35); transition: background 0.28s ease, border-color 0.28s ease, box-shadow 0.28s ease; }
.section-header .chevron::before { content: ""; width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(180deg, #ffffff, #cbd5e1); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); transform: translateX(0); transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), background 0.28s ease; }
.section-header .chevron::after { content: "OFF"; position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: 0.52rem; font-weight: 800; letter-spacing: 0.7px; color: rgba(255, 255, 255, 0.42); pointer-events: none; }
.section-header .chevron i, .section-header .chevron .accordion-action-text { display: none; }
.section-header:hover .chevron, .section-header:focus-visible .chevron { border-color: rgba(99, 102, 241, 0.35); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 28px rgba(99, 102, 241, 0.12); }
.section.expanded .section-header .chevron { background: linear-gradient(135deg, var(--accent), #818cf8); border-color: rgba(129, 140, 248, 0.58); box-shadow: 0 0 30px rgba(99, 102, 241, 0.22); }
.section.expanded .section-header .chevron::before { transform: translateX(28px); background: linear-gradient(180deg, #ffffff, #eef2ff); }
.section.expanded .section-header .chevron::after { content: "ON"; left: 10px; right: auto; color: rgba(255, 255, 255, 0.88); }
.section-body { overflow: hidden; max-height: 0; transition: max-height 0.56s cubic-bezier(0.16, 1, 0.3, 1); }
.section-body-inner { padding-top: 24px; padding-bottom: 10px; opacity: 0; transform: translateY(-6px); transition: opacity 0.28s ease 0.08s, transform 0.28s ease 0.08s; }
.section.expanded .section-body-inner { opacity: 1; transform: translateY(0); }
.panel-tag { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 10px; display: block; }
h2 { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 10px; transition: color 0.3s; }
.panel-desc { color: var(--text-secondary); font-size: 1rem; }
.metrics-strip { display: grid; grid-template-columns: repeat(5, 1fr); padding: 24px 0; border-bottom: 1px solid var(--border); }
.metric-block { padding: 0 20px; }
.metric-block:first-child { padding-left: 0; }
.metric-block:last-child { padding-right: 0; }
.metric-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.metric-value { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.04em; color: var(--text-primary); font-family: var(--font-sans); }
.metric-value.champion-color { color: var(--champion); }
.overview-text { color: var(--text-secondary); max-width: 900px; }
.dependency-list { display: flex; flex-direction: column; gap: 4px; }
.dependency-row { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.dependency-row:last-child { border-bottom: none; }
.dep-icon { font-size: 1.2rem; color: var(--text-primary); margin-top: 3px; width: 24px; text-align: center; }
.dependency-row strong { font-size: 1.05rem; font-weight: 600; display: block; margin-bottom: 4px; }
.dependency-row span { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }
.timeline-flow { position: relative; padding-left: 28px; }
.flow-node { position: relative; padding-bottom: 24px; display: flex; align-items: flex-start; gap: 18px; }
.flow-node:last-child { padding-bottom: 0; }
.flow-dot { position: absolute; left: -28px; top: 7px; width: 10px; height: 10px; background: var(--accent); border-radius: 50%; z-index: 1; }
.flow-node::before { content: ""; position: absolute; left: -24px; top: 22px; width: 1px; height: calc(100% - 12px); background: var(--border); }
.flow-node:last-child::before { display: none; }
.flow-content { display: flex; gap: 16px; }
.flow-step { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-muted); font-weight: 600; min-width: 24px; }
.flow-content strong { display: block; font-size: 1rem; font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
.flow-content span { font-size: 0.85rem; color: var(--text-secondary); }
.theory-split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.theory-block { background: var(--surface-card); border: 1px solid var(--border); border-radius: 14px; padding: 30px; transition: border-color 0.2s; }
.theory-block:hover { border-color: var(--border-hover); }
.theory-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.theory-title { font-size: 1.15rem; font-weight: 600; }
.theory-badge { font-family: var(--font-mono); font-size: 0.68rem; color: var(--accent); background: var(--accent-glow); padding: 4px 10px; border-radius: 4px; font-weight: 500; }
.theory-badge.champion-badge { color: var(--champion); background: var(--champion-glow); }
.theory-math-container { background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; overflow-x: auto; }
.theory-explanation { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.matrix-table-container { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-card); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9rem; }
th { background: rgba(255,255,255,0.02); color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; padding: 16px 24px; border-bottom: 1px solid var(--border); }
td { padding: 16px 24px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }
tr:hover td { color: var(--text-primary); background: rgba(255,255,255,0.01); }
td code { font-family: var(--font-mono); color: var(--accent); font-size: 0.85rem; background: var(--accent-glow); padding: 3px 8px; border-radius: 4px; }
.taxonomy-tag { font-size: 0.75rem; font-weight: 500; color: var(--text-primary); background: rgba(255,255,255,0.06); padding: 4px 10px; border-radius: 4px; display: inline-block; }
.taxonomy-tag.target-style { background: var(--champion-glow); color: var(--champion); font-weight: 600; }
.target-row-highlight td { background: rgba(16,185,129,0.02); }
.terminal-panel { background: #07080d; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.terminal-header { background: rgba(255,255,255,0.02); border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; }
.terminal-dots { display: flex; gap: 6px; }
.terminal-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.terminal-title { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }
.terminal-body { padding: 30px; overflow-x: auto; font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.65; color: #cbd5e1; }
.code-comment { color: #475569; font-style: italic; }
.code-keyword { color: #f43f5e; font-weight: 500; }
.code-fn { color: #38bdf8; }
.code-str { color: #10b981; }
.code-num { color: #fbbf24; }
.viz-display-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; justify-content: center; }
.viz-wrapper-card { background: var(--surface-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); will-change: transform; }
.viz-wrapper-card:hover { transform: translateY(-8px); box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1); }
.viz-wrapper-card img { width: 100%; height: auto; max-height: 280px; object-fit: contain; background: #0a0b10; transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
.viz-wrapper-card:hover img { transform: scale(1.02); }
.viz-meta-text { position: relative; z-index: 2; background: var(--surface-card); padding: 15px; font-size: 0.88rem; color: var(--text-secondary); text-align: center; font-weight: 600; border-top: 1px solid var(--border); }
.lightbox-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); display: none; z-index: 10000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(10px); }
.lightbox-overlay.active { display: flex; }
.lightbox-wrapper { position: relative; max-width: 90%; max-height: 90%; }
.lightbox-wrapper img { max-width: 100%; max-height: 90vh; border-radius: 8px; box-shadow: 0 24px 48px rgba(0,0,0,0.8); }
.lightbox-close { position: absolute; top: -40px; right: 0; color: white; font-size: 1.5rem; cursor: pointer; }
.engine-insights-stack { display: flex; flex-direction: column; gap: 4px; margin-bottom: 32px; }
.insight-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.insight-row:last-child { border-bottom: none; }
.insight-row.rank-leader { border-bottom-color: rgba(16,185,129,0.25); }
.insight-left-meta { display: flex; align-items: center; gap: 20px; }
.insight-rank-index { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 700; color: var(--text-muted); min-width: 76px; width: auto; flex: 0 0 76px; }
.rank-leader .insight-rank-index { color: var(--champion); }
.insight-model-identity strong { display: block; font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.insight-model-identity span { font-size: 0.85rem; color: var(--text-secondary); }
.insight-score-metrics { text-align: right; display: flex; gap: 32px; }
.insight-score-item { display: flex; flex-direction: column; align-items: flex-end; }
.insight-score-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
.insight-score-value { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }
.insight-score-value.accuracy-highlight { color: var(--champion); }
.insight-score-value.loss-highlight { color: var(--champion); }
.executive-summary-box { background: transparent; border-left: 2px solid var(--border); padding: 16px 24px; font-size: 0.92rem; color: var(--text-secondary); }
.executive-summary-box strong { color: var(--text-primary); }
.synthesis-gradient-box { background: transparent; border-left: 4px solid var(--champion); padding: 24px 0 24px 24px; }
.synthesis-gradient-box p { margin-bottom: 12px; font-size: 0.95rem; color: var(--text-secondary); }
.synthesis-gradient-box p:last-child { margin-bottom: 0; }
.synthesis-gradient-box strong { color: var(--text-primary); }
.portfolio-footer-gate { display: flex; justify-content: center; padding: 40px 0; margin-top: 40px; border-top: 1px solid var(--border); }
.contact-icons { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.icon-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text-muted); font-size: 1.25rem; transition: color 0.2s ease, transform 0.2s ease; }
.icon-link:hover { color: var(--accent); transform: translateY(-2px); }
.editorial-credits { text-align: center; margin-top: 40px; font-size: 0.8rem; font-family: var(--font-mono); color: var(--text-muted); letter-spacing: 0.5px; }
.stagger-child { opacity: 0; transform: translateY(20px); transition: opacity 0.55s ease, transform 0.55s ease; }
.stagger-child.revealed { opacity: 1; transform: translateY(0); }
@media (max-width: 1024px) { .metrics-strip { grid-template-columns: repeat(2, 1fr); gap: 16px; } .theory-split { grid-template-columns: 1fr; } h1 { font-size: 2.5rem; } .section { padding: 40px 0; } }
@media (max-width: 760px) { .accordion-guide { align-items: flex-start; flex-direction: column; gap: 6px; margin-top: 24px; padding: 14px 16px; } .accordion-guide-hint { font-size: 0.82rem; } .section-header { grid-template-columns: 1fr auto; gap: 14px; padding: 18px 0 18px 18px; } .section-header .chevron { width: 58px; height: 34px; } .section-header .chevron::before { width: 26px; height: 26px; } .section.expanded .section-header .chevron::before { transform: translateX(24px); } .viz-display-grid { grid-template-columns: 1fr; } .insight-left-meta { flex-direction: column; gap: 4px; } .insight-score-metrics { flex-direction: column; gap: 8px; align-items: flex-end; } }
@media (max-width: 640px) { .metrics-strip { grid-template-columns: 1fr; } h1 { font-size: 2.2rem; } .hero-section { padding: 60px 20px 30px 20px; } .main-layout { padding: 0 20px; } .section { padding: 32px 0; } }
@media (prefers-reduced-motion: reduce) { .section-collapsible, .section-header, .section-header::before, .section-header::after, .section-header .chevron, .section-header .chevron::before, .section-header .chevron::after, .section-body, .section-body-inner, .stagger-child { transition: none !important; } }

/* ===== Cassava project additions: keep original visual language, add notebook tabs ===== */
.btn-modern-secondary {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.045);
    color: var(--text-primary);
    padding: 16px 28px;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-modern-secondary:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    background: rgba(255,255,255,0.07);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}
.notebook-switcher {
    position: sticky;
    top: 14px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 34px 0 20px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(12, 13, 20, 0.84);
    backdrop-filter: blur(18px);
    box-shadow: 0 24px 60px rgba(0,0,0,0.24);
}
.notebook-tab {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 14px 16px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.96rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: none;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}
.notebook-tab i { margin-right: 8px; }
.notebook-tab:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.035);
    border-color: var(--border);
}
.notebook-tab.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(99,102,241,0.22), rgba(16,185,129,0.08));
    border-color: rgba(99,102,241,0.34);
    box-shadow: 0 0 34px rgba(99,102,241,0.10);
}
.notebook-panel { display: none; }
.notebook-panel.active { display: block; }
.inference-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 24px;
    align-items: stretch;
}
.inference-card { grid-column: span 2; }
.inference-card:nth-child(4) { grid-column: 2 / span 2; }
.inference-card:nth-child(5) { grid-column: 4 / span 2; }
.inference-card img {
    max-height: 520px;
    object-fit: contain;
}
.theory-math-container code {
    color: var(--accent);
    font-family: var(--font-mono);
    white-space: normal;
    line-height: 1.7;
}
.executive-summary-box code,
.overview-text code,
.flow-content code,
.panel-desc code {
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}
@media (max-width: 900px) {
    .notebook-switcher { position: relative; top: 0; grid-template-columns: 1fr; }
    .inference-grid { grid-template-columns: 1fr; }
    .inference-card,
    .inference-card:nth-child(4),
    .inference-card:nth-child(5) { grid-column: auto; }
}

/* Final visual alignment polish: keep metric numbers and diagnostic scores on clean baselines */
.metrics-strip {
    align-items: stretch;
}
.metric-block {
    min-height: 118px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
.metric-label {
    min-height: 42px;
    display: flex;
    align-items: flex-start;
    line-height: 1.45;
}
.metric-value {
    line-height: 1;
    margin-top: 2px;
    white-space: nowrap;
}
.insight-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 32px;
}
.insight-left-meta {
    min-width: 0;
}
.insight-rank-index {
    width: 86px;
    min-width: 86px;
    white-space: nowrap;
}
.insight-score-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(118px, 1fr));
    min-width: 320px;
    gap: 28px;
    align-items: start;
}
.insight-score-item {
    min-width: 118px;
}
.insight-score-label {
    min-height: 20px;
    line-height: 1.35;
    display: block;
}
.insight-score-value {
    line-height: 1;
    margin-top: 6px;
    white-space: nowrap;
}
@media (max-width: 1024px) {
    .metric-block { min-height: 106px; }
    .metric-label { min-height: 32px; }
}
@media (max-width: 760px) {
    .insight-row {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .insight-rank-index {
        width: auto;
        min-width: auto;
    }
    .insight-score-metrics {
        min-width: 0;
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    .metric-block { min-height: auto; }
    .metric-label { min-height: auto; }
}

/* ===== Wheat detection additions ===== */
.metrics-strip.wheat-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.compact-k { font-family: var(--font-mono); letter-spacing: -0.06em; }
.wheat-viz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.wheat-viz-wide { grid-column: 1 / -1; }
.wheat-viz-card img { max-height: 420px; object-fit: contain; }
.inference-three-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.inference-three-grid .viz-wrapper-card img { max-height: 460px; object-fit: contain; }
.phase-stack { display: flex; flex-direction: column; gap: 0; margin-bottom: 28px; }
.phase-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 380px; gap: 28px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--border); }
.phase-row:last-child { border-bottom: none; }
.phase-row.rank-leader { border-bottom-color: rgba(16,185,129,0.25); }
.phase-index { font-family: var(--font-mono); color: var(--text-muted); font-weight: 700; white-space: nowrap; }
.phase-row.rank-leader .phase-index { color: var(--champion); }
.phase-main strong { display: block; font-size: 1.08rem; color: var(--text-primary); margin-bottom: 4px; }
.phase-main span { display: block; color: var(--text-secondary); font-size: 0.88rem; line-height: 1.55; }
.phase-metrics { display: grid; grid-template-columns: repeat(3, minmax(96px, 1fr)); gap: 20px; text-align: right; }
.phase-metric-label { display: block; min-height: 20px; font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.2px; line-height: 1.35; }
.phase-metric-value { display: block; margin-top: 6px; font-family: var(--font-mono); font-size: 1.28rem; font-weight: 800; color: var(--text-primary); line-height: 1; white-space: nowrap; }
.phase-metric-value.good { color: var(--champion); }
.code-mini { max-height: 520px; overflow: auto; }
.formula-line { color: var(--text-secondary); font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.7; }
.note-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 22px; }
.note-card { border: 1px solid var(--border); background: var(--surface-card); border-radius: 14px; padding: 22px; }
.note-card strong { display: block; color: var(--text-primary); margin-bottom: 8px; }
.note-card span { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; }
@media (max-width: 1024px) { .metrics-strip.wheat-metrics { grid-template-columns: repeat(2, 1fr); } .phase-row { grid-template-columns: 1fr; gap: 12px; } .phase-metrics { text-align: left; max-width: 480px; } .phase-metric-value { font-size: 1.12rem; } .note-grid, .inference-three-grid, .wheat-viz-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .metrics-strip.wheat-metrics { grid-template-columns: 1fr; } .phase-metrics { grid-template-columns: 1fr; } }


/* ===== Enhanced Wheat page fixes and richer technical layouts ===== */
.notebook-switcher { position: relative !important; top: auto !important; z-index: 3 !important; }
.section { scroll-margin-top: 24px; }
.theory-block, .note-card, .terminal-panel, .matrix-table-container { min-width: 0; }
.theory-math-container { overflow-x: auto; max-width: 100%; }
.theory-math-container mjx-container { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.formula-line, .terminal-body pre, .terminal-body code { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.terminal-body { overflow-x: auto; }
.metric-block { min-width: 0; }
.metric-value { font-size: clamp(1.8rem, 3vw, 2.5rem); }
.tech-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.tech-card { background: var(--surface-card); border: 1px solid var(--border); border-radius: 14px; padding: 26px; min-width: 0; }
.tech-card:hover { border-color: var(--border-hover); }
.tech-card h3 { font-size: 1.12rem; margin-bottom: 12px; color: var(--text-primary); }
.tech-card p, .tech-card li { color: var(--text-secondary); font-size: 0.92rem; line-height: 1.65; }
.tech-card ul { padding-left: 18px; margin-top: 10px; }
.tech-badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 0.68rem; color: var(--accent); background: var(--accent-glow); padding: 5px 10px; border-radius: 6px; margin-bottom: 14px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin: 24px 0; }
.kpi-card { border: 1px solid var(--border); background: rgba(255,255,255,0.025); border-radius: 14px; padding: 20px; min-height: 118px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi-label { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-muted); line-height: 1.4; min-height: 34px; }
.kpi-value { font-size: 1.85rem; font-weight: 800; color: var(--text-primary); line-height: 1; white-space: nowrap; }
.kpi-value.good { color: var(--champion); }
.phase-row { grid-template-columns: 115px minmax(0, 1fr) 430px; }
.phase-metrics { grid-template-columns: repeat(3, minmax(105px, 1fr)); }
.phase-main { min-width: 0; }
.pipeline-table td:nth-child(1) { width: 190px; }
.pipeline-table td:nth-child(2) { width: 220px; }
.code-pill { font-family: var(--font-mono); color: var(--accent); background: var(--accent-glow); padding: 2px 7px; border-radius: 4px; font-size: 0.84em; }
.viz-display-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.viz-display-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.big-viz img { max-height: 560px; }
.synthesis-gradient-box ul { padding-left: 20px; color: var(--text-secondary); }
.synthesis-gradient-box li { margin-bottom: 8px; }
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tech-grid, .viz-display-grid.two, .viz-display-grid.three { grid-template-columns: 1fr; }
  .phase-row { grid-template-columns: 1fr; }
  .phase-metrics { max-width: none; text-align: left; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .phase-metrics { grid-template-columns: 1fr; }
  .pipeline-table td:nth-child(1), .pipeline-table td:nth-child(2) { width: auto; }
}


/* ===== Final Wheat polish: restore template behavior and prevent layout breakage ===== */
.notebook-switcher { position: relative !important; top: auto !important; z-index: 5 !important; }
.notebook-panel { display: none !important; }
.notebook-panel.active { display: block !important; }
.terminal-panel.code-showcase { max-width: 100%; }
.terminal-panel.code-showcase .terminal-body { max-height: none !important; overflow-x: auto; overflow-y: visible; padding: 28px 32px; }
.terminal-panel.code-showcase pre { white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; font-size: 0.84rem; line-height: 1.7; }
.code-mini { max-height: none !important; overflow-y: visible !important; }
.viz-display-grid.two { grid-template-columns: minmax(0, 760px); justify-content: center; }
.viz-display-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); justify-content: center; }
.big-viz { max-width: 820px; margin-left: auto; margin-right: auto; }
.big-viz img { display: block; margin-left: auto; margin-right: auto; max-height: 520px; object-fit: contain; }
.wheat-viz-wide { max-width: 900px; margin-left: auto; margin-right: auto; }
.theory-math-container, .formula-line { overflow-x: auto; white-space: normal; }
.formula-line { overflow-wrap: anywhere; word-break: normal; }
.tech-card, .theory-block, .note-card { overflow: hidden; }
@media (max-width: 900px) { .viz-display-grid.three { grid-template-columns: 1fr; } }


/* ===== Wheat final correction: restore two-part template behavior ===== */
.metrics-strip.wheat-metrics-six { grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; }
.metrics-strip.wheat-metrics-six .metric-block { min-height: 130px; display: flex; flex-direction: column; justify-content: flex-end; }
.metrics-strip.wheat-metrics-six .metric-label { min-height: 42px; display: flex; align-items: flex-end; }
.metrics-strip.wheat-metrics-six .metric-value { line-height: 1; margin-top: 14px; }
.notebook-panel { display: none !important; }
.notebook-panel.active { display: block !important; }
.notebook-tab { font-family: var(--font-sans) !important; }
.terminal-panel.code-showcase { max-width: 980px; margin-left: auto; margin-right: auto; }
.terminal-panel .terminal-body { overflow-x: auto; overflow-y: visible; max-height: none !important; }
.terminal-panel .terminal-body pre { margin: 0; white-space: pre; overflow-wrap: normal; word-break: normal; min-width: max-content; }
.code-mini { max-height: none !important; overflow: visible !important; }
.viz-display-grid.two { grid-template-columns: minmax(0, 820px); justify-content: center; }
.viz-display-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); justify-content: center; }
.viz-wrapper-card.big-viz { width: 100%; }
.big-viz img, .wheat-viz-card img { display: block; margin-left: auto; margin-right: auto; object-fit: contain; }
.matrix-table-container { overflow-x: auto; }
@media (max-width: 1180px) { .metrics-strip.wheat-metrics-six { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .metrics-strip.wheat-metrics-six { grid-template-columns: 1fr; } .metrics-strip.wheat-metrics-six .metric-block, .metrics-strip.wheat-metrics-six .metric-label { min-height: auto; } .viz-display-grid.three { grid-template-columns: 1fr; } }


/* ===== Wheat implementation polish requested after review ===== */
.implementation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
}
.terminal-panel.implementation-code {
    max-width: 100%;
    margin: 0;
    overflow: hidden;
}
.terminal-panel.implementation-code .terminal-body.compact-code {
    padding: 24px 26px;
    overflow-x: auto;
    overflow-y: visible;
}
.terminal-panel.implementation-code .terminal-body.compact-code pre {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    min-width: 0;
    font-size: 0.82rem;
    line-height: 1.72;
}
.compact-param-table td:nth-child(1) { width: 230px; }
.compact-param-table td:nth-child(2) { width: 260px; }
.viz-display-grid.two,
.viz-display-grid.two-card-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    justify-content: center;
    align-items: start;
}
.viz-display-grid.two .viz-wrapper-card.big-viz {
    max-width: 100%;
}
.viz-display-grid.two .viz-wrapper-card.big-viz img {
    width: 100%;
    max-height: 520px;
    object-fit: contain;
}
.terminal-body.code-mini pre {
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    min-width: 0 !important;
}
@media (max-width: 980px) {
    .implementation-grid,
    .viz-display-grid.two,
    .viz-display-grid.two-card-row {
        grid-template-columns: 1fr !important;
    }
    .compact-param-table td:nth-child(1),
    .compact-param-table td:nth-child(2) { width: auto; }
}

.viz-display-grid.single-centered { grid-template-columns: minmax(0, 820px); justify-content: center; }
@media (max-width: 980px) { .viz-display-grid.single-centered { grid-template-columns: 1fr; } }

/* ===== Box Office Revenue page additions ===== */
.notebook-switcher.box-office-switcher {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.box-office-metrics .metric-label {
    min-height: 42px;
}
.box-office-viz-grid .viz-wrapper-card img {
    max-height: 380px;
    object-fit: contain;
}
.box-office-viz-grid {
    align-items: start;
}
.tech-card code,
.note-card code,
.synthesis-gradient-box code {
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}
@media (max-width: 980px) {
    .notebook-switcher.box-office-switcher {
        grid-template-columns: 1fr;
    }
}

/* Box Office final behavior: keep the project switcher visible while scrolling */
.notebook-switcher.box-office-switcher {
    position: sticky !important;
    top: 14px !important;
    z-index: 50 !important;
}

@media (max-width: 900px) {
    .notebook-switcher.box-office-switcher {
        position: sticky !important;
        top: 8px !important;
    }
}

/* ===== Disaster Twitts page additions ===== */
.notebook-switcher.disaster-switcher {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: sticky !important;
    top: 14px !important;
    z-index: 50 !important;
}

.disaster-metrics .metric-label {
    min-height: 42px;
}

.disaster-viz-grid .viz-wrapper-card img,
.viz-wrapper-card.big-viz img {
    width: 100%;
    object-fit: contain;
}

.disaster-viz-grid .viz-wrapper-card img {
    max-height: 420px;
}

.viz-display-grid.single-centered .viz-wrapper-card.big-viz img {
    max-height: 560px;
}

.viz-title {
    position: relative;
    z-index: 2;
    background: var(--surface-card);
    padding: 15px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.architecture-flow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
    margin: 26px 0;
}

.architecture-flow .flow-step {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: var(--font-sans);
}

.architecture-flow .flow-step span {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.architecture-flow .flow-step strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.architecture-flow .flow-step p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
}

.architecture-flow .flow-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.formula-box {
    margin-top: 24px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(16, 185, 129, 0.04));
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    overflow-x: auto;
}

.formula-box p {
    margin-bottom: 12px;
}

.note-card code,
.architecture-flow code,
.formula-box code,
.synthesis-gradient-box code {
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.synthesis-gradient-box {
    padding: 30px;
    border: 1px solid rgba(99, 102, 241, 0.24);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(16, 185, 129, 0.08), rgba(255, 255, 255, 0.018));
    color: var(--text-secondary);
}

.library-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.library-strip span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.eda-compact-grid .viz-wrapper-card img,
.eda-gallery .viz-wrapper-card img {
    max-height: 300px;
    object-fit: contain;
    background: #ffffff;
}

.eda-gallery {
    align-items: start;
}

.eda-gallery .viz-wrapper-card {
    min-height: 0;
}

.eda-gallery .viz-title,
.eda-compact-grid .viz-title {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.data-table td,
.data-table th {
    vertical-align: top;
}

@media (max-width: 1100px) {
    .notebook-switcher.disaster-switcher,
    .architecture-flow {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .architecture-flow .flow-arrow {
        display: none;
    }
}

@media (max-width: 760px) {
    .notebook-switcher.disaster-switcher,
    .architecture-flow {
        grid-template-columns: 1fr;
    }

    .notebook-switcher.disaster-switcher {
        top: 8px !important;
    }
}


/* ===== Mobile-only correction layer for Disaster Twitts page =====
   Desktop behavior above is preserved. These overrides activate only on
   phone-sized screens to improve reading flow and remove accidental overflow. ===== */
@media (max-width: 760px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    body * {
        min-width: 0;
    }

    img,
    svg,
    video,
    canvas,
    iframe {
        max-width: 100%;
    }

    .hero-section,
    .main-layout {
        width: 100%;
        max-width: 100%;
        padding-left: clamp(16px, 5vw, 22px);
        padding-right: clamp(16px, 5vw, 22px);
    }

    .hero-section {
        padding-top: 52px;
        padding-bottom: 30px;
        overflow: visible;
    }

    .hero-accent-blur {
        left: 50%;
        width: 88vw;
        max-width: 380px;
        height: 220px;
        filter: blur(28px);
    }

    .hero-meta {
        max-width: 100%;
        font-size: 0.68rem;
        line-height: 1.8;
        letter-spacing: 0.12em;
        overflow-wrap: anywhere;
    }

    h1 {
        max-width: 100%;
        font-size: clamp(2.05rem, 10vw, 2.85rem);
        line-height: 1.12;
        letter-spacing: -0.035em;
        overflow-wrap: anywhere;
    }

    .hero-subtitle,
    .overview-text,
    .panel-desc,
    .theory-explanation,
    .synthesis-gradient-box,
    .architecture-flow .flow-step p,
    .note-card span,
    .dependency-row span {
        max-width: 100%;
        font-size: 0.96rem;
        line-height: 1.72;
        overflow-wrap: anywhere;
    }

    .btn-group {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        align-items: stretch;
    }

    .btn-modern-primary,
    .btn-modern-secondary {
        width: 100%;
        min-height: 56px;
        justify-content: center;
        padding: 14px 18px;
        font-size: 0.98rem;
        text-align: center;
    }

    .metrics-strip,
    .metrics-strip.wheat-metrics,
    .metrics-strip.wheat-metrics-six,
    .metrics-strip.disaster-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px;
        padding: 18px 0;
        margin-bottom: 24px;
        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }

    .metric-block,
    .metric-block:first-child,
    .metric-block:last-child,
    .metrics-strip.wheat-metrics-six .metric-block {
        min-height: auto;
        padding: 16px;
        border: 1px solid var(--border) !important;
        border-radius: 14px;
        background: rgba(255,255,255,0.025);
        justify-content: flex-start;
    }

    .metric-label,
    .metrics-strip.wheat-metrics-six .metric-label,
    .disaster-metrics .metric-label {
        min-height: auto;
        margin-bottom: 12px;
        font-size: 0.64rem;
        line-height: 1.35;
        letter-spacing: 0.08em;
        align-items: flex-start;
    }

    .metric-value,
    .metrics-strip.wheat-metrics-six .metric-value {
        margin-top: 0;
        font-size: clamp(1.28rem, 8vw, 1.95rem);
        line-height: 1.05;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .notebook-switcher.disaster-switcher,
    .notebook-switcher {
        position: sticky !important;
        top: 8px !important;
        z-index: 80 !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px;
        margin: 22px 0 16px;
        padding: 8px;
        border-radius: 16px;
        max-height: min(42vh, 330px);
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .notebook-tab {
        min-height: 46px;
        padding: 11px 10px;
        font-size: 0.8rem;
        line-height: 1.25;
        white-space: normal;
        text-align: center;
    }

    .notebook-tab i {
        margin-right: 5px;
    }

    .section {
        padding: 30px 0;
        scroll-margin-top: 14px;
    }

    .accordion-guide {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 14px 16px;
        border-radius: 14px;
        margin-top: 20px;
    }

    .accordion-guide-hint {
        font-size: 0.82rem;
        line-height: 1.55;
    }

    .section-header {
        grid-template-columns: minmax(0, 1fr) 54px;
        gap: 10px;
        padding: 16px 0 16px 16px;
        border-radius: 14px;
    }

    .section-header::before {
        top: 16px;
        bottom: 16px;
    }

    .panel-header-content {
        min-width: 0;
    }

    .panel-tag {
        font-size: 0.66rem;
        line-height: 1.45;
        letter-spacing: 0.12em;
        overflow-wrap: anywhere;
    }

    h2,
    .panel-header-content h2 {
        font-size: clamp(1.35rem, 7vw, 2rem);
        line-height: 1.16;
        overflow-wrap: anywhere;
    }

    .section-header .chevron,
    .chevron {
        width: 54px;
        height: 32px;
        margin-right: 0;
        justify-self: end;
    }

    .section-header .chevron::before,
    .chevron::before {
        width: 24px;
        height: 24px;
    }

    .section.expanded .section-header .chevron::before,
    .section.expanded .chevron::before {
        transform: translateX(22px);
    }

    .section-header .chevron::after,
    .chevron::after {
        right: 7px;
        font-size: 0.48rem;
    }

    .section.expanded .section-header .chevron::after,
    .section.expanded .chevron::after {
        left: 8px;
    }

    .section-body-inner {
        padding-top: 18px;
    }

    .note-grid,
    .artifact-grid,
    .diagnostic-grid,
    .class-grid,
    .mini-insight-grid,
    .tech-grid,
    .implementation-grid,
    .theory-split,
    .viz-display-grid.two,
    .viz-display-grid.three,
    .viz-display-grid.single-centered {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        margin: 20px 0;
    }

    .kpi-card {
        min-height: auto;
        padding: 16px;
        border-radius: 13px;
    }

    .kpi-label {
        min-height: auto;
        font-size: 0.61rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .kpi-value {
        font-size: clamp(1.2rem, 7vw, 1.75rem);
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .note-card,
    .artifact-card,
    .diagnostic-card,
    .class-card,
    .mini-insight-card,
    .tech-card,
    .theory-block,
    .terminal-panel,
    .matrix-table-container,
    .synthesis-gradient-box,
    .architecture-flow .flow-step,
    .viz-wrapper-card {
        max-width: 100%;
        border-radius: 13px;
    }

    .note-card,
    .artifact-card,
    .diagnostic-card,
    .class-card,
    .mini-insight-card,
    .tech-card,
    .theory-block,
    .architecture-flow .flow-step {
        padding: 20px;
    }

    .synthesis-gradient-box {
        padding: 22px;
        border-left-width: 3px;
        border-radius: 14px;
    }

    .dependency-row {
        gap: 12px;
        padding: 14px 0;
    }

    .dep-icon {
        flex: 0 0 22px;
        width: 22px;
        font-size: 1rem;
    }

    .dependency-row strong,
    .dependency-row span,
    .flow-content strong,
    .flow-content span,
    .note-card strong,
    .note-card span,
    .theory-title,
    .theory-explanation,
    .architecture-flow .flow-step strong,
    .architecture-flow .flow-step p {
        overflow-wrap: anywhere;
    }

    .timeline-flow {
        padding-left: 20px;
    }

    .flow-node {
        padding-bottom: 20px;
    }

    .flow-dot {
        left: -20px;
        top: 9px;
    }

    .flow-node::before {
        left: -16px;
        top: 21px;
    }

    .flow-content {
        display: grid;
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .flow-step {
        font-size: 0.76rem;
    }

    .architecture-flow {
        grid-template-columns: 1fr !important;
        gap: 12px;
        margin: 22px 0;
    }

    .architecture-flow .flow-arrow {
        display: none !important;
    }

    .architecture-flow .flow-step {
        gap: 7px;
    }

    .architecture-flow .flow-step span {
        font-size: 0.68rem;
        line-height: 1.35;
    }

    .theory-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 14px;
    }

    .theory-badge,
    .taxonomy-tag {
        max-width: 100%;
        white-space: normal;
        line-height: 1.35;
    }

    .theory-math-container,
    .formula-box {
        max-width: 100%;
        padding: 14px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: normal;
        font-size: 0.78rem;
        line-height: 1.65;
    }

    .theory-math-container mjx-container {
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .viz-wrapper-card:hover {
        transform: none;
        box-shadow: none;
    }

    .viz-wrapper-card:hover img {
        transform: none;
    }

    .viz-title,
    .eda-gallery .viz-title,
    .eda-compact-grid .viz-title {
        min-height: auto;
        padding: 13px;
        font-size: 0.82rem;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

    .viz-wrapper-card img,
    .viz-wrapper-card.big-viz img,
    .viz-display-grid.single-centered .viz-wrapper-card.big-viz img,
    .eda-compact-grid .viz-wrapper-card img,
    .eda-gallery .viz-wrapper-card img {
        width: 100%;
        max-height: none;
        height: auto;
        object-fit: contain;
    }

    .terminal-header {
        padding: 12px 14px;
        gap: 10px;
    }

    .terminal-title {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .terminal-body,
    .terminal-panel.code-showcase .terminal-body,
    .terminal-panel.implementation-code .terminal-body.compact-code {
        padding: 18px 16px;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: visible;
    }

    .terminal-body pre,
    .terminal-body code,
    .terminal-panel.code-showcase pre,
    .terminal-panel .terminal-body pre,
    .terminal-panel.implementation-code .terminal-body.compact-code pre {
        min-width: 0 !important;
        max-width: 100%;
        white-space: pre-wrap !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
        font-size: 0.76rem;
        line-height: 1.72;
    }

    .matrix-table-container {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .matrix-table-container table,
    .matrix-table-container thead,
    .matrix-table-container tbody,
    .matrix-table-container th,
    .matrix-table-container td,
    .matrix-table-container tr {
        display: block;
        width: 100%;
    }

    .matrix-table-container thead {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }

    .matrix-table-container tbody {
        display: grid;
        gap: 12px;
    }

    .matrix-table-container tr {
        border: 1px solid var(--border);
        border-radius: 13px;
        background: var(--surface-card);
        overflow: hidden;
    }

    .matrix-table-container tr:hover td {
        background: transparent;
    }

    .matrix-table-container td {
        display: grid;
        grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        padding: 13px 15px;
        border-bottom: 1px solid var(--border);
        color: var(--text-secondary);
        text-align: left;
        overflow-wrap: anywhere;
    }

    .matrix-table-container td:last-child {
        border-bottom: none;
    }

    .matrix-table-container td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-family: var(--font-mono);
        font-size: 0.64rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        line-height: 1.45;
        text-transform: uppercase;
    }

    td code,
    .overview-text code,
    .panel-desc code,
    .note-card code,
    .theory-math-container code,
    .terminal-body code,
    .formula-box code,
    .architecture-flow code,
    .synthesis-gradient-box code {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .portfolio-footer-gate {
        padding: 30px 16px;
        margin-top: 26px;
    }

    .contact-icons {
        width: 100%;
        justify-content: center;
        gap: 14px;
    }

    .icon-link {
        width: 44px;
        height: 44px;
        border: 1px solid var(--border);
        border-radius: 999px;
        background: rgba(255,255,255,0.025);
        font-size: 1.1rem;
    }

    .editorial-credits {
        margin: 18px 0 28px;
        padding: 0 18px;
        line-height: 1.6;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 380px) {
    .kpi-grid,
    .metrics-strip,
    .metrics-strip.wheat-metrics,
    .metrics-strip.wheat-metrics-six,
    .metrics-strip.disaster-metrics {
        grid-template-columns: 1fr !important;
    }

    .matrix-table-container td {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

@media (max-width: 340px) {
    .notebook-switcher.disaster-switcher,
    .notebook-switcher {
        grid-template-columns: 1fr !important;
    }
}

/* ===== Disaster mobile sticky tabs + one-row footer refinement ===== */
@media (max-width: 760px) {
    .notebook-switcher.disaster-switcher,
    .notebook-switcher {
        display: flex !important;
        grid-template-columns: none !important;
        align-items: stretch;
        position: sticky !important;
        top: 8px !important;
        z-index: 90 !important;
        width: 100%;
        min-height: 60px;
        max-height: none;
        gap: 8px;
        margin: 22px 0 16px;
        padding: 7px;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
    }

    .notebook-switcher.disaster-switcher::-webkit-scrollbar,
    .notebook-switcher::-webkit-scrollbar {
        display: none;
    }

    .notebook-tab {
        flex: 0 0 auto;
        min-width: max-content;
        min-height: 46px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 10px 14px;
        font-size: 0.8rem;
        line-height: 1.2;
        text-align: center;
        white-space: nowrap;
        scroll-snap-align: center;
    }

    .notebook-tab i {
        flex: 0 0 auto;
        margin-right: 6px;
    }

    .portfolio-footer-gate {
        padding-left: 8px;
        padding-right: 8px;
    }

    .contact-icons {
        width: 100%;
        display: flex;
        flex-wrap: nowrap !important;
        align-items: center;
        justify-content: center;
        gap: clamp(6px, 2vw, 12px);
    }

    .icon-link {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

@media (max-width: 340px) {
    .notebook-switcher.disaster-switcher,
    .notebook-switcher {
        display: flex !important;
        grid-template-columns: none !important;
    }

    .contact-icons {
        gap: 6px;
    }

    .icon-link {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
    }
}

/* Keep viewport-level horizontal clipping without creating a sticky-breaking scroll container. */
@media (max-width: 760px) {
    html,
    body {
        overflow-x: clip !important;
    }
}
