@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&display=swap');

/* ============================================================
   DESIGN TOKENS: all theme values in one place
   ============================================================ */
:root {
    --bg: #f5f2ec;
    --surface: #fdfaf4;
    --panel: #ece8e0;
    --border: #d8d0c4;
    --border-subtle: rgba(33, 29, 24, 0.08);
    --text: #1e1a16;
    --text-2: #3d352b;
    --muted: #6a5f52;
    --faint: #9a9082;
    --accent: #2c6a61;
    --accent-bg: rgba(44, 106, 97, 0.08);
    --accent-border: rgba(44, 106, 97, 0.28);
    --good: #5c6b5a;
    --good-bg: rgba(92, 107, 90, 0.09);
    --good-border: rgba(92, 107, 90, 0.26);
    --attn: #7c5c2a;
    --attn-bg: rgba(124, 92, 42, 0.09);
    --attn-border: rgba(124, 92, 42, 0.28);
    --mono-bg: #ede7db;
    --mono-text: #302a22;
    --card: var(--surface);
    --card-hover: #fffcf5;
    --shadow-card: 0 2px 8px rgba(33, 29, 24, 0.06), 0 1px 2px rgba(33, 29, 24, 0.04);
    --shadow-hover: 0 10px 28px rgba(33, 29, 24, 0.10), 0 2px 6px rgba(33, 29, 24, 0.05);

    --serif: "Instrument Serif", Georgia, serif;
    --body: "Geist", "Inter", system-ui, -apple-system, sans-serif;
    --mono: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 16px;
    --text-md: 18px;
    --text-lg: 22px;
    --text-xl: clamp(24px, 3vw, 32px);

    --radius: 7px;
    --radius-sm: 4px;
    --sidebar-w: 420px;
}

[data-theme="dark"] {
    --bg: #131110;
    --surface: #1f1a15;
    --panel: #191410;
    --border: rgba(235, 225, 210, 0.13);
    --border-subtle: rgba(235, 225, 210, 0.07);
    --text: #ede5d8;
    --text-2: #cfc3b2;
    --muted: #a79987;
    --faint: #6f6457;
    --accent: #80bfb3;
    --accent-bg: rgba(128, 191, 179, 0.09);
    --accent-border: rgba(128, 191, 179, 0.28);
    --good: #9eaa9c;
    --good-bg: rgba(158, 170, 156, 0.09);
    --good-border: rgba(158, 170, 156, 0.24);
    --attn: #d4a655;
    --attn-bg: rgba(212, 166, 85, 0.09);
    --attn-border: rgba(212, 166, 85, 0.28);
    --mono-bg: rgba(235, 225, 210, 0.07);
    --mono-text: #dfd3c2;
    --card-hover: #262019;
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.38);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    font-family: var(--body);
    font-size: var(--text-base);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* subtle grain overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(26, 22, 16, 0.07) 0.4px, transparent 0.4px);
    background-size: 3px 3px;
    opacity: 0.18;
    z-index: 0;
}

[data-theme="dark"] body::before {
    opacity: 0.55;
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.page-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 28px;
    position: relative;
    z-index: 1;
}

.layout {
    display: grid;
    grid-template-columns: minmax(260px, 30%) minmax(0, 70%);
    column-gap: 56px;
    align-items: start;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 72px 0 56px;
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar {
    background-image: repeating-linear-gradient(to bottom,
            rgba(255, 255, 255, 0.014) 0,
            rgba(255, 255, 255, 0.014) 1px,
            transparent 1px,
            transparent 56px);
}

[data-theme="dark"] .sidebar {
    background-image: none;
}

.sidebar-inner {
    min-height: calc(100vh - 128px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* ============================================================
   IDENTITY BLOCK
   ============================================================ */
.name {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(28px, 3.4vw, 36px);
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--text);
}

.role {
    margin-top: 10px;
    font-family: var(--body);
    font-weight: 600;
    color: var(--accent);
    font-size: var(--text-sm);
    letter-spacing: 0.01em;
    min-height: 22px;
}

/* typing cursor */
.role.role-typing::after {
    content: "";
    display: inline-block;
    width: 1.5px;
    height: 1em;
    margin-left: 3px;
    background: currentColor;
    vertical-align: -2px;
}

@media (prefers-reduced-motion: no-preference) {
    .role.role-typing::after {
        animation: blink-caret 0.85s steps(1, end) infinite;
    }
}

.bio {
    margin-top: 16px;
    max-width: 34ch;
    color: var(--text-2);
    font-size: var(--text-sm);
    line-height: 1.72;
}

.avail-pill {
    margin-top: 22px;
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--good-border);
    background: var(--good-bg);
    color: var(--good);
    border-radius: 999px;
    padding: 5px 13px;
    font-family: var(--mono);
    font-size: var(--text-xs);
    letter-spacing: 0.04em;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--good);
    flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .status-dot {
        animation: pulse-dot 2s ease-in-out infinite;
    }
}

