/* ── Design-System ─────────────────────────────────────── */
:root {
  --sidebar-bg:   #0B1423;
  --sidebar-w:    240px;
  --bg:           #F6F5F1;
  --bg-card:      #ffffff;
  --blue:         #2563EB;
  --amber:        #D97706;
  --red:          #DC2626;
  --green:        #059669;
  --ink:          #1C1917;
  --muted:        #78716C;
  --border:       #E7E5E4;
  --formula-bg:   #EFF6FF;
  --radius:       10px;
  --ff-display:   'Fraunces', Georgia, serif;
  --ff-body:      'IBM Plex Sans', system-ui, sans-serif;
  --ff-mono:      'JetBrains Mono', Menlo, monospace;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--ff-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ── App Shell ─────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 0;
  /* subtle dot matrix */
  background-image: radial-gradient(circle, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 18px 18px;
  background-color: var(--sidebar-bg);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.12) transparent;
  z-index: 50;
  transition: transform .3s ease;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.75rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  transition: background .15s;
}
a.sidebar-brand:hover {
  background: rgba(255,255,255,.05);
}
.sidebar-brand-icon {
  width: 30px; height: 30px;
  background: var(--blue);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-icon svg { display: block; }
.sidebar-brand-name {
  font-family: var(--ff-display);
  font-weight: 600;
  color: #fff;
  font-size: .9rem;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-family: var(--ff-mono);
  font-size: .6rem;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .12em;
}

.sidebar-nav { flex: 1; padding: .75rem .75rem; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--ff-mono);
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: rgba(255,255,255,.3);
  padding: .25rem .75rem .5rem;
}
.nav-section-label svg { opacity: .7; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .75rem;
  border-radius: 7px;
  font-size: .85rem;
  color: rgba(255,255,255,.5);
  cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.8); }
.nav-item.active { background: rgba(37,99,235,.22); color: #fff; font-weight: 500; }
.nav-item .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  flex-shrink: 0;
  transition: background .15s;
}
.nav-item.active .dot { background: var(--blue); }
.nav-item .soon-badge {
  margin-left: auto;
  font-family: var(--ff-mono);
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.25);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 4px;
  padding: 1px 5px;
}
.nav-item.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.sidebar-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-family: var(--ff-mono);
  font-size: .65rem;
  color: rgba(255,255,255,.2);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 40;
}

/* ── Main content area ─────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Mobile header ─────────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}
.hamburger {
  background: none; border: none; cursor: pointer; padding: .25rem;
  color: var(--ink); display: flex; align-items: center;
}

/* ── Homepage layout ───────────────────────────────────── */
.page-home {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}
.hero { margin-bottom: 3rem; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--ff-mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--blue);
  background: #EFF6FF;
  border-radius: 999px;
  padding: .35rem .8rem;
  margin-bottom: 1rem;
}
.hero-badge .pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.hero h1 {
  font-family: var(--ff-display);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.18;
  margin-bottom: .6rem;
}
.hero h1 span { color: var(--blue); }
.hero p {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 500px;
  line-height: 1.65;
}

.category-section { margin-bottom: 2.5rem; }
.category-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .35rem;
}
.category-title {
  font-family: var(--ff-display);
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
}
.category-rule { flex: 1; border: none; border-top: 1px solid var(--border); }
.category-desc { font-size: .875rem; color: var(--muted); margin-bottom: 1.25rem; }
.concept-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .85rem;
}

