/* ====== Reset & base ====== */
* { 
  box-sizing: border-box; 
  max-width: 100%;
}
html, body { 
  margin: 0; 
  padding: 0; 
  overflow-x: hidden;
  width: 100%;
}
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Performance optimizations */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  --bg: #0b1020;           /* základ pozadí (tmavé) */
  --bg-elev: #111830;      /* zvýrazněné pozadí */
  --text: #e7ecff;         /* základ textu */
  --muted: #a8b3cf;        /* sekundární text */
  --primary: #6366f1;      /* indigo */
  --primary-600: #5458e9;
  --accent: #10b981;       /* emerald */
  --warn: #f59e0b;         /* amber */
  --chip: #1d2547;
  --border: #243053;

  /* světlejší téma přepneme přes class na <html> */
  --l-bg: #f7f9ff;
  --l-bg-elev: #ffffff;
  --l-text: #0b1020;
  --l-muted: #435279;
  --l-border: #e3e9ff;

  --radius: 12px;
  --shadow: 0 10px 30px rgba(3, 10, 40, .2);
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

html { font-family: var(--font); }
body {
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.12), transparent 70%) ,
              linear-gradient(180deg, #070b18 0%, var(--bg) 100%);
  line-height: 1.6;
}

/* světlé téma */
html.light body {
  color: var(--l-text);
  background: linear-gradient(180deg, var(--l-bg) 0%, #eef3ff 100%);
}

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

/* ====== Layout ====== */
.container {
  width: min(1100px, 100%);
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left)), max(16px, env(safe-area-inset-right));
  box-sizing: border-box;
}

.section {
  padding: 72px 0;
}
.section.alt {
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.02) 30%, transparent);
}
html.light .section.alt {
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.03) 30%, transparent);
}

.row {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.grid {
  display: grid; gap: 20px;
  width: 100%;
}

/* ====== Header ====== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  background: rgba(7,11,24,.55);
  border-bottom: 1px solid var(--border);
  transform: translateY(0);
  transition: transform 0.3s ease-in-out;
}

.site-header.header-hidden {
  transform: translateY(-100%);
}

html.light .site-header {
  background: rgba(255,255,255,.7);
  border-bottom: 1px solid var(--l-border);
}
.header-inner { height: 64px; justify-content: space-between; }
.brand { 
  font-weight: 800; 
  letter-spacing: .5px; 
  font-size: 20px; 
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.3s ease;
}
.brand:hover { text-decoration: none; transform: scale(1.05); }

/* Stylování loga - závorky a text */
.brand-brackets {
  color: #4A90E2; /* Modrá jako na logu */
  font-weight: 900;
  font-size: 22px;
}
.brand-text {
  background: linear-gradient(135deg, #FF6B35 0%, #4A90E2 50%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* Ve světlém režimu */
html.light .brand-brackets {
  color: #2E5BBA; /* Tmavší modrá */
}
html.light .brand-text {
  background: linear-gradient(135deg, #E55A2B 0%, #2E5BBA 50%, #4F46E5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-dot { color: var(--accent); }
.header-controls { display: flex; gap: 8px; align-items: center; }
.nav { display: flex; gap: 32px; }
.nav a { color: var(--muted); font-weight: 500; transition: color 0.2s ease; }
.nav a:hover { color: var(--text); }
html.light .nav a { color: var(--l-muted); }
html.light .nav a:hover { color: var(--l-text); }

/* Mobile navigation */
.mobile-toggle { 
  display: none; 
  font-size: 18px; 
}

/* Mobilní menu CSS je na konci souboru s !important */

/* ====== Hero ====== */
.hero { position: relative; }
.hero-content { 
  display: grid; 
  grid-template-columns: 1fr auto; 
  gap: 48px; 
  align-items: center; 
}
.hero-text { max-width: none; }
.hero-title {
  font-size: clamp(24px, 4.6vw, 44px);
  line-height: 1.1;
  margin: 0 0 14px 0;
}
.hero-subtitle {
  margin: 0 0 18px 0;
  color: var(--muted);
  max-width: 60ch;
}
.hero .actions { gap: 10px; flex-wrap: wrap; }
.profile-photo {
  width: 200px; height: 200px;
  border-radius: 50%; object-fit: cover;
  border: 4px solid var(--accent);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}
.profile-photo:hover { transform: scale(1.02); }

@media (max-width: 768px) {
  .hero-content { 
    grid-template-columns: 1fr; 
    text-align: center; 
    gap: 24px; 
  }
  .profile-photo { width: 150px; height: 150px; }
}

.hero-gradient {
  position: absolute; inset: -60px 0 auto 0; height: 220px;
  background: radial-gradient(600px 120px at 30% 0%,
    rgba(16,185,129,.35), transparent 70%),
    radial-gradient(600px 120px at 70% 0%,
    rgba(99,102,241,.35), transparent 70%);
  pointer-events: none;
}

/* ====== Buttons, chips, cards ====== */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  padding: 10px 14px; border-radius: 10px;
  box-shadow: var(--shadow); display: inline-flex; align-items: center;
  gap: 8px; font-weight: 600;
}
.btn:hover { transform: translateY(-1px); transition: .15s ease; }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  border: none; color: white;
}
.btn.outline {
  background: transparent;
}
.btn.ghost {
  background: transparent; border-color: transparent; box-shadow: none;
}
.btn.link {
  background: transparent; border: none; box-shadow: none; padding: 8px;
  color: var(--accent); font-weight: 700;
}

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--chip); color: #cfe3ff;
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border);
  font-weight: 600; cursor: pointer; user-select: none;
}
.chip:hover { filter: brightness(1.1); }
.chip.active { outline: 2px solid var(--accent); }

