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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  line-height: 1.6;
  text-rendering: optimizeSpeed;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

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

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}
/* ============================================
   THEME SYSTEM — 3 Complete Palettes
   ============================================ */

/* --- DARK THEME (Default) --- */
html[data-theme="dark"] {
  --bg-primary: #08080b;
  --bg-secondary: #0f0f14;
  --bg-elevated: #16161d;
  --bg-card: rgba(22, 22, 29, 0.8);
  --bg-card-hover: rgba(30, 30, 40, 0.9);
  --bg-input: rgba(22, 22, 29, 0.6);

  --text-primary: #e8e6e3;
  --text-secondary: #a09daa;
  --text-muted: #706d7d;
  --text-accent: #64d8ff;

  --accent-1: #64d8ff;
  --accent-2: #a78bfa;
  --accent-glow: rgba(100, 216, 255, 0.15);
  --accent-gradient: linear-gradient(135deg, #64d8ff, #a78bfa);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(100, 216, 255, 0.3);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(100, 216, 255, 0.1);

  --particle-primary: 100, 216, 255;
  --particle-secondary: 167, 139, 250;
  --particle-tertiary: 56, 189, 248;
  --particle-glow: 0.4;
  --particle-bg-alpha: 0.6;

  --nav-bg: rgba(8, 8, 11, 0.85);
  --nav-border: rgba(255, 255, 255, 0.05);

  --btn-primary-bg: #64d8ff;
  --btn-primary-text: #08080b;
  --btn-primary-hover: #8ae3ff;
  --btn-outline-border: rgba(100, 216, 255, 0.4);
  --btn-outline-hover-bg: rgba(100, 216, 255, 0.1);

  --chip-bg: rgba(100, 216, 255, 0.08);
  --chip-border: rgba(100, 216, 255, 0.15);
  --chip-text: #b4e8f7;
  --chip-hover-bg: rgba(100, 216, 255, 0.15);

  --timeline-line: rgba(100, 216, 255, 0.15);
  --timeline-dot: #64d8ff;

  --nda-bg: rgba(250, 176, 5, 0.1);
  --nda-border: rgba(250, 176, 5, 0.3);
  --nda-text: #fbbf24;

  --chat-user-bg: rgba(100, 216, 255, 0.15);
  --chat-ai-bg: rgba(22, 22, 29, 0.9);
  --chat-border: rgba(100, 216, 255, 0.2);

  --scrollbar-track: #0f0f14;
  --scrollbar-thumb: #2a2a35;
}

/* --- LIGHT THEME --- */
html[data-theme="light"] {
  --bg-primary: #fafaf9;
  --bg-secondary: #f1f0ee;
  --bg-elevated: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-input: rgba(235, 233, 230, 0.9);

  --text-primary: #1a1a1a;
  --text-secondary: #555350;
  --text-muted: #6d6b62;
  --text-accent: #0c7c9e;

  --accent-1: #0c7c9e;
  --accent-2: #7c3aed;
  --accent-glow: rgba(12, 124, 158, 0.1);
  --accent-gradient: linear-gradient(135deg, #0c7c9e, #7c3aed);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-card: rgba(0, 0, 0, 0.12);
  --border-accent: rgba(12, 124, 158, 0.3);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 30px rgba(12, 124, 158, 0.08);

  --particle-primary: 12, 100, 140;
  --particle-secondary: 100, 45, 200;
  --particle-tertiary: 6, 150, 180;
  --particle-glow: 0.25;
  --particle-bg-alpha: 0.5;

  --nav-bg: rgba(250, 250, 249, 0.92);
  --nav-border: rgba(0, 0, 0, 0.06);

  --btn-primary-bg: #0c7c9e;
  --btn-primary-text: #ffffff;
  --btn-primary-hover: #0e8fb5;
  --btn-outline-border: rgba(12, 124, 158, 0.4);
  --btn-outline-hover-bg: rgba(12, 124, 158, 0.06);

  --chip-bg: rgba(12, 124, 158, 0.06);
  --chip-border: rgba(12, 124, 158, 0.12);
  --chip-text: #0c7c9e;
  --chip-hover-bg: rgba(12, 124, 158, 0.1);

  --timeline-line: rgba(12, 124, 158, 0.15);
  --timeline-dot: #0c7c9e;

  --nda-bg: rgba(217, 119, 6, 0.08);
  --nda-border: rgba(217, 119, 6, 0.25);
  --nda-text: #b45309;

  --chat-user-bg: rgba(12, 124, 158, 0.1);
  --chat-ai-bg: rgba(241, 240, 238, 0.9);
  --chat-border: rgba(12, 124, 158, 0.15);

  --scrollbar-track: #f1f0ee;
  --scrollbar-thumb: #d0cfcc;
}

/* --- COLOR FUSION THEME ("Digital Synesthesia") --- */
html[data-theme="fusion"] {
  --bg-primary: #0d0d12;
  --bg-secondary: #12121a;
  --bg-elevated: #1a1a25;
  --bg-card: rgba(26, 26, 37, 0.75);
  --bg-card-hover: rgba(35, 35, 50, 0.85);
  --bg-input: rgba(26, 26, 37, 0.6);

  --text-primary: #f0eef5;
  --text-secondary: #a09cb0;
  --text-muted: #7a7690;
  --text-accent: #ff6eb4;

  --accent-1: #ff6eb4;
  --accent-2: #00e5ff;
  --accent-glow: rgba(255, 110, 180, 0.12);
  --accent-gradient: linear-gradient(135deg, #ff6eb4, #00e5ff, #ffe066, #a78bfa);

  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-card: rgba(255, 110, 180, 0.1);
  --border-accent: rgba(255, 110, 180, 0.3);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(255, 110, 180, 0.08);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(255, 110, 180, 0.1), 0 0 80px rgba(0, 229, 255, 0.05);

  --particle-primary: 255, 110, 180;
  --particle-secondary: 0, 229, 255;
  --particle-tertiary: 255, 224, 102;
  --particle-glow: 0.5;
  --particle-bg-alpha: 0.7;

  --nav-bg: rgba(13, 13, 18, 0.85);
  --nav-border: rgba(255, 110, 180, 0.08);

  --btn-primary-bg: linear-gradient(135deg, #ff6eb4, #a78bfa);
  --btn-primary-text: #0d0d12;
  --btn-primary-hover: linear-gradient(135deg, #ff8ec6, #b9a0fc);
  --btn-outline-border: rgba(255, 110, 180, 0.4);
  --btn-outline-hover-bg: rgba(255, 110, 180, 0.1);

  --chip-bg: rgba(255, 110, 180, 0.06);
  --chip-border: rgba(255, 110, 180, 0.12);
  --chip-text: #e8a0c8;
  --chip-hover-bg: rgba(255, 110, 180, 0.12);

  --timeline-line: rgba(255, 110, 180, 0.15);
  --timeline-dot: #ff6eb4;

  --nda-bg: rgba(255, 224, 102, 0.08);
  --nda-border: rgba(255, 224, 102, 0.25);
  --nda-text: #ffe066;

  --chat-user-bg: rgba(255, 110, 180, 0.12);
  --chat-ai-bg: rgba(26, 26, 37, 0.9);
  --chat-border: rgba(255, 110, 180, 0.2);

  --scrollbar-track: #12121a;
  --scrollbar-thumb: #2a2a3a;

  /* Fusion-specific: animated gradient bg */
  --fusion-gradient-1: #ff6eb4;
  --fusion-gradient-2: #00e5ff;
  --fusion-gradient-3: #ffe066;
  --fusion-gradient-4: #a78bfa;
}

/* --- THEME TRANSITION --- */
html {
  --transition-theme: 0.4s ease;
}

body,
.nav,
.timeline__card,
.project-card,
.stat-card,
.chip,
.chat,
.contact__card {
  transition:
    background-color var(--transition-theme),
    color var(--transition-theme),
    border-color var(--transition-theme),
    box-shadow var(--transition-theme);
}
/* ============================================
   BASE STYLES — Mobile First
   ============================================ */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  padding-top: env(safe-area-inset-top, 0);
}

/* iOS input styling fix */
input, textarea, button, select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 0;
}
button { border-radius: 0; }

/* Focus visible styles for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
}

/* iOS momentum scrolling */
.chat__messages,
.nav__links {
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }

/* Container — mobile first */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Section — mobile first */
.section {
  padding: 64px 0;
  position: relative;
}

.section__title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section__subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 600px;
}

h1, h2, h3, h4 { line-height: 1.2; }

strong {
  color: var(--text-accent);
  font-weight: 600;
}

/* Buttons — mobile first (full width on mobile) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  min-height: 48px; /* Touch target */
}

.btn--primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}
.btn--primary:hover {
  background: var(--btn-primary-hover);
  box-shadow: var(--shadow-glow);
}