/* Concept card */
.concept-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  position: relative;
  transition: box-shadow .2s, transform .2s, border-color .2s;
  display: block;
  overflow: hidden;
}
.concept-card::before {
  content: '';
  position: absolute;
  top: 0; left: 1.5rem; right: 1.5rem;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--card-color, var(--blue));
  opacity: 0;
  transition: opacity .2s;
}
.concept-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); transform: translateY(-1px); border-color: #D4D2CF; }
.concept-card:hover::before { opacity: 1; }
.concept-card.disabled { opacity: .5; pointer-events: none; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .8rem; }
.card-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--card-color, var(--blue));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--ff-mono);
  font-weight: 600;
  font-size: .85rem;
}
.card-arrow { color: #C4C2BF; transition: color .2s; margin-top: .2rem; }
.concept-card:hover .card-arrow { color: var(--muted); }
.soon-pill {
  font-family: var(--ff-mono);
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #B5B0AA;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: .2rem;
}
.card-title { font-family: var(--ff-display); font-size: 1rem; font-weight: 600; margin-bottom: .25rem; transition: color .2s; }
.concept-card:hover .card-title { color: var(--blue); }
.card-sub { font-size: .8rem; color: var(--muted); line-height: 1.45; }
.card-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .65rem; }
.tag { font-family: var(--ff-mono); font-size: .6rem; padding: 2px 6px; border-radius: 4px; background: #F3F2EF; color: #8A8278; }

/* ── Concept page ──────────────────────────────────────── */
.page-concept { max-width: 860px; margin: 0 auto; padding: 0 2rem 4rem; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--muted);
  padding: 1.25rem 0 .5rem;
  font-family: var(--ff-mono);
}
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb-sep { color: #D0CCC8; }

/* Concept header */
.concept-header { margin-bottom: 1rem; }
.concept-category {
  font-family: var(--ff-mono);
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--blue);
  margin-bottom: .4rem;
}
.concept-title {
  font-family: var(--ff-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: .4rem;
}
.concept-subtitle { font-size: 1rem; color: var(--muted); }

/* Section tabs / jump nav */
.section-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2.5rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
  padding-top: .5rem;
}
.section-tab {
  font-family: var(--ff-mono);
  font-size: .75rem;
  padding: .5rem .85rem;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  transition: color .15s;
  letter-spacing: .02em;
  margin-bottom: -2px;
  border-bottom: 2px solid transparent;
}
.section-tab:hover { color: var(--ink); }
.section-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 500; }