.card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elev), rgba(255,255,255,.01));
  border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  transition: transform 0.2s ease;
  will-change: transform;
}
.card:hover {
  transform: translateY(-2px);
}

html.light .btn { border-color: var(--l-border); background: var(--l-bg-elev); color: var(--l-text); }
html.light .btn.outline { background: transparent; }
html.light .chip { background: #eff3ff; color: #213a6b; border-color: var(--l-border); }
html.light .card { background: var(--l-bg-elev); border-color: var(--l-border); }

/* ====== Sections ====== */
.section-head { justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.section-head h2 { margin: 0; }

/* O mně */
.about-content {
  display: grid; gap: 24px;
}
.about-content .card h3 {
  margin: 0 0 12px 0; font-size: 18px;
  display: flex; align-items: center; gap: 8px;
}
.about-content .card p {
  margin: 0 0 14px 0; color: var(--muted);
}
.about-content .card p:last-child { margin-bottom: 0; }
.feature-list {
  margin: 12px 0 0 0; padding: 0; list-style: none;
  display: grid; gap: 6px;
}
.feature-list li {
  color: var(--muted); font-weight: 500;
}
html.light .about-content .card p { color: var(--l-muted); }
html.light .feature-list li { color: var(--l-muted); }

/* Articles */
.articles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 20px;
}
.article {
  display: flex; flex-direction: column; gap: 12px;
}
.article h3 { 
  margin: 0; font-size: 18px; 
  color: var(--text);
}
html.light .article h3 { color: var(--l-text); }
.article .article-meta {
  display: flex; gap: 12px; align-items: center;
  font-size: 14px; color: var(--muted);
  margin: 0 0 8px 0;
}
html.light .article .article-meta { color: var(--l-muted); }
.article .article-excerpt { 
  margin: 0; color: var(--muted); 
  line-height: 1.5;
}
html.light .article .article-excerpt { color: var(--l-muted); }
.article .article-link {
  color: var(--accent); font-weight: 600;
  margin-top: auto; padding-top: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
  padding-left: 0;
}
.article .article-link:hover {
  text-decoration: underline;
}

/* Timeline */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: ''; position: absolute; left: 12px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
html.light .timeline::before { background: var(--l-border); }
.timeline-item {
  position: relative; margin-bottom: 32px;
  opacity: 0; transform: translateX(30px);
  transition: all 0.5s ease;
}
.timeline-item.animate { opacity: 1; transform: translateX(0); }
.timeline-dot {
  position: absolute; left: -38px; top: 8px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
}
html.light .timeline-dot { border-color: var(--l-bg); }
.timeline-content h3 {
  margin: 0 0 4px 0; color: var(--accent); font-size: 16px;
}
.timeline-content h4 {
  margin: 0 0 8px 0; font-size: 18px;
}
.timeline-content p {
  margin: 0; color: var(--muted);
}
html.light .timeline-content p { color: var(--l-muted); }

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 20px;
}
.project {
  display: flex; flex-direction: column; gap: 12px;
}
.project h3 { margin: 0; font-size: 18px; }
.project p { margin: 0; color: var(--muted); }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }

.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 20px;
}
.skill { display: grid; gap: 8px; }
.bar {
  height: 10px; border-radius: 999px; overflow: hidden; background: #101935; border: 1px solid var(--border);
}
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); }

.tips-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.tips-list li { padding: 14px; border-left: 4px solid var(--accent); background: rgba(16,185,129,.07); border-radius: 8px; }
html.light .tips-list li { background: #eafff6; }

/* ====== Contact ====== */
.contact-list { margin: 8px 0 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.contact.card { max-width: 640px; }

/* ====== Footer ====== */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); }
html.light .site-footer { border-top-color: var(--l-border); color: var(--l-muted); }
.site-footer .muted { color: inherit; }

/* ====== Responsive ====== */
@media (max-width: 720px) {
  /* Desktop navigation je skrytá, mobilní menu funguje přes .mobile-toggle */
  
  /* Hero sekce */
  .hero-content {
    flex-direction: column;
    text-align: center;
    gap: 32px;
  }
  .hero-text {
    order: 2;
  }
  .hero-photo {
    order: 1;
  }
  .hero-title {
    font-size: 24px;
    line-height: 1.3;
  }
  .actions {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .actions .btn {
    width: 100%;
    max-width: 280px;
  }
  
  /* Timeline */
  .timeline {
    padding-left: 0;
    position: relative;
  }
  .timeline::before {
    left: 20px;
  }
  .timeline-item {
    margin-left: 0;
    padding-left: 50px;
    margin-bottom: 32px;
  }
  .timeline-dot {
    left: 15px;
    width: 10px;
    height: 10px;
  }
  .timeline-content {
    margin-left: 0;
  }
  
  /* Grid layouts */
  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .projects {
    grid-template-columns: 1fr;
  }
  .skills {
    grid-template-columns: 1fr;
  }
  .tools-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
    gap: 12px;
  }
  
  /* Sections */
  .section {
    padding: 48px 0;
  }
  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }
  
  /* Filters */
  .filters {
    flex-wrap: wrap;
    gap: 8px;
  }
  .chip {
    font-size: 14px;
    padding: 6px 12px;
  }
  
  /* Contact */
  .contact-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  /* About cards */
  .about-content .card {
    padding: 20px;
  }
  
  /* Typography */
  h1 {
    font-size: 28px;
  }
  h2 {
    font-size: 24px;
  }
  
  /* Container */
  .container {
    width: 100%;
    padding-inline: 16px;
    margin-inline: auto;
  }
  
  /* Contact form specific mobile fixes */
  .contact-form {
    padding: 20px 16px;
    margin: 0 -8px;
  }
  
  .form-group input,
  .form-group textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px 16px;
  }
  
  .form-group textarea {
    min-height: 100px;
  }
  
  .contact-form .btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
  }
  
  /* Loading screen mobile */
  .loading-screen .logo-container {
    padding: 20px;
  }
  
  .loading-screen .logo-text {
    font-size: 28px;
  }
  
  /* Theme toggle */
  .theme-toggle {
    right: 20px;
    top: 20px;
  }
}