/* ============================================================
   SIDE NAV
   ============================================================ */
.side-nav {
    margin-top: 44px;
}

.side-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    border-left: 2px solid transparent;
    padding: 4px 0 4px 12px;
    text-decoration: none;
    color: var(--muted);
    font-family: var(--mono);
    font-size: var(--text-xs);
    letter-spacing: 0.10em;
    text-transform: uppercase;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

.nav-link:focus-visible {
    color: var(--text);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.nav-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-bg);
    padding: 6px 10px 6px 12px;
}

/* ============================================================
   SOCIAL ROW
   ============================================================ */
.social-row {
    margin-top: 42px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.social-row a {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.social-row a:hover {
    color: var(--accent);
    background: var(--accent-bg);
    transform: translateY(-1px);
}

.social-row a:focus-visible {
    color: var(--accent);
    background: var(--accent-bg);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.social-row svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.theme-toggle:hover {
    color: var(--text-2);
    background: var(--mono-bg);
    border-color: var(--border);
}

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

.theme-icon-light {
    display: none;
}

.theme-icon-dark {
    display: flex;
}

[data-theme="dark"] .theme-icon-light {
    display: flex;
}

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

.theme-toggle-mob {
    width: 38px;
    height: 38px;
    margin: 0;
    padding: 0;
}

.theme-toggle-mob:hover {
    color: var(--text);
    background: none;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.content {
    padding: 72px 0 80px;
}

.section {
    padding: 28px 0;
}

.section-head {
    margin-bottom: 18px;
}

.section-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    background: var(--mono-bg);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

h2 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: var(--text-xl);
    line-height: 1.14;
    letter-spacing: -0.015em;
    color: var(--text);
}

.section-head h2::after {
    content: "";
    display: block;
    width: 36px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
    margin-top: 10px;
}

.section-body,
.project-grid,
.stack-grid,
.edu-list,
.contact-list,
.site-footer,
.all-repos {
    max-width: 700px;
}

.section-body p {
    color: var(--text-2);
    font-size: var(--text-base);
    line-height: 1.73;
    margin-bottom: 14px;
}

/* ============================================================
   PROJECT CARDS
   ============================================================ */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.pcard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
    padding: 22px 24px;
}

.pcard:hover {
    border-color: var(--accent-border);
    box-shadow: var(--shadow-hover);
}

@media (prefers-reduced-motion: no-preference) {
    .pcard:hover {
        transform: translateY(-2px);
    }
}

.pcard.featured {
    grid-column: 1 / -1;
    border-color: var(--accent-border);
    background: linear-gradient(160deg, var(--surface) 70%, var(--accent-bg) 100%);
}

/* ---- top row ---- */
.pcard-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.pcard-num {
    font-family: var(--mono);
    color: var(--faint);
    font-size: var(--text-xs);
    white-space: nowrap;
    flex-shrink: 0;
}

.pcard-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 8px;
    font-family: var(--mono);
    font-size: 9.5px;
    color: var(--muted);
    white-space: nowrap;
}

.tag-status {
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 2px 9px;
}

.tag-status::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.tag-status-published {
    background: var(--accent-bg);
    border-color: var(--accent-border);
    color: var(--accent);
}

.tag-status-attn {
    background: var(--attn-bg);
    border-color: var(--attn-border);
    color: var(--attn);
}

.tag-status-ok {
    background: var(--good-bg);
    border-color: var(--good-border);
    color: var(--good);
}

.tag-status-kaggle {
    background: var(--mono-bg);
    border-color: var(--border);
    color: var(--mono-text);
}

/* ---- card headings and hook ---- */
.pcard h3 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 20px;
    line-height: 1.26;
    letter-spacing: -0.01em;
    margin-bottom: 9px;
    color: var(--text);
}

.hook {
    color: var(--text-2);
    font-size: var(--text-sm);
    line-height: 1.66;
    margin-bottom: 12px;
}

.pcard-image {
    margin: 0 0 14px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.pcard-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* ---- callout block ---- */
.callout {
    display: block;
    border-left: 3px solid var(--accent);
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 16px;
    font-family: var(--serif);
    font-style: italic;
    font-size: 15px;
    line-height: 1.68;
    margin-bottom: 14px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.callout::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(135deg,
            var(--accent) 0,
            var(--accent) 1px,
            transparent 1px,
            transparent 10px);
    opacity: 0.035;
    pointer-events: none;
    z-index: 0;
}

/* ---- accordion ---- */
.pcard-accordions {
    border-top: 1px solid var(--border-subtle);
    margin-top: 4px;
}

.accordion-item {
    border-bottom: 1px solid var(--border-subtle);
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 0;
    background: none;
    border: none;
    color: var(--text-2);
    font-family: var(--mono);
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    text-align: left;
    transition: color 0.18s ease;
}

.accordion-trigger:hover {
    color: var(--accent);
}

.accordion-trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
    color: var(--accent);
}

