/* =============================================================
   satheeshvelu.blog — "Lab Console" theme
   Dark and light themes share one set of tokens. The theme is set on
   <html data-theme="dark|light"> by the small script in base.html.
   ============================================================= */

/* ---------- Tokens: dark (default) ---------- */
:root {
    color-scheme: dark;
    --bg: #0D1117;
    --surface: #161B22;
    --surface-2: #1C2128;
    --border: #30363D;
    --border-soft: #21262D;
    --text: #E6EDF3;
    --text-2: #D0D7DE;
    --muted: #9DA7B3;
    --faint: #6E7681;
    --accent: #F2B84B;
    --accent-hover: #FFD27F;
    --accent-ink: #0D1117;
    --accent-soft: rgba(242, 184, 75, 0.12);
    --nav-active-bg: #F2B84B;
    --nav-active-fg: #0D1117;
    --info: #7EC4FF;
    --ok: #3FB950;
    --danger: #FF7B72;
    --warn-bg: #1F1A10;
    --warn-border: #5C4A1E;
    --code-bg: #161B22;
    --header-bg: rgba(13, 17, 23, 0.92);

    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    --radius: 10px;
    --radius-lg: 12px;
    --wrap: 1200px;
    --gutter: 20px;

    /* Older names still used inside posts and tool pages */
    --bg-color: var(--bg);
    --bg-grad: var(--surface);
    --glass-bg: var(--surface);
    --glass-border: var(--border);
    --glass-highlight: var(--border);
    --text-primary: var(--text);
    --text-main: var(--text);
    --text-secondary: var(--muted);
    --text-muted: var(--muted);
    --accent-color: var(--accent);
    --accent-light: var(--accent);
    --neon-blue: var(--info);
    --neon-green: var(--ok);
    --neon-pink: var(--danger);
    --neon-purple: var(--info);
    --neon-yellow: var(--accent);
    --safe: var(--ok);
}

/* ---------- Tokens: light ---------- */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #FAFAF7;
    --surface: #FFFFFF;
    --surface-2: #F3F4F1;
    --border: #D0D7DE;
    --border-soft: #E6E8EB;
    --text: #1F2328;
    --text-2: #33383F;
    --muted: #57606A;
    --faint: #6E7781;
    --accent: #9A6700;
    --accent-hover: #7A5200;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(154, 103, 0, 0.10);
    --nav-active-bg: #1F2328;
    --nav-active-fg: #FFFFFF;
    --info: #0969DA;
    --ok: #1A7F37;
    --danger: #CF222E;
    --warn-bg: #FFF8E5;
    --warn-border: #E8D19A;
    --code-bg: #F3F4F1;
    --header-bg: rgba(250, 250, 247, 0.92);
}

/* Without JavaScript, follow the device setting */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        color-scheme: light;
        --bg: #FAFAF7; --surface: #FFFFFF; --surface-2: #F3F4F1; --border: #D0D7DE; --border-soft: #E6E8EB;
        --text: #1F2328; --text-2: #33383F; --muted: #57606A; --faint: #6E7781;
        --accent: #9A6700; --accent-hover: #7A5200; --accent-ink: #FFFFFF; --accent-soft: rgba(154, 103, 0, 0.10);
        --nav-active-bg: #1F2328; --nav-active-fg: #FFFFFF;
        --info: #0969DA; --ok: #1A7F37; --danger: #CF222E; --warn-bg: #FFF8E5; --warn-border: #E8D19A;
        --code-bg: #F3F4F1; --header-bg: rgba(250, 250, 247, 0.92);
    }
}