/* Extra small devices - malé telefony */
@media (max-width: 480px) {
  .hero-title {
    font-size: 20px;
  }
  
  .hero-subtitle {
    font-size: 14px;
  }
  
  .tools-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .timeline-item {
    padding-left: 40px;
  }
  
  .timeline::before {
    left: 15px;
  }
  
  .timeline-dot {
    left: 10px;
  }
  
  .section {
    padding: 32px 0;
  }
  
  .contact-form {
    padding: 16px 12px;
  }
  
  .container {
    width: 100%;
    padding-inline: 12px;
  }
  
  /* Lepší touch targets */
  .chip {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }
  
  .btn {
    min-height: 48px;
    touch-action: manipulation;
  }
}

/* ====== Loading Screen ====== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}
html.light .loading-screen {
  background: var(--l-bg);
}

.loading-content {
  text-align: center;
  max-width: 300px;
}

.loading-logo {
  margin-bottom: 32px;
  font-size: 32px;
  font-weight: 800;
}
.loading-brackets {
  color: #4A90E2;
  margin-right: 8px;
}
.loading-text {
  background: linear-gradient(135deg, #FF6B35 0%, #4A90E2 50%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loading-bar {
  width: 200px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 auto 16px;
}
.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  border-radius: 999px;
  width: 0%;
  animation: loading 2s ease-in-out;
}
@keyframes loading {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

.loading-message {
  color: var(--muted);
  margin: 0;
}

/* ====== Tools Grid ====== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 16px;
  width: 100%;
}
.tool-card {
  padding: 20px;
  text-align: center;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  position: relative;
}
.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
html.light .tool-card {
  background: var(--l-bg-elev);
  border-color: var(--l-border);
}

.tool-link-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 12px;
  opacity: 0.6;
}

.tool-icon {
  font-size: 32px;
  margin-bottom: 12px;
}
.tool-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}
.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
html.light .tool-card p {
  color: var(--l-muted);
}

/* ====== Contact Form ====== */
.contact-content {
  display: grid;
  gap: 40px;
  grid-template-columns: 1fr 1fr;
  align-items: start;
}
@media (max-width: 720px) {
  .contact-content {
    grid-template-columns: 1fr;
  }
}

.contact-info h3 {
  color: var(--accent);
  margin: 0 0 16px 0;
}
.contact-info p {
  color: var(--muted);
  margin-bottom: 24px;
}
html.light .contact-info p {
  color: var(--l-muted);
}

.contact-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.contact-link {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--chip);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}
.contact-link:hover {
  background: var(--primary);
  text-decoration: none;
  transform: translateY(-2px);
}
html.light .contact-link {
  background: var(--l-border);
  color: var(--l-text);
}

.contact-form {
  max-width: none;
}
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}
html.light .form-group label {
  color: var(--l-text);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s ease;
}
html.light .form-group input,
html.light .form-group textarea {
  background: var(--l-bg-elev);
  border-color: var(--l-border);
  color: var(--l-text);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.contact-form .btn {
  width: 100%;
  position: relative;
}
.btn-loading {
  display: none;
}
.contact-form.loading .btn-text {
  display: none;
}
.contact-form.loading .btn-loading {
  display: inline;
}

/* ====== Konfetíčka ====== */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--accent);
  animation: confetti-fall 3s linear infinite;
  z-index: 1000;
}