.accordion-trigger .acc-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--faint);
    transition: transform 0.22s ease, color 0.18s ease;
}

.accordion-trigger[aria-expanded="true"] .acc-icon {
    transform: rotate(45deg);
    color: var(--accent);
}

.accordion-trigger[aria-expanded="true"] {
    color: var(--accent);
}

.accordion-panel {
    padding-bottom: 14px;
}

.accordion-panel[hidden] {
    display: none;
}

.accordion-panel p {
    color: var(--text-2);
    font-size: var(--text-sm);
    line-height: 1.72;
    margin-top: 8px;
}

.accordion-panel p:first-child {
    margin-top: 0;
}

.accordion-panel p strong {
    color: var(--text);
    font-weight: 600;
}

.accordion-panel code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: var(--mono-bg);
    color: var(--mono-text);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
}

/* ---- chips ---- */
.chips {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    border: 1px solid var(--border);
    background: var(--mono-bg);
    color: var(--mono-text);
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.02em;
    max-width: 100%;
}

.chip-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---- card footer ---- */
.pcard-foot {
    margin-top: 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.pcard-foot a {
    display: inline-flex;
    text-decoration: none;
    color: var(--accent);
    border: 1px solid var(--accent-border);
    border-radius: 999px;
    padding: 4px 11px;
    font-family: var(--mono);
    font-size: var(--text-xs);
    transition: background 0.18s ease, border-color 0.18s ease;
}

.pcard-foot a:hover {
    background: var(--accent-bg);
}

.pcard-foot a:focus-visible {
    background: var(--accent-bg);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.pcard-foot span {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--faint);
}

.all-repos {
    margin-top: 18px;
    text-align: right;
}

.all-repos a {
    font-family: var(--mono);
    color: var(--accent);
    text-decoration: none;
    font-size: 11.5px;
    opacity: 0.8;
    transition: opacity 0.18s ease;
}

.all-repos a:hover {
    opacity: 1;
    text-decoration: underline;
}

.all-repos a:focus-visible {
    opacity: 1;
    text-decoration: underline;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================================
   STACK GRID
   ============================================================ */
.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.stack-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.22s ease, transform 0.22s ease;
}

.stack-card:hover {
    box-shadow: var(--shadow-hover);
}

@media (prefers-reduced-motion: no-preference) {
    .stack-card:hover {
        transform: translateY(-1px);
    }
}

.stack-card h3 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.3;
    margin-bottom: 4px;
    color: var(--text);
}

.stack-sub {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--faint);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.stack-card ul {
    list-style: none;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.stack-card li {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: baseline;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.stack-card li:last-child {
    border-bottom: none;
}

.tool {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--mono-text);
}

.tool.core {
    color: var(--accent);
}

.tool.core::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 6px;
    vertical-align: 1px;
    opacity: 0.75;
}

.note {
    font-family: var(--mono);
    font-size: 9.5px;
    color: var(--faint);
    font-style: italic;
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ============================================================
   EDUCATION
   ============================================================ */
.edu-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.edu-entry {
    padding: 20px 22px;
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 18px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.18s ease;
}

.edu-entry:last-child {
    border-bottom: none;
}

.edu-entry:hover {
    background: var(--card-hover);
}

.period {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--faint);
    letter-spacing: 0.05em;
    padding-top: 3px;
    line-height: 1.5;
}

.edu-entry h3 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.3;
    margin-bottom: 4px;
    color: var(--text);
}

.inst {
    color: var(--text-2);
    font-size: var(--text-sm);
}

.detail {
    margin-top: 3px;
    font-family: var(--mono);
    color: var(--faint);
    font-size: 10px;
}

.accent-val {
    color: var(--accent);
}

/* ============================================================
   CONTACT
   ============================================================ */
.contact-list {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 16px;
    text-decoration: none;
    color: inherit;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.contact-card:hover {
    border-color: var(--accent-border);
    box-shadow: var(--shadow-hover);
}

.contact-card:focus-visible {
    border-color: var(--accent-border);
    box-shadow: var(--shadow-hover);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
    .contact-card:hover,
    .contact-card:focus-visible {
        transform: translateY(-1px);
    }
}

.contact-card:hover .contact-icon,
.contact-card:focus-visible .contact-icon {
    color: var(--accent);
    background: var(--accent-bg);
    transition: color 0.15s ease, background 0.15s ease;
}

.contact-primary {
    border-color: var(--accent-border);
    background: var(--accent-bg);
}

.contact-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    background: var(--mono-bg);
    transition: color 0.18s ease, background 0.18s ease;
    flex-shrink: 0;
}