/* Concept section block */
.concept-section { scroll-margin-top: 60px; margin-bottom: 3.5rem; }
.section-heading {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.section-number {
  font-family: var(--ff-mono);
  font-size: .7rem;
  color: rgba(37,99,235,.6);
  background: #EFF6FF;
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: 500;
}
.section-heading h2 {
  font-family: var(--ff-display);
  font-size: 1.35rem;
  font-weight: 600;
}

/* Prose content */
.prose { font-size: .95rem; line-height: 1.7; color: var(--ink); }
.prose p { margin-bottom: 1rem; }
.prose h3 { font-family: var(--ff-display); font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 .5rem; }

/* Formula block */
.formula-block {
  background: var(--formula-bg);
  border-left: 3px solid var(--blue);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  font-family: var(--ff-mono);
}
.formula-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--blue);
  font-weight: 600;
  margin-bottom: .4rem;
}
.formula-vars {
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.formula-var {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-size: .82rem;
}
.formula-var .sym { color: var(--blue); min-width: 60px; }
.formula-var .desc { color: var(--muted); }
.formula-var .unit { font-family: var(--ff-mono); font-size: .75rem; color: #A09890; }

/* ── Simulation ────────────────────────────────────────── */
.sim-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.sim-canvas-wrap { background: #FDFCF8; position: relative; }
#sim-canvas { display: block; width: 100%; height: auto; }
.sim-controls {
  padding: 1rem 1.25rem;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.sliders-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.slider-group { display: flex; flex-direction: column; gap: .35rem; }
.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  font-family: var(--ff-mono);
}
.slider-name { color: var(--muted); }
.slider-value { font-weight: 600; }
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  background: #E7E5E4;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: currentColor;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  cursor: pointer;
  transition: transform .1s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.sim-buttons { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.btn {
  font-family: var(--ff-mono);
  font-size: .8rem;
  padding: .5rem 1.1rem;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-weight: 500;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1D4ED8; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: #F3F2EF; color: var(--ink); }
.btn-secondary:hover { background: #EDECEA; }
.work-live {
  margin-left: auto;
  font-family: var(--ff-mono);
  font-size: .95rem;
  font-weight: 600;
  color: var(--blue);
}

/* ── Chart ─────────────────────────────────────────────── */
.chart-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.chart-desc { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; line-height: 1.55; }

/* ── Calculator ────────────────────────────────────────── */
.calc-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.calc-inputs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.calc-group { display: flex; flex-direction: column; gap: .35rem; }
.calc-label {
  font-family: var(--ff-mono);
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.calc-input-row { display: flex; align-items: center; gap: .4rem; }
.calc-input {
  width: 100%;
  font-family: var(--ff-mono);
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .45rem .65rem;
  color: var(--ink);
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.calc-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.calc-unit { font-family: var(--ff-mono); font-size: .8rem; color: var(--muted); flex-shrink: 0; }

.calc-result {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  display: none;
}
.calc-result.visible { display: block; }
.result-primary {
  font-family: var(--ff-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: .5rem;
}
.result-steps {
  font-family: var(--ff-mono);
  font-size: .82rem;
  color: var(--muted);
  line-height: 2;
}
.result-steps .step-line { display: block; }
.result-steps .step-result { color: var(--ink); font-weight: 500; }

/* ── Quiz ──────────────────────────────────────────────── */
.quiz-wrap { display: flex; flex-direction: column; gap: 1.5rem; }
.quiz-question { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.q-number {
  font-family: var(--ff-mono);
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--blue);
  margin-bottom: .5rem;
}
.q-text { font-size: .95rem; font-weight: 500; margin-bottom: 1rem; line-height: 1.55; }
.q-options { display: flex; flex-direction: column; gap: .5rem; }
.q-option {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .6rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: .88rem;
  line-height: 1.45;
  background: none;
  text-align: left;
  color: var(--ink);
  font-family: var(--ff-body);
  width: 100%;
}
.q-option:hover:not([disabled]) { border-color: var(--blue); background: #EFF6FF; }
.q-option[disabled] { cursor: default; }
.q-option.correct { border-color: var(--green); background: #F0FDF4; color: #065F46; }
.q-option.wrong   { border-color: var(--red);   background: #FEF2F2; color: #991B1B; }
.q-opt-key {
  font-family: var(--ff-mono);
  font-size: .75rem;
  font-weight: 700;
  min-width: 20px;
  margin-top: 1px;
}
.q-explanation {
  margin-top: .85rem;
  font-size: .84rem;
  color: #3B5A3E;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: 7px;
  padding: .65rem .9rem;
  line-height: 1.55;
  display: none;
}
.q-explanation.visible { display: block; }
.quiz-score {
  text-align: center;
  padding: 1.5rem;
  background: var(--formula-bg);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius);
  display: none;
}
.quiz-score.visible { display: block; }
.score-num {
  font-family: var(--ff-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--blue);
}
.score-label { color: var(--muted); font-size: .9rem; margin-top: .25rem; }

/* ── Section rule ─────────────────────────────────────── */
hr.section-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── Callout box ──────────────────────────────────────── */
.callout {
  background: #FFFBEB;
  border-left: 3px solid var(--amber);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: .92rem;
  line-height: 1.65;
  color: #78350F;
}
.callout strong { color: #92400E; }

/* ── System grid (Energieinfrastruktur) ───────────────── */
.system-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .85rem;
  margin: 1rem 0;
}
.system-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.system-item-label {
  font-family: var(--ff-mono);
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: .35rem;
}
.system-item-title {
  font-family: var(--ff-display);
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.system-item-text {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    height: 100%;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }
  .mobile-header { display: flex; }
  .concept-grid { grid-template-columns: repeat(2, 1fr); }
  .sliders-row { grid-template-columns: 1fr; }
  .calc-inputs { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
  .page-home { padding: 1.5rem 1rem 3rem; }
  .page-concept { padding: 0 1rem 3rem; }
  .system-grid { grid-template-columns: 1fr; }
}
/* ── Concept links (shared footer links on concept pages) ──────── */
.concept-links {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .8rem;
  color: var(--muted);
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.concept-links a {
  font-family: var(--ff-mono);
  font-size: .72rem;
  color: var(--blue);
  border: 1px solid rgba(37,99,235,.25);
  border-radius: 6px;
  padding: .25rem .65rem;
  transition: background .15s;
  text-decoration: none;
}
.concept-links a:hover { background: #EFF6FF; }

/* ── Numbers grid (key stats block) ───────────────────────────── */
.numbers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  margin: 1rem 0;
}
.number-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
}
.number-val {
  font-family: var(--ff-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue);
}
.number-lbl {
  font-size: .75rem;
  color: var(--muted);
  margin-top: .15rem;
  line-height: 1.45;
}
@media (max-width: 600px) {
  .numbers-grid { grid-template-columns: repeat(2, 1fr); }
}

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