/* ==========================================================================
   Design System: guill.sh minimalist aesthetic with Catppuccin colors
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;1,400&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400;1,8..60,600&display=swap');

:root {
    /* Fonts */
    --font-serif: "Source Serif 4", Georgia, serif;
    --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

    /* Catppuccin Latte (Light Theme) */
    --primary-bg: #eff1f5;
    --sidebar-bg: #e6e9ef;
    --text-main: #4c4f69;
    --text-muted: #6c6f85;
    --text-bold: #5c5f77;
    --accent-color: #8463a4;
    --accent-red: #d20f39;
    --accent-blue: #1e66f5;
    --accent-purple: #8839ef;
    --accent-green: #40a02b;
    --border-color: #ccd0da;
    --surface-bg: #ccd0da;
    --dot-empty: #bcc0cc;
    --selection-bg: #a3e635; /* Lime green */
    --selection-color: #1e1e2e;

    --paper: var(--primary-bg);
    --ink: var(--text-main);
    --muted: var(--text-muted);
    --rule: var(--border-color);
    --accent: var(--accent-color);
    --code-bg: var(--sidebar-bg);
    --measure: 38rem;

    /* Syntax Highlighting (Latte) */
    --code-keyword: #8839ef;
    --code-type: #1e66f5;
    --code-number: #fe640b;
    --code-string: #40a02b;
    --code-comment: #7c7f93;
    --code-builtin: #209fb5;
    --code-preprocessor: #e64553;
}

/* System Dark Preference fallback if not explicitly set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Catppuccin Mocha (Dark Theme) */
        --primary-bg: #1e1e2e;
        --sidebar-bg: #181825;
        --text-main: #cdd6f4;
        --text-muted: #a6adc8;
        --text-bold: #bac2de;
        --accent-color: #cba6f7;
        --accent-red: #f38ba8;
        --accent-blue: #89b4fa;
        --accent-purple: #cba6f7;
        --accent-green: #a6e3a1;
        --border-color: #313244;
        --surface-bg: #313244;
        --dot-empty: #45475a;
        --selection-bg: #f5c2e7;
        --selection-color: #1e1e2e;

        --paper: var(--primary-bg);
        --ink: var(--text-main);
        --muted: var(--text-muted);
        --rule: var(--border-color);
        --accent: var(--accent-color);
        --code-bg: var(--sidebar-bg);

        /* Syntax Highlighting (Mocha) */
        --code-keyword: #cba6f7;
        --code-type: #89b4fa;
        --code-number: #fab387;
        --code-string: #a6e3a1;
        --code-comment: #6c7086;
        --code-builtin: #74c7ec;
        --code-preprocessor: #eba0ac;
    }
}

/* Explicit Dark Theme via data-theme attribute */
[data-theme="dark"] {
    --primary-bg: #1e1e2e;
    --sidebar-bg: #181825;
    --text-main: #cdd6f4;
    --text-muted: #a6adc8;
    --text-bold: #bac2de;
    --accent-color: #cba6f7;
    --accent-red: #f38ba8;
    --accent-blue: #89b4fa;
    --accent-purple: #cba6f7;
    --accent-green: #a6e3a1;
    --border-color: #313244;
    --surface-bg: #313244;
    --dot-empty: #45475a;
    --selection-bg: #f5c2e7;
    --selection-color: #1e1e2e;

    --paper: var(--primary-bg);
    --ink: var(--text-main);
    --muted: var(--text-muted);
    --rule: var(--border-color);
    --accent: var(--accent-color);
    --code-bg: var(--sidebar-bg);

    --code-keyword: #cba6f7;
    --code-type: #89b4fa;
    --code-number: #fab387;
    --code-string: #a6e3a1;
    --code-comment: #6c7086;
    --code-builtin: #74c7ec;
    --code-preprocessor: #eba0ac;
}

