/* ============================================================
   Design System
   ============================================================ */
:root {
  --color-bg: #ffffff;
  --color-surface: #f8f9fa;
  --color-border: #e9ecef;
  --color-text: #1a1a2e;
  --color-text-muted: #6c757d;
  --color-accent: #0066cc;
  --color-accent-hover: #0052a3;
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
  --max-width: 1100px;
  --nav-height: 60px;
  color-scheme: light dark;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

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

a:hover {
  color: var(--color-accent-hover);
}

img {
  display: block;
  max-width: 100%;
}

/* ============================================================
   Layout Utilities
   ============================================================ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

section {
  padding: 80px 0;
}

section:nth-child(even) {
  background: var(--color-surface);
}

.section-heading {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 48px;
  position: relative;
  display: inline-block;
}

.section-heading::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -10px;
  width: 40px;
  height: 2px;
  background: var(--color-accent);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary,
.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 200ms, color 200ms, border-color 200ms;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--color-accent);
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

.btn-outline:hover {
  background: var(--color-accent);
  color: #fff;
}

/* ============================================================
   Navigation
   ============================================================ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.nav .container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.nav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  transition: color 200ms;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--color-accent);
}

@media (max-width: 768px) {
  .nav {
    display: none;
  }
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 24px;
  padding-top: var(--nav-height);
  background: linear-gradient(160deg, #f8f9fa 0%, #ffffff 60%);
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 64px;
  max-width: 860px;
  width: 100%;
}

.hero-photo {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  flex-shrink: 0;
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  object-position: center;
  transform: scale(1.5);
  transform-origin: left;
}

.hero-photo--placeholder {
  background: var(--color-surface);
  border: 2px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-photo--placeholder::after {
  content: 'MG';
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-border);
  letter-spacing: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .hero-content > * {
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
  }

  .hero-content > *:nth-child(1) { animation-delay: 0ms; }
  .hero-content > *:nth-child(2) { animation-delay: 80ms; }
  .hero-content > *:nth-child(3) { animation-delay: 160ms; }
  .hero-content > *:nth-child(4) { animation-delay: 240ms; }
  .hero-content > *:nth-child(5) { animation-delay: 320ms; }
}

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

.hero h1 {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 12px;
}

.hero-title {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--color-accent);
  margin-bottom: 12px;
}

.hero-tagline {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

.hero-location {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 36px;
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-ctas {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 768px) {
  .hero {
    padding-top: 0;
  }

  .hero-inner {
    flex-direction: column;
    text-align: center;
    gap: 32px;
  }

  .hero-content {
    align-items: center;
  }

  .hero-photo {
    width: 140px;
    height: 140px;
  }

  .hero-ctas {
    justify-content: center;
  }

  .hero h1 {
    font-size: 2.25rem;
  }

  .hero-title {
    font-size: 1.1rem;
  }
}

/* ============================================================
   About
   ============================================================ */
.about-body {
  display: block;
}

.about-summary {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  line-height: 1.75;
  max-width: 640px;
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 180px;
}

.stat {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 768px) {

  .stats-grid {
    flex-direction: row;
    min-width: unset;
  }

  .stat {
    flex: 1;
  }

  .stat-number {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    flex-direction: column;
  }
}

/* ============================================================
   Skills
   ============================================================ */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.skill-group {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.skill-group h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 0.875rem;
  color: var(--color-text);
}

/* ============================================================
   Experience Timeline
   ============================================================ */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--color-border);
}

.timeline-item {
  position: relative;
  margin-bottom: 40px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -28px;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-accent);
}

.timeline-company {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin-bottom: 4px;
}

.timeline-role {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.timeline-dates {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.timeline-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-bullets li {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  padding-left: 16px;
  position: relative;
}

.timeline-bullets li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--color-border);
}

/* ============================================================
   Projects
   ============================================================ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.project-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 200ms, border-color 200ms;
}

.project-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 20px rgba(0, 102, 204, 0.1);
}

.project-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin: 0;
}

.project-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.project-desc {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0;
  flex: 1;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.project-tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-accent);
  background: rgba(0, 102, 204, 0.08);
  border: 1px solid rgba(0, 102, 204, 0.2);
  border-radius: 20px;
  padding: 3px 10px;
}

/* ============================================================
   Certifications
   ============================================================ */
.cert-wrapper {
  display: flex;
  justify-content: center;
}

/* ============================================================
   Education
   ============================================================ */
.edu-card {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  box-shadow: var(--shadow-card);
}

.edu-header {
  margin-bottom: 28px;
}

.edu-card h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.edu-card p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.edu-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.edu-details {
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-top: 1px solid var(--color-border);
  padding-top: 24px;
}

.edu-section h4 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.edu-dissertation {
  font-size: 0.95rem;
  color: var(--color-text);
  font-style: italic;
  line-height: 1.5;
}

/* ============================================================
   Contact
   ============================================================ */
.contact-inner {
  max-width: 480px;
}

.contact-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
}

