/* ============================================
   Project Euler Solutions — Premium Design System
   Light Theme Inspired by Project Euler
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Core palette — Project Euler inspired */
  --bg-base: #faf9f7;
  --bg-raised: #f3f1ed;
  --bg-surface: #ece9e3;
  --bg-overlay: #e5e1da;

  /* Glass (light mode) */
  --glass-bg: rgba(107, 78, 61, 0.04);
  --glass-border: rgba(107, 78, 61, 0.10);
  --glass-hover: rgba(107, 78, 61, 0.07);
  --glass-active: rgba(107, 78, 61, 0.12);

  /* Text */
  --text-primary: #2c2017;
  --text-secondary: #6b5b4e;
  --text-muted: #9a8c7f;
  --text-inverse: #ffffff;

  /* Accent — PE Brown + Orange */
  --accent-1: #6b4e3d;
  /* PE brown */
  --accent-2: #8b6914;
  /* Dark gold */
  --accent-3: #ff9933;
  /* PE orange */
  --accent-gradient: linear-gradient(135deg, #6b4e3d 0%, #8b5a2b 50%, #a0522d 100%);
  --accent-gradient-warm: linear-gradient(135deg, #ff9933 0%, #e8851e 100%);
  --accent-glow: 0 0 40px rgba(255, 153, 51, 0.10);

  /* Language colors */
  --color-math: #2e7d32;
  --color-cpp: #c62828;
  --color-python: #1565c0;
  --color-java: #e65100;

  /* Spacing & Radius */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(107, 78, 61, 0.08), 0 1px 2px rgba(107, 78, 61, 0.06);
  --shadow-md: 0 4px 16px rgba(107, 78, 61, 0.10);
  --shadow-lg: 0 12px 48px rgba(107, 78, 61, 0.12);
  --shadow-glow: 0 0 60px rgba(255, 153, 51, 0.06);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 0.15s;
  --t-normal: 0.3s;
  --t-slow: 0.5s;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Layout */
  --max-w: 1240px;
  --header-h: 64px;

  /* Header backdrop (overridden in dark) */
  --header-bg: rgba(250, 249, 247, 0.88);

  /* Syntax highlighting — Light (One Light) */
  --code-text: #383a42;
  --code-comment: #a0a1a7;
  --code-punctuation: #383a42;
  --code-keyword: #a626a4;
  --code-string: #50a14f;
  --code-number: #986801;
  --code-function: #4078f2;
  --code-class: #c18401;
  --code-operator: #0184bc;
  --code-variable: #e45649;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
  --bg-base: #0c1628;
  --bg-raised: #131f36;
  --bg-surface: #1a2944;
  --bg-overlay: #213252;

  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-hover: rgba(255, 255, 255, 0.08);
  --glass-active: rgba(255, 255, 255, 0.14);

  --text-primary: #e8e4df;
  --text-secondary: #a09a92;
  --text-muted: #6b6560;
  --text-inverse: #ffffff;

  --accent-1: #d4a574;
  --accent-2: #c49a4c;
  --accent-3: #ff9933;
  --accent-gradient: linear-gradient(135deg, #d4a574 0%, #c49a4c 50%, #e8a645 100%);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 60px rgba(255, 153, 51, 0.08);

  --header-bg: rgba(12, 22, 40, 0.88);

  /* Dark syntax highlighting (Tomorrow Night) */
  --code-text: #c5c8c6;
  --code-comment: #969896;
  --code-punctuation: #c5c8c6;
  --code-keyword: #cc99cc;
  --code-string: #7ec699;
  --code-number: #f99157;
  --code-function: #6699cc;
  --code-class: #ffcc66;
  --code-operator: #66cccc;
  --code-variable: #f2777a;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent-1);
  text-decoration: none;
  transition: color var(--t-fast);
}

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

::selection {
  background: rgba(255, 153, 51, 0.2);
  color: var(--text-primary);
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-raised);
}

::-webkit-scrollbar-thumb {
  background: var(--glass-active);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 78, 61, 0.25);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--header-bg);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-bottom: 1px solid var(--glass-border);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
}

.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: white;
  box-shadow: 0 2px 12px rgba(107, 78, 61, 0.2);
}

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