.btn--outline {
  background: transparent;
  border: 1.5px solid var(--btn-outline-border);
  color: var(--text-accent);
}
.btn--outline:hover {
  background: var(--btn-outline-hover-bg);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge--nda {
  background: var(--nda-bg);
  border: 1px solid var(--nda-border);
  color: var(--nda-text);
}
.badge--featured {
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  color: var(--text-accent);
}

.mono { font-family: 'JetBrains Mono', monospace; }

/* Canvas */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.nav, .hero, .section, .footer {
  position: relative;
  z-index: 1;
}

/* ============================================
   TABLET+ (768px)
   ============================================ */
@media (min-width: 768px) {
  .container { padding: 0 24px; }
  .section { padding: 100px 0; }
  .section__title { font-size: 2.25rem; }
  .section__subtitle { margin-bottom: 40px; }
  .btn { width: auto; }
}

/* ============================================
   DESKTOP (1024px)
   ============================================ */
@media (min-width: 1024px) {
  .section { padding: 120px 0; }
  .section__title { font-size: 2.75rem; }
  .section__subtitle { margin-bottom: 48px; }

  .btn--primary:hover,
  .btn--outline:hover {
    transform: translateY(-2px);
  }
}
/* ============================================
   HERO — Mobile First
   ============================================ */
.hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 16px;
}