.confetti:nth-child(2n) { background: var(--primary); }
.confetti:nth-child(3n) { background: var(--warn); }
.confetti:nth-child(4n) { background: #ff6b9d; }
.confetti:nth-child(5n) { background: #4ecdc4; }

.confetti.square { border-radius: 0; }
.confetti.circle { border-radius: 50%; }
.confetti.triangle {
  background: transparent;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid var(--accent);
  width: 0;
  height: 0;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ====== Mobile Navigation - FINAL OVERRIDE ====== */
@media (max-width: 768px) {
  /* Reset header layout */
  .site-header .header-inner {
    height: 64px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative !important;
  }

  .site-header .header-controls {
    position: relative !important;
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex-wrap: nowrap !important;
    margin-left: auto !important;
  }

  .site-header #themeToggle {
    order: 1 !important;
    position: relative !important;
    display: flex !important;
    padding: 10px !important;
    font-size: 16px !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 6px !important;
    background: var(--bg-elev) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    flex-shrink: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 1002 !important;
    box-shadow: none !important;
    transform: none !important;
  }

  .site-header .mobile-toggle { 
    order: 2 !important;
    position: relative !important;
    display: flex !important;
    transform: none !important;
    z-index: 1001 !important;
    background: var(--bg-elev) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    cursor: pointer !important;
    padding: 10px !important;
    border-radius: 6px !important;
    font-size: 18px !important;
    width: 44px !important;
    height: 44px !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s ease !important;
    flex-shrink: 0 !important;
    box-shadow: none !important;
  }

  /* Override .btn.ghost specifically on mobile */
  .site-header #themeToggle.btn.ghost {
    background: var(--bg-elev) !important;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
  }

  .site-header .mobile-toggle.btn.ghost {
    background: var(--bg-elev) !important;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
  }

  .site-header .mobile-toggle:hover {
    background-color: var(--bg-secondary) !important;
  }

  html.light .site-header .mobile-toggle {
    background: var(--l-bg-elev) !important;
    border-color: var(--l-border) !important;
    color: var(--l-text) !important;
  }

  html.light .site-header #themeToggle {
    background: var(--l-bg-elev) !important;
    border-color: var(--l-border) !important;
    color: var(--l-text) !important;
  }

  html.light .site-header .mobile-toggle:hover {
    background-color: var(--l-bg-secondary) !important;
  }

  html.light .site-header #themeToggle:hover {
    background-color: var(--l-bg-secondary) !important;
  }

  /* Light mode override for .btn.ghost */
  html.light .site-header #themeToggle.btn.ghost {
    background: var(--l-bg-elev) !important;
    border: 1px solid var(--l-border) !important;
    color: var(--l-text) !important;
  }

  html.light .site-header .mobile-toggle.btn.ghost {
    background: var(--l-bg-elev) !important;
    border: 1px solid var(--l-border) !important;
    color: var(--l-text) !important;
  }
  
  .nav {
    position: fixed !important; 
    top: 72px !important; 
    right: 8px !important; 
    width: min(180px, 45vw) !important;
    background: var(--bg-elev) !important; 
    border: 1px solid var(--border) !important;
    border-radius: 6px 0 0 6px !important;
    flex-direction: column !important; 
    gap: 0 !important; 
    padding: 8px 0 !important;
    transform: translateX(100%) !important; 
    transition: transform 0.3s ease !important; 
    pointer-events: none !important;
    z-index: 1000 !important;
    box-shadow: var(--shadow) !important;
    display: flex !important;
  }
  
  html.light .nav { 
    background: var(--l-bg-elev) !important; 
    border-color: var(--l-border) !important; 
  }
  
  .nav.active { 
    transform: translateX(0) !important; 
    pointer-events: all !important; 
  }
  
  .nav a { 
    padding: 10px 16px !important; 
    display: block !important;
    border-bottom: 1px solid transparent !important;
    transition: all 0.2s ease !important;
    text-align: left !important;
    font-size: 13px !important;
    white-space: nowrap !important;
    font-weight: 500 !important;
  }
  
  .nav a:hover {
    background-color: var(--bg-secondary) !important;
    border-bottom-color: var(--border) !important;
  }
  
  html.light .nav a:hover {
    background-color: var(--l-bg-secondary) !important;
  }
}

/* ====== Reduced motion ====== */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ====== Horizontal scroll prevention ====== */
img, svg, video, canvas, audio, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

