/* ============================================================
   Manish Biswas — AI Portfolio
   Pixel / CRT theme. Tokens live here once and are reused.
   ============================================================ */

:root {
    --bg: #0f1020;
    --bg-2: #16172e;
    --panel: #1c1d3a;
    --panel-2: #20224a;
    --panel-3: #12142c;
    --ink: #eef1ff;
    --ink-dim: #b6bce0;
    --muted: #8b91c0;
    --line: #2d2f5e;
    --stroke: #070814;
    --frame: #d5daf7;
    --accent: #ffd166;
    --accent-2: #06d6a0;
    --accent-3: #ef476f;
    --accent-4: #5cc8ff;
    --user-bubble: #74c5f8;
    --user-ink: #071018;
    --danger: #ef476f;
    --shadow: 6px 6px 0 #000;
    --shadow-sm: 4px 4px 0 #000;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    --max-w: 1180px;
    --header-h: 76px;
    --section-y: 64px;
    --chat-h: 380px;
    --n: 12px;
    --b: 4px;
    --font-pixel: 'Press Start 2P', 'Courier New', monospace;
    --font-mono: 'VT323', 'Courier New', monospace;
    --text-2xs: 9px;
    --text-xs: 11px;
    --text-sm: 16px;
    --text-md: 18px;
    --text-lg: 22px;
    --text-xl: 28px;
    --totop: 18px;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    background-image:
        radial-gradient(circle at 10% 0%, rgba(92, 200, 255, 0.08) 0%, transparent 35%),
        radial-gradient(circle at 90% 30%, rgba(239, 71, 111, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 100%, rgba(6, 214, 160, 0.08) 0%, transparent 45%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.03) 0px,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 1px,
        transparent 3px
    );
    z-index: 1;
    mix-blend-mode: overlay;
}

img { max-width: 100%; display: block; }
.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }

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

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -48px;
    left: var(--space-3);
    background: var(--accent);
    color: var(--stroke);
    padding: var(--space-2) var(--space-3);
    z-index: 9999;
    font-family: var(--font-pixel);
    font-size: var(--text-2xs);
}
.skip-link:focus { top: var(--space-3); }

/* Square pixel frames. Hard offset shadow, no clipped corners. */

/* ============================================================
   Buttons
   ============================================================ */
.box-button {
    display: inline-block;
    background: var(--accent);
    border: 3px solid #000;
    padding: 0 0 6px;
    box-shadow: 4px 4px 0 #000;
    vertical-align: middle;
    transition: transform 0.08s steps(2), box-shadow 0.08s steps(2);
}
.box-button.alt { background: var(--accent-2); }
.box-button .button {
    background: var(--panel);
    border: 3px solid var(--ink);
    padding: 10px 14px;
    font-family: var(--font-pixel);
    color: var(--ink);
    width: 100%;
    cursor: pointer;
    margin: 0;
    display: block;
    text-decoration: none;
    text-align: center;
    min-height: 44px;
}
.box-button .button span {
    font-size: var(--text-xs);
    letter-spacing: 1px;
    display: block;
    line-height: 1.5;
}
.box-button:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #000; }
.box-button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #000; }
.box-button.danger { background: var(--danger); }
.box-button:has(button:disabled) { pointer-events: none; opacity: 0.5; }
.btn:disabled {
    cursor: not-allowed;
    transform: none;
    box-shadow: 3px 3px 0 #000;
}