[data-theme="light"] {
    --primary-bg: #eff1f5;
    --sidebar-bg: #e6e9ef;
    --text-main: #4c4f69;
    --text-muted: #6c6f85;
    --text-bold: #5c5f77;
    --accent-color: #8463a4;
    --accent-red: #d20f39;
    --accent-blue: #1e66f5;
    --accent-purple: #8839ef;
    --accent-green: #40a02b;
    --border-color: #ccd0da;
    --surface-bg: #ccd0da;
    --dot-empty: #bcc0cc;
    --selection-bg: #a3e635; /* Lime green */
    --selection-color: #1e1e2e;

    --paper: var(--primary-bg);
    --ink: var(--text-main);
    --muted: var(--text-muted);
    --rule: var(--border-color);
    --accent: var(--accent-color);
    --code-bg: var(--sidebar-bg);

    --code-keyword: #8839ef;
    --code-type: #1e66f5;
    --code-number: #fe640b;
    --code-string: #40a02b;
    --code-comment: #7c7f93;
    --code-builtin: #209fb5;
    --code-preprocessor: #e64553;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-serif);
    font-kerning: normal;
    margin: 0;
    padding-inline: 1.25rem;
    font-size: 1.125rem;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.25s ease, color 0.25s ease;
    overflow-x: hidden;
}

::selection {
    background-color: var(--selection-bg) !important;
    color: var(--selection-color) !important;
}

::-moz-selection {
    background-color: var(--selection-bg) !important;
    color: var(--selection-color) !important;
}

*::selection {
    background-color: var(--selection-bg) !important;
    color: var(--selection-color) !important;
}

*::-moz-selection {
    background-color: var(--selection-bg) !important;
    color: var(--selection-color) !important;
}

/* Explicit Light Theme Selection (Lime Green) */
body[data-theme="light"] ::selection,
body:not([data-theme="dark"]) ::selection,
body[data-theme="light"] *::selection,
body:not([data-theme="dark"]) *::selection {
    background-color: #a3e635 !important;
    color: #1e1e2e !important;
}

body[data-theme="light"] ::-moz-selection,
body:not([data-theme="dark"]) ::-moz-selection,
body[data-theme="light"] *::-moz-selection,
body:not([data-theme="dark"]) *::-moz-selection {
    background-color: #a3e635 !important;
    color: #1e1e2e !important;
}

mark, .highlight, .highlighter {
    background-color: var(--selection-bg) !important;
    color: var(--selection-color) !important;
    padding: 0.05em 0.25em;
    border-radius: 2px;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a {
    color: inherit;
    text-decoration-line: underline;
    text-decoration-color: var(--accent);
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
    color: var(--accent);
}

h1, h2, h3 {
    text-wrap: balance;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ink);
}

h1 {
    letter-spacing: -0.01em;
    margin: 0 0 1rem;
    font-size: 2rem;
}