.logo-accent {
  color: var(--text-muted);
  font-weight: 500;
}

/* Navigation */
.nav-links {
  display: flex;
  gap: 2px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 3px;
}

.nav-link {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  border: none;
  background: none;
  font-family: var(--font-body);
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link.active {
  color: var(--text-inverse);
  background: var(--accent-3);
  box-shadow: 0 2px 8px rgba(255, 153, 51, 0.25);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  background: var(--glass-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
}

.theme-toggle:hover {
  color: var(--accent-3);
  border-color: rgba(255, 153, 51, 0.25);
  background: var(--glass-hover);
}

.theme-toggle .icon-moon {
  display: none;
}

.theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

/* Language Selector */
.lang-selector {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--t-fast);
}

.lang-btn:hover {
  border-color: rgba(107, 78, 61, 0.2);
  background: var(--glass-hover);
}

.lang-btn .flag {
  font-size: 1.1rem;
  line-height: 1;
}

.lang-btn .lang-label {
  display: none;
}

.lang-btn .chevron {
  opacity: 0.5;
  transition: transform var(--t-fast);
}

@media (min-width: 640px) {
  .lang-btn .lang-label {
    display: inline;
  }
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: all var(--t-normal) var(--ease-out);
  overflow: hidden;
  z-index: 200;
}

.lang-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--t-fast);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.lang-option:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.lang-option.active {
  background: rgba(255, 153, 51, 0.08);
  color: var(--accent-1);
  font-weight: 600;
}

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
}

.mobile-menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all var(--t-fast);
}

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

  .mobile-menu-btn {
    display: flex;
  }

  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg-base);
    border-bottom: 1px solid var(--glass-border);
    border-radius: 0;
    padding: 12px;
    gap: 4px;
    z-index: 99;
    box-shadow: var(--shadow-md);
  }
}

/* ---------- Hero Section ---------- */
.hero {
  position: relative;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 80px 24px 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  animation: float 20s ease-in-out infinite alternate;
}

.hero-orb-1 {
  width: 500px;
  height: 500px;
  background: rgba(255, 153, 51, 0.08);
  top: -200px;
  left: -100px;
  animation-delay: 0s;
}

.hero-orb-2 {
  width: 400px;
  height: 400px;
  background: rgba(107, 78, 61, 0.05);
  bottom: -150px;
  right: -100px;
  animation-delay: -7s;
}

.hero-orb-3 {
  width: 300px;
  height: 300px;
  background: rgba(255, 153, 51, 0.04);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -20px) scale(1.05);
  }

  66% {
    transform: translate(-20px, 15px) scale(0.95);
  }

  100% {
    transform: translate(10px, -10px) scale(1.02);
  }
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  background: rgba(255, 153, 51, 0.08);
  border: 1px solid rgba(255, 153, 51, 0.18);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-1);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

.hero-content h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
  color: var(--accent-1);
}

.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--accent-gradient-warm);
  color: white;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: all var(--t-normal) var(--ease-out);
  box-shadow: 0 4px 20px rgba(255, 153, 51, 0.25);
  font-family: var(--font-body);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(255, 153, 51, 0.35);
  color: white;
}

.btn-primary:active {
  transform: translateY(0);
}

/* Hero Stats */
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 48px;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-1);
  font-variant-numeric: tabular-nums;
}

.hero-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

/* ---------- Banner Section ---------- */
.banner-section {
  max-width: var(--max-w);
  margin: 0 auto 24px;
  padding: 0 24px;
  padding-top: calc(var(--header-h) + 16px);
}

.banner-inner {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: default;
}

.banner-img {
  width: 100%;
  height: 400px;
  display: block;
  object-fit: cover;
  object-position: center 55%;
}

.banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right,
      rgba(0, 0, 0, 0.6) 0%,
      rgba(0, 0, 0, 0.3) 30%,
      rgba(0, 0, 0, 0.05) 60%,
      transparent 100%);
}

.banner-text-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px 36px;
  max-width: 25%;
}