.btn {
    font-family: var(--font-pixel);
    font-size: var(--text-2xs);
    letter-spacing: 1px;
    min-height: 44px;
    padding: 12px 14px;
    border: 3px solid #000;
    cursor: pointer;
    line-height: 1.4;
    box-shadow: 4px 4px 0 #000;
    transition: transform 0.08s steps(2), box-shadow 0.08s steps(2);
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #000; }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #000; }
.btn-primary { background: var(--accent); color: #1a1408; }
.btn-primary:disabled { background: var(--accent); color: #1a1408; opacity: 0.45; }
.btn-secondary {
    background: var(--panel);
    color: var(--accent-2);
    border-color: var(--accent-2);
}
.btn-ghost {
    background: transparent;
    color: var(--ink-dim);
    border: 3px solid var(--line);
    box-shadow: none;
    min-height: 36px;
    padding: 8px 10px;
}
.btn-ghost:hover {
    color: var(--ink);
    border-color: var(--ink);
    background: var(--panel);
    box-shadow: 3px 3px 0 #000;
}

.nav-center .box-button .button,
.nav-right .box-button .button { padding: 8px 10px; min-height: 44px; }
.nav-center .box-button .button span,
.nav-right .box-button .button span { font-size: var(--text-2xs); }
a.nav-link.is-active {
    background: var(--accent);
    color: #1a1408;
    border-color: #000;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--bg);
    border-bottom: 3px solid var(--stroke);
}

#top-nav {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: var(--header-h);
}

.nav-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-link { text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.brand {
    font-family: var(--font-pixel);
    font-size: 13px;
    color: var(--ink);
    letter-spacing: 1px;
}
.brand-dot { color: var(--accent); }
.tagline {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--ink-dim);
    letter-spacing: 0.5px;
}
.nav-link { color: var(--ink); text-decoration: none; }

.nav-menu { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.nav-center, .nav-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: nowrap;
}

.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    background: var(--panel);
    border: 3px solid var(--ink);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    padding: 0;
    position: relative;
}
.nav-toggle .bar {
    display: block;
    width: 18px;
    height: 3px;
    background: var(--ink);
    position: absolute;
    left: 10px;
    transition: transform 0.12s steps(2), opacity 0.12s steps(2);
}
.nav-toggle .bar:nth-child(1) { top: 16px; }
.nav-toggle .bar:nth-child(2) { top: 24px; }
.nav-toggle.is-open .bar:nth-child(1) { top: 20px; transform: rotate(45deg); }
.nav-toggle.is-open .bar:nth-child(2) { top: 20px; transform: rotate(-45deg); }

/* ============================================================
   Layout
   ============================================================ */
main {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
}

section {
    width: 100%;
    padding: var(--section-y) 0;
    scroll-margin-top: calc(var(--header-h) + 12px);
    min-width: 0;
}

.section-title {
    font-family: var(--font-pixel);
    font-size: clamp(15px, 2vw, 22px);
    line-height: 1.55;
    margin: 0 0 var(--space-3);
    letter-spacing: 1px;
}
.section-title .accent { color: var(--accent); }
.section-title .accent-2 { color: var(--accent-2); }
.section-subtitle {
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    color: var(--ink-dim);
    margin: 0 0 var(--space-6);
    max-width: 62ch;
}

.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.5s steps(6), transform 0.5s steps(6);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ============================================================
   Hero
   ============================================================ */
.hero { padding-top: var(--space-7); padding-bottom: var(--section-y); }
.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: var(--space-7);
    align-items: center;
}
.hero-eyebrow {
    font-family: var(--font-pixel);
    font-size: var(--text-2xs);
    color: var(--accent-2);
    margin: 0 0 var(--space-4);
    letter-spacing: 2px;
}
.hero-title {
    font-family: var(--font-pixel);
    font-size: clamp(18px, 2.3vw, 26px);
    line-height: 1.55;
    margin: 0 0 var(--space-5);
    letter-spacing: 1px;
}
.hero-title .accent { color: var(--accent); }
.hero-title .accent-2 { color: var(--accent-2); }
.hero-sub {
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    color: var(--ink-dim);
    margin: 0 0 var(--space-5);
    max-width: 58ch;
    line-height: 1.45;
}
.hero-sub a {
    color: var(--accent-2);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}
.stat-pill {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    flex: 1 1 140px;
}
.stat-pill strong {
    font-family: var(--font-pixel);
    font-size: var(--text-xs);
    color: var(--accent);
    letter-spacing: 1px;
}
.stat-pill span {
    font-family: var(--font-mono);
    color: var(--ink-dim);
    font-size: var(--text-sm);
}

