/* ═══════════════════════════════════════════════════════════════
   BI-IDO Státnicové poznámky – Mobile-First CSS
   ═══════════════════════════════════════════════════════════════ */

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

/* ── CSS Custom Properties ── */
:root {
  /* Colors – Light Theme */
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f3f9;
  --bg-code: #f0f2f8;
  --bg-highlight: rgba(99, 102, 241, 0.06);
  
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-heading: #0f172a;
  
  --accent-1: #4f46e5;     /* Indigo */
  --accent-2: #7c3aed;     /* Violet */
  --accent-3: #0891b2;     /* Cyan */
  --accent-4: #059669;     /* Emerald */
  --accent-5: #d97706;     /* Amber */
  --accent-6: #dc2626;     /* Red */
  --accent-7: #db2777;     /* Pink */
  
  --gradient-1: linear-gradient(135deg, #4f46e5, #7c3aed);
  --gradient-2: linear-gradient(135deg, #0891b2, #059669);
  --gradient-3: linear-gradient(135deg, #d97706, #dc2626);
  
  --border-color: #e2e8f0;
  --border-accent: rgba(79, 70, 229, 0.25);
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.1);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

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

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

/* ── Background Pattern ── */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(79, 70, 229, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(124, 58, 237, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(8, 145, 178, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* ── Header ── */
.hero {
  background: var(--gradient-1);
  padding: 2rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 1px, transparent 1px);
  background-size: 30px 30px;
  animation: heroPattern 20s linear infinite;
}

@keyframes heroPattern {
  0% { transform: translate(0, 0); }
  100% { transform: translate(30px, 30px); }
}

.hero h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  position: relative;
  z-index: 1;
  letter-spacing: -0.02em;
}

.hero .subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,0.85);
  margin-top: 0.5rem;
  position: relative;
  z-index: 1;
  font-weight: 300;
}

.hero .badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  position: relative;
  z-index: 1;
}

.hero .badge {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 0.35rem 0.85rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ── Navigation / TOC ── */
.toc-bar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
}

.toc-bar h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  display: none; /* shown on tablet+ via media query */
}

/* Header row: toggle (mobile) or label (desktop) + home link */
.toc-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.toc-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0;
}

.toc-toggle .toggle-icon {
  font-size: 0.65rem;
  transition: transform 0.2s ease;
}

.toc-toggle[aria-expanded="true"] .toggle-icon {
  transform: rotate(180deg);
}

.home-link {
  color: var(--accent-1);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border-accent);
  border-radius: 100px;
  white-space: nowrap;
  transition: var(--transition);
}

.home-link:hover {
  background: var(--bg-highlight);
}

.toc-links {
  display: none; /* hidden on mobile by default */
  flex-direction: column;
  gap: 0.4rem;
}

.toc-links.open {
  display: flex;
  margin-top: 0.6rem;
}

.toc-links a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toc-links a:hover {
  background: var(--bg-highlight);
  color: var(--accent-1);
}

.toc-links a .num {
  background: var(--gradient-1);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Main Container ── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* ── Section (Okruh) ── */
.okruh {
  margin-bottom: 3rem;
  animation: fadeInUp 0.5s ease-out;
}

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

.okruh-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-1);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.okruh-header::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(79,70,229,0.05));
  pointer-events: none;
}

.okruh-header .okruh-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-1);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.okruh-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
}

.okruh-header .okruh-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  line-height: 1.6;
}

/* ── Content Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
}

.card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card h3 .icon {
  font-size: 1.3rem;
}

.card h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-3);
  margin: 1rem 0 0.5rem;
}

.card h5 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-4);
  margin: 0.75rem 0 0.5rem;
}

.card p {
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.card ul, .card ol {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.card li {
  margin-bottom: 0.4rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.card li::marker {
  color: var(--accent-1);
}

/* ── Key Terms ── */
.term {
  color: var(--accent-3);
  font-weight: 600;
}

.term-def {
  background: rgba(8, 145, 178, 0.06);
  border-left: 3px solid var(--accent-3);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0.75rem 0;
}

.term-def strong {
  color: var(--accent-3);
}

/* ── Highlight Box ── */
.highlight-box {
  background: var(--bg-highlight);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}

.highlight-box.warning {
  background: rgba(217, 119, 6, 0.06);
  border-color: rgba(217, 119, 6, 0.25);
}

.highlight-box.danger {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.25);
}

.highlight-box.success {
  background: rgba(5, 150, 105, 0.06);
  border-color: rgba(5, 150, 105, 0.25);
}

