/* Dark mode — follows device default; override with html[data-theme] */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --bg-subtle: #111827;
    --surface: #151d2e;
    --surface-glass: rgba(21, 29, 46, 0.82);
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.12);
    --border-strong: rgba(148, 163, 184, 0.22);
    --accent: #60a5fa;
    --accent-light: #93c5fd;
    --accent-hover: #3b82f6;
    --accent-soft: rgba(96, 165, 250, 0.14);
    --accent-glow: rgba(96, 165, 250, 0.28);
    --violet-soft: rgba(167, 139, 250, 0.14);
    --teal-soft: rgba(45, 212, 191, 0.12);
    --amber-soft: rgba(251, 191, 36, 0.12);
    --rose-soft: rgba(251, 113, 133, 0.1);
    --success-bg: rgba(16, 185, 129, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 16px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.35), 0 32px 64px rgba(0, 0, 0, 0.45);
  }
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #111827;
  --surface: #151d2e;
  --surface-glass: rgba(21, 29, 46, 0.82);
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --accent: #60a5fa;
  --accent-light: #93c5fd;
  --accent-hover: #3b82f6;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --accent-glow: rgba(96, 165, 250, 0.28);
  --violet-soft: rgba(167, 139, 250, 0.14);
  --teal-soft: rgba(45, 212, 191, 0.12);
  --amber-soft: rgba(251, 191, 36, 0.12);
  --rose-soft: rgba(251, 113, 133, 0.1);
  --success-bg: rgba(16, 185, 129, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 16px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.35), 0 32px 64px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bg-mesh-inner {
    background:
      radial-gradient(ellipse 50% 40% at 10% 8%, rgba(59, 130, 246, 0.15), transparent 55%),
      radial-gradient(ellipse 45% 38% at 92% 12%, rgba(124, 58, 237, 0.12), transparent 52%),
      radial-gradient(ellipse 55% 45% at 78% 88%, rgba(13, 148, 136, 0.1), transparent 55%),
      linear-gradient(165deg, #0b1120 0%, #111827 35%, #0f172a 70%, #0b1120 100%);
  }
  :root:not([data-theme="light"]) .section-subtle {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.9) 0%, rgba(15, 23, 42, 0.85) 100%);
    border-color: rgba(148, 163, 184, 0.1);
  }
  :root:not([data-theme="light"]) .section-colored {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
  }
  :root:not([data-theme="light"]) .nav.scrolled {
    background: rgba(15, 23, 42, 0.92);
  }
  :root:not([data-theme="light"]) .hero-content h1,
  :root:not([data-theme="light"]) .hero-word {
    background: linear-gradient(135deg, #f8fafc 0%, #60a5fa 45%, #a78bfa 75%, #c4b5fd 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  :root:not([data-theme="light"]) .hero-panel {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(21, 29, 46, 0.95) 100%);
  }
  :root:not([data-theme="light"]) .hero-meta,
  :root:not([data-theme="light"]) .bento-card,
  :root:not([data-theme="light"]) .service-card,
  :root:not([data-theme="light"]) .project-card,
  :root:not([data-theme="light"]) .tech-icon-item,
  :root:not([data-theme="light"]) .skill-group,
  :root:not([data-theme="light"]) .contact-form,
  :root:not([data-theme="light"]) .contact-info-panel {
    background: rgba(21, 29, 46, 0.88);
    border-color: rgba(148, 163, 184, 0.12);
  }
  :root:not([data-theme="light"]) .cta-band {
    background: linear-gradient(135deg, rgba(21, 29, 46, 0.95) 0%, rgba(30, 41, 59, 0.8) 100%);
  }
  :root:not([data-theme="light"]) .footer {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(11, 17, 32, 0.98));
  }
  :root:not([data-theme="light"]) .education-card {
    background: linear-gradient(135deg, rgba(21, 29, 46, 0.95), rgba(30, 41, 59, 0.7));
  }
  :root:not([data-theme="light"]) .status-banner p { color: #6ee7b7; }
  :root:not([data-theme="light"]) .form-success { color: #6ee7b7; }
  :root:not([data-theme="light"]) .bg-dots {
    background-image: radial-gradient(rgba(96, 165, 250, 0.15) 1.5px, transparent 1.5px);
  }
  :root:not([data-theme="light"]) .bg-pattern-diagonal {
    opacity: 0.06;
    background: repeating-linear-gradient(-45deg, transparent, transparent 12px, rgba(96, 165, 250, 0.4) 12px, rgba(96, 165, 250, 0.4) 13px);
  }
}

html[data-theme="dark"] .bg-mesh-inner {
  background:
    radial-gradient(ellipse 50% 40% at 10% 8%, rgba(59, 130, 246, 0.15), transparent 55%),
    radial-gradient(ellipse 45% 38% at 92% 12%, rgba(124, 58, 237, 0.12), transparent 52%),
    linear-gradient(165deg, #0b1120 0%, #111827 50%, #0b1120 100%);
}

html[data-theme="dark"] .section-subtle,
html[data-theme="dark"] .section-colored,
html[data-theme="dark"] .hero-panel,
html[data-theme="dark"] .hero-meta,
html[data-theme="dark"] .bento-card,
html[data-theme="dark"] .service-card,
html[data-theme="dark"] .project-card,
html[data-theme="dark"] .tech-icon-item,
html[data-theme="dark"] .skill-group,
html[data-theme="dark"] .contact-form,
html[data-theme="dark"] .contact-info-panel,
html[data-theme="dark"] .cta-band,
html[data-theme="dark"] .education-card {
  background: rgba(21, 29, 46, 0.88);
  border-color: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .hero-content h1,
html[data-theme="dark"] .hero-word {
  background: linear-gradient(135deg, #f8fafc 0%, #60a5fa 45%, #a78bfa 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

html[data-theme="dark"] .nav.scrolled { background: rgba(15, 23, 42, 0.92); }
html[data-theme="dark"] .footer { background: linear-gradient(180deg, #0f172a, #0b1120); }

/* Theme toggle */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; margin-left: 0.25rem;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text-muted);
  cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.theme-toggle svg { width: 18px; height: 18px; }
html[data-theme="dark"] .theme-toggle .icon-sun,
:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
}