.hero-art { display: flex; justify-content: center; min-width: 0; }
.hero-screen {
    width: 100%;
    max-width: 460px;
    background: #06071a;
    border: 4px solid var(--ink);
    box-shadow: 6px 6px 0 #000;
}
.hero-screen-bar {
    background: var(--panel);
    border-bottom: 3px solid var(--frame);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.hero-screen-bar span {
    width: 12px;
    height: 12px;
    background: var(--accent-3);
    border: 2px solid #000;
}
.hero-screen-bar span:nth-child(2) { background: var(--accent); }
.hero-screen-bar span:nth-child(3) { background: var(--accent-2); }
.hero-screen-bar em {
    margin-left: auto;
    font-style: normal;
    font-family: var(--font-pixel);
    font-size: var(--text-2xs);
    color: var(--ink-dim);
    letter-spacing: 1px;
}
.hero-screen-body {
    padding: 18px 16px 20px;
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    color: var(--accent-2);
    line-height: 1.45;
    background: #06071a;
}
.hero-screen-body p { margin: 0 0 4px; }
.hero-screen-body .prompt { color: var(--accent); margin-right: 6px; }
.hero-screen-body .muted { color: var(--ink-dim); }
.caret {
    display: inline-block;
    width: 10px;
    background: var(--accent-2);
    color: var(--accent-2);
    margin-left: 4px;
    animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============================================================
   About / Skills
   ============================================================ */
.about-grid,
.skills-grid {
    display: grid;
    gap: var(--space-4);
    align-items: stretch;
}
.about-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.skills-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.about-card,
.skill-block,
.work-card,
.stat-pill {
    background: var(--panel);
    border: 3px solid var(--line);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55);
}

.about-card,
.skill-block {
    padding: var(--space-5);
    height: 100%;
    transition: transform 0.12s steps(2), border-color 0.12s linear, box-shadow 0.12s steps(2);
}
.about-card:hover,
.skill-block:hover {
    transform: translate(-2px, -2px);
    border-color: var(--accent);
    box-shadow: 6px 6px 0 #000;
}
.about-card-icon {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    margin-bottom: var(--space-3);
    background: var(--panel-2);
    border: 3px solid #000;
    line-height: 1;
}
.about-card h3,
.skill-block h3 {
    font-family: var(--font-pixel);
    font-size: var(--text-xs);
    margin: 0 0 var(--space-3);
    letter-spacing: 1px;
    line-height: 1.5;
}
.about-card h3 { color: var(--accent); }
.about-card p {
    font-family: var(--font-mono);
    color: var(--ink-dim);
    margin: 0;
    font-size: var(--text-md);
    line-height: 1.45;
}
.skill-block { background: var(--panel-2); }
.skill-block h3 {
    color: var(--accent-4);
    border-bottom: 2px dashed var(--line);
    padding-bottom: var(--space-2);
}
.skill-block ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-family: var(--font-mono);
    color: var(--ink-dim);
    font-size: var(--text-md);
}
.skill-block li { padding: 6px 0; border-bottom: 1px dashed rgba(45, 47, 94, 0.7); }
.skill-block li:last-child { border-bottom: none; }
.skill-block li::before { content: "▸ "; color: var(--accent); }

/* ============================================================
   Chat
   ============================================================ */
.chat-layout {
    display: grid;
    grid-template-columns: minmax(220px, 0.34fr) minmax(0, 1fr);
    gap: var(--space-6);
    align-items: center;
}
.chat-stage {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    min-height: 280px;
}
.avatar-lg {
    width: min(240px, 100%);
    height: auto;
    image-rendering: pixelated;
    animation: avatar-bob 1.2s steps(2) infinite;
}
.chat-stage.is-talking .avatar-lg { animation: avatar-talk 0.28s steps(2) infinite; }
@keyframes avatar-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes avatar-talk {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px) translateX(2px); }
}

.chat-window {
    background: var(--panel-2);
    border: 3px solid var(--line);
    box-shadow: 6px 6px 0 #000;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 12px;
    background: var(--panel);
    border-bottom: 4px solid var(--stroke);
}
.chat-badge {
    width: 36px;
    height: 36px;
    object-fit: contain;
    background: var(--panel-3);
    border: 3px solid #000;
    image-rendering: pixelated;
    flex: 0 0 36px;
}
.chat-id { min-width: 0; flex: 1; }
.chat-name {
    margin: 0;
    font-family: var(--font-pixel);
    font-size: var(--text-2xs);
    letter-spacing: 1px;
    color: var(--ink);
}
.chat-status {
    margin: 4px 0 0;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--accent-2);
    display: flex;
    align-items: center;
    gap: 6px;
}
.online-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-2);
    box-shadow: 0 0 0 2px #000;
    animation: blink 1.2s steps(2) infinite;
}