.highlight-box .box-title {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.highlight-box .box-title.accent { color: var(--accent-1); }
.highlight-box .box-title.warning { color: var(--accent-5); }
.highlight-box .box-title.danger { color: var(--accent-6); }
.highlight-box .box-title.success { color: var(--accent-4); }

/* ── Code ── */
code {
  font-family: var(--font-mono);
  background: var(--bg-code);
  color: var(--accent-3);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.85em;
  border: 1px solid var(--border-color);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: var(--gradient-1);
}

th {
  color: #fff;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

tr:hover td {
  background: var(--bg-highlight);
}

/* ── Workflow / Lifecycle Diagram ── */
.lifecycle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
}

.lifecycle .state {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-1);
  white-space: nowrap;
}

.lifecycle .state.active {
  background: var(--gradient-1);
  color: #fff;
  border-color: transparent;
}

.lifecycle .arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* ── Summary Box ── */
.summary-box {
  background: linear-gradient(135deg, rgba(79,70,229,0.05), rgba(124,58,237,0.05));
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.summary-box h3 {
  color: var(--accent-2);
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.summary-box ul {
  padding-left: 1.25rem;
}

.summary-box li {
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.summary-box li::marker {
  color: var(--accent-2);
}

/* ── Q&A Section ── */
.qa-section {
  margin: 1.5rem 0;
}

.qa-section h3 {
  color: var(--accent-5);
  font-size: 1.1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.qa-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: var(--transition);
}

.qa-item:hover {
  border-color: var(--border-accent);
}

.qa-question {
  padding: 1rem 1.25rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--text-heading);
  user-select: none;
  transition: var(--transition);
}

.qa-question:hover {
  background: var(--bg-highlight);
}

.qa-question::after {
  content: '▸';
  color: var(--accent-5);
  font-size: 1.2rem;
  transition: transform 0.3s ease;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.qa-item.open .qa-question::after {
  transform: rotate(90deg);
}

.qa-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
}

.qa-item.open .qa-answer {
  max-height: 1000px;
  padding: 0 1.25rem 1rem;
}

.qa-answer p, .qa-answer ul {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

.qa-answer ul {
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

/* ── Comparison Box ── */
.comparison {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

.comparison .col {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.comparison .col h4 {
  margin-top: 0;
}

/* ── Scroll-to-Top ── */
.scroll-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  background: var(--gradient-1);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-md);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-top:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
}

/* ─── Separator ─── */
.separator {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
  margin: 2rem 0;
}

/* ── Strong/Bold in context ── */
strong {
  color: var(--text-heading);
  font-weight: 600;
}

/* ── Sub-card ── */
.sub-card {
  background: rgba(79, 70, 229, 0.04);
  border: 1px solid rgba(79, 70, 229, 0.12);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 0.75rem 0;
}

/* ═══════════════════════════════════════════════════════════════
   TAHÁK – doplňky (obrázky, vzorce, legendy)   [mobile-first]
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Barvy grafů – stejné významy jako v knize ISLP */
  --viz-true:   #0f172a;   /* skutečná f – černá */
  --viz-orange: #ea580c;   /* lineární / málo flexibilní */
  --viz-blue:   #2563eb;   /* „tak akorát“ */
  --viz-green:  #16a34a;   /* přeflexibilní (overfit) */
  --viz-red:    #dc2626;   /* test MSE */
  --viz-grey:   #94a3b8;   /* training MSE */
  --viz-purple: #9333ea;   /* Bayesova hranice */
  --viz-axis:   #64748b;
  --viz-grid:   #e8ecf4;
  --viz-label:  #475569;
  --viz-classA: #ea580c;   /* oranžová třída */
  --viz-classB: #2563eb;   /* modrá třída */
}

/* ── Obrázek / graf ── */
.figure {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin: 1rem 0;
}

.figure svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.figure figcaption {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.figure figcaption strong { color: var(--text-heading); }

.fig-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* ── Legenda pod grafem ── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin-top: 0.6rem;
}

.legend .item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend .swatch {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend .swatch.dashed {
  height: 0;
  border-top: 3px dashed currentColor;
  background: none !important;
}

.legend .swatch.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ── Vzorce ── */
.formula {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-1);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.85rem 1rem;
  margin: 0.85rem 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.9;
  text-align: center;
  position: relative;
}

.formula .eq-num {
  position: absolute;
  top: 0.35rem;
  right: 0.6rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.formula .var { color: var(--accent-1); font-style: italic; font-weight: 600; }
.formula .lead { display: block; font-family: var(--font-body); font-size: 0.78rem;
                 color: var(--text-muted); margin-top: 0.4rem; text-align: center; }

/* zlomek psaný svisle */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: -0.55em;
  margin: 0 0.15rem;
  line-height: 1.15;
  font-size: 0.85em;
}

.frac .num { border-bottom: 1.5px solid currentColor; padding: 0 0.25rem; }
.frac .den { padding: 0 0.25rem; }

/* suma se spodním a horním indexem */
.sum {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: -0.5em;
  margin: 0 0.15rem;
  line-height: 1;
}

.sum .big { font-size: 1.5em; }
.sum .lim { font-size: 0.6em; color: var(--text-secondary); }

/* barevný popis členů rovnice */
.eq-parts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
}

.eq-parts .part {
  border-left: 3px solid var(--border-color);
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--bg-card-hover);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.eq-parts .part b { display: block; font-size: 0.8rem; margin-bottom: 0.1rem; }
.eq-parts .part.red    { border-left-color: var(--accent-6); }
.eq-parts .part.red b    { color: var(--accent-6); }
.eq-parts .part.blue   { border-left-color: var(--accent-3); }
.eq-parts .part.blue b   { color: var(--accent-3); }
.eq-parts .part.green  { border-left-color: var(--accent-4); }
.eq-parts .part.green b  { color: var(--accent-4); }
.eq-parts .part.amber  { border-left-color: var(--accent-5); }
.eq-parts .part.amber b  { color: var(--accent-5); }

/* ── Q&A: dlouhé odpovědi se nesmí useknout ── */
.qa-item.open .qa-answer { max-height: none; }

.qa-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.6rem;
}

.qa-toolbar button {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  color: var(--accent-1);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition);
}