@media (min-width: 768px) {
    :root { --gutter: 32px; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: 80px;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

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

button, input, select, textarea { font: inherit; color: inherit; }

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

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.info { color: var(--info); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding-inline: max(var(--gutter), env(safe-area-inset-left));
}

main.site-main { flex: 1; }

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
}

.brand {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.0625rem;
    color: var(--text);
    white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand-at { color: var(--accent); }
.brand-prompt { color: var(--muted); }

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

.site-nav {
    display: none;
    gap: 2px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.site-nav a {
    color: var(--text);
    padding: 10px 12px;
    border-radius: 6px;
}
.site-nav a:hover { background: var(--surface); color: var(--text); }
.site-nav a[aria-current="page"] {
    background: var(--nav-active-bg);
    color: var(--nav-active-fg);
    font-weight: 600;
}

.theme-switch {
    display: flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.theme-switch button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] {
    background: var(--nav-active-bg);
    color: var(--nav-active-fg);
}

.menu-btn {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.mobile-nav {
    display: none;
    border-top: 1px solid var(--border);
    padding: 8px 0 14px;
    font-family: var(--font-mono);
}
.mobile-nav.open { display: block; }
.mobile-nav a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 4px;
    color: var(--text);
    border-bottom: 1px dashed var(--border);
}
.mobile-nav a:last-child { border-bottom: 0; }
.mobile-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

@media (min-width: 860px) {
    .site-nav { display: flex; }
    .menu-btn, .mobile-nav, .mobile-nav.open { display: none; }
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 56px;
    padding-bottom: env(safe-area-inset-bottom);
}

.footer-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    justify-content: space-between;
    padding-block: 24px 32px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
}
.footer-row a { color: var(--muted); }
.footer-row a:hover { color: var(--text); }
.status-dot { color: var(--ok); }

/* ---------- Shared bits ---------- */
.kicker {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--accent);
    margin: 0;
}

.section-title {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
    margin: 0 0 12px;
}
.section-title .faint { color: var(--faint); }

.page-head {
    padding-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.page-head h1 {
    margin: 0;
    font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem);
    line-height: 1.15;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.page-head p { margin: 0; color: var(--muted); font-size: 1.0625rem; max-width: 640px; }

.back-link {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    min-height: 32px;
}
.back-link:hover { color: var(--text); }

.tag {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
}

.cat { font-family: var(--font-mono); color: var(--accent); }
.cat-tech, .cat-technology { color: var(--info); }

.search-field {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: var(--font-mono);
}
.search-field:focus-within { border-color: var(--accent); }
.search-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 1rem; /* 16px stops iOS zooming in */
    font-family: var(--font-mono);
}
.search-field input::placeholder { color: var(--faint); }
.search-field .prompt { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    cursor: pointer;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] {
    background: var(--nav-active-bg);
    border-color: var(--nav-active-bg);
    color: var(--nav-active-fg);
    font-weight: 600;
}

.more-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

/* ---------- Home ---------- */
.hero {
    padding-top: 36px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 760px;
}
.hero h1 {
    margin: 0;
    font-size: clamp(1.875rem, 1.3rem + 2.6vw, 2.75rem);
    line-height: 1.15;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.hero p { margin: 0; color: var(--muted); font-size: 1.0625rem; }
.hero .search-field { margin-top: 6px; }

.home-section { margin-top: 40px; }

/* ---------- Tools ---------- */
.tool-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.tool-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 12px 16px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.tool-card:last-child { border-bottom: 0; }
.tool-card:hover { color: var(--text); background: var(--surface-2); }
.tool-card .tool-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tool-card .tool-meta { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.tool-card .tool-name { font-size: 1rem; font-weight: 500; }
.tool-card .tool-desc { display: none; font-size: 0.875rem; color: var(--muted); line-height: 1.5; }
.tool-card .tool-run { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--accent); white-space: nowrap; }

@media (min-width: 700px) {
    .tool-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
        background: transparent;
        border: 0;
        border-radius: 0;
        overflow: visible;
    }
    .tool-card {
        flex-direction: column;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding: 18px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
    }
    .tool-card:last-child { border-bottom: 1px solid var(--border); }
    .tool-card:hover { border-color: var(--muted); }
    .tool-card .tool-text { gap: 8px; }
    .tool-card .tool-meta { order: -1; }
    .tool-card .tool-name { font-size: 1.0625rem; font-weight: 600; }
    .tool-card.with-desc .tool-desc { display: block; }
}

.tool-group { margin-top: 36px; }

/* ---------- Note lists ---------- */
.note-list { display: flex; flex-direction: column; }

.note-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 0;
    border-bottom: 1px dashed var(--border);
    color: var(--text);
}
.note-row:hover { color: var(--text); }
.note-row:hover .note-title { color: var(--accent); }
.note-date { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.note-cat { font-family: var(--font-mono); font-size: 0.75rem; }
.note-title { font-size: 1.0625rem; font-weight: 500; line-height: 1.35; }
.note-snippet { display: none; color: var(--muted); font-size: 0.9375rem; line-height: 1.5; }
.note-row .note-top { display: flex; gap: 8px; align-items: baseline; }

@media (min-width: 700px) {
    .note-row {
        display: grid;
        grid-template-columns: 110px 110px minmax(0, 1fr);
        column-gap: 16px;
        align-items: baseline;
    }
    .note-row .note-top { display: contents; }
    .note-date, .note-cat { font-size: 0.8125rem; }
    .note-body { display: flex; flex-direction: column; gap: 4px; }
    .note-snippet { display: block; }
}

.empty-state {
    padding: 28px 0;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

/* ---------- Article ---------- */
.post-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 40px 56px;
    align-items: flex-start;
    padding-top: 24px;
}

.post-main {
    flex: 999 1 560px;
    min-width: 0;
    max-width: 760px;
}

.post-aside {
    flex: 1 1 220px;
    min-width: 0;
    display: none;
}

@media (min-width: 1040px) {
    .post-aside {
        display: block;
        position: sticky;
        top: 96px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
    .toc-mobile { display: none; }
}

.post-header { display: flex; flex-direction: column; gap: 14px; margin-bottom: 8px; }
.post-header h1 {
    margin: 0;
    font-size: clamp(1.75rem, 1.25rem + 2.2vw, 2.625rem);
    line-height: 1.18;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.post-meta { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--muted); }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.toc-title { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); margin: 0 0 8px; }
.toc-list { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 1px solid var(--border); }
.toc-item a {
    display: block;
    padding: 5px 0;
    font-size: 0.875rem;
    color: var(--text-2);
    line-height: 1.4;
}
.toc-item a:hover { color: var(--text); }
.toc-item a.active { color: var(--accent); font-weight: 500; }
.toc-level-3 a { padding-left: 12px; font-size: 0.8125rem; color: var(--muted); }

.toc-mobile {
    margin: 8px 0 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.toc-mobile summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 48px;
    padding: 0 14px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    cursor: pointer;
    list-style: none;
}
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile summary::after { content: "▾"; color: var(--muted); }
.toc-mobile[open] summary::after { content: "▴"; }
.toc-mobile .toc-list { margin: 0 14px 14px; }

.post-nav {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.post-nav a {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}
.post-nav a:hover { border-color: var(--muted); color: var(--text); }
.post-nav .dir { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.post-nav .next { text-align: right; }

.draft-banner {
    background: var(--warn-bg);
    border-bottom: 1px solid var(--warn-border);
    color: var(--text);
    text-align: center;
    padding: 10px var(--gutter);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: var(--accent);
    z-index: 60;
}

/* ---------- Prose (rendered Markdown) ---------- */
.prose {
    font-size: 1.0625rem;
    line-height: 1.75;
    color: var(--text-2);
    counter-reset: h2;
    overflow-wrap: break-word;
}
@media (min-width: 768px) { .prose { font-size: 1.125rem; } }

.prose > * + * { margin-top: 1.1em; }
.prose p { margin: 0; }
.prose p + p { margin-top: 1em; }

.prose h1, .prose h2, .prose h3, .prose h4 {
    color: var(--text);
    line-height: 1.3;
    font-weight: 600;
    margin: 1.8em 0 0.5em;
}
.prose h1 { font-size: 1.5em; }
.prose h2 { font-size: 1.375em; }
.prose h3 { font-size: 1.15em; }
.prose h4 { font-size: 1em; }
.prose.auto-num h2::before {
    counter-increment: h2;
    content: counter(h2, decimal-leading-zero) " ";
    font-family: var(--font-mono);
    color: var(--accent);
    font-weight: 500;
}
.prose > :first-child { margin-top: 0; }

.prose strong { color: var(--text); }
.prose a { text-decoration: underline; text-decoration-color: var(--accent-soft); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.prose a:hover { text-decoration-color: var(--accent); }

.prose ul, .prose ol { padding-left: 1.4em; margin-bottom: 0; }
.prose li + li { margin-top: 0.35em; }
.prose li > ul, .prose li > ol { margin-top: 0.35em; }
.prose ul li::marker { color: var(--accent); }
.prose ol li::marker { color: var(--muted); font-family: var(--font-mono); font-size: 0.9em; }

.prose hr { border: 0; border-top: 1px dashed var(--border); margin: 2em 0; }

.prose img {
    display: block;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-inline: auto;
}

.prose blockquote {
    margin: 1.4em 0 0;
    padding: 14px 18px;
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95em;
}
.prose blockquote > :first-child { margin-top: 0; }

.prose code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1em 0.35em;
    color: var(--text);
}

.code-block {
    margin-top: 1.4em;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.code-block-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px 6px 14px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
}
.copy-btn {
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
}
.copy-btn:hover { border-color: var(--muted); }

.prose pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85em;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}
.code-block pre { border: 0; border-radius: 0; }
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; color: var(--text); }

.table-wrap {
    margin-top: 1.4em;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
}
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9em; line-height: 1.5; }
.table-wrap table { margin: 0; }
.prose th {
    text-align: left;
    padding: 10px 14px;
    background: var(--surface-2);
    font-family: var(--font-mono);
    font-size: 0.8em;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}