.hero__content {
  max-width: 800px;
  will-change: transform, opacity;
}

.hero__label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero__name {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 12px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__title {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 400;
}

.hero__separator {
  color: var(--text-accent);
  margin: 0 6px;
  opacity: 0.5;
}

.hero__tagline {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.hero__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero__scroll {
  position: absolute;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.hero__scroll-line {
  width: 1px;
  height: 32px;
  background: var(--accent-gradient);
  animation: scrollLine 2s ease-in-out infinite;
}

@keyframes scrollLine {
  0%, 100% { transform: scaleY(0); transform-origin: top; }
  50% { transform: scaleY(1); transform-origin: top; }
  51% { transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ============================================
   ABOUT — Mobile First
   ============================================ */
.about__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

.about__text p {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.7;
}

.about__lead {
  font-size: 1.1rem !important;
  color: var(--text-primary) !important;
  font-weight: 500;
  margin-bottom: 20px !important;
}

.about__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  transition: all 0.3s ease;
}

.stat-card__number {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card__label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ============================================
   TIMELINE — Mobile First
   ============================================ */
.timeline {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.timeline__line {
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--timeline-line);
}

.timeline__item {
  position: relative;
  padding-left: 40px;
  padding-bottom: 36px;
}
.timeline__item:last-child { padding-bottom: 0; }

.timeline__dot {
  position: absolute;
  left: 7px;
  top: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--timeline-dot);
  box-shadow: 0 0 0 4px var(--bg-primary), 0 0 20px rgba(var(--particle-primary), 0.3);
  z-index: 1;
}

.timeline__card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 20px;
  transition: all 0.3s ease;
}

.timeline__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.timeline__role {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.timeline__company {
  font-size: 0.85rem;
  color: var(--text-accent);
  margin-top: 2px;
}

.timeline__date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timeline__progression {
  font-size: 0.75rem;
  color: var(--text-accent);
  margin-top: 4px;
  font-weight: 500;
  opacity: 0.8;
}

.timeline__list { list-style: none; }
.timeline__list li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}
.timeline__list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-1);
  opacity: 0.5;
}

/* ============================================
   SKILLS — Mobile First
   ============================================ */
.skills__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.skills__category {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 20px;
  transition: all 0.3s ease;
}

.skills__category-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-accent);
  margin-bottom: 12px;
}
.skills__category-title svg { flex-shrink: 0; opacity: 0.7; }

