/* ============ TOKENS ============ */
:root {
  --bg: #F6F1E7;
  --bg-alt: #EFE7D8;
  --surface: #FFFDF8;
  --ink: #2B2620;
  --ink-muted: #6E6455;
  --accent: #4C6B58;
  --accent-ink: #F6F1E7;
  --accent-soft: #DCE6DB;
  --accent-2: #A9793F;
  --border: #E0D6C2;
  --shadow: rgba(43, 38, 32, 0.08);

  --font-display: "Fraunces", serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --maxw: 1080px;
  --radius: 14px;
  --dur: 0.6s;
}

html[data-theme="dark"] {
  --bg: #1B1814;
  --bg-alt: #24201A;
  --surface: #24201A;
  --ink: #F1EAD9;
  --ink-muted: #A79C89;
  --accent: #8FBF9F;
  --accent-ink: #17231C;
  --accent-soft: rgba(143, 191, 159, 0.14);
  --accent-2: #D8B074;
  --border: #38322A;
  --shadow: rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  transition: background var(--dur) ease, color var(--dur) ease;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
section { padding: 96px 24px; }
.wrap { max-width: var(--maxw); margin: 0 auto; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--ink);
  margin-bottom: 16px;
  box-shadow: 0 4px 12px var(--shadow);
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.eyebrow::before {
  content: "";
  width: 22px; height: 1px;
  background: var(--accent);
  display: inline-block;
}

/* ============ NAV ============ */
header.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
}
.logo {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.25rem;
  display: flex; align-items: center; gap: 8px;
}
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 700;
}
.nav-links { display: flex; gap: 32px; align-items: center; }
.nav-links a {
  font-size: 0.92rem; color: var(--ink-muted); font-weight: 500;
  position: relative; padding: 4px 0;
  transition: color 0.25s ease;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: -2px;
  width: 0; height: 1.5px; background: var(--accent);
  transition: width 0.3s ease;
}
.nav-links a:hover::after { width: 100%; }

.theme-toggle {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--ink);
  transition: transform 0.4s cubic-bezier(.2,.8,.2,1), border-color 0.3s ease, background 0.3s ease;
}
.theme-toggle:hover { transform: rotate(20deg); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
html[data-theme="dark"] .theme-toggle .moon { display: none; }
html[data-theme="dark"] .theme-toggle .sun { display: block; }

.nav-toggle { display: none; background: none; border: none; color: var(--ink); cursor: pointer; }

/* ============ HERO ============ */
.hero {
  padding: 120px 24px 80px;
  position: relative;
  overflow: hidden;
}
.hero-inner { max-width: var(--maxw); margin: 0 auto; position: relative; }
.hero h1 {
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  line-height: 1.02;
}
.hero h1 .role {
  display: block;
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  font-size: 0.42em;
  margin-top: 14px;
}
.hero-sub {
  max-width: 560px;
  margin-top: 26px;
  font-size: 1.08rem;
  color: var(--ink-muted);
}
.hero-sub strong { color: var(--ink); font-weight: 600; }

.hero-cta { display: flex; gap: 16px; margin-top: 38px; flex-wrap: wrap; }
.btn {
  font-family: var(--font-body); font-weight: 600; font-size: 0.92rem;
  padding: 13px 26px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1), box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -8px var(--shadow); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }

/* hero route line: drawn on load, echoes a shipping route / navigation line */
.hero-route { margin-top: 64px; width: 100%; max-width: 640px; }
.hero-route path {
  fill: none; stroke: var(--accent); stroke-width: 1.6;
  stroke-dasharray: 900; stroke-dashoffset: 900;
  animation: draw 2.4s 0.3s cubic-bezier(.2,.7,.3,1) forwards;
}
.hero-route circle {
  fill: var(--bg); stroke: var(--accent-2); stroke-width: 1.6;
  opacity: 0; animation: pop 0.5s 2.2s ease forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { to { opacity: 1; } }

/* ============ REVEAL ============ */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.8s ease, transform 0.8s cubic-bezier(.2,.7,.3,1); }
.reveal.in { opacity: 1; transform: translateY(0); }

/* ============ SECTION HEADS ============ */
.section-head { margin-bottom: 48px; max-width: 620px; }
.section-head h2 { font-size: clamp(1.8rem, 3.4vw, 2.4rem); }
.section-head p { color: var(--ink-muted); margin-top: 12px; font-size: 1rem; }