.chat-thread {
    height: var(--chat-h);
    overflow-x: hidden;
    overflow-y: auto;
    padding: var(--space-4);
    background: var(--panel-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--panel);
}
.chat-thread::-webkit-scrollbar { width: 12px; }
.chat-thread::-webkit-scrollbar-track { background: var(--panel); }
.chat-thread::-webkit-scrollbar-thumb {
    background: var(--accent);
    border: 3px solid var(--panel);
}

.msg {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
    max-width: 75%;
    width: fit-content;
}
.msg-ai { align-self: flex-start; }
.msg-user { align-self: flex-end; }
.msg-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    object-fit: contain;
    image-rendering: pixelated;
    background: var(--panel);
    border: 3px solid #000;
}
.bubble {
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    min-width: 0;
}
.bubble-ai {
    background: var(--panel);
    color: var(--ink);
    border: 3px solid var(--line);
    box-shadow: 3px 3px 0 #000;
}
.bubble-user {
    background: var(--user-bubble);
    color: var(--user-ink);
    border: 3px solid #000;
    box-shadow: 3px 3px 0 #000;
    width: fit-content;
    max-width: 100%;
}

.typing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 64px;
    min-height: 44px;
    padding: 12px 14px;
    background: var(--panel);
    border: 3px solid var(--line);
}
.typing span {
    width: 8px;
    height: 8px;
    background: var(--accent-2);
    animation: typing-dot 0.9s steps(2) infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-dot {
    0%, 40% { opacity: 0.25; transform: translateY(0); }
    50%, 100% { opacity: 1; transform: translateY(-3px); }
}

.chip-row {
    display: flex;
    gap: var(--space-2);
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 12px;
    background: var(--bg);
    border-top: 3px solid var(--stroke);
    scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.prompt-chip {
    flex: 0 0 auto;
    background: var(--panel);
    color: var(--ink);
    border: 3px solid var(--line);
    box-shadow: 3px 3px 0 #000;
    font-family: var(--font-mono);
    font-size: var(--text-md);
    padding: 8px 12px;
    min-height: 44px;
    cursor: pointer;
    transition: transform 0.08s steps(2), border-color 0.08s linear, color 0.08s linear;
}
.prompt-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translate(-2px, -2px);
}
.prompt-chip:active { transform: translate(2px, 2px); box-shadow: 0 0 0 #000; }

.chat-composer {
    display: flex;
    gap: var(--space-2);
    align-items: flex-end;
    padding: 12px;
    background: var(--panel);
    border-top: 3px solid var(--stroke);
}
#user-input {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    max-height: 120px;
    resize: none;
    background: var(--panel-3);
    border: 3px solid var(--line);
    color: var(--ink);
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    line-height: 1.35;
    field-sizing: content;
}
#user-input::placeholder { color: var(--muted); }
#user-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}
#send-btn { flex: 0 0 auto; align-self: stretch; }

/* ============================================================
   Work
   ============================================================ */
.work-row-title {
    font-family: var(--font-pixel);
    font-size: var(--text-xs);
    margin: 0 0 var(--space-3);
    color: var(--accent-2);
    letter-spacing: 1px;
}
.work-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0 0 var(--space-4);
}
.work-filter {
    --n: 6px;
    font-family: var(--font-pixel);
    font-size: var(--text-2xs);
    letter-spacing: 1px;
    padding: 10px 12px;
    min-height: 44px;
    border: 3px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    box-shadow: 3px 3px 0 #000;
    transition: transform 0.08s steps(2), background 0.08s linear, color 0.08s linear;
}
.work-filter:hover { transform: translate(-2px, -2px); border-color: var(--accent); }
.work-filter:active { transform: translate(2px, 2px); box-shadow: 0 0 0 #000; }
.work-filter.is-active {
    background: var(--accent);
    color: #1a1408;
    border-color: #000;
}

.carousel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: stretch;
}
.carousel-btn {
    width: 44px;
    min-height: 44px;
    align-self: center;
    background: var(--panel);
    border: 3px solid var(--ink);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: grid;
    place-items: center;
}
.carousel-btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #000; }
.carousel-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #000; }
.carousel-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.px-arrow {
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
}
.px-arrow-left { border-right: 10px solid var(--accent); }
.px-arrow-right { border-left: 10px solid var(--accent); }