.skills__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-block;
  padding: 5px 12px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--chip-text);
  transition: all 0.25s ease;
}

/* ============================================
   PROJECTS — Mobile First
   ============================================ */
.projects__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 22px;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}
.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.project-card--featured {
  border-color: var(--border-accent);
}
.project-card--featured::before { opacity: 0.5; }

.project-card__badge {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.project-card__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.project-card__desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
}

.project-card__tech {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 14px;
}
.project-card__tech span {
  padding: 3px 9px;
  background: var(--chip-bg);
  border-radius: 6px;
  font-size: 0.7rem;
  color: var(--chip-text);
  font-weight: 500;
}

.project-card__demo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================
   CHAT — Mobile First
   ============================================ */
.chat {
  max-width: 780px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  /* Mobile: fixed width, responsive height */
  width: calc(100vw - 32px);
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  height: min(520px, 65vh);
}

.chat__messages {
  padding: 14px;
  flex: 1;
  min-height: 0; /* flex child scrolling fix */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat__message {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: messageIn 0.3s ease;
}

.chat__message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat__avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--accent-gradient);
  color: var(--bg-primary);
}

.chat__message--user .chat__avatar {
  background: var(--text-muted);
  color: var(--bg-primary);
}

.chat__bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.55;
}

.chat__message--ai .chat__bubble {
  background: var(--chat-ai-bg);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-top-left-radius: 4px;
}

.chat__message--user .chat__bubble {
  background: var(--chat-user-bg);
  color: var(--text-primary);
  border-top-right-radius: 4px;
}

.chat__suggestions {
  padding: 0 16px 12px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  scrollbar-width: none;
}
.chat__suggestions::-webkit-scrollbar { display: none; }

.chat__suggestion-chip {
  padding: 8px 14px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 16px;
  font-size: 0.75rem;
  color: var(--chip-text);
  cursor: pointer;
  transition: all 0.25s ease;
  min-height: 36px;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat__input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  gap: 8px;
  flex-shrink: 0;
}

.chat__input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.chat__input {
  width: 100%;
  padding: 12px 50px 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 16px; /* prevents iOS zoom */
  outline: none;
  transition: border-color 0.3s ease;
  min-height: 48px;
  -webkit-appearance: none;
}
.chat__input:focus { border-color: var(--border-accent); }
.chat__input::placeholder { color: var(--text-muted); }

.chat__char-count {
  position: absolute;
  right: 10px;
  font-size: 0.6rem;
  color: var(--text-muted);
  pointer-events: none;
}

.chat__send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  color: var(--bg-primary);
  transition: all 0.3s ease;
}
.chat__send:disabled { opacity: 0.4; cursor: not-allowed; }

.chat__typing { display: flex; gap: 4px; padding: 8px 0; }
.chat__typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-muted);
  animation: typingDot 1.4s infinite;
}
.chat__typing span:nth-child(2) { animation-delay: 0.2s; }
.chat__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   CONTACT — Mobile First
   ============================================ */
.contact__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 32px;
}

.contact__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  text-align: center;
  transition: all 0.3s ease;
  min-height: 48px;
}

.contact__card svg { color: var(--text-accent); }