.contact-tagline {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  margin-bottom: 32px;
}

.contact-links {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--color-border);
}

.contact-item:first-child {
  padding-top: 0;
  border-top: none;
}

.contact-item:last-child {
  padding-bottom: 0;
}

.contact-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.contact-item-icon svg {
  color: var(--color-accent);
}

.contact-item-body {
  min-width: 0;
}

.contact-item-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.contact-item-value {
  font-size: 0.95rem;
  color: var(--color-text);
}

.contact-link-inline {
  display: inline-flex;
  align-items: center;
  color: var(--color-text);
  font-size: 0.95rem;
  word-break: break-word;
}

.contact-link-icon {
  height: 18px;
  width: auto;
}

.contact-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 32px;
}

@media (max-width: 768px) {
  .contact-card {
    padding: 24px;
  }
}

/* ============================================================
   Chat — toggle button (independent fixed element)
   ============================================================ */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1001;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 200ms ease;
  animation: toggle-pulse 5s ease-out infinite;
}

.chat-toggle:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
}

.chat-toggle.is-hidden {
  display: none;
}

/* ============================================================
   Chat — panel (independent fixed element)
   ============================================================ */
.chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 360px;
  display: none;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 1000;
}

.chat-panel.is-open {
  display: flex;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-panel-identity {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-panel-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  text-decoration: none;
}
.chat-panel-title:hover {
  text-decoration: underline;
}

.chat-panel-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-panel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: goldie-pulse 1.4s ease-in-out infinite;
}

.chat-panel-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.chat-panel-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.3rem;
  padding: 0;
  line-height: 1;
  transition: color 150ms;
}

.chat-panel-close:hover {
  color: var(--color-text);
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 120px;
  max-height: 360px;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}

.chat-window:focus {
  outline: none;
}

.chat-footer {
  border-top: 1px solid var(--color-border);
  padding: 12px 14px;
  background: #ffffff;
  flex-shrink: 0;
}


.chat-message {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
}

.chat-message--user {
  align-self: flex-end;
  background: var(--color-accent);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-message p { margin-bottom: 6px; }
.chat-message p:last-child { margin-bottom: 0; }
.chat-message ol { margin: 4px 0; padding-left: 18px; }
.chat-message li { margin-bottom: 4px; }
.chat-message li:last-child { margin-bottom: 0; }

.chat-message--ai {
  align-self: flex-start;
  background: #ffffff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: var(--radius-sm);
}

.chat-message--error {
  align-self: flex-start;
  background: #fff5f5;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-bottom-left-radius: var(--radius-sm);
}

/* ── Thinking state — matches GOLDIE status style ── */
.chat-thinking {
  align-self: flex-start;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-thinking__label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.chat-thinking__row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.chat-thinking__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: goldie-pulse 1.4s ease-in-out infinite;
}

.chat-thinking__text {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.chat-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: currentColor;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* ── Widget file chip ── */
.chat-file-chip {
  display: none;
  align-items: center;
  gap: 5px;
  background: #eef4ff;
  border: 1px solid #c7d9f5;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.75rem;
  color: var(--color-accent);
  font-weight: 500;
}

.chat-file-chip:not([hidden]) { display: flex; }

.chat-file-chip__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.chat-file-chip__remove {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 150ms;
}

.chat-file-chip__remove:hover { color: var(--color-text); }

/* ── Widget attach button ── */
.chat-attach {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms, color 150ms;
}

.chat-attach:hover { background: #eef4ff; color: var(--color-accent); }
.chat-attach:disabled { opacity: 0.4; cursor: default; }

.chat-input {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  padding: 9px 12px;
  font-family: var(--font-base);
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 200ms;
  resize: none;
  overflow-y: auto;
  line-height: 1.45;
}

.chat-input:focus {
  border-color: var(--color-accent);
}

.chat-input::placeholder {
  color: var(--color-text-muted);
}

.chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms;
}

.chat-send:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   Chat — backdrop (mobile only)
   ============================================================ */
.chat-backdrop {
  display: none;
}

/* ============================================================
   Chat — mobile overrides
   ============================================================ */
/* Bottom sheet — rises from bottom, falls back down */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(0);    opacity: 1; }
  to   { transform: translateY(100%); opacity: 0; }
}

/* Double-pulse every 5 seconds, long idle gap between */
@keyframes toggle-pulse {
  0%   { box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 0   rgba(0, 102, 204, 0.55); }
  7%   { box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 12px rgba(0, 102, 204, 0);   }
  14%  { box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 0   rgba(0, 102, 204, 0.35); }
  21%  { box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 10px rgba(0, 102, 204, 0);   }
  100% { box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 0   rgba(0, 102, 204, 0);    }
}