p {
    text-wrap: pretty;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.muted {
    color: var(--muted);
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */

.site-header,
main,
.site-footer {
    max-width: var(--measure);
    width: 100%;
    margin-inline: auto;
}

main {
    flex: 1 0 auto;
    padding-block: 3.5rem 5rem;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.site-header {
    font-family: var(--font-mono);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem 1.5rem;
    padding-block: 2.25rem 0;
    font-size: 0.875rem;
}

.site-header .header-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.site-header .brand-avatar {
    width: 22px;
    height: 22px;
    object-fit: contain;
    vertical-align: middle;
    transition: transform 0.2s ease;
}

.site-header .brand-avatar:hover {
    transform: rotate(-10deg) scale(1.15);
}

.site-header .wordmark {
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.site-header .wordmark:hover {
    color: var(--accent);
}

.site-header nav {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
}

.site-header nav a,
.site-header nav button.nav-link {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.site-header nav a:hover,
.site-header nav button.nav-link:hover,
.site-header nav a[aria-current="page"],
.site-header nav button.nav-link.active {
    color: var(--ink);
}

.site-header nav button.nav-link.active {
    text-decoration-line: underline;
    text-decoration-color: var(--accent);
    text-underline-offset: 0.3em;
    text-decoration-thickness: 1.5px;
}

body[data-theme="light"] .site-header nav button.nav-link.active,
body:not([data-theme="dark"]) .site-header nav button.nav-link.active {
    text-decoration-color: #84cc16;
}

/* Theme Toggle */
.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem;
    line-height: 1;
    transition: color 0.15s ease, transform 0.15s ease;
    vertical-align: middle;
}

.theme-toggle-btn:hover {
    color: var(--accent);
    transform: scale(1.15);
}

.theme-toggle-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* ==========================================================================
   Content Sections
   ========================================================================== */

.content-section {
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.content-section.active {
    display: block;
    opacity: 1;
}

/* Section Headings */
.section {
    margin-top: 3.5rem;
}

.section > h2,
h2.section-header {
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    font-weight: 400;
}

.intro p {
    margin: 0 0 1rem;
}

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

.intro-bio {
    font-size: 1.15rem;
    line-height: 1.65;
}

/* ==========================================================================
   Post List (Writing)
   ========================================================================== */

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

.post-list li {
    grid-template-columns: 7.5rem 1fr;
    gap: 1rem;
    padding-block: 0.45rem;
    display: grid;
    align-items: baseline;
    transition: transform 0.1s ease;
}

.post-list time {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: 0.875rem;
}

.post-list a {
    text-decoration: none;
    color: var(--ink);
}

.post-list a:hover {
    color: var(--accent);
    text-decoration-line: underline;
    text-decoration-color: var(--accent);
    text-underline-offset: 0.18em;
}

.draft-tag,
.tag-badge {
    border: 1px solid var(--accent);
    font-family: var(--font-mono);
    color: var(--accent);
    vertical-align: 0.1em;
    border-radius: 2px;
    margin-left: 0.5rem;
    padding: 0 0.35em;
    font-size: 0.75rem;
}

/* ==========================================================================
   Projects
   ========================================================================== */

.project {
    margin-bottom: 2rem;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.project h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.project-meta,
.project-year {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--muted);
    white-space: nowrap;
}

.project p {
    margin: 0.25rem 0 0;
}

.project-subitem {
    margin-top: 0.75rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--rule);
}

.stack {
    font-family: var(--font-mono);
    color: var(--muted);
    font-size: 0.8125rem;
    margin-top: 0.35rem !important;
    text-align: left;
}

/* ==========================================================================
   Archive & Tables (Projects, Education, Extracurriculars)
   ========================================================================== */

.archive-group {
    margin-top: 2rem;
}

.archive-group h3 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

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

.archive li {
    border-top: 1px solid var(--rule);
    grid-template-columns: 8.5rem 1fr;
    gap: 0.25rem 1rem;
    padding-block: 0.65rem;
    display: grid;
}

.archive-name {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--muted);
    padding-top: 0.15rem;
}

.archive-summary {
    font-size: 1rem;
    line-height: 1.5;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.archive-summary strong {
    font-weight: 600;
    color: var(--ink);
}

.archive-summary ul {
    margin: 0.35rem 0 0 1.25rem;
    padding: 0;
}

.archive-summary li {
    border-top: none;
    padding-block: 0.15rem;
    display: list-item;
}

.archive .stack {
    display: block;
    margin-top: 0.2rem !important;
}

/* ==========================================================================
   CV Actions
   ========================================================================== */

.cv-actions {
    font-family: var(--font-mono);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin: 0 0 2.5rem;
    font-size: 0.875rem;
}

.cv-actions a {
    color: var(--ink);
}

/* ==========================================================================
   Contact Form (guill.sh style)
   ========================================================================== */

.contact-intro {
    margin-bottom: 2rem;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.form-input {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--ink);
    background: var(--code-bg);
    border: 1px solid var(--rule);
    border-radius: 3px;
    padding: 0.55rem 0.75rem;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    width: 100%;
}

textarea.form-input {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-submit {
    align-self: flex-start;
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-mono);
    cursor: pointer;
    border-radius: 3px;
    padding: 0.45rem 1.25rem;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.btn-submit:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-status {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    padding: 0.75rem;
    border-radius: 3px;
    margin-top: 1rem;
}

/* ==========================================================================
   Article & Prose (Single Post View)
   ========================================================================== */

.back-link {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 2rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    transition: color 0.15s ease;
}

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

.post-header,
.blog-post-header {
    margin-bottom: 2rem;
}

.post-header h1,
.blog-post-header h1 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 2.2rem;
    line-height: 1.25;
    border: none;
    padding-bottom: 0;
    /* Reserve enough height for the full title so the typewriter
       animation never causes the page to shift up/down */
    min-height: 5.5rem;
}

.meta {
    font-family: var(--font-mono);
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
}

.lede {
    color: var(--muted);
    margin: 1.25rem 0 0;
    font-size: 1.25rem;
    line-height: 1.45;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.post-declaration {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--muted);
    margin: 0.85rem 0 2rem;
    line-height: 1.5;
}

.post-declaration p {
    margin: 0 0 0.25rem 0;
    text-align: left;
}

.post-declaration p:last-child {
    margin-bottom: 0;
}

.post-declaration a {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.post-declaration a:hover {
    color: var(--accent);
}

/* Spacer between declaration block and article body */
.content-spacer {
    height: 1.5rem;
}

/* Prose reading typography */
.prose > :first-child {
    margin-top: 0;
}

.prose h2 {
    margin: 2.75rem 0 0.75rem;
    font-size: 1.375rem;
}

.prose h3 {
    margin: 2rem 0 0.5rem;
    font-size: 1.125rem;
}

.prose p {
    margin: 0 0 1.1rem;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.prose ul,
.prose ol {
    margin: 0 0 1.1rem;
    padding-left: 1.4rem;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.prose li + li {
    margin-top: 0.3rem;
}

.prose blockquote {
    border-left: 2px solid var(--rule);
    color: var(--muted);
    margin: 1.5rem 0;
    padding-left: 1.1rem;
    font-style: italic;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: 2.5rem 0;
}

.prose img {
    max-width: 100%;
    height: auto;
    margin: 1.75rem auto;
    display: block;
    border-radius: 4px;
    border: 1px solid var(--rule);
}

.prose table {
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9375rem;
    display: block;
    overflow-x: auto;
    width: 100%;
}

.prose th,
.prose td {
    border-bottom: 1px solid var(--rule);
    text-align: left;
    padding: 0.45rem 1.5rem 0.45rem 0;
}

.prose th {
    font-weight: 600;
}

.prose :not(pre) > code {
    background: var(--code-bg);
    font-family: var(--font-mono);
    border-radius: 3px;
    padding: 0.1em 0.3em;
    font-size: 0.85em;
    color: var(--ink);
}

.prose pre {
    background: var(--code-bg);
    border: 1px solid var(--rule);
    font-family: var(--font-mono);
    tab-size: 2;
    border-radius: 4px;
    margin: 1.5rem 0;
    padding: 1rem 1.1rem;
    font-size: 0.875rem;
    line-height: 1.55;
    overflow-x: auto;
    color: var(--ink);
}

.prose pre code {
    font-family: inherit;
    background: transparent;
    padding: 0;
}

@media (width >= 42rem) {
    .prose pre {
        margin-inline: -1.1rem;
    }
}

.highlight-box {
    border: 1px solid var(--rule);
    background: color-mix(in srgb, var(--code-bg) 45%, var(--paper));
    border-radius: 4px;
    margin: 2rem 0;
    padding: 1.25rem;
}

.highlight-box h2 {
    margin-top: 0;
    font-size: 1.2rem;
}

.highlight-box p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   guill.sh Elements: Diagrams, Bar Charts, Demos & Footnotes
   ========================================================================== */

/* Technical Diagrams */
.diagram {
    max-width: 100%;
    height: auto;
    margin-inline: auto;
    display: block;
    margin-block: 2rem;
}

.diagram text {
    fill: var(--ink);
    font-family: var(--font-mono);
    font-size: 11px;
}

.diagram .small {
    fill: var(--muted);
    font-size: 9.5px;
}

.diagram .box {
    fill: var(--code-bg);
    stroke: var(--rule);
    stroke-width: 1px;
}

.diagram .box.accent {
    stroke: var(--accent);
    fill: color-mix(in srgb, var(--accent) 8%, var(--code-bg));
}

.diagram .group {
    fill: none;
    stroke: var(--muted);
    stroke-dasharray: 4 4;
}

.diagram .line {
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.25px;
}

.diagram .line.accent {
    stroke: var(--accent);
}

.diagram .dot,
.diagram marker path {
    fill: var(--muted);
}

.diagram marker.accent path {
    fill: var(--accent);
}

.diagram .axis {
    stroke: var(--rule);
    stroke-width: 1px;
}

/* Horizontal Bar Charts */
.barchart {
    margin: 1.5rem 0;
}

.compas-barchart-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin-bottom: 0.85rem;
    padding: 0.6rem 0.85rem;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--ink);
}

.legend-swatch-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.swatch-box {
    width: 14px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

.swatch-red {
    background: #d20f39;
}

[data-theme="dark"] .swatch-red {
    background: #f38ba8;
}

.swatch-blue {
    background: #1e66f5;
}

[data-theme="dark"] .swatch-blue {
    background: #89b4fa;
}

.legend-ratio-pill {
    margin-left: auto;
    background: color-mix(in srgb, var(--accent-red) 12%, var(--paper));
    color: var(--accent-red);
    border: 1px solid color-mix(in srgb, var(--accent-red) 30%, transparent);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.barchart .hbars {
    margin: 0;
    padding: 0;
    list-style: none;
}

.barchart .hbars li {
    grid-template-columns: 10rem 1fr 3.25rem;
    align-items: center;
    gap: 0.35rem 0.75rem;
    margin: 0.65rem 0;
    display: grid;
}

.hbar-label {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--ink);
    font-weight: 500;
}

.hbar {
    background: color-mix(in srgb, var(--rule) 60%, transparent);
    border: 1px solid var(--rule);
    border-radius: 4px;
    height: 0.95rem;
    overflow: hidden;
}

.hbar > span {
    height: 100%;
    display: block;
    border-radius: 2px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* High contrast bar differentiation */
.barchart .hbars li:first-child .hbar > span {
    background: #d20f39; /* High Alert Red in Light Mode */
}

[data-theme="dark"] .barchart .hbars li:first-child .hbar > span {
    background: #f38ba8; /* Mocha Red */
}

.barchart .hbars li:nth-child(2) .hbar > span {
    background: #1e66f5; /* Royal Blue in Light Mode */
}

[data-theme="dark"] .barchart .hbars li:nth-child(2) .hbar > span {
    background: #89b4fa; /* Mocha Blue */
}

.hbar-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink);
}

.hbar-note {
    color: var(--muted);
    grid-column: 1 / 4;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    margin-top: 0.35rem;
}

/* Interactive Demos & Simulators */
.demo {
    border: 1px solid var(--rule);
    background: color-mix(in srgb, var(--code-bg) 50%, var(--paper));
    border-radius: 4px;
    margin: 2.25rem 0;
    padding: 1.25rem 1.25rem 1.35rem;
    font-size: 1rem;
}

@media (min-width: 42rem) {
    .demo {
        margin-inline: -1.1rem;
    }
}

.demo p {
    margin: 0 0 0.75rem;
    text-align: left;
}

.demo .demo-label {
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    display: block;
}

.demo button {
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-mono);
    cursor: pointer;
    border-radius: 3px;
    padding: 0.35rem 0.7rem;
    font-size: 0.8125rem;
    transition: all 0.15s ease;
}

.demo button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.demo button[aria-pressed="true"],
.demo button.active {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, var(--paper));
    font-weight: 500;
}

.demo-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.demo .readout-card {
    border: 1px solid var(--rule);
    background: var(--paper);
    border-radius: 3px;
    padding: 0.85rem 1rem;
    margin-top: 1rem;
}

.demo .readout-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.demo .readout-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    padding-block: 0.25rem;
    border-bottom: 1px dashed var(--rule);
}

.demo .readout-row:last-child {
    border-bottom: none;
}

.demo .readout-row .val-high {
    color: var(--accent-red);
    font-weight: 600;
}

.demo .readout-row .val-lime {
    color: var(--accent-green);
    font-weight: 600;
}

.demo .readout-row .val-accent {
    color: var(--accent);
    font-weight: 600;
}

/* Post references & citations */
sup.citation {
    font-size: 0.75rem;
    vertical-align: 0.4em;
    line-height: 0;
}

sup.citation a {
    text-decoration: none;
    font-family: var(--font-mono);
    color: var(--accent);
    padding: 0 0.15rem;
    border-radius: 2px;
    transition: background-color 0.15s ease;
}

sup.citation a:hover {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.references-section {
    border-top: 1px solid var(--rule);
    color: var(--muted);
    margin-top: 3.5rem;
    padding-top: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.55;
}

.references-section::before {
    content: "References";
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 1rem;
    font-size: 0.75rem;
    display: block;
    color: var(--muted);
}

.references-section ol {
    padding-left: 1.5rem;
    margin: 0;
}

.references-section li {
    margin-bottom: 0.65rem;
    padding: 0.2rem 0.35rem;
    border-radius: 3px;
    transition: background-color 0.35s ease;
}

.references-section li:target {
    background-color: color-mix(in srgb, #a3e635 25%, var(--paper));
    outline: 1px solid #a3e635;
}

.references-section a.backref {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
    margin-left: 0.35rem;
    display: inline-block;
    vertical-align: middle;
    transition: transform 0.15s ease;
}

.references-section a.backref:hover {
    transform: translateY(-1px);
    color: var(--ink);
}

/* Presentation Container in guill.sh style */
.pres-container {
    margin: 3rem 0;
    border: 1px solid var(--rule);
    background: color-mix(in srgb, var(--code-bg) 40%, var(--paper));
    border-radius: 4px;
    padding: 1.25rem;
}

.pres-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pres-controls-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pres-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

.pres-header a,
.pres-header button {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.pres-iframe-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    min-height: 480px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    overflow: hidden;
    background: #0d1117;
}

.pres-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
    display: block;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
    border-top: 1px solid var(--rule);
    font-family: var(--font-mono);
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    padding-block: 1.75rem 3.5rem;
    font-size: 0.8125rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
}

.site-footer a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.site-footer a:hover {
    color: var(--ink);
}

.footer-copy {
    color: var(--muted);
}

/* ==========================================================================
   Editorial Figures, Media & Grids (guill.sh style)
   ========================================================================== */

.post-figure {
    margin: 2.25rem 0;
}

.post-figure figcaption {
    font-family: var(--font-mono);
    font-size: 0.78125rem;
    color: var(--muted);
    text-align: center;
    margin-top: 0.75rem;
    line-height: 1.5;
}

.img-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: center;
}

.img-grid-2 img {
    margin: 0;
    width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid var(--rule);
    display: block;
}

.tri-pillar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.75rem 0 2rem;
}

.pillar-card {
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 1.25rem 1rem;
    text-align: center;
    background: var(--paper);
}

.pillar-card img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin: 0 auto 0.75rem;
    display: block;
    border: none;
}

.pillar-card h4 {
    margin: 0 0 0.35rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

.pillar-card p {
    font-size: 0.8125rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.4;
    text-align: center;
}

@media (max-width: 620px) {
    .tri-pillar-grid {
        grid-template-columns: 1fr;
    }
    .img-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 38rem) {
    h1 {
        font-size: 1.75rem;
    }

    main {
        padding-block: 2.5rem 3.5rem;
    }

    .post-list li {
        grid-template-columns: 1fr;
        gap: 0.1rem;
        padding-block: 0.5rem;
    }

    .archive li {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .site-header nav {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}


/* ==========================================================================
   Clouds Banner
   ========================================================================== */

.clouds-banner-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.25rem auto 2rem;
    text-align: center;
    width: 100%;
}

.clouds-banner {
    max-width: 100%;
    width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid var(--rule);
    display: block;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* -------------------------------------------------------------------------- */
/* KaTeX LaTeX Math Styling                                                   */
/* -------------------------------------------------------------------------- */
.katex {
    font-size: 1.05em;
    text-rendering: auto;
}

.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0;
    margin: 1rem 0;
}