.contact__label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.contact__value {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

.contact__note {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================
   SECURITY & PERFORMANCE — Mobile First
   ============================================ */
.security__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.security__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
}

.security__icon {
  color: var(--text-accent);
  margin-bottom: 14px;
}

.security__card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.security__grade {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  line-height: 1;
}

.security__desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.security__link {
  font-size: 0.78rem;
  color: var(--text-accent);
  font-weight: 500;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  padding: 32px 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

/* ============================================
   TABLET+ (768px)
   ============================================ */
@media (min-width: 768px) {
  .hero__name { font-size: 4rem; }
  .hero__title { font-size: 1.2rem; }
  .hero__tagline { font-size: 0.85rem; margin-bottom: 40px; }
  .hero__actions { flex-direction: row; justify-content: center; gap: 16px; }
  .hero__scroll { bottom: 36px; }

  .about__grid { grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; }
  .about__lead { font-size: 1.2rem !important; }

  .timeline__line { left: 18px; }
  .timeline__item { padding-left: 52px; padding-bottom: 44px; }
  .timeline__dot { left: 11px; }
  .timeline__header { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 16px; }
  .timeline__card { padding: 24px; }
  .timeline__role { font-size: 1.1rem; }
  .timeline__list li { font-size: 0.9rem; }

  .skills__grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .skills__category { padding: 24px; }

  .projects__grid { grid-template-columns: 1fr 1fr; gap: 20px; }
  .project-card--featured { grid-column: 1 / -1; }
  .project-card { padding: 26px; }

  .chat { width: auto; height: 560px; }
  .chat__messages { padding: 20px; }
  .chat__input { font-size: 0.9rem; padding: 14px 50px 14px 16px; }
  .chat__message { max-width: 85%; }
  .chat__suggestions { flex-wrap: wrap; overflow-x: visible; }

  .contact__grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }

  .security__grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}

/* ============================================
   DESKTOP (1024px)
   ============================================ */
@media (min-width: 1024px) {
  .hero__name { font-size: 5.5rem; }
  .hero__title { font-size: 1.4rem; }
  .hero__tagline { font-size: 0.95rem; }

  .about__grid { gap: 60px; }
  .about__stats { gap: 20px; align-content: center; }
  .stat-card { padding: 28px 20px; }
  .stat-card__number { font-size: 2.5rem; }
  .stat-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-4px);
  }

  .timeline__card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
  }

  .skills__grid { grid-template-columns: repeat(3, 1fr); gap: 28px; }
  .skills__category:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
  }
  .chip:hover {
    background: var(--chip-hover-bg);
    border-color: var(--border-accent);
    transform: translateY(-1px);
  }

  .projects__grid { gap: 24px; }
  .project-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-4px);
  }
  .project-card:hover::before { opacity: 1; }

  .chat__messages { padding: 24px; max-height: 450px; }

  .security__grid { grid-template-columns: repeat(4, 1fr); }

  .contact__card:hover,
  .security__card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-4px);
  }

  .chat__send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
  }

  .chat__suggestion-chip:hover {
    background: var(--chip-hover-bg);
    border-color: var(--border-accent);
  }
}
/* ============================================
   PASSWORD GATE — Mobile First
   ============================================ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  transition: opacity 0.6s ease, visibility 0.6s ease;
  overflow: hidden;
}
.gate.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
html.authed .gate { display: none !important; }

#gate-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }

.gate__card {
  position: relative; z-index: 1; text-align: center;
  padding: 36px 24px;
  background: rgba(var(--particle-primary), 0.03);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  backdrop-filter: blur(24px);
  max-width: 360px; width: 90%;
  box-shadow: var(--shadow-lg);
}

.gate__logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 12px;
}
.gate__subtitle { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 28px; }
.gate__input-wrap { display: flex; gap: 8px; }
.gate__input {
  flex: 1; padding: 14px; background: var(--bg-input); border: 1px solid var(--border-subtle);
  border-radius: 12px; color: var(--text-primary); font-size: 0.9rem; outline: none;
  min-height: 48px; transition: border-color 0.3s ease;
}
.gate__input:focus { border-color: var(--border-accent); }
.gate__input::placeholder { color: var(--text-muted); }
.gate__submit {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-gradient); color: var(--bg-primary); flex-shrink: 0;
}
.gate__error { color: #f87171; font-size: 0.78rem; margin-top: 8px; min-height: 1.2em; }

/* Gate theme switcher — inside card, top-right corner, always collapsible */
.gate__corner-theme {
  position: absolute; top: 12px; right: 12px;
}
.gate__corner-theme:not(.expanded) .theme-btn:not(.active) {
  display: none;
}