.banner-headline {
  font-size: clamp(0.95rem, 1.6vw, 1.35rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 153, 51, 0.2);
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.banner-subtext {
  font-size: clamp(0.6rem, 0.85vw, 0.75rem);
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
  margin-top: 5px;
  font-weight: 500;
  font-style: italic;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .banner-text-wrap {
    padding: 16px 20px;
    max-width: 50%;
  }
}

/* ---------- Problems Section ---------- */
.problems-section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-1);
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 360px;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: var(--font-body);
  transition: all var(--t-fast);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-3);
  box-shadow: 0 0 0 3px rgba(255, 153, 51, 0.1);
  background: var(--bg-base);
}

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

/* Problem Grid */
.problems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.problem-card {
  padding: 20px;
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.problem-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient-warm);
  opacity: 0;
  transition: opacity var(--t-normal);
}

.problem-card:hover {
  border-color: rgba(255, 153, 51, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(107, 78, 61, 0.08);
}

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

.problem-card>* {
  position: relative;
  z-index: 1;
}

.problem-card .problem-number {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.problem-card .problem-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 14px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.problem-card .problem-langs {
  display: flex;
  gap: 5px;
}

.lang-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.lang-badge.cpp {
  background: rgba(198, 40, 40, 0.08);
  color: var(--color-cpp);
}

.lang-badge.python {
  background: rgba(21, 101, 192, 0.08);
  color: var(--color-python);
}

.lang-badge.java {
  background: rgba(230, 81, 0, 0.08);
  color: var(--color-java);
}

.lang-badge.off {
  opacity: 0.3;
  filter: grayscale(1);
}

/* ---------- Problem Detail ---------- */
.problem-detail {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.problem-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: var(--font-body);
}

.back-btn:hover {
  color: var(--accent-1);
  border-color: rgba(107, 78, 61, 0.2);
  background: var(--glass-hover);
}

.problem-nav-arrows {
  display: flex;
  gap: 6px;
}

.problem-nav-btn {
  width: 36px;
  height: 34px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: var(--font-body);
}

.problem-nav-btn:hover:not(.disabled):not(:disabled) {
  color: var(--accent-1);
  border-color: rgba(107, 78, 61, 0.2);
  background: var(--glass-hover);
}

.problem-nav-btn.disabled,
.problem-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

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

.problem-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  color: var(--accent-1);
}

.problem-header .euler-link {
  font-size: 0.85rem;
  color: var(--accent-3);
  opacity: 0.9;
}

.problem-header .euler-link:hover {
  opacity: 1;
}

/* Code Section */
.code-section {
  margin-bottom: 40px;
}

.code-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
  color: var(--accent-1);
}

.code-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 4px 4px 0;
}

.code-tab {
  padding: 9px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-tab:hover {
  color: var(--text-secondary);
}

.code-tab.active {
  color: var(--text-primary);
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--bg-base);
}

.code-tab .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.code-tab .dot.math {
  background: var(--color-math);
}

.code-tab .dot.cpp {
  background: var(--color-cpp);
}

.code-tab .dot.python {
  background: var(--color-python);
}

.code-tab .dot.java {
  background: var(--color-java);
}

.code-panel {
  position: relative;
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}

.code-panel pre {
  margin: 0;
  padding: 24px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--text-primary);
  tab-size: 4;
  background: var(--bg-raised);
}

.code-panel code {
  font-family: var(--font-mono);
}

/* Math content */
.code-panel .math-content {
  padding: 28px;
}

.math-content h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 28px 0 12px;
  color: var(--accent-1);
}

.math-content h3:first-child {
  margin-top: 0;
}

.math-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 24px 0 10px;
  color: var(--text-primary);
}

.math-content p {
  margin-bottom: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.math-content em {
  color: var(--accent-1);
  font-style: italic;
}

.math-content code {
  padding: 2px 7px;
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--color-math);
}

.math-content ol,
.math-content ul {
  margin: 12px 0;
  padding-left: 24px;
  color: var(--text-secondary);
}

.math-content li {
  margin-bottom: 6px;
}

.math-content sup a {
  color: var(--accent-3);
  font-weight: 600;
}

.math-content blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent-3);
  background: var(--bg-raised);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

/* Copy Button */
.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-secondary);
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--t-fast);
  z-index: 10;
}

.copy-btn:hover {
  color: var(--accent-1);
  border-color: rgba(107, 78, 61, 0.2);
}