.prose td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: top; }

/* Embedded charts and widgets inside posts */
.prose .js-plotly-plot, .prose .plotly-graph-div { max-width: 100%; }
.prose iframe { max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius); }

/* ---------- Projects ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.project-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.project-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.project-category-badge { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); }
.project-title { margin: 0; font-size: 1.125rem; font-weight: 600; line-height: 1.35; }
.project-desc { margin: 0; color: var(--muted); font-size: 0.9375rem; line-height: 1.55; flex: 1; }
.project-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.project-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    cursor: pointer;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }

/* Old tag class used by older pages */
.label {
    display: inline-flex;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
}

/* ---------- About ---------- */
.about-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 28px 48px;
    margin-top: 28px;
}
.about-text { flex: 999 1 480px; min-width: 0; max-width: 720px; }
.about-side { flex: 1 1 240px; display: flex; flex-direction: column; gap: 24px; }
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
}
.skills { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Back to top ---------- */
.back-to-top {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-mono);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 40;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }

/* =============================================================
   Tool pages (calculators). Class names are kept from the old
   site so the calculator scripts keep working.
   ============================================================= */
.glass-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.calc-page-header { padding-top: 32px; margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.calc-page-title {
    margin: 0;
    font-size: clamp(1.75rem, 1.25rem + 2.2vw, 2.5rem);
    line-height: 1.15;
    font-weight: 600;
    color: var(--text);
}
.calc-page-subtitle { margin: 0; color: var(--muted); font-size: 1.0625rem; }

.calc-tabs {
    display: flex;
    gap: 6px;
    padding: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.calc-tabs::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .calc-tabs { flex-wrap: wrap; overflow: visible; } }

.calc-tab, .vdiv-mode-btn, .filter-sub-tab {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    white-space: nowrap;
    cursor: pointer;
}
.calc-tab:hover, .vdiv-mode-btn:hover, .filter-sub-tab:hover { background: var(--surface-2); }
.calc-tab.active, .vdiv-mode-btn.active, .filter-sub-tab.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-fg);
    font-weight: 600;
}
.vdiv-mode-btn, .filter-sub-tab { border-color: var(--border); }

