:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Dark Theme (Default) */
  --bg-body: #05070d;
  --bg-card: rgba(13, 17, 28, 0.7);
  --bg-card-hover: rgba(22, 28, 45, 0.85);
  --bg-chip: rgba(255, 255, 255, 0.05);
  --bg-chip-hover: rgba(255, 255, 255, 0.1);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(56, 189, 248, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #0284c7;
  --accent-cyan: #06b6d4;
  --accent-glow: rgba(14, 165, 233, 0.25);

  --badge-live-bg: rgba(16, 185, 129, 0.15);
  --badge-live-text: #34d399;
  --badge-live-border: rgba(16, 185, 129, 0.3);

  --badge-lib-bg: rgba(56, 189, 248, 0.15);
  --badge-lib-text: #38bdf8;
  --badge-lib-border: rgba(56, 189, 248, 0.3);

  --badge-cv-bg: rgba(168, 85, 247, 0.15);
  --badge-cv-text: #c084fc;
  --badge-cv-border: rgba(168, 85, 247, 0.3);

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

html.light {
  --bg-body: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #ffffff;
  --bg-chip: #f1f5f9;
  --bg-chip-hover: #e2e8f0;
  --border-color: #e2e8f0;
  --border-hover: #0284c7;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent-blue: #0284c7;
  --accent-cyan: #0891b2;
  --accent-glow: rgba(14, 165, 233, 0.15);

  --badge-live-bg: rgba(16, 185, 129, 0.12);
  --badge-live-text: #059669;
  --badge-live-border: rgba(16, 185, 129, 0.25);

  --badge-lib-bg: rgba(2, 132, 199, 0.12);
  --badge-lib-text: #0284c7;
  --badge-lib-border: rgba(2, 132, 199, 0.25);

  --badge-cv-bg: rgba(147, 51, 234, 0.12);
  --badge-cv-text: #7e22ce;
  --badge-cv-border: rgba(147, 51, 234, 0.25);

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Subtle engineering grid background */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background-image: 
    linear-gradient(var(--border-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: -1px -1px;
  opacity: 0.35;
  z-index: -1;
  mask-image: radial-gradient(ellipse at 50% 20%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 20%, black 30%, transparent 80%);
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* Top Navigation Bar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 40px;
  box-shadow: var(--shadow-card);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: #34d399;
  box-shadow: 0 0 10px #34d399;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--bg-chip);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.nav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-chip-hover);
  border-color: var(--border-hover);
}

.nav-btn.btn-vilghelm {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.25);
}

.nav-btn.btn-vilghelm:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-chip);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background: var(--bg-chip-hover);
  border-color: var(--border-hover);
  transform: scale(1.05);
}

html.light .icon-moon { display: block; }
html.light .icon-sun { display: none; }
html:not(.light) .icon-moon { display: none; }
html:not(.light) .icon-sun { display: block; }

/* Hero Section */
.hero {
  text-align: center;
  margin-bottom: 56px;
  padding: 20px 0;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--badge-lib-bg);
  color: var(--badge-lib-text);
  border: 1px solid var(--badge-lib-border);
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
  line-height: 1.15;
}

.hero-highlight {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 50%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: clamp(16px, 2.5vw, 19px);
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto 32px;
}

/* Author Quick Info Bar */
.author-bar {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 8px 20px 8px 10px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
}

.author-bar img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border-hover);
}

.author-text {
  text-align: left;
  font-size: 13px;
}

.author-name {
  font-weight: 700;
  color: var(--text-primary);
}

.author-role {
  color: var(--text-muted);
}

.author-link {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.author-link:hover {
  text-decoration: underline;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 56px;
}

.project-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.project-card.calc::before { background: linear-gradient(90deg, #10b981, #06b6d4); }
.project-card.grid::before { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.project-card.cv::before { background: linear-gradient(90deg, #8b5cf6, #ec4899); }

.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.project-card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-chip);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.badge {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.badge-live {
  background: var(--badge-live-bg);
  color: var(--badge-live-text);
  border: 1px solid var(--badge-live-border);
}

.badge-lib {
  background: var(--badge-lib-bg);
  color: var(--badge-lib-text);
  border: 1px solid var(--badge-lib-border);
}

.badge-cv {
  background: var(--badge-cv-bg);
  color: var(--badge-cv-text);
  border: 1px solid var(--badge-cv-border);
}

.project-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-domain {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #38bdf8;
  margin-bottom: 14px;
  display: inline-block;
}

.project-desc {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 22px;
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tech-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-chip);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.project-card:hover .card-action {
  color: #38bdf8;
}

/* About Creator Banner / Bridge Section */
.author-bridge-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 56px;
  box-shadow: var(--shadow-card);
}

.bridge-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.bridge-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border-hover);
  flex-shrink: 0;
}

.bridge-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.bridge-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 580px;
}

.btn-primary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: none;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary-action:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.45);
  transform: translateY(-2px);
}

/* Footer */
footer {
  text-align: center;
  padding-top: 32px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 13.5px;
}

footer a {
  color: var(--text-secondary);
  text-decoration: underline;
  transition: color 0.2s;
}

footer a:hover {
  color: #38bdf8;
}

@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }
  .nav-actions {
    justify-content: space-between;
  }
  .author-bridge-card {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .bridge-content {
    flex-direction: column;
    align-items: flex-start;
  }
}