.work-row-scroll {
    border: 3px solid var(--line);
    background: var(--panel-2);
    box-shadow: 4px 4px 0 #000;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    padding: var(--space-4);
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--panel);
}
.work-row-scroll::-webkit-scrollbar { height: 12px; }
.work-row-scroll::-webkit-scrollbar-track { background: var(--panel); }
.work-row-scroll::-webkit-scrollbar-thumb {
    background: var(--accent);
    border: 3px solid var(--panel);
}
.work-row {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--space-4);
    align-items: stretch;
    min-height: 220px;
    transition: opacity 0.16s steps(4), transform 0.16s steps(4);
}
.work-row.is-swapping { opacity: 0; transform: translateY(8px); }
.work-empty {
    font-family: var(--font-mono);
    color: var(--ink-dim);
    margin: var(--space-5) var(--space-2);
}

.work-card {
    flex: 0 0 300px;
    width: 300px;
    scroll-snap-align: start;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-height: 100%;
    cursor: pointer;
    transition: transform 0.12s steps(2), border-color 0.12s linear, box-shadow 0.12s steps(2), opacity 0.35s ease;
}
.work-card.is-entering { opacity: 0; transform: translateY(10px); }
.work-card.is-entering.is-visible {
    opacity: 1;
    transform: none;
    transition-delay: calc(var(--card-i, 0) * 45ms);
}
.work-card:hover {
    transform: translate(-2px, -2px);
    border-color: var(--accent);
    box-shadow: 6px 6px 0 #000;
}
.work-thumb {
    width: 48px;
    height: 48px;
    border: 3px solid #000;
    background: var(--accent);
    display: grid;
    place-items: center;
    font-size: 24px;
    box-shadow: 3px 3px 0 #000;
}
.work-card:nth-child(2n) .work-thumb { background: var(--accent-2); }
.work-card:nth-child(3n) .work-thumb { background: var(--accent-4); }
.work-card:nth-child(4n) .work-thumb { background: var(--accent-3); }
.work-card h3 {
    font-family: var(--font-pixel);
    font-size: var(--text-xs);
    color: var(--ink);
    margin: 4px 0 0;
    letter-spacing: 1px;
    line-height: 1.5;
}
.work-card p {
    font-family: var(--font-mono);
    color: var(--ink-dim);
    font-size: var(--text-md);
    margin: 0;
    line-height: 1.4;
}
.tech-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.tech-tag {
    font-family: var(--font-pixel);
    font-size: 8px;
    padding: 4px 6px;
    border: 2px solid #000;
    color: #fff;
    letter-spacing: 0.5px;
    line-height: 1.4;
}
.tech-tag.python { background: #3776ab; }
.tech-tag.fastapi { background: #009688; }
.tech-tag.websocket { background: #ff6b35; }
.tech-tag.openai { background: #10a37f; }
.tech-tag.docker { background: #2496ed; }
.tech-tag.opencv { background: #5c3ee8; }
.tech-tag.mediapipe { background: #4285f4; }
.tech-tag.numpy { background: #4dabcf; }
.tech-tag.javascript { background: #f7df1e; color: #222; }
.tech-tag.nodejs { background: #339933; }
.tech-tag.express { background: #000; }
.tech-tag.mongodb { background: #47a248; }
.tech-tag.html { background: #e34c26; }
.tech-tag.react { background: #61dafb; color: #003042; }
.tech-tag.firebase { background: #ffca28; color: #222; }
.tech-tag.expo { background: #000; }
.tech-tag.typescript { background: #3178c6; }
.tech-tag.nextjs { background: #111; }
.tech-tag.threejs { background: #049ef4; color: #003042; }
.tech-tag.gemini { background: #4285f4; }
.tech-tag.elasticsearch { background: #fecc63; color: #222; }
.tech-tag.supabase { background: #3ecf8e; color: #003042; }
.tech-tag.vite { background: #646cff; }
.tech-tag.leaflet { background: #199900; }

.work-card-buttons {
    display: flex;
    gap: var(--space-2);
    margin-top: auto;
    padding-top: var(--space-2);
}
.work-card-buttons .box-button { flex: 1; min-width: 0; }
.work-open-btn,
.github-btn { font-family: var(--font-pixel); color: inherit; }
.work-open-btn span,
.github-btn span { font-size: var(--text-2xs); }

/* ============================================================
   Work panel
   ============================================================ */
#work-panel {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 110%);
    width: min(960px, calc(100% - 32px));
    z-index: 1000;
    transition: transform 0.28s steps(5);
}
#work-panel-inner {
    background: var(--panel);
    border: 4px solid var(--frame);
    box-shadow: 0 -8px 0 #000;
    padding: var(--space-5);
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
}
#work-panel.panel-open { transform: translate(-50%, 0); }
#work-panel-close { float: right; }
#work-panel-title {
    font-family: var(--font-pixel);
    font-size: var(--text-sm);
    color: var(--accent);
    margin: var(--space-2) 48px var(--space-4) 0;
    letter-spacing: 1px;
    line-height: 1.5;
}
#work-panel-body p {
    font-family: var(--font-mono);
    font-size: var(--text-md);
    color: var(--ink-dim);
    line-height: 1.5;
    margin: 0 0 10px;
    overflow-wrap: anywhere;
}
#work-panel-body strong { color: var(--accent-2); }
.panel-github { margin: 0 0 var(--space-4); }

/* ============================================================
   Explore / Contact
   ============================================================ */
#external-cta,
#contact { text-align: center; }
#external-cta .section-subtitle,
#contact .section-subtitle { margin-left: auto; margin-right: auto; }
#external-cta { padding: var(--section-y) var(--space-5); }
.cta-buttons {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    flex-wrap: wrap;
    align-items: stretch;
}
.cta-buttons .box-button { min-width: 220px; }
.cta-buttons .box-button .button span { font-size: var(--text-2xs); }

.contact-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
}
.contact-email {
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    color: var(--ink);
    text-decoration: none;
    border: 3px solid var(--accent);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    padding: 10px 16px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}
.contact-email:hover {
    color: #1a1408;
    background: var(--accent);
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow);
}
.social-row {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: var(--space-4);
    align-items: center;
    justify-content: center;
}
.social-icon {
    --n: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 3px solid var(--ink);
    background: var(--panel);
    box-shadow: 4px 4px 0 #000;
    color: var(--ink);
    transition: transform 0.08s steps(2), filter 0.08s steps(2), background 0.08s linear, color 0.08s linear;
}
.social-icon svg { width: 22px; height: 22px; fill: currentColor; display: block; }
.social-row li:nth-child(2) .social-icon { background: #10243f; color: var(--user-bubble); border-color: var(--user-bubble); }
.social-row li:nth-child(3) .social-icon { background: #10121c; }
.social-row li:nth-child(4) .social-icon { background: #2a1220; color: #ff8fab; border-color: var(--accent-3); }
.social-icon:hover,
.social-icon:focus-visible {
    background: var(--accent);
    color: #000;
    border-color: #000;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
}
.social-icon:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #000; }

.card-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: var(--text-md);
    color: var(--ink-dim);
    padding: 8px 4px;
    min-height: 44px;
    border-bottom: 2px dashed transparent;
}
.card-cta-icon { color: var(--accent); font-family: var(--font-pixel); font-size: var(--text-2xs); }
.card-cta-arrow { display: inline-block; transition: transform 0.12s steps(2); }
.card-cta:hover,
.card-cta:focus-visible { color: var(--ink); border-bottom-color: var(--accent); }
.card-cta:hover .card-cta-arrow { transform: translateX(4px); }

/* ============================================================
   Footer / back to top
   ============================================================ */
.site-footer {
    border-top: 3px solid var(--stroke);
    background: rgba(15, 16, 32, 0.96);
    position: relative;
    z-index: 2;
}
.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: var(--space-6) 24px;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto;
    gap: var(--space-5);
    align-items: center;
}
.footer-brand .brand { font-size: 12px; }
.footer-brand p {
    margin: 8px 0 0;
    font-family: var(--font-mono);
    color: var(--ink-dim);
    font-size: var(--text-sm);
}
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-4); }
.footer-links a {
    font-family: var(--font-pixel);
    font-size: var(--text-2xs);
    color: var(--ink-dim);
    letter-spacing: 1px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}
.footer-links a:hover { color: var(--accent); }
.footer-copy {
    margin: 0;
    text-align: right;
    font-family: var(--font-mono);
    color: var(--muted);
    font-size: var(--text-sm);
}

.back-to-top {
    position: fixed;
    right: 18px;
    bottom: var(--totop);
    width: 46px;
    height: 46px;
    border: 3px solid #000;
    background: var(--accent);
    color: #000;
    font-family: var(--font-pixel);
    font-size: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    display: none;
    z-index: 150;
}
.back-to-top.show { display: grid; place-items: center; }
.back-to-top:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.back-to-top:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #000; }

/* ============================================================
   Scrollbars (page). Horizontal bars are clipped, not shown.
   ============================================================ */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--line); border: 3px solid var(--bg-2); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============================================================
   Loading ghost
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 16, 32, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s, visibility 0.4s;
}
.loading-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-text {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-pixel);
    font-size: var(--text-2xs);
    color: var(--accent);
    letter-spacing: 2px;
    width: max-content;
    margin: 0;
}
#ghost { position: relative; scale: 0.8; }
#red {
    animation: upNDown infinite 0.5s;
    position: relative;
    width: 140px;
    height: 140px;
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    grid-template-rows: repeat(14, 1fr);
    grid-column-gap: 0px;
    grid-row-gap: 0px;
    grid-template-areas:
        "a1  a2  a3  a4  a5  top0  top0  top0  top0  a10 a11 a12 a13 a14"
        "b1  b2  b3  top1 top1 top1 top1 top1 top1 top1 top1 b12 b13 b14"
        "c1 c2 top2 top2 top2 top2 top2 top2 top2 top2 top2 top2 c13 c14"
        "d1 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 d14"
        "e1 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 e14"
        "f1 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 top3 f14"
        "top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4"
        "top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4"
        "top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4"
        "top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4"
        "top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4"
        "top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4 top4"
        "st0 st0 an4 st1 an7 st2 an10 an10 st3 an13 st4 an16 st5 st5"
        "an1 an2 an3 an5 an6 an8 an9 an9 an11 an12 an14 an15 an17 an18";
}
@keyframes upNDown {
    0%, 49% { transform: translateY(0px); }
    50%, 100% { transform: translateY(-10px); }
}
#top0,#top1,#top2,#top3,#top4,
#st0,#st1,#st2,#st3,#st4,#st5 { background-color: var(--accent-3); }
#top0 { grid-area: top0; } #top1 { grid-area: top1; } #top2 { grid-area: top2; }
#top3 { grid-area: top3; } #top4 { grid-area: top4; }
#st0 { grid-area: st0; } #st1 { grid-area: st1; } #st2 { grid-area: st2; }
#st3 { grid-area: st3; } #st4 { grid-area: st4; } #st5 { grid-area: st5; }
#an1, #an18, #an6, #an12, #an7, #an13, #an8, #an11 { animation: flicker0 infinite 0.5s; }
#an2, #an17, #an3, #an16, #an4, #an15, #an9, #an10 { animation: flicker1 infinite 0.5s; }
#an1 { grid-area: an1; } #an18 { grid-area: an18; }
#an2 { grid-area: an2; } #an17 { grid-area: an17; }
#an3 { grid-area: an3; } #an16 { grid-area: an16; }
#an4 { grid-area: an4; } #an15 { grid-area: an15; }
#an6 { grid-area: an6; } #an12 { grid-area: an12; }
#an7 { grid-area: an7; } #an13 { grid-area: an13; }
#an8 { grid-area: an8; } #an11 { grid-area: an11; }
#an9 { grid-area: an9; } #an10 { grid-area: an10; }
@keyframes flicker0 {
    0%, 49% { background-color: var(--accent-3); }
    50%, 100% { background-color: transparent; }
}
@keyframes flicker1 {
    0%, 49% { background-color: transparent; }
    50%, 100% { background-color: var(--accent-3); }
}
#eye, #eye1 { width: 40px; height: 50px; position: absolute; top: 30px; }
#eye { left: 10px; }
#eye1 { right: 30px; }
#eye::before, #eye1::before {
    content: ""; background: white;
    width: 20px; height: 50px; transform: translateX(10px);
    display: block; position: absolute;
}
#eye::after, #eye1::after {
    content: ""; background: white;
    width: 40px; height: 30px; transform: translateY(10px);
    display: block; position: absolute;
}
#pupil, #pupil1 {
    width: 20px; height: 20px;
    background: var(--accent-4);
    position: absolute; top: 50px; z-index: 1;
    animation: eyesMovement infinite 3s;
}
#pupil { left: 10px; }
#pupil1 { right: 50px; }
@keyframes eyesMovement {
    0%, 49% { transform: translateX(0px); }
    50%, 99% { transform: translateX(10px); }
    100% { transform: translateX(0px); }
}
#shadow {
    background: #000;
    width: 100px;
    height: 12px;
    position: absolute;
    left: 20px;
    top: 108%;
    animation: shadowMovement infinite 0.5s;
}
@keyframes shadowMovement {
    0%, 49% { opacity: 0.55; }
    50%, 100% { opacity: 0.2; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
    .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
    .nav-toggle { display: inline-block; }
    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--bg-2);
        border-bottom: 3px solid var(--stroke);
        padding: 0 16px;
        gap: 12px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.2s steps(4), padding 0.2s steps(4);
    }
    .nav-menu.is-open {
        max-height: min(80vh, 640px);
        overflow-y: auto;
        padding: 16px;
    }
    .nav-center, .nav-right {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .nav-center .box-button,
    .nav-right .box-button { width: 100%; }
    .nav-center .box-button .button,
    .nav-right .box-button .button { min-height: 44px; }
}

@media (max-width: 800px) {
    :root { --section-y: 48px; --chat-h: 300px; }
    .hero-grid,
    .chat-layout { grid-template-columns: 1fr; }
    .about-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chat-layout { align-items: stretch; }
    .chat-window { order: -1; }
    .chat-stage { min-height: 0; padding-top: var(--space-4); }
    .avatar-lg { width: 160px; }
    .footer-inner { grid-template-columns: 1fr; text-align: center; justify-items: center; }
    .footer-copy { text-align: center; }
    .footer-links { justify-content: center; }
}

@media (min-width: 720px) {
    .chip-row { flex-wrap: wrap; overflow: visible; }
}

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

@media (max-width: 768px) {
    body { font-size: var(--text-md); }
    main { padding: 0 16px; }
    #top-nav { padding: 12px 16px; }
    .section-title { font-size: 15px; }
    .section-subtitle { font-size: var(--text-md); }
    .hero-title { font-size: 20px; }
    .work-card { flex-basis: 78%; width: 78%; }
    .work-card-buttons { flex-direction: column; }
    .contact-email { font-size: var(--text-lg); }
    .cta-buttons .box-button { min-width: 0; width: 100%; }
}

@media (max-width: 420px) {
    .brand { font-size: 11px; }
    .tagline { font-size: 14px; }
    .skills-grid { grid-template-columns: 1fr; }
    .hero-screen-body { font-size: var(--text-md); }
    .carousel { grid-template-columns: minmax(0, 1fr); }
    .carousel-btn { display: none; }
    .msg { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; transition: none; }
    .avatar-lg,
    .chat-stage.is-talking .avatar-lg,
    .caret,
    .online-dot,
    .typing span,
    #red,
    #pupil,
    #pupil1,
    #shadow,
    #an1, #an2, #an3, #an4, #an6, #an7, #an8, #an9,
    #an10, #an11, #an12, #an13, #an15, #an16, #an17, #an18 {
        animation: none;
    }
    .chat-thread { scroll-behavior: auto; }
}