pre, code {
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

table {
  width: 100%;
  table-layout: fixed;
  overflow-x: auto;
}

/* Ensure all text content wraps properly */
p, h1, h2, h3, h4, h5, h6, span, div {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ====== Article Modal ====== */
.article-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(5px);
}

.article-modal.active {
  opacity: 1;
}

.article-modal-content {
  background: var(--bg-elev);
  border-radius: 12px;
  max-width: 900px;
  max-height: 90vh;
  width: 95%;
  position: relative;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.article-modal.active .article-modal-content {
  transform: translateY(0);
}

.article-modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  font-size: 30px;
  cursor: pointer;
  color: var(--muted);
  z-index: 1001;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.article-modal-close:hover {
  background-color: var(--bg-elev);
  color: var(--text);
}

.article-modal-body {
  padding: 40px;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
  line-height: 1.7;
}

.article-modal .article-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article-modal .article-header h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.article-modal .article-content h2 {
  margin: 2rem 0 1rem;
  font-size: 1.5rem;
  color: var(--text);
}

.article-modal .article-content h3 {
  margin: 1.5rem 0 0.8rem;
  font-size: 1.2rem;
  color: var(--text);
}

.article-modal .article-content p {
  margin-bottom: 1.2rem;
  color: var(--text);
}

.article-modal .article-content blockquote {
  margin: 1.5rem 0;
  padding: 1.2rem;
  background: var(--bg);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  font-style: italic;
  color: var(--muted);
}

.article-modal .article-content pre {
  background: var(--bg);
  padding: 1.2rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow-x: auto;
  margin: 1.2rem 0;
  font-size: 0.9rem;
}

.article-modal .article-content code {
  background: var(--bg);
  color: var(--text);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
}

.article-modal .article-content pre code {
  background: none;
  padding: 0;
}

.article-modal .article-content ul,
.article-modal .article-content ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.article-modal .article-content li {
  margin-bottom: 0.5rem;
}

.article-modal .tag {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  margin-right: 0.5rem;
  display: inline-block;
  margin-bottom: 0.3rem;
}

/* Mobile responsiveness pro modal */
@media (max-width: 768px) {
  .article-modal-content {
    width: 98%;
    max-height: 95vh;
    margin: 10px;
  }
  
  .article-modal-body {
    padding: 20px;
  }
  
  .article-modal .article-header h1 {
    font-size: 1.6rem;
  }
  
  .article-modal .article-content h2 {
    font-size: 1.3rem;
  }
}

/* ====== Light Mode for Article Modal ====== */
html.light .article-modal-content {
  background: var(--l-bg-elev) !important;
  color: var(--l-text);
}

html.light .article-modal .article-header {
  border-bottom-color: var(--l-border) !important;
}

html.light .article-modal .article-header h1,
html.light .article-modal .article-content h2,
html.light .article-modal .article-content h3 {
  color: var(--l-text) !important;
}

html.light .article-modal .article-content p,
html.light .article-modal .article-content li {
  color: var(--l-text) !important;
}

html.light .article-modal .article-content blockquote {
  background: var(--l-bg) !important;
  border-left-color: var(--l-border) !important;
  color: var(--l-muted) !important;
}

html.light .article-modal .article-content pre {
  background: var(--l-bg) !important;
  border: 1px solid var(--l-border) !important;
  color: var(--l-text) !important;
}

html.light .article-modal .article-content code {
  background: var(--l-bg) !important;
  color: var(--l-text) !important;
}

html.light .article-modal-close {
  color: var(--l-muted) !important;
}

html.light .article-modal-close:hover {
  background-color: var(--l-bg) !important;
  color: var(--l-text) !important;
}

/* ====== Scroll to Top Button ====== */
.scroll-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

@media (max-width: 768px) {
  .scroll-to-top {
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    font-size: 18px;
    z-index: 999;
  }
}

html.light .article-modal .tag {
  background: var(--l-bg) !important;
  color: var(--l-text) !important;
  border: 1px solid var(--l-border) !important;
}