.contact-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.4;
    min-width: 0;
}

.contact-label {
    font-family: var(--mono);
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--faint);
}

.contact-value {
    color: var(--text-2);
    font-size: var(--text-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-arrow {
    color: var(--faint);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: transform 0.18s ease, color 0.18s ease;
}

.contact-arrow svg {
    width: 16px;
    height: 16px;
}

.contact-card:hover .contact-arrow {
    transform: translateX(2px);
    color: var(--accent);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    margin-top: 32px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 18px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.site-footer p {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--faint);
}

.back-to-top {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 38px;
    height: 38px;
    border: 1px solid var(--accent-border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.18s ease;
    z-index: 150;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.back-to-top:hover {
    background: var(--accent-bg);
    transform: translateY(-1px);
}

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

/* ============================================================
   SCROLL PROGRESS BAR
   ============================================================ */
.scroll-progress {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: 2px;
    background: linear-gradient(to right, var(--accent), var(--good));
    opacity: 0.55;
    transform-origin: left center;
    transform: scaleX(0);
    z-index: 9999;
    pointer-events: none;
    transition: transform 0.08s linear;
}

/* ============================================================
   SCROLL REVEAL: only when user allows motion
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(14px);
        transition: opacity 0.5s ease, transform 0.5s ease;
    }

    .reveal.vis {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   MOBILE HEADER (hidden on desktop)
   ============================================================ */
.mobile-top,
.mobile-nav,
.nav-toggle {
    display: none;
}

/* ============================================================
   SKIP LINK (accessibility)
   ============================================================ */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--accent);
    color: var(--bg);
    padding: 8px 16px;
    z-index: 10000;
    font-family: var(--mono);
    font-size: 12px;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

/* ============================================================
   ANIMATIONS: defined once, used with prefers-reduced-motion
   ============================================================ */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes blink-caret {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* ============================================================
   RESPONSIVE: 1020px
   ============================================================ */
@media (max-width: 1020px) {
    :root {
        --sidebar-w: 300px;
    }

    .layout {
        column-gap: 36px;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   RESPONSIVE: 900px
   ============================================================ */
@media (max-width: 900px) {
    :root {
        --sidebar-w: 0px;
    }

    .page-wrap {
        padding: 0 20px;
    }

    .layout {
        display: block;
    }

    .sidebar {
        position: static;
        height: auto;
        overflow: visible;
        padding: 24px 0 20px;
        border-bottom: 1px solid var(--border);
        background-image: none;
    }

    .sidebar-inner {
        min-height: auto;
    }

    .social-row {
        display: none;
    }

    .theme-toggle {
        display: none;
    }

    .theme-toggle-mob {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .content {
        padding-top: 4px;
    }

    .section {
        padding: 22px 0;
    }

    .project-grid,
    .stack-grid {
        grid-template-columns: 1fr;
    }

    .edu-entry {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .scroll-progress {
        left: 0;
    }
}

@media (max-width: 768px) {
    .mobile-top {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 120;
        height: 56px;
        background: transparent;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 36px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
        color: var(--text-2);
        cursor: pointer;
    }

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

    .nav-toggle .icon-close {
        display: none;
    }

    .nav-toggle[aria-expanded="true"] .icon-menu {
        display: none;
    }

    .nav-toggle[aria-expanded="true"] .icon-close {
        display: block;
    }

    #mobile-nav {
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 14px 20px;
        display: flex;
        flex-direction: column;
        gap: 6px;
        opacity: 0;
        transform: translateY(-6px);
        pointer-events: none;
        visibility: hidden;
        transition: opacity 0.22s ease, transform 0.22s ease;
        z-index: 121;
    }

    #mobile-nav.open {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
        visibility: visible;
    }

    #mobile-nav .nav-link {
        border-left: 0;
        border-radius: var(--radius-sm);
        padding: 5px 0;
    }

    #mobile-nav .nav-link.active {
        border-left: 0;
        border-bottom: 1px solid var(--accent);
        padding: 5px 0;
    }
}

@media (max-width: 600px) {
    .stack-card li {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .note {
        text-align: left;
        font-size: 9px;
        color: var(--muted);
    }
}

/* ============================================================
   RESPONSIVE: 540px
   ============================================================ */
@media (max-width: 540px) {
    .page-wrap {
        padding: 0 14px;
    }

    .pcard,
    .stack-card,
    .edu-entry,
    .contact-card {
        padding: 14px 16px;
    }
}