.qa-toolbar button:hover { background: var(--bg-highlight); }

.qa-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem;
  border-radius: 100px;
  background: var(--bg-highlight);
  color: var(--accent-1);
  border: 1px solid var(--border-accent);
  margin-right: 0.4rem;
  vertical-align: 1px;
}

/* ── Přepínač jazyka CZ / EN ── */
.toc-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border-accent);
  border-radius: 100px;
  overflow: hidden;
  background: var(--bg-card);
}

.lang-switch button {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.28rem 0.6rem;
  transition: var(--transition);
}

.lang-switch button:hover { background: var(--bg-highlight); color: var(--accent-1); }

.lang-switch button[aria-pressed="true"] {
  background: var(--gradient-1);
  color: #fff;
}

/* ── Popup po přepnutí na angličtinu ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  animation: modalFade 0.2s ease-out;
}

.modal-backdrop[hidden] { display: none; }

@keyframes modalFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
  animation: modalPop 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  font-family: var(--font-body);
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--accent-6);
}

.modal-icon {
  font-size: 2.4rem;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.4;
  color: var(--text-heading);
}

/* ── Drobnosti ── */
.en { color: var(--text-muted); font-style: italic; }
.mini { font-size: 0.82rem; color: var(--text-secondary); }

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0;
}

.pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 100px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
}

.pill.up   { border-color: rgba(5,150,105,0.35);  color: var(--accent-4); }
.pill.down { border-color: rgba(220,38,38,0.35);  color: var(--accent-6); }

/* ═══════════════════════════════════════════════════════════════
   TABLET (≥ 640px)
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  .hero {
    padding: 3rem 2rem;
  }
  
  .hero h1 {
    font-size: 2.2rem;
  }
  
  .hero .subtitle {
    font-size: 1.1rem;
  }
  
  .container {
    padding: 1.5rem;
  }
  
  .toc-bar h2 {
    display: block;
  }

  .toc-toggle {
    display: none;
  }

  .toc-bar-header {
    margin-bottom: 0.75rem;
  }

  .toc-links,
  .toc-links.open {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 0;
  }
  
  .card {
    padding: 1.5rem;
  }
  
  .okruh-header {
    padding: 2rem;
  }
  
  .okruh-header h2 {
    font-size: 1.6rem;
  }
  
  .comparison {
    grid-template-columns: 1fr 1fr;
  }

  .fig-grid {
    grid-template-columns: 1fr 1fr;
  }

  .eq-parts {
    grid-template-columns: 1fr 1fr;
  }

  .formula {
    font-size: 1.05rem;
    padding: 1rem 1.25rem;
  }

  .figure {
    padding: 1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DESKTOP (≥ 1024px)
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .hero h1 {
    font-size: 2.6rem;
  }
  
  .container {
    padding: 2rem;
  }
  
  .card {
    padding: 2rem;
  }
  
  .okruh-header {
    padding: 2.5rem;
  }
  
  .okruh-header h2 {
    font-size: 1.8rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */
@media print {
  @page {
    size: A4;
    margin: 10mm 10mm 12mm;
  }

  html,
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 9pt;
    line-height: 1.3;
    scroll-behavior: auto;
  }

  body::before,
  .hero::before {
    display: none !important;
    content: none !important;
  }

  .container {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .hero,
  .toc-bar,
  .lang-switch,
  .modal-backdrop,
  .scroll-top,
  .qa-question::after,
  .subject-list a .arrow,
  .summary-box,
  .qa-section,
  .print-hide {
    display: none !important;
  }

  .okruh {
    margin: 0 0 3mm;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .okruh + .okruh {
    break-before: page;
    page-break-before: always;
  }

  .okruh-header {
    background: #fff !important;
    border: 0.5px solid #555;
    border-left: 2px solid #000 !important;
    border-radius: 0;
    box-shadow: none !important;
    margin-bottom: 1.5mm;
    padding: 1.8mm 2.2mm;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .okruh-header::after {
    display: none !important;
  }

  .card,
  .qa-item,
  .sub-card,
  .highlight-box,
  .term-def,
  .subject-column,
  .comparison .col {
    background: #fff !important;
    border: 0.5px solid #ccc !important;
    border-radius: 0;
    box-shadow: none !important;
    margin-bottom: 1.2mm;
    padding: 1.5mm 2mm;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .highlight-box,
  .term-def,
  .sub-card,
  .comparison .col {
    border-left: 1.5px solid #999 !important;
  }

  .highlight-box.warning,
  .highlight-box.danger,
  .highlight-box.success {
    border-left: 2px solid #777 !important;
  }

  .qa-item {
    overflow: visible !important;
  }

  .qa-question {
    background: #fff !important;
    border-bottom: 0.5px solid #ddd;
    padding: 1mm 1.5mm;
  }

  .qa-answer,
  .qa-item.open .qa-answer {
    max-height: none !important;
    overflow: visible !important;
    padding: 1mm 1.5mm 1.5mm !important;
  }

  .table-wrap {
    border-radius: 0;
    overflow: visible;
  }

  table {
    font-size: 8.4pt;
    width: 100%;
  }

  thead {
    background: #fff !important;
  }

  th,
  td {
    border: 0.5px solid #aaa;
    color: #000 !important;
    padding: 1mm 1.5mm;
    vertical-align: top;
    white-space: normal;
  }

  th {
    font-weight: 700;
  }

  tr:hover td {
    background: #fff !important;
  }

  pre,
  code {
    background: #fff !important;
    border: 0.5px solid #ccc !important;
    color: #000 !important;
  }

  pre {
    font-size: 8pt;
    line-height: 1.25;
    margin: 1mm 0;
    overflow: visible;
    padding: 1.2mm;
    white-space: pre-wrap;
    word-break: break-word;
  }

  code {
    padding: 0.2mm 0.8mm;
  }

  a,
  a:visited {
    color: #000 !important;
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    word-break: break-all;
  }

  .subjects-grid {
    gap: 2mm;
    grid-template-columns: 1fr !important;
  }

  .column-header {
    background: #fff !important;
    border-bottom: 1px solid #bdbdbd;
    color: #000 !important;
  }

  .subject-list a {
    border-left: none !important;
    padding: 1.2mm 1.5mm;
  }

  .subject-list a .subject-code {
    background: #fff !important;
    border-color: #bdbdbd !important;
    color: #000 !important;
  }

  .lifecycle .state,
  .lifecycle .state.active {
    background: #fff !important;
    border-color: #7a7a7a !important;
    color: #000 !important;
  }

  .lifecycle .arrow {
    color: #555 !important;
  }

  h1,
  h2,
  h3,
  h4,
  h5 {
    break-after: avoid-page;
    color: #000 !important;
    page-break-after: avoid;
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }

  h1 { font-size: 16pt !important; }
  h2 { font-size: 13pt !important; }
  h3 { font-size: 11.2pt !important; }
  h4 { font-size: 10.2pt !important; }
  h5 { font-size: 9.8pt !important; }

  img,
  svg {
    break-inside: avoid-page;
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  .figure {
    background: #fff !important;
    border: 0.5px solid #ccc !important;
    border-radius: 0;
    break-inside: avoid-page;
    padding: 1.5mm 2mm;
    page-break-inside: avoid;
  }

  .figure svg { max-height: 62mm; }

  .figure figcaption { color: #000 !important; font-size: 8pt; }

  .fig-grid,
  .eq-parts {
    gap: 2mm;
    grid-template-columns: 1fr 1fr;
  }

  .formula {
    background: #fff !important;
    border: 0.5px solid #ccc !important;
    border-left: 1.5px solid #999 !important;
    font-size: 9pt;
    line-height: 1.7;
    margin: 1.5mm 0;
    padding: 1.5mm 2mm;
  }

  .eq-parts .part,
  .pill {
    background: #fff !important;
    color: #000 !important;
  }

  .qa-toolbar { display: none !important; }

  .legend .item,
  .mini,
  .en { color: #000 !important; }

  footer {
    border-top: 1px solid #bdbdbd;
    color: #444 !important;
    margin-top: 8mm;
    padding-top: 4mm;
  }
}