/* ============ ABOUT ============ */
.about { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.about-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 56px; align-items: center; }
.about-photo {
  width: 100%; aspect-ratio: 1/1; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.about-photo img { width: 100%; height: 100%; object-fit: cover; }
.about-photo .placeholder { color: var(--ink-muted); font-family: var(--font-mono); font-size: 0.85rem; text-align: center; padding: 20px; }
.about-text p { font-size: 1.06rem; color: var(--ink); }
.about-text p + p { margin-top: 16px; color: var(--ink-muted); }
.about-stats { display: flex; gap: 36px; margin-top: 32px; flex-wrap: wrap; }
.stat b { display: block; font-family: var(--font-display); font-size: 2rem; color: var(--accent); }
.stat span { font-size: 0.82rem; color: var(--ink-muted); }

/* ============ EXPERIENCE (route/timeline) ============ */
.timeline { position: relative; padding-left: 44px; }
.timeline::before {
  content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px;
  background: var(--border);
}
.timeline-progress {
  position: absolute; left: 9px; top: 6px; width: 2px; height: 0%;
  background: var(--accent);
  transition: height 1.4s cubic-bezier(.2,.7,.3,1);
}
.timeline-item { position: relative; padding-bottom: 56px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: -44px; top: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.timeline-dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.timeline-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 30px;
  transition: transform 0.35s cubic-bezier(.2,.7,.3,1), box-shadow 0.35s ease, border-color 0.35s ease;
}
.timeline-card:hover { transform: translateY(-3px); box-shadow: 0 16px 32px -18px var(--shadow); border-color: var(--accent); }
.role-row { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.role-row h3 { font-size: 1.24rem; }
.role-date { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-muted); white-space: nowrap; }
.role-company { color: var(--accent); font-weight: 600; font-size: 0.92rem; margin-bottom: 16px; display: block; }
.role-list { display: flex; flex-direction: column; gap: 10px; }
.role-list li { position: relative; padding-left: 18px; color: var(--ink-muted); font-size: 0.95rem; }
.role-list li::before { content: "—"; position: absolute; left: 0; color: var(--accent-2); }

/* ============ SKILLS ============ */
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }
.skill-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 26px; }
.skill-group h3 { font-size: 0.75rem; font-family: var(--font-mono); font-weight: 500; color: var(--ink-muted); margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.04em; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 0.84rem; padding: 7px 13px; border-radius: 999px;
  background: var(--accent-soft); color: var(--ink); border: 1px solid transparent;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.chip:hover { transform: translateY(-2px) scale(1.03); border-color: var(--accent); }

/* ============ PROJECTS ============ */
.projects-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }
.project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 30px; display: flex; flex-direction: column; gap: 14px;
  transition: transform 0.35s cubic-bezier(.2,.7,.3,1), box-shadow 0.35s ease, border-color 0.35s ease;
}
.project-card:hover { transform: translateY(-4px); box-shadow: 0 18px 36px -20px var(--shadow); border-color: var(--accent); }
.project-top { display: flex; justify-content: space-between; align-items: flex-start; }
.project-top h3 { font-size: 1.18rem; }
.project-links { display: flex; gap: 10px; }
.icon-link {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.icon-link:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.icon-link svg { width: 15px; height: 15px; }
.project-card p.desc { color: var(--ink-muted); font-size: 0.95rem; }
.project-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 8px; }
.tag { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent); background: transparent; border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; }

/* ============ EDU / CERTS / ACHIEVEMENTS ============ */
.background-stack { display: flex; flex-direction: column; gap: 28px; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 30px; }
.info-card h3 { font-size: 1.05rem; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.info-card h3 svg { width: 18px; height: 18px; color: var(--accent); }

/* Education styles */
.edu-list { display: flex; flex-direction: column; gap: 20px; }
.edu-item { display: flex; flex-direction: column; gap: 6px; }
.edu-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.edu-degree { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; color: var(--ink); margin: 0; }
.edu-institution { color: var(--accent); font-weight: 600; font-size: 0.96rem; }
.edu-meta { display: flex; gap: 12px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.edu-badge { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink); background: var(--accent-soft); padding: 4px 10px; border-radius: 6px; font-weight: 500; }
.edu-date { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-muted); }