.copy-btn.copied {
  color: var(--color-math);
  border-color: rgba(46, 125, 50, 0.3);
}

/* ---------- About Page ---------- */
.about-page {
  max-width: 720px;
  margin: 60px auto;
  padding: 0 24px;
}

.about-card {
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 48px;
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.about-photo {
  width: 160px;
  height: 200px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
}

.about-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about-info {
  flex: 1;
}

.about-name {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  color: var(--accent-1);
}

.about-role {
  font-size: 0.9rem;
  color: var(--accent-3);
  margin-bottom: 16px;
  font-weight: 500;
}

.about-bio {
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 0.95rem;
}

.about-social {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  transition: all var(--t-fast);
  font-size: 1.1rem;
}

.social-link:hover {
  color: var(--accent-1);
  border-color: rgba(107, 78, 61, 0.2);
  background: var(--glass-hover);
}

@media (max-width: 640px) {
  .about-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 24px;
  }

  .about-photo {
    width: 120px;
    height: 150px;
  }

  .about-social {
    justify-content: center;
  }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--glass-border);
  padding: 32px 24px;
  text-align: center;
  background: var(--bg-raised);
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.site-footer p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-attr {
  margin-top: 6px;
}

/* ---------- Page Transitions ---------- */
.page {
  display: none;
}

.page.active {
  display: block;
  animation: pageIn 0.35s var(--ease-out);
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .hero {
    padding: 48px 20px 64px;
  }

  .hero-content h1 {
    font-size: 2rem;
  }

  .hero-stats {
    gap: 20px;
  }

  .problems-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
  }

  .problem-card {
    padding: 16px;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .search-wrapper {
    max-width: 100%;
  }

  .problem-detail {
    padding: 20px 16px 60px;
  }

  .code-tabs {
    padding: 3px 3px 0;
  }

  .code-tab {
    padding: 7px 12px;
    font-size: 0.78rem;
  }
}

@media (max-width: 480px) {
  .problems-grid {
    grid-template-columns: 1fr 1fr;
  }

  .problem-card .problem-title {
    font-size: 0.85rem;
  }

  .hero-badge {
    font-size: 0.7rem;
  }
}

/* ---------- RTL Support ---------- */
html[dir="rtl"] {
  .search-icon {
    left: auto;
    right: 14px;
  }

  .search-input {
    padding: 10px 42px 10px 16px;
  }

  .lang-dropdown {
    right: auto;
    left: 0;
  }

  .math-content {
    direction: rtl;
    text-align: right;
  }

  .math-content blockquote {
    border-left: none;
    border-right: 3px solid var(--accent-3);
  }
}

/* ---------- MathJax Overrides ---------- */
mjx-container {
  overflow-x: auto !important;
  max-width: 100% !important;
}

mjx-math {
  font-size: 105% !important;
}

/* ---------- Prism.js Theme (uses CSS variables for auto light/dark) ---------- */
.code-panel pre[class*="language-"],
.code-panel code[class*="language-"] {
  color: var(--code-text);
  background: var(--bg-raised);
}

.code-panel .token.comment,
.code-panel .token.prolog,
.code-panel .token.doctype,
.code-panel .token.cdata {
  color: var(--code-comment);
}

.code-panel .token.punctuation {
  color: var(--code-punctuation);
}

.code-panel .token.property,
.code-panel .token.tag,
.code-panel .token.boolean,
.code-panel .token.number,
.code-panel .token.constant,
.code-panel .token.symbol {
  color: var(--code-number);
}

.code-panel .token.selector,
.code-panel .token.attr-name,
.code-panel .token.string,
.code-panel .token.char,
.code-panel .token.builtin {
  color: var(--code-string);
}

.code-panel .token.operator,
.code-panel .token.entity,
.code-panel .token.url {
  color: var(--code-operator);
}

.code-panel .token.atrule,
.code-panel .token.attr-value,
.code-panel .token.keyword {
  color: var(--code-keyword);
}

.code-panel .token.function {
  color: var(--code-function);
}

.code-panel .token.class-name {
  color: var(--code-class);
}

.code-panel .token.regex,
.code-panel .token.important,
.code-panel .token.variable {
  color: var(--code-variable);
}