.vdiv-mode-strip, .filter-sub-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.filter-sub-panel { display: none; }
.filter-sub-panel.active { display: block; }

.calc-panel { display: none; padding: 18px; margin-bottom: 16px; }
.calc-panel.active { display: block; }
@media (min-width: 768px) { .calc-panel { padding: 28px; } }

.calc-panel-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.calc-icon { font-size: 1.75rem; line-height: 1; flex-shrink: 0; }
@media (max-width: 600px) { .calc-icon { display: none; } }
.calc-title { margin: 0 0 6px; font-size: 1.375rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.calc-desc { margin: 0; color: var(--muted); font-size: 0.9375rem; line-height: 1.55; }

.calc-body { display: grid; grid-template-columns: 1fr; gap: 28px; align-items: start; }
@media (min-width: 900px) { .calc-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; } }

.calc-inputs { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.calc-section-label {
    margin: 4px 0 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
}
.calc-input-row { display: flex; flex-direction: column; gap: 6px; }
.calc-input-row label { font-size: 0.875rem; color: var(--text-2); }

/* Inputs: standalone, or inside a group with a unit */
.calc-input {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 1rem; /* 16px stops iOS zooming in */
    outline: none;
}
.calc-input:focus { border-color: var(--accent); }
.calc-input::placeholder { color: var(--faint); }
select.calc-input { cursor: pointer; }

.calc-input-group {
    display: flex;
    align-items: stretch;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.calc-input-group:focus-within { border-color: var(--accent); }
.calc-input-group .calc-input { flex: 1; border: 0; border-radius: 0; background: transparent; }

.calc-unit, .calc-unit-select {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--surface-2);
    border: 0;
    border-left: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    white-space: nowrap;
}
.calc-unit-select { min-width: 60px; cursor: pointer; outline: none; font-size: 1rem; }

.calc-unit-toggles { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 4px; }
.calc-unit-toggle { display: flex; align-items: center; gap: 6px; min-height: 32px; font-size: 0.875rem; color: var(--text-2); cursor: pointer; }
.calc-unit-toggle input { accent-color: var(--accent); cursor: pointer; }

.calc-slider-row { margin: 10px 0; }
.calc-slider, .calc-range { width: 100%; accent-color: var(--accent); }

.calc-btn {
    min-height: 48px;
    padding: 0 20px;
    margin-top: 6px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
}
.calc-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.calc-btn-ghost {
    min-height: 44px;
    padding: 0 16px;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    cursor: pointer;
}
.calc-btn-ghost:hover { border-color: var(--muted); }

.calc-output { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.calc-result {
    min-height: 120px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
}
.calc-result-placeholder { color: var(--muted); font-family: var(--font-mono); font-size: 0.8125rem; text-align: center; }
.calc-result-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-soft);
}
.calc-result-row:last-child { border-bottom: 0; }
.calc-result-label { color: var(--muted); font-size: 0.875rem; }
.calc-result-value { font-family: var(--font-mono); font-size: 1.0625rem; font-weight: 600; color: var(--accent); text-align: right; }
.calc-result-unit { font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.calc-error { color: var(--danger); font-size: 0.9375rem; }

.calc-formula, .calc-diagram, .calc-info-box {
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-2);
    font-size: 0.875rem;
    line-height: 1.6;
}
.calc-formula { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--muted); }
.calc-ascii { margin: 0; font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); line-height: 1.5; overflow-x: auto; }

.privacy-disclaimer {
    margin-top: 10px;
    padding: 8px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8125rem;
    color: var(--text-2);
}

/* Breakdown tables built by the calculator scripts */
#tax-breakdown-table table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
#tax-breakdown-table th, #tax-breakdown-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); text-align: left; }
#tax-breakdown-table td:last-child, #tax-breakdown-table th:last-child { text-align: right; font-family: var(--font-mono); }

/* Resistor colour-code preview */
.resistor-band-row { display: flex; flex-direction: column; gap: 14px; }
.color-band-select option { font-weight: 600; }
.resistor-preview { display: flex; justify-content: center; padding: 16px 0 4px; }
.resistor-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 160px;
    padding: 12px 24px;
    border-radius: 30px;
    background: linear-gradient(90deg, #8B7355, #C8A96A, #8B7355);
}
.resistor-band { width: 14px; height: 34px; border-radius: 3px; }

/* ---------- Print ---------- */
@media print {
    .site-header, .site-footer, .back-to-top, .post-aside, .toc-mobile, .post-nav, .copy-btn { display: none !important; }
    body { background: #fff; color: #000; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