/* Certifications 2-column grid styles */
.cert-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; list-style: none; margin: 0; padding: 0; }
.cert-card-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 18px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; transition: border-color 0.25s ease, transform 0.25s ease;
}
.cert-card-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.cert-info { display: flex; flex-direction: column; gap: 3px; }
.cert-title { color: var(--ink); font-weight: 600; font-size: 0.94rem; }
.cert-issuer { color: var(--ink-muted); font-size: 0.84rem; }
.cert-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500;
  color: var(--accent); background: var(--accent-soft);
  padding: 6px 12px; border-radius: 6px; border: 1px solid transparent;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
  white-space: nowrap; text-decoration: none; flex-shrink: 0;
}
.cert-link:hover { transform: translateY(-1px); background: var(--accent); color: var(--accent-ink); }

/* Achievements styles */
.achievements-list { display: flex; flex-direction: column; gap: 14px; }
.achievement-row { display: flex; gap: 14px; align-items: center; padding: 16px 18px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; transition: border-color 0.25s ease, transform 0.25s ease; }
.achievement-row:hover { border-color: var(--accent); transform: translateY(-2px); }
.achievement-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.achievement-icon svg { width: 16px; height: 16px; }
.achievement-body { flex: 1; }
.achievement-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
.achievement-title { color: var(--ink); font-weight: 600; font-size: 0.95rem; }
.achievement-issuer { font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent); font-weight: 500; }

/* ============ CONTACT / FOOTER ============ */
.contact { text-align: center; background: var(--bg-alt); border-top: 1px solid var(--border); }
.contact h2 { font-size: clamp(2rem, 5vw, 3rem); max-width: 640px; margin: 0 auto; }
.contact p { color: var(--ink-muted); margin-top: 16px; max-width: 480px; margin-left: auto; margin-right: auto; }
.contact-links { display: flex; justify-content: center; gap: 16px; margin-top: 40px; flex-wrap: wrap; }

footer { padding: 32px 24px; text-align: center; font-size: 0.82rem; color: var(--ink-muted); font-family: var(--font-mono); }
.footer-sep { margin: 0 8px; opacity: 0.5; }
.cookie-settings-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  transition: color 0.25s ease;
}
.cookie-settings-btn:hover {
  color: var(--accent);
}

@media (max-width: 860px) {
  .about-grid, .split-grid, .skills-grid, .projects-grid, .cert-grid { grid-template-columns: 1fr; }
  .nav-links {
    position: fixed; top: 70px; right: 24px; left: 24px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    flex-direction: column; align-items: flex-start; padding: 20px;
    box-shadow: 0 20px 40px -20px var(--shadow);
    transform: translateY(-12px); opacity: 0; pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  .nav-links.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-toggle { display: block; }
}

/* ============ COOKIE CONSENT BANNER & BACKDROP ============ */
.cookie-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  cursor: pointer;
  animation: cookieFadeIn 0.3s ease;
}
.cookie-overlay[hidden] {
  display: none !important;
}
@keyframes cookieFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cookie-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(500px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: 0 16px 40px var(--shadow), 0 0 0 1px var(--border);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: cookieSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.cookie-banner[hidden] {
  display: none !important;
}
@keyframes cookieSlideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.cookie-banner-content {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
  padding-right: 20px;
}
.cookie-icon {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}
.cookie-banner-content p {
  font-size: 0.85rem;
  color: var(--ink-muted);
  line-height: 1.45;
  margin: 0;
}
.cookie-close-btn {
  position: absolute;
  top: -4px;
  right: -8px;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.2s ease, background 0.2s ease;
}
.cookie-close-btn:hover {
  color: var(--ink);
  background: var(--accent-soft);
}
.cookie-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
}
@media (max-width: 600px) {
  .cookie-banner {
    bottom: 16px;
    width: calc(100vw - 24px);
    padding: 14px 16px;
  }
}

/* ============ ACCESSIBILITY & ACTIVE NAV ============ */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.nav-links a {
  position: relative;
}
.nav-links a.active {
  color: var(--accent);
  font-weight: 600;
}