@media (max-width: 768px) {
  /* Backdrop */
  .chat-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 1001;
    pointer-events: none;
    transition: background 0.25s ease;
  }

  .chat-backdrop.is-visible {
    background: rgba(0, 0, 0, 0.45);
    pointer-events: auto;
  }

  /* Closing state — slide back down before display:none */
  .chat-panel.is-closing {
    animation: slideDown 0.22s ease forwards;
    pointer-events: none;
  }

  /* Toggle: above home indicator */
  .chat-toggle {
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
  }

  /* Bottom sheet — rises from bottom, keyboard pushes it up,
     max-height caps it so it never overlaps the Dynamic Island */
  .chat-panel.is-open {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 50dvh;
    max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
    border-radius: 16px 16px 0 0;
    border: none;
    z-index: 1002;
    animation: slideUp 0.3s ease;
  }

  /* Rounded top corners on header to match sheet */
  .chat-panel-header {
    padding-top: 14px;
    border-radius: 16px 16px 0 0;
    background: #ffffff;
  }

  /* Chat window fills space between header and footer */
  .chat-window {
    max-height: none;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }

  /* Sit above home indicator when keyboard is closed */
  .chat-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  /* Prevent iOS auto-zoom on input focus */
  .chat-input {
    font-size: 16px;
  }
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 24px 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ============================================================
   GOLDIE Status Indicator
   ============================================================ */
.goldie-status {
  position: fixed;
  top: 0;
  right: 24px;
  height: var(--nav-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 200;
  min-width: 0;
}

.goldie-status.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.goldie-status__label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.goldie-status__row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.goldie-status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: goldie-pulse 1.4s ease-in-out infinite;
}

.goldie-status__text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

@keyframes goldie-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

@media (max-width: 768px) {
  .goldie-status {
    top: 0;
    right: 0;
    left: 0;
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: #ffffff;
    padding-top: calc(env(safe-area-inset-top) + 10px);
    padding-bottom: 10px;
    padding-left: 20px;
    padding-right: 20px;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-100%);
    z-index: 9999;
  }

  .goldie-status.is-visible {
    transform: translateY(0);
  }

  .goldie-status__label {
    color: var(--color-accent);
  }

  .goldie-status__text {
    color: var(--color-text-muted);
  }
}

/* ============================================================
   Cookie Consent Banner
   ============================================================ */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #1a1a2e;
  color: #fff;
  padding: 1rem 1.5rem;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.15);
}

.cookie-banner--visible {
  transform: translateY(0);
}

.cookie-banner__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.cookie-banner__text {
  flex: 1;
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  min-width: 200px;
}

.cookie-banner__actions {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

.cookie-banner__btn {
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s ease;
}

.cookie-banner__btn:hover {
  opacity: 0.85;
}

.cookie-banner__btn--accept {
  background: var(--color-accent);
  color: #fff;
}

.cookie-banner__btn--decline {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.cookie-banner__link {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: underline;
  white-space: nowrap;
}
.cookie-banner__link:hover {
  color: #fff;
}

.footer-divider {
  margin: 0 0.5rem;
  color: var(--color-border);
}

.footer-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.footer-link:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* ============================================================
   Dark Mode  — follows device/OS preference
   No nested @media rules — iOS Safari doesn't support them.
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:           #0d0d0f;
    --color-surface:      #161618;
    --color-border:       #2a2a2e;
    --color-text:         #e8e8f0;
    --color-text-muted:   #8b8b9e;
    --color-accent:       #4d9ef7;
    --color-accent-hover: #3d8de6;
    --shadow-card:        0 2px 12px rgba(0, 0, 0, 0.35);
  }

  .nav {
    background: rgba(13, 13, 15, 0.95);
  }

  .hero {
    background: linear-gradient(160deg, #161618 0%, #0d0d0f 60%);
  }

  .chat-panel-header,
  .chat-footer {
    background: var(--color-bg);
  }

  .goldie-status {
    background: var(--color-bg);
  }

  .chat-message--ai {
    background: var(--color-surface);
  }

  .chat-message--error {
    background: #2a1010;
    color: #ff7070;
    border-color: #4a2020;
  }

  .chat-file-chip {
    background: #0d1e35;
    border-color: #1e3d5c;
  }

  .chat-attach:hover {
    background: #0d1e35;
  }

  .project-card:hover {
    box-shadow: 0 4px 20px rgba(77, 158, 247, 0.15);
  }

  .project-tag {
    background: rgba(77, 158, 247, 0.1);
    border-color: rgba(77, 158, 247, 0.25);
  }
}

/* Toggle pulse recoloured for dark — separate query avoids nesting */
@media (prefers-color-scheme: dark) {
  @keyframes toggle-pulse {
    0%   { box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 0    rgba(77, 158, 247, 0.55); }
    7%   { box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 12px rgba(77, 158, 247, 0);    }
    14%  { box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 0    rgba(77, 158, 247, 0.35); }
    21%  { box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 10px rgba(77, 158, 247, 0);    }
    100% { box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 0    rgba(77, 158, 247, 0);    }
  }
}

@media (prefers-color-scheme: dark) and (max-width: 768px) {
  .chat-panel-header {
    background: var(--color-bg);
  }
}

