/* ==========================================================================
   Muhammad Ahmad: portfolio
   ========================================================================== */

:root {
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

    --accent: #7c5cff;
    --accent-2: #22d3ee;
    --accent-soft: rgba(124, 92, 255, 0.14);
    --gradient: linear-gradient(120deg, #7c5cff 0%, #4f8cff 50%, #22d3ee 100%);
    --success: #22c55e;
    --danger: #ef4444;

    --radius: 16px;
    --radius-sm: 10px;
    --header-h: 68px;
    --container: 1180px;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

[data-theme='dark'] {
    --bg: #0a0d14;
    --bg-alt: #0d111b;
    --surface: #121827;
    --surface-2: #182033;
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.28);
    --text: #e8ebf3;
    --muted: #9aa4b8;
    --heading: #ffffff;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    --header-bg: rgba(10, 13, 20, 0.72);
    color-scheme: dark;
}

[data-theme='light'] {
    --bg: #f7f8fc;
    --bg-alt: #eef1f8;
    --surface: #ffffff;
    --surface-2: #f3f5fb;
    --border: rgba(15, 23, 42, 0.09);
    --border-strong: rgba(15, 23, 42, 0.18);
    --text: #273044;
    --muted: #5b6577;
    --heading: #0b1220;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --header-bg: rgba(247, 248, 252, 0.8);
    --accent-soft: rgba(124, 92, 255, 0.1);
    color-scheme: light;
}

/* ----- Base ----- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s, color 0.3s;
}
body.no-scroll { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { color: var(--heading); line-height: 1.2; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.container { width: min(100% - 2.5rem, var(--container)); margin-inline: auto; }
.narrow { max-width: 900px; }
.visually-hidden {
    position: absolute !important; 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; left: 1rem; top: -3rem; z-index: 200; padding: 0.6rem 1rem;
    background: var(--accent); color: #fff; border-radius: var(--radius-sm); transition: top 0.2s;
}
.skip-link:focus { top: 1rem; }
.gradient-text { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ----- Buttons & chips ----- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
    padding: 0.8rem 1.35rem; border-radius: 999px; font-weight: 600; font-size: 0.95rem;
    border: 1px solid transparent; transition: transform 0.2s var(--ease), box-shadow 0.2s, background 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn--primary { background: var(--gradient); color: #fff; box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35); }
.btn--primary:hover { box-shadow: 0 12px 30px rgba(124, 92, 255, 0.45); }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--heading); }
.btn--ghost:hover { border-color: var(--accent); }
.btn--sm { padding: 0.55rem 1rem; font-size: 0.875rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.6; pointer-events: none; }

.icon-btn {
    display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    background: transparent; border: 1px solid var(--border); color: var(--text); transition: border-color 0.2s, background 0.2s;
}
.icon-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.badge {
    display: inline-flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.9rem; border-radius: 999px;
    font-size: 0.85rem; font-weight: 500; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: pulse 2s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.chip {
    display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.5rem 0.9rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border-strong); font-size: 0.85rem; font-weight: 600; color: var(--heading);
    box-shadow: var(--shadow);
}
.chip i { color: var(--accent); }

/* ----- Header ----- */
.header {
    position: fixed; inset: 0 0 auto; z-index: 100; height: var(--header-h);
    background: var(--header-bg); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid transparent; transition: border-color 0.3s;
}
.header.is-scrolled { border-bottom-color: var(--border); }
.nav { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.nav__logo { display: flex; align-items: center; gap: 0.65rem; font-weight: 700; color: var(--heading); }
.nav__logo-mark {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
    background: var(--gradient); color: #fff; font-size: 0.85rem; font-weight: 800; letter-spacing: 0.02em;
}
.nav__menu { display: flex; gap: 0.25rem; }
.nav__link { display: block; padding: 0.5rem 0.85rem; border-radius: 999px; font-size: 0.92rem; font-weight: 500; color: var(--muted); transition: color 0.2s, background 0.2s; }
.nav__link:hover, .nav__link.is-active { color: var(--heading); background: var(--accent-soft); }
.nav__actions { display: flex; align-items: center; gap: 0.6rem; }
.nav__toggle { display: none; }

/* ----- Hero ----- */
.hero { position: relative; padding: calc(var(--header-h) + 4.5rem) 0 3rem; overflow: hidden; }
.hero__glow {
    position: absolute; inset: -20% -10% auto; height: 620px; pointer-events: none; opacity: 0.55;
    background: radial-gradient(40% 50% at 25% 30%, rgba(124, 92, 255, 0.35), transparent 70%),
                radial-gradient(35% 45% at 80% 20%, rgba(34, 211, 238, 0.22), transparent 70%);
    filter: blur(20px);
}
.hero__grid { position: relative; display: grid; grid-template-columns: 1.25fr 0.9fr; gap: 3rem; align-items: center; }
.hero__title { font-size: clamp(2.3rem, 5vw, 3.6rem); font-weight: 800; margin: 1.25rem 0 1.1rem; }
.hero__lead { font-size: 1.12rem; color: var(--muted); max-width: 40rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.hero__social { display: flex; gap: 0.6rem; margin-top: 1.75rem; }
.hero__social a {
    display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
    border: 1px solid var(--border-strong); color: var(--muted); transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.hero__social a:hover { color: var(--heading); border-color: var(--accent); transform: translateY(-2px); }
.hero__visual { position: relative; justify-self: center; }
.hero__photo {
    width: min(380px, 78vw); aspect-ratio: 1; border-radius: 32px; padding: 6px; background: var(--gradient);
    box-shadow: 0 30px 80px rgba(124, 92, 255, 0.25); transform: rotate(-2deg);
}
.hero__photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 27px; transform: rotate(2deg); background: var(--surface); }
.chip--float { position: absolute; animation: float 6s ease-in-out infinite; }
.chip--1 { top: 8%; left: -12%; }
.chip--2 { bottom: 18%; right: -10%; animation-delay: -2s; }
.chip--3 { bottom: -4%; left: 6%; animation-delay: -4s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.stats {
    position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 4rem 0 0;
}
.stat { padding: 1.25rem 1.4rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat dd { margin: 0; font-size: 2rem; font-weight: 800; color: var(--heading); letter-spacing: -0.03em; order: -1; }
.stat { display: flex; flex-direction: column; }
.stat dt { font-size: 0.88rem; color: var(--muted); }

/* ----- Sections ----- */
.section { padding: 6rem 0; }
.section--alt { background: var(--bg-alt); }
.section__head { text-align: center; max-width: 720px; margin: 0 auto 3rem; }
.section__head--left { text-align: left; margin: 0; }
.section__head--sub { margin: 4rem 0 1.5rem; text-align: left; max-width: none; }
.eyebrow { font-family: var(--mono); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); margin-bottom: 0.75rem; }
[data-theme='dark'] .eyebrow { color: #a594ff; }
.section__title { font-size: clamp(1.8rem, 3.5vw, 2.5rem); font-weight: 800; }
.section__title--sm { font-size: 1.4rem; }
.section__subtitle { color: var(--muted); margin-top: 0.85rem; font-size: 1.05rem; }
.section__subtitle--left { max-width: 30rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* About */
.about { display: grid; grid-template-columns: 0.8fr 1.4fr; gap: 3rem; align-items: start; }
.about__body { display: grid; gap: 1.1rem; font-size: 1.05rem; }
.about__body strong { color: var(--heading); }
.about__facts { display: grid; gap: 0.6rem; margin-top: 0.5rem; }
.about__facts li { display: flex; gap: 0.75rem; align-items: baseline; color: var(--muted); font-size: 0.97rem; }
.about__facts i { color: var(--accent); width: 1rem; text-align: center; }

/* Services */
.services { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.service { padding: 1.75rem; transition: transform 0.25s var(--ease), border-color 0.25s; }
.service:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.service__icon {
    display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; margin-bottom: 1.1rem;
    background: var(--accent-soft); color: var(--accent); font-size: 1.2rem;
}
[data-theme='dark'] .service__icon { color: #a594ff; }
.service h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.service p { color: var(--muted); font-size: 0.95rem; }

/* Projects */
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-bottom: 2.25rem; }
.filter {
    padding: 0.5rem 1.05rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
    font-size: 0.9rem; font-weight: 500; color: var(--muted); transition: all 0.2s;
}
.filter:hover { color: var(--heading); border-color: var(--accent); }
.filter.is-active { background: var(--gradient); color: #fff; border-color: transparent; }
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
.projects__status { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 2rem; }
.projects__more { display: flex; justify-content: center; margin-top: 2.25rem; }
.project {
    display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
    transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}
.project:hover { transform: translateY(-5px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.project__media { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; border-bottom: 1px solid var(--border); }
.project__media img { position: relative; width: 100%; height: 100%; object-fit: cover; object-position: top; background: var(--surface-2); transition: transform 0.5s var(--ease); }
.project:hover .project__media img { transform: scale(1.04); }
.project__fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.5rem; color: var(--accent); background: radial-gradient(circle at 30% 30%, var(--accent-soft), transparent 70%); }
.project__badge {
    position: absolute; top: 0.8rem; right: 0.8rem; padding: 0.3rem 0.7rem; border-radius: 999px;
    background: rgba(10, 13, 20, 0.78); color: #fff; font-size: 0.75rem; font-weight: 600; backdrop-filter: blur(6px);
    display: inline-flex; gap: 0.4rem; align-items: center;
}
.project__badge i { color: #fbbf24; }
.project__body { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.35rem 1.4rem 1.4rem; flex: 1; }
.project__cat { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); }
[data-theme='dark'] .project__cat { color: #a594ff; }
.project__title { font-size: 1.12rem; }
.project__desc { color: var(--muted); font-size: 0.93rem; flex: 1; }
.project__links { display: flex; gap: 1rem; padding-top: 0.5rem; border-top: 1px solid var(--border); margin-top: 0.25rem; }
.project__links a, .project__links button {
    display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; font-weight: 600; color: var(--heading);
    background: none; border: 0; padding: 0.4rem 0;
}
.project__links a:hover, .project__links button:hover { color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tags li {
    padding: 0.28rem 0.7rem; border-radius: 999px; font-size: 0.8rem; font-weight: 500;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}

/* Timeline */
.timeline { position: relative; display: grid; gap: 1.5rem; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--accent), var(--accent-2)); opacity: 0.45; }
.timeline__item { position: relative; }
.timeline__marker { position: absolute; left: -2rem; top: 1.6rem; width: 16px; height: 16px; border-radius: 50%; background: var(--gradient); box-shadow: 0 0 0 5px var(--accent-soft); }
.timeline__marker--edu { background: var(--accent-2); }
.timeline__card { padding: 1.6rem 1.75rem; }
.timeline__head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.timeline__head h3 { font-size: 1.15rem; }
.timeline__org { color: var(--muted); font-size: 0.95rem; margin-top: 0.2rem; }
.timeline__date { font-family: var(--mono); font-size: 0.82rem; color: var(--accent); white-space: nowrap; padding-top: 0.2rem; }
[data-theme='dark'] .timeline__date { color: #a594ff; }
.timeline__list { display: grid; gap: 0.6rem; }
.timeline__list li { position: relative; padding-left: 1.3rem; color: var(--text); font-size: 0.97rem; }
.timeline__list li::before { content: ''; position: absolute; left: 0; top: 0.62em; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); }

.research { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.research__item { padding: 1.5rem; }
.research__item i { font-size: 1.3rem; color: var(--accent-2); margin-bottom: 0.9rem; }
.research__item h4 { font-size: 1.02rem; margin-bottom: 0.5rem; }
.research__item p { color: var(--muted); font-size: 0.92rem; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.skill-group { padding: 1.5rem; }
.skill-group h3 { display: flex; align-items: center; gap: 0.6rem; font-size: 1.02rem; margin-bottom: 1rem; }
.skill-group h3 i { color: var(--accent); }

/* Contact */
.contact { display: grid; grid-template-columns: 1fr 1.1fr; gap: 3rem; align-items: start; }
.contact__list { display: grid; gap: 0.9rem; margin-top: 2rem; }
.contact__list li { display: flex; align-items: center; gap: 0.9rem; }
.contact__list i {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    background: var(--accent-soft); color: var(--accent);
}
.contact__list a { word-break: break-word; }
.contact__list a:hover { color: var(--accent); }
.contact__form { padding: 1.75rem; display: grid; gap: 1rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { display: grid; gap: 0.4rem; font-size: 0.88rem; font-weight: 600; color: var(--heading); }
.field input, .field textarea {
    width: 100%; padding: 0.8rem 0.95rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--bg); color: var(--text); font: inherit; font-weight: 400; resize: vertical; transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.is-invalid input, .field.is-invalid textarea { border-color: var(--danger); }
.form-status { font-size: 0.92rem; min-height: 1.4em; text-align: center; }
.form-status.is-success { color: var(--success); }
.form-status.is-error { color: var(--danger); }

/* Footer */
.footer { padding: 2rem 0; border-top: 1px solid var(--border); }
.footer__inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; }
.footer__links { display: flex; gap: 1rem; }
.footer__links a:hover { color: var(--heading); }

/* ----- Modal ----- */
.modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 1.25rem; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(3, 6, 12, 0.7); backdrop-filter: blur(4px); animation: fade 0.2s; }
.modal__panel {
    position: relative; width: min(920px, 100%); max-height: calc(100vh - 2.5rem); overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: var(--shadow);
    animation: rise 0.25s var(--ease); outline: none;
}
.modal__close { position: sticky; top: 1rem; float: right; margin: 1rem 1rem 0 0; z-index: 2; background: var(--surface); }
.modal__body { padding: 2rem 2.25rem 2.25rem; display: grid; gap: 1.5rem; }
.modal__body h2 { font-size: 1.7rem; padding-right: 2rem; }
.modal__body h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.modal__desc { color: var(--text); font-size: 1rem; }
.modal__hero { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.modal__hero { margin: 0; }
.modal__hero img { width: 100%; max-height: 460px; object-fit: contain; }
.modal__hero figcaption { padding: 0.6rem 0.9rem; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--border); }
.modal__list { display: grid; gap: 0.55rem; }
.modal__list li { display: flex; gap: 0.7rem; align-items: baseline; }
.modal__list i { color: var(--success); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.9rem; }
.gallery figure { margin: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.gallery a { display: block; aspect-ratio: 16 / 10; overflow: hidden; }
.gallery img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform 0.4s var(--ease); }
.gallery a:hover img { transform: scale(1.05); }
.gallery figcaption { padding: 0.55rem 0.75rem; font-size: 0.8rem; color: var(--muted); }
.modal__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }

/* ----- Chat assistant ----- */
.chat-launcher {
    position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 250; display: inline-flex; align-items: center; gap: 0.6rem;
    padding: 0.9rem 1.25rem; border-radius: 999px; border: 0; background: var(--gradient); color: #fff; font-weight: 700;
    box-shadow: 0 12px 34px rgba(124, 92, 255, 0.45); transition: transform 0.2s var(--ease), opacity 0.2s;
}
.chat-launcher:hover { transform: translateY(-3px); }
.chat-launcher i { font-size: 1.15rem; }
.chat-launcher.is-hidden { opacity: 0; pointer-events: none; transform: scale(0.9); }

.chat {
    position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 260; width: min(400px, calc(100vw - 2rem)); height: min(620px, calc(100vh - 3rem));
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4); overflow: hidden; animation: rise 0.25s var(--ease);
}
.chat[hidden] { display: none; }
.chat__header { display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.chat__header .icon-btn { width: 34px; height: 34px; font-size: 0.9rem; }
.chat__avatar { position: relative; width: 40px; height: 40px; flex-shrink: 0; }
.chat__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.chat__avatar .dot { position: absolute; right: 0; bottom: 0; border: 2px solid var(--surface-2); width: 11px; height: 11px; }
.chat__title { flex: 1; display: grid; line-height: 1.3; min-width: 0; }
.chat__title strong { color: var(--heading); font-size: 0.95rem; }
.chat__title span { color: var(--muted); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat__messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; scroll-behavior: smooth; }
.msg { max-width: 88%; padding: 0.7rem 0.95rem; border-radius: 16px; font-size: 0.92rem; line-height: 1.55; word-wrap: break-word; }
.msg--bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg--user { align-self: flex-end; background: var(--gradient); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg--error { border-color: rgba(239, 68, 68, 0.4); color: var(--danger); }
.msg p + p, .msg p + ul, .msg ul + p { margin-top: 0.5rem; }
.msg ul { list-style: disc; padding-left: 1.15rem; display: grid; gap: 0.25rem; margin-top: 0.35rem; }
.msg a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
[data-theme='dark'] .msg a { color: #a594ff; }
.msg strong { color: var(--heading); }
.msg code { font-family: var(--mono); font-size: 0.85em; padding: 0.1em 0.35em; border-radius: 5px; background: var(--surface); }
.typing { display: inline-flex; gap: 4px; padding: 0.3rem 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat__suggestions { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0 1rem 0.75rem; }
.chat__suggestions[hidden] { display: none; }
.chat__suggestions button {
    padding: 0.4rem 0.75rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
    font-size: 0.8rem; color: var(--text); transition: border-color 0.2s, color 0.2s;
}
.chat__suggestions button:hover { border-color: var(--accent); color: var(--heading); }
.chat__form { display: flex; gap: 0.5rem; align-items: flex-end; padding: 0.75rem; border-top: 1px solid var(--border); }
.chat__form textarea {
    flex: 1; resize: none; max-height: 120px; padding: 0.7rem 0.9rem; border-radius: 14px; border: 1px solid var(--border-strong);
    background: var(--bg); color: var(--text); font: inherit; font-size: 0.92rem; line-height: 1.45;
}
.chat__form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat__send { flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--gradient); color: #fff; transition: opacity 0.2s; }
.chat__send[disabled] { opacity: 0.5; cursor: not-allowed; }
.chat__note { padding: 0 1rem 0.7rem; font-size: 0.72rem; color: var(--muted); text-align: center; }

/* ----- Reveal on scroll ----- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }

/* ----- Responsive ----- */
@media (max-width: 1024px) {
    .services, .projects, .skills, .research { grid-template-columns: repeat(2, 1fr); }
    .hero__grid { grid-template-columns: 1fr 0.8fr; gap: 2rem; }
    .nav__link { padding: 0.5rem 0.6rem; }
}

@media (max-width: 860px) {
    .nav__toggle { display: inline-grid; }
    .nav__cta { display: none; }
    .nav__menu {
        position: fixed; top: var(--header-h); left: 0; right: 0; flex-direction: column; gap: 0.25rem; padding: 1rem 1.25rem 1.5rem;
        background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
        transform: translateY(-120%); transition: transform 0.3s var(--ease); visibility: hidden;
    }
    .nav__menu.is-open { transform: none; visibility: visible; }
    .nav__link { padding: 0.8rem 1rem; font-size: 1rem; }
    .hero { padding-top: calc(var(--header-h) + 2.5rem); }
    .hero__grid, .about, .contact { grid-template-columns: 1fr; }
    .hero__visual { order: -1; margin-bottom: 1rem; }
    .hero__photo { width: min(260px, 70vw); }
    .chip--1 { left: -18%; }
    .chip--2 { right: -18%; }
    .stats { grid-template-columns: repeat(2, 1fr); margin-top: 3rem; }
    .section { padding: 4.5rem 0; }
}

@media (max-width: 600px) {
    .services, .projects, .skills, .research, .field-row { grid-template-columns: 1fr; }
    .nav__logo-text { display: none; }
    .hero__actions .btn { flex: 1 1 100%; }
    .chip--float { display: none; }
    .modal { padding: 0; }
    .modal__panel { max-height: 100vh; height: 100%; border-radius: 0; }
    .modal__body { padding: 1.25rem 1.25rem 2rem; }
    .chat { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; }
    .chat-launcher { right: 1rem; bottom: 1rem; padding: 0.95rem; }
    .chat-launcher__label { display: none; }
    .timeline { padding-left: 1.5rem; }
    .timeline__marker { left: -1.5rem; }
    .timeline::before { left: 7px; }
    .timeline__card { padding: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; }
}
