:root {
  --bg: #F6F5F0;
  --card: #FFFFFF;
  --text: #1C1917;
  --text2: #57534E;
  --text3: #A8A29E;
  --border: #E7E5E0;
  --accent1: #DC4A1A;
  --accent2: #1B6EC2;
  --accent3: #16803C;
  --accent4: #7C3AED;
  --code-bg: #1E293B;
  --code-text: #E2E8F0;
  --highlight: #FEF3C7;
  --info-bg: #EFF6FF;
  --info-border: #BFDBFE;
  --warn-bg: #FFFBEB;
  --warn-border: #FDE68A;
  --success-bg: #F0FDF4;
  --success-border: #BBF7D0;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Nunito Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: 'Source Serif 4', serif; line-height: 1.3; }
.container { max-width: 880px; margin: 0 auto; padding: 0 20px; }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
.fade-up { animation: fadeUp 0.4s ease both; }
.slide-in { animation: slideIn 0.35s ease both; }

/* Header */
.site-header {
  background: linear-gradient(160deg, #0F172A 0%, #1E293B 60%, #334155 100%);
  color: white;
  padding: 40px 0 36px;
  position: relative;
  overflow: hidden;
}
.site-header::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 85%, rgba(220,74,26,0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(27,110,194,0.12) 0%, transparent 40%);
}
.header-grid {
  position: absolute; inset: 0; opacity: 0.04;
  background-image:
    linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px);
  background-size: 48px 48px;
}
.header-content { position: relative; z-index: 1; }
.header-tag {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 2.5px; text-transform: uppercase;
  color: #60A5FA; margin-bottom: 10px;
}
.header-title { font-size: clamp(30px, 6vw, 50px); font-weight: 700; margin-bottom: 6px; }
.header-sub { font-size: 16px; opacity: 0.7; font-weight: 400; }
.header-prof { font-size: 14px; opacity: 0.5; margin-top: 4px; }

/* Navigation breadcrumb */
.breadcrumb {
  padding: 16px 0 0;
  display: flex; gap: 8px; align-items: center; font-size: 13px;
}
.breadcrumb a {
  color: var(--accent2); text-decoration: none; font-weight: 600; cursor: pointer;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--text3); }

/* Unit cards */
.units-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px; margin-top: 8px;
}
.unit-card {
  background: var(--card); border: 2px solid var(--border); border-radius: 16px;
  padding: 28px; cursor: pointer; transition: all 0.25s ease;
  position: relative; overflow: hidden; text-align: left; font-family: inherit;
  color: var(--text);
}
.unit-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.08); }
.unit-card-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.unit-card-icon { font-size: 38px; margin-bottom: 14px; }
.unit-card-tag { font-size: 11px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; }
.unit-card-title { font-family: 'Source Serif 4', serif; font-size: 21px; font-weight: 700; }
.unit-card-count { font-size: 12px; color: var(--text3); margin-top: 8px; }

/* Topic list */
.topic-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 24px; cursor: pointer; display: flex; align-items: center; gap: 16px;
  transition: all 0.2s ease; font-family: inherit; text-align: left; color: var(--text); width: 100%;
}
.topic-item:hover { border-color: var(--accent2); transform: translateX(4px); }
.topic-num {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; flex-shrink: 0;
}
.topic-title { font-weight: 700; font-size: 16px; }
.topic-meta { font-size: 12px; color: var(--text3); margin-top: 3px; }

/* Content article styles */
.article { background: var(--card); border-radius: 16px; padding: 32px; border: 1px solid var(--border); margin-bottom: 20px; }
.article h3 { font-size: 22px; margin-bottom: 16px; color: var(--text); }
.article h4 { font-size: 17px; margin: 24px 0 10px; color: var(--text); font-weight: 700; }
.article p { margin-bottom: 14px; color: var(--text2); font-size: 15px; }
.article strong { color: var(--text); font-weight: 700; }
.article ul, .article ol { margin: 10px 0 16px 20px; color: var(--text2); font-size: 15px; }
.article li { margin-bottom: 6px; }
.article img { max-width: 100%; height: auto; border-radius: 8px; }

/* Info boxes */
.info-box {
  border-radius: 12px; padding: 18px 20px; margin: 18px 0;
  font-size: 14px; border-left: 4px solid;
}
.info-box.blue { background: var(--info-bg); border-color: #3B82F6; }
.info-box.yellow { background: var(--warn-bg); border-color: #F59E0B; }
.info-box.green { background: var(--success-bg); border-color: #22C55E; }
.info-box.red { background: #FEF2F2; border-color: #EF4444; }
.info-box-title { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }

/* Code blocks */
.code-block {
  background: var(--code-bg); color: var(--code-text); border-radius: 10px;
  padding: 18px 20px; margin: 14px 0; font-family: 'Courier New', monospace;
  font-size: 13px; line-height: 1.7; overflow-x: auto; white-space: pre;
}
.code-inline {
  background: #F1F0EB; padding: 2px 7px; border-radius: 4px;
  font-family: 'Courier New', monospace; font-size: 13px; color: #B91C1C;
}

/* Data tables */
.data-table {
  width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px;
}
.data-table th {
  background: #F1F0EB; padding: 10px 14px; text-align: left;
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text2);
}
.data-table tr:hover td { background: #FAFAF8; }

/* SVG diagrams */
.diagram-container {
  margin: 20px 0; text-align: center; overflow-x: auto;
}
.diagram-container svg { max-width: 100%; height: auto; }
.diagram-caption {
  font-size: 12px; color: var(--text3); margin-top: 8px; font-style: italic;
}

/* Exercises */
.exercises-toggle {
  width: 100%; padding: 16px 24px; border-radius: 14px; cursor: pointer;
  font-size: 16px; font-weight: 700; transition: all 0.2s; font-family: inherit;
  margin-bottom: 16px;
}
.exercise-item {
  display: flex; gap: 14px; padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.exercise-item:last-child { border-bottom: none; }
.exercise-num {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
}

/* Footer */
.site-footer {
  text-align: center; padding: 40px 20px; font-size: 13px; color: var(--text3);
  border-top: 1px solid var(--border); margin-top: 48px;
}

/* Loading state */
.loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; font-size: 18px; color: var(--text3);
}

/* Topic navigation buttons */
.topic-nav-btn {
  border-radius: 10px; padding: 12px 20px; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 13px;
  transition: all 0.2s;
}
.topic-nav-btn.prev {
  background: white; border: 1px solid #ddd; color: var(--text);
}
.topic-nav-btn.next {
  background: var(--accent2); border: none; color: white;
}
.topic-nav-btn:hover { transform: translateX(2px); }

/* Responsive */
@media (max-width: 600px) {
  .article { padding: 20px; }
  .units-grid { grid-template-columns: 1fr; }
}

/* Print styles */
@media print {
  .site-header { background: white !important; color: black !important; }
  .breadcrumb, .exercises-toggle, .topic-nav-btn { display: none !important; }
  .article { break-inside: avoid; }
}