.gate__hint { font-size: 0.65rem; color: var(--text-muted); }

/* ============================================
   NAVIGATION — Mobile First
   ============================================ */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 0 16px; padding-top: env(safe-area-inset-top, 0);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  transition: background 0.3s ease, box-shadow 0.3s ease;
  will-change: transform;
}
@supports (backdrop-filter: blur(12px)) {
  @media (min-width: 768px) {
    .nav { backdrop-filter: blur(12px); }
  }
}
.nav--scrolled { box-shadow: var(--shadow-sm); }

.nav__inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center;
  height: 52px;
}

/* Mobile: theme-switcher LEFT, AS CENTER, hamburger RIGHT */
.nav__logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  flex-shrink: 0;
  position: absolute; left: 50%; transform: translateX(-50%);
}

/* Theme switcher — collapsible on mobile */
.theme-switcher {
  display: flex; gap: 2px; padding: 2px;
  background: var(--bg-input); border-radius: 10px;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* Hide non-active when collapsed — MOBILE ONLY */
@media (max-width: 767px) {
  .theme-switcher:not(.expanded) .theme-btn:not(.active) {
    display: none;
  }
}

.nav__hamburger { margin-left: auto; }
.theme-btn {
  width: 36px; height: 32px; min-width: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; color: var(--text-muted);
  transition: all 0.3s ease; flex-shrink: 0;
}
.theme-btn.active {
  background: var(--accent-glow); color: var(--text-accent);
  box-shadow: 0 0 10px rgba(var(--particle-primary), 0.2);
}

/* Logout — desktop icon (hidden on mobile) */
.nav__logout--desktop {
  display: none;
  flex-shrink: 0; width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-muted);
  transition: all 0.3s ease;
}
.nav__logout--desktop:hover { color: #f87171; }

/* Logout — inside mobile menu */
/* Remove border from last link before logout */
.nav__links li:nth-last-child(2) a {
  border-bottom: none;
}
.nav__menu-logout {
  margin-top: 8px; padding-top: 16px;
  border-top: 1px solid var(--border-subtle) !important;
  border-bottom: none !important;
}
.nav__logout-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 14px 0;
  font-size: 1rem; color: #f87171;
  background: none; border: none; cursor: pointer;
  transition: opacity 0.3s ease;
}
.nav__logout-btn:hover { opacity: 0.7; }

/* Hamburger — mobile only */
.nav__hamburger {
  display: flex; flex-direction: column; gap: 5px;
  padding: 4px; min-height: 44px; min-width: 44px;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav__hamburger span {
  display: block; width: 20px; height: 2px;
  background: var(--text-primary); border-radius: 2px;
  transition: all 0.3s ease;
}
.nav__hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav__hamburger.active span:nth-child(2) { opacity: 0; }
.nav__hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Mobile nav menu — full screen overlay */
.nav__links {
  position: fixed; top: 52px; left: 0; right: 0;
  height: calc(100vh - 52px); height: calc(100dvh - 52px);
  background: var(--bg-primary); backdrop-filter: blur(24px);
  flex-direction: column; padding: 24px 24px;
  padding-bottom: env(safe-area-inset-bottom, 24px);
  gap: 0; z-index: 200;
  transform: translateX(100%); opacity: 0; pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; overflow-y: auto;
}
.nav__links.open { transform: translateX(0); opacity: 1; pointer-events: auto; }

.nav__links a {
  font-size: 1.1rem; color: var(--text-secondary);
  transition: color 0.3s ease;
  padding: 16px 0; min-height: 56px;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}
.nav__links a:hover, .nav__links a.active { color: var(--text-accent); }

/* ============================================
   SCROLL TO TOP
   ============================================ */
.scroll-top {
  position: fixed; bottom: 24px; right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  z-index: 90; width: 48px; height: 48px;
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border-card);
  backdrop-filter: blur(12px); color: var(--text-accent);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: all 0.3s ease; cursor: pointer;
}
.scroll-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.scroll-top:active { transform: scale(0.92); }

/* ============================================
   TABLET+ (768px)
   ============================================ */
@media (min-width: 768px) {
  .nav { padding: 0 24px; }
  .nav__inner { height: 64px; gap: 16px; }

  .nav__hamburger { display: none; }
  .nav__menu-logout { display: none; }

  /* Desktop order: AS(1) | links(2, centered) | theme(3) | logout(4) */
  .nav__logo { order: 1; position: static; transform: none; }
  .nav__links {
    order: 2;
    position: static; flex-direction: row; padding: 0; gap: 24px;
    transform: none; opacity: 1; pointer-events: auto;
    background: none; backdrop-filter: none; overflow: visible;
    flex: 1; height: auto; z-index: auto;
    align-items: center; justify-content: center;
  }
  .theme-switcher { order: 3; margin: 0; flex-shrink: 0; }
  .theme-btn { width: 32px; height: 28px; }
  .nav__logout--desktop { order: 4; display: flex; }
  .nav__links a {
    font-size: 0.82rem; padding: 0; min-height: auto;
    border-bottom: none; position: relative;
  }
  .nav__links a::after {
    content: ''; position: absolute; bottom: -4px; left: 0;
    width: 0; height: 2px; background: var(--accent-gradient);
    transition: width 0.3s ease;
  }
  .nav__links a:hover::after, .nav__links a.active::after { width: 100%; }

  .gate__submit:hover { transform: scale(1.05); box-shadow: var(--shadow-glow); }
  .scroll-top:hover { border-color: var(--border-accent); box-shadow: var(--shadow-glow); }
}

/* ============================================
   FUSION THEME EFFECTS
   ============================================ */
html[data-theme="fusion"] .hero__name {
  background: linear-gradient(135deg, #ff6eb4, #00e5ff, #ffe066, #a78bfa);
  background-size: 300% 300%;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: fusionGradient 6s ease infinite;
}
html[data-theme="fusion"] .section__title {
  background: linear-gradient(135deg, #ff6eb4, #00e5ff, #ffe066);
  background-size: 300% 300%;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: fusionGradient 6s ease infinite;
}
html[data-theme="fusion"] .stat-card,
html[data-theme="fusion"] .timeline__card,
html[data-theme="fusion"] .skills__category,
html[data-theme="fusion"] .project-card,
html[data-theme="fusion"] .contact__card,
html[data-theme="fusion"] .security__card { backdrop-filter: blur(16px) saturate(1.3); }
html[data-theme="fusion"] .project-card::before {
  background: linear-gradient(90deg, #ff6eb4, #00e5ff, #ffe066, #a78bfa);
  background-size: 300% 100%; animation: fusionBorder 4s linear infinite;
}
html[data-theme="fusion"] .timeline__dot { animation: fusionPulse 2s ease infinite; }

@keyframes fusionGradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes fusionBorder { 0% { background-position: 0% 0%; } 100% { background-position: 300% 0%; } }
@keyframes fusionPulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--bg-primary), 0 0 20px rgba(255, 110, 180, 0.3); }
  50% { box-shadow: 0 0 0 4px var(--bg-primary), 0 0 30px rgba(0, 229, 255, 0.4); }
}
/* ============================================
   SHAKE ANIMATION (password gate)
   ============================================ */
.shake {
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ============================================
   SCROLL ANIMATIONS
   ============================================ */
[data-animate] {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-animate="fade-right"] {
  transform: translateX(-40px);
}
[data-animate="fade-left"] {
  transform: translateX(40px);
}
[data-animate="scale-in"] {
  transform: scale(0.95);
}

[data-animate].is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger children */
.skills__chips .chip,
.projects__grid .project-card,
.about__stats .stat-card,
.timeline__item {
  transition-delay: calc(var(--stagger-index, 0) * 60ms);
}

/* ============================================
   PARALLAX ELEMENTS
   ============================================ */
.parallax-element {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  [data-animate] {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero__scroll-line {
    animation: none;
    opacity: 0.5;
  }

  #particle-canvas {
    display: none;
  }
}
