:root {
  --bg: #f6f7fb; --fg: #1c2333; --muted: #5b6478; --card: #ffffff;
  --accent: #2456d6; --accent-dark: #1a3f9e; --border: #e2e6f0;
  --up: #0d7a45; --down: #b02a37;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--fg); line-height: 1.55; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1rem; }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; }
.site-header nav a { margin-left: 1rem; color: var(--accent); text-decoration: none; }
main { padding: 1.5rem 1rem 3rem; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted);
  font-size: 0.85rem; padding: 1rem 0; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; margin-top: 0; }
.hero { text-align: center; padding: 2rem 0; }
.subtitle { color: var(--muted); font-size: 1.1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.2rem 1.4rem; margin-bottom: 1.4rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.notice { background: #fff8e6; border: 1px solid #f0dfa8; border-radius: 8px;
  padding: 0.7rem 1rem; margin: 0.8rem 0; font-size: 0.92rem; }
.error-box { background: #fdecec; border: 1px solid #f2b8bd; border-radius: 8px;
  padding: 0.8rem 1rem; margin: 0.8rem 0; color: var(--down); }
.btn { display: inline-block; padding: 0.55rem 1.2rem; border-radius: 8px;
  border: 1px solid var(--accent); color: var(--accent); background: transparent;
  cursor: pointer; text-decoration: none; font-size: 1rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.scenario-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem; align-items: start; }
.scenario-form fieldset { border: 1px solid var(--border); border-radius: 8px; }
.scenario-form legend { font-weight: 600; font-size: 0.9rem; padding: 0 0.3rem; }
.scenario-form label { display: block; font-size: 0.85rem; color: var(--muted);
  margin-bottom: 0.6rem; }
.scenario-form input { display: block; width: 100%; padding: 0.4rem 0.5rem;
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; margin-top: 0.15rem; }
.scenario-form button { grid-column: 1 / -1; justify-self: start; }
table.data { border-collapse: collapse; width: 100%; margin: 0.6rem 0 1rem; font-size: 0.93rem; }
table.data th, table.data td { border: 1px solid var(--border); padding: 0.4rem 0.6rem;
  text-align: left; }
table.data thead th { background: #eef1f8; }
table.matrix { width: auto; }
.timeline { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; }
.t-node { border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 1rem;
  background: #fafbfe; min-width: 180px; font-size: 0.9rem; }
.t-node.up { border-left: 4px solid var(--up); }
.t-node.down { border-left: 4px solid var(--down); }
.t-label { font-weight: 600; margin-bottom: 0.3rem; }
.t-branch { display: flex; flex-direction: column; gap: 0.6rem; }
.t-arrows { font-size: 1.6rem; color: var(--muted); }
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.tab-btn { border: 1px solid var(--border); background: #f0f2f8; border-radius: 999px;
  padding: 0.35rem 0.9rem; font-size: 0.85rem; cursor: pointer; }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-panel.hidden { display: none; }
.question { color: var(--muted); }
pre { background: #10182b; color: #dce4f5; padding: 0.9rem 1.1rem; border-radius: 8px;
  overflow-x: auto; font-size: 0.85rem; }
pre code { background: none; color: inherit; }
code { background: #eef1f8; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.88em; }
.formulas li { margin-bottom: 0.5rem; }
.subst { color: var(--muted); }
.inline-form { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.inline-form label { font-size: 0.85rem; color: var(--muted); }
.inline-form input { display: block; padding: 0.35rem 0.5rem; border: 1px solid var(--border);
  border-radius: 6px; margin-top: 0.15rem; }
@media (max-width: 700px) { .timeline { flex-direction: column; align-items: stretch; }
  .t-arrows { display: none; } }

/* ================= v0.2 Finanzwelt ================= */
:root {
  --chart-1: #2456d6; --chart-2: #0d7a45; --chart-3: #c47f00; --chart-4: #7b3fd4;
  --code-bg: #0f172a; --code-fg: #dbe4f5; --grid-line: #e6e9f2;
}
:root[data-theme="dark"] {
  --bg: #0e1320; --fg: #e6eaf4; --muted: #93a0ba; --card: #171e30;
  --accent: #6f96ff; --accent-dark: #4d77ee; --border: #2a3450;
  --up: #3ecf8e; --down: #ff7a85; --grid-line: #232c45;
  --chart-1: #6f96ff; --chart-2: #3ecf8e; --chart-3: #f4b84a; --chart-4: #b48bff;
}
:root[data-theme="dark"] body { background: var(--bg); color: var(--fg); }
:root[data-theme="dark"] table.data thead th { background: #1d2540; }
:root[data-theme="dark"] .tab-btn { background: #1d2540; color: var(--fg); }
:root[data-theme="dark"] .tab-btn.active { background: var(--accent); color: #0e1320; }
:root[data-theme="dark"] .notice { background: #2a2410; border-color: #4d431e; }
:root[data-theme="dark"] .error-box { background: #351b20; border-color: #63303a; }
:root[data-theme="dark"] .t-node { background: #1a2138; }

.theme-toggle { border: 1px solid var(--border); background: transparent; color: var(--fg);
  border-radius: 999px; padding: 0.25rem 0.7rem; cursor: pointer; font-size: 0.85rem;
  margin-left: 1rem; }

/* Layout: Parameterpanel links, Ergebnisse rechts */
.world-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 1.4rem;
  align-items: start; }
@media (max-width: 980px) { .world-layout { grid-template-columns: 1fr; } }
.world-params { position: sticky; top: 1rem; max-height: calc(100vh - 2rem);
  overflow-y: auto; }
.world-params fieldset { border: 1px solid var(--border); border-radius: 8px;
  margin: 0 0 0.9rem; padding: 0.6rem 0.8rem 0.4rem; }
.world-params legend { font-weight: 600; font-size: 0.85rem; padding: 0 0.3rem; }
.param { margin-bottom: 0.75rem; }
.param-head { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.82rem; color: var(--muted); gap: 0.5rem; }
.param-head input[type="number"] { width: 5.6rem; padding: 0.15rem 0.35rem;
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;
  background: var(--card); color: var(--fg); text-align: right; }
.param input[type="range"] { width: 100%; accent-color: var(--accent); margin-top: 0.25rem; }
.param-inline { display: flex; align-items: center; gap: 0.45rem; font-size: 0.85rem;
  color: var(--muted); margin-bottom: 0.5rem; }
.world-status { font-size: 0.8rem; color: var(--muted); min-height: 1.2em; }

/* KPI-Leiste */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem; margin-bottom: 1.2rem; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.6rem 0.9rem; }
.kpi .k-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); }
.kpi .k-value { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 0.75rem; color: var(--muted); }
.kpi.good .k-value { color: var(--up); } .kpi.bad .k-value { color: var(--down); }

/* Charts */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem; margin-bottom: 1.2rem; }
.chart-card { background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.8rem 1rem; }
.chart-card h3 { margin: 0 0 0.2rem; font-size: 0.95rem; }
.chart-card .c-sub { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.4rem; }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.7rem; font-size: 0.78rem;
  color: var(--muted); margin-top: 0.3rem; }
.chart-legend .sw { display: inline-block; width: 0.7em; height: 0.7em;
  border-radius: 2px; margin-right: 0.3em; }
.svg-axis { stroke: var(--muted); stroke-width: 1; }
.svg-grid { stroke: var(--grid-line); stroke-width: 1; }
.svg-zero { stroke: var(--muted); stroke-dasharray: 4 3; }
.svg-label { fill: var(--muted); font-size: 10px; }
.svg-marker { fill: var(--fg); font-size: 10px; font-weight: 600; }

/* Mathematik-Ansicht */
.math-step { border-left: 3px solid var(--accent); padding: 0.4rem 0 0.4rem 0.9rem;
  margin: 0.8rem 0; }
.math-step .m-label { font-weight: 600; font-size: 0.9rem; }
.math-row { font-size: 1.02rem; margin: 0.35rem 0; font-family: "STIX Two Math",
  "Cambria Math", Georgia, serif; }
.math-row.m-sub { color: var(--muted); }
.math-row.m-res { font-weight: 650; }
.math-note { font-size: 0.8rem; color: var(--muted); }
.frac { display: inline-flex; flex-direction: column; text-align: center;
  vertical-align: middle; margin: 0 0.15em; }
.frac .num { border-bottom: 1px solid currentColor; padding: 0 0.25em; line-height: 1.15; }
.frac .den { padding: 0 0.25em; line-height: 1.15; }

/* Python-Ansicht */
.code-block { background: var(--code-bg); color: var(--code-fg); border-radius: 10px;
  padding: 0.9rem 1.1rem; overflow-x: auto; font-size: 0.82rem; line-height: 1.5;
  font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, monospace; }
.code-module { font-size: 0.75rem; color: var(--muted); font-family: ui-monospace, monospace; }

/* Marktteilnehmer */
.persona-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem; }
.persona { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.9rem 1.1rem; }
.persona h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.persona .p-question { font-size: 0.82rem; color: var(--muted); font-style: italic; }
.persona dl { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.7rem;
  font-size: 0.85rem; margin: 0.6rem 0 0.4rem; }
.persona dt { color: var(--muted); } .persona dd { margin: 0; font-variant-numeric: tabular-nums; }
.persona details { font-size: 0.83rem; margin-top: 0.4rem; }
.persona summary { cursor: pointer; color: var(--accent); }

.htmx-request #world-results { opacity: 0.45; transition: opacity 120ms; }