/* ============ FLOATING BACK TO TOP ============ */
.back-to-top {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 42px;
  height: 42px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 999;
  text-decoration: none;
  transition: transform 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  backdrop-filter: blur(8px);
}
.back-to-top:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  color: var(--accent);
}
.back-to-top[hidden] {
  display: none !important;
}

/* ============ TOAST NOTIFICATION ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.86rem;
  font-family: var(--font-mono);
  box-shadow: 0 10px 28px var(--shadow);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast[hidden] {
  display: none !important;
}
@keyframes toastFadeIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ PRINT STYLES (PDF RESUME VIEW) ============ */
@media print {
  body {
    background: #ffffff !important;
    color: #111111 !important;
    font-size: 11pt !important;
  }
  .nav, .theme-toggle, .nav-toggle, .hero-cta, .cookie-banner, .back-to-top, .toast, .ai-chat-widget, footer {
    display: none !important;
  }
  main {
    margin: 0 !important;
    padding: 0 !important;
  }
  section {
    padding: 16px 0 !important;
    border: none !important;
    background: none !important;
    break-inside: avoid;
  }
  .wrap {
    max-width: 100% !important;
    padding: 0 !important;
  }
  .timeline-item, .project-card, .info-card, .achievement-row, .cert-card-item {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
  .eyebrow {
    color: #555 !important;
  }
  a {
    color: #111 !important;
    text-decoration: underline !important;
  }
}

/* ============ AI ASSISTANT CHAT WIDGET ============ */
.ai-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  font-family: var(--font-body);
}

.ai-chat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 18px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--shadow);
  transition: transform 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  backdrop-filter: blur(10px);
}
.ai-chat-toggle:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--accent);
}
.ai-badge {
  background: var(--accent);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-chat-window {
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: min(380px, calc(100vw - 32px));
  height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(16px);
  animation: aiChatSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
}
.ai-chat-window[hidden] {
  display: none !important;
}
@keyframes aiChatSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-chat-header {
  padding: 14px 16px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ai-key-btn {
  background: none;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.75;
  transition: opacity 0.2s ease;
}
.ai-key-btn:hover { opacity: 1; }

.ai-key-drawer {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.ai-key-drawer p { margin: 0 0 8px 0; line-height: 1.35; }
.ai-key-drawer a { color: var(--accent); text-decoration: underline; }
.key-input-wrap {
  display: flex;
  gap: 6px;
}
.key-input-wrap input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  color: var(--ink);
  outline: none;
}
.ai-key-drawer[hidden] {
  display: none !important;
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.ai-chat-header h4 {
  font-size: 0.9rem;
  margin: 0;
  font-family: var(--font-display);
}
.status-indicator {
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  display: block;
}
.ai-chat-close {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s ease;
}
.ai-chat-close:hover { color: var(--ink); }

.ai-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message {
  max-width: 88%;
  font-size: 0.86rem;
  line-height: 1.5;
  border-radius: 12px;
  padding: 10px 14px;
}
.message p { margin: 0 0 6px 0; }
.message p:last-child { margin-bottom: 0; }
.bot-message {
  align-self: flex-start;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--ink);
  border-bottom-left-radius: 2px;
}
.bot-message ul, .bot-message ol { margin: 6px 0; padding-left: 18px; }
.bot-message li { margin-bottom: 4px; }
.bot-message code { background: rgba(0,0,0,0.06); padding: 2px 5px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.8rem; }
.bot-message pre { background: var(--bg); padding: 8px 12px; border-radius: 6px; overflow-x: auto; font-family: var(--font-mono); font-size: 0.78rem; margin: 8px 0; }
.bot-message a { color: var(--accent); text-decoration: underline; word-break: break-all; }
.bot-message h1, .bot-message h2, .bot-message h3, .bot-message h4 { margin: 8px 0 4px 0; font-size: 0.92rem; }
.user-message {
  align-self: flex-end;
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.chip-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ai-chat-input-form {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 8px;
}
.ai-chat-input-form input {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.84rem;
  color: var(--ink);
  font-family: var(--font-body);
  outline: none;
}
.ai-chat-input-form input:focus {
  border-color: var(--accent);
}
.ai-chat-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}
.ai-chat-send:hover { opacity: 0.9; }

@media (max-width: 600px) {
  .ai-chat-window {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 76px;
    height: 420px;
  }
}
