:root {
  --sb-w: 210px;
  --sb-bg: #1e293b;
  --primary: #2563eb;
  --bg: #f1f5f9;
  --card: #fff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --radius: 8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
       background: var(--bg); color: var(--text); }

/* ── Layout ── */
.app { display: flex; height: 100vh; height: 100dvh; }

/* ── Sidebar ── */
.sb {
  width: var(--sb-w); background: var(--sb-bg);
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.sb-brand {
  padding: 1.1rem 1rem .9rem;
  border-bottom: 1px solid #334155;
}
.sb-brand h2 { color: #f1f5f9; font-size: .95rem; font-weight: 700; }
.sb-brand p  { color: #64748b;  font-size: .72rem; margin-top: .15rem; }

.sb-nav { padding: .85rem .65rem; flex: 1; }
.sb-group-lbl {
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: #475569;
  padding: .4rem .5rem .3rem;
}
.nav-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .7rem; border-radius: 6px;
  font-size: .84rem; color: #94a3b8;
  cursor: pointer; transition: background .12s, color .12s;
  user-select: none;
}
.nav-item:hover { background: #263446; color: #cbd5e1; }
.nav-item.active { background: var(--primary); color: #fff; }
.sb-footer {
  padding: .65rem 1rem;
  border-top: 1px solid #334155;
  font-size: .7rem; color: #475569;
}

/* ── Main ── */
.main {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 1.1rem 1.1rem max(6rem, calc(env(safe-area-inset-bottom) + 6rem)); display: flex; flex-direction: column; gap: 1rem;
}

/* ── Cards ── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.15rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
  margin-bottom: .85rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Step card header (title + remove btn) ── */
.step-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .85rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Field rows ── */
.flbl {
  min-width: 44px; display: flex; align-items: center; justify-content: flex-end;
  font-size: .95rem;
}
.feq { color: var(--muted); font-size: .95rem; }
.finput {
  width: 105px; border: 1px solid var(--border); border-radius: 5px;
  padding: .38rem .5rem; font-size: .9rem; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.finput:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.finput:disabled { cursor: not-allowed; opacity: .55; background: #f8fafc; }
.finput[readonly]  { background: #f8fafc; cursor: default; color: var(--muted); }
.finput.pk-computed { background: #f0fdf4; border-color: #86efac; color: #166534; }
.khint { font-size: .75rem; color: var(--muted); white-space: nowrap; }

/* ── Unknown checkbox ── */
.bc-unk-lbl {
  display: flex; align-items: center; gap: .3rem;
  font-size: .78rem; color: var(--muted);
  cursor: pointer; margin-left: .4rem; user-select: none;
}
.bc-unk-lbl input[type="checkbox"] { cursor: pointer; }

/* ── Input grids ── */
.za-grid {
  display: grid;
  grid-template-columns: max-content max-content 105px max-content;
  column-gap: .45rem; row-gap: .55rem;
  align-items: center;
}
.za-grid-5 {
  display: grid;
  grid-template-columns: max-content max-content 105px max-content auto;
  column-gap: .45rem; row-gap: .55rem;
  align-items: center;
}
.za-field { display: contents; }

/* ── Remove button ── */
.btn-remove-step {
  background: none; border: none; color: var(--muted);
  font-size: 1.25rem; line-height: 1; cursor: pointer;
  padding: .1rem .35rem; border-radius: 4px;
  transition: background .12s, color .12s; flex-shrink: 0;
}
.btn-remove-step:hover { background: #fee2e2; color: #ef4444; }

/* ── Δ-Modus toggle button ── */
.pk-delta-btn {
  background: none; border: 1.5px solid #cbd5e1; color: var(--muted);
  font-size: .8rem; font-weight: 700; line-height: 1; cursor: pointer;
  padding: .1rem .3rem; border-radius: 4px; margin-left: .3rem;
  transition: background .12s, color .12s, border-color .12s;
}
.pk-delta-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pk-delta-btn:hover:not(.active) { background: #eff6ff; border-color: var(--primary); color: var(--primary); }

/* ── Add-step button ── */
.btn-add-step {
  display: flex; align-items: center; gap: .45rem;
  background: #fff; color: var(--primary);
  border: 2px dashed var(--primary); border-radius: 8px;
  padding: .5rem 1.4rem; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
}
.btn-add-step:hover { background: #eff6ff; }
.btn-add-icon { font-size: 1.1rem; line-height: 1; }

/* ── Berechnen button ── */
.btn-berechnen {
  background: var(--primary); color: #fff;
  border: none; border-radius: 6px;
  padding: .55rem 1.6rem; font-size: .92rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
  letter-spacing: .02em;
}
.btn-berechnen:hover { background: #1d4ed8; }
.btn-berechnen:active { background: #1e40af; }

/* ── Result display ── */
.bc-section-lbl {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
  margin: .9rem 0 .35rem;
}
.bc-section-lbl:first-child { margin-top: 0; }
.bc-eq-block {
  display: flex; flex-direction: column; gap: .45rem;
  padding: .65rem .9rem;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 6px;
}
.bc-eq-row {
  display: flex; align-items: baseline; gap: .6rem;
  font-size: .92rem; line-height: 1.6;
}
.bc-eq-num {
  min-width: 3.5rem;
  display: flex; align-items: center;
}
.bc-error { color: #ef4444; font-size: .88rem; margin-top: .6rem; }

/* ── Rechenweg ── */
.bc-rechenweg {
  display: flex; flex-direction: column; gap: .55rem;
  margin: .35rem 0 .55rem;
}
.bc-step {
  padding: .5rem .9rem;
  background: #f0f9ff; border-left: 3px solid #60a5fa;
  border-radius: 0 6px 6px 0;
  display: flex; flex-direction: column; gap: .4rem;
  overflow-x: auto;
}
.bc-step-gl {
  background: #e0f2fe; border-left-color: #0284c7;
}
.bc-step-line { font-size: .88rem; line-height: 1.6; }
.bc-rw-lbl {
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #93c5fd; margin: .5rem 0 .2rem;
}

/* ── Mode Toggle ── */
.pk-mode-toggle { display: flex; gap: .5rem; }
.pk-mode-btn {
  padding: .38rem 1.1rem; border-radius: 6px;
  border: 1px solid var(--border); background: #fff;
  font-size: .86rem; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.pk-mode-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pk-mode-btn:hover:not(.active) { background: #f1f5f9; }

/* ── Charts ── */
.pk-charts-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.pk-chart-wrap { flex: 1; min-width: 240px; }
.pk-chart-wrap canvas { display: block; width: 100%; height: 180px; }

/* ── IO Buttons (Speichern / Laden) ── */
.btn-io {
  background: #fff; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px;
  padding: .48rem 1rem; font-size: .84rem; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  display: flex; align-items: center; gap: .35rem;
}
.btn-io:hover { background: #f1f5f9; border-color: #cbd5e1; color: var(--text); }

/* ── Example Picker Modal ── */
.pk-picker-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 999; display: flex; align-items: center; justify-content: center;
}
.pk-picker-box {
  background: #fff; border-radius: 10px; padding: 1.4rem 1.6rem;
  min-width: 280px; max-width: 420px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.pk-picker-title { font-weight: 700; font-size: .95rem; margin-bottom: .9rem; color: var(--text); }
.pk-picker-list { display: flex; flex-direction: column; gap: .4rem; max-height: 340px; overflow-y: auto; }
.pk-picker-item {
  text-align: left; background: #f8fafc; border: 1px solid var(--border);
  border-radius: 6px; padding: .55rem .8rem; cursor: pointer;
  font-size: .88rem; color: var(--text); transition: background .12s; width: 100%;
}
.pk-picker-item:hover { background: #eff6ff; border-color: #bfdbfe; }
.pk-picker-item small { color: var(--muted); font-size: .76rem; display: block; margin-top: .1rem; }
.pk-picker-cancel {
  margin-top: .85rem; width: 100%; padding: .42rem; background: none;
  border: 1px solid var(--border); border-radius: 5px;
  cursor: pointer; color: var(--muted); font-size: .82rem;
}
.pk-picker-cancel:hover { background: #f1f5f9; }

/* ── Placeholder ── */
.placeholder-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .75rem; padding: 3rem 1rem; text-align: center;
}
.placeholder-icon {
  width: 52px; height: 52px; border-radius: 12px;
  background: #eff6ff; display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.placeholder-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.placeholder-sub   { font-size: .85rem; color: var(--muted); max-width: 320px; line-height: 1.5; }

/* ── Energieerhaltungssatz ── */
.es-bauteile-list {
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.es-bauteil-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafcff;
  padding: 1rem;
}
.es-bauteil-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .9rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}
.es-bauteil-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
}
.es-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .85rem .95rem;
}
.es-field {
  display: flex;
  flex-direction: column;
  gap: .32rem;
}
.es-field label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
}
.es-seil-block {
  margin-top: .95rem;
  padding-top: .85rem;
  border-top: 1px solid var(--border);
}
.es-seil-title {
  margin-bottom: .75rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.es-input,
.es-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .6rem;
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.es-input:focus,
.es-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ── Responsive sidebar ── */
.es-segment-meta {
  font-size: .78rem;
  color: var(--muted);
}
@media(max-width: 600px) { .sb { display: none; } }

/* ── Raumkinematik ── */
.rk-item {
  border: 1px solid var(--border); border-radius: 6px;
  padding: .7rem .9rem; margin-bottom: .55rem; background: #fafafa;
}
.rk-item:last-child { margin-bottom: 0; }
.rk-item-hdr {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .5rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border);
}
.rk-item-ttl {
  font-size: .75rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.rk-row { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.rk-lbl { font-size: .83rem; color: var(--text); white-space: nowrap; }
.rk-select {
  border: 1px solid var(--border); border-radius: 5px;
  padding: .32rem .5rem; font-size: .85rem; color: var(--text);
  background: #fff; outline: none; cursor: pointer;
}
.rk-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.rk-coord-row { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.rk-coord-lbl { font-size: .78rem; color: var(--muted); min-width: 5.5rem; }
.rk-coord-in { width: 85px !important; }
.rk-empty { font-size: .82rem; color: var(--muted); padding: .3rem 0; font-style: italic; }

/* ── Grundgesetz Kraft-Zeilen ── */
.gg-kraft-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: .45rem;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 6px;
  padding: .4rem .65rem;
}
.gg-kraft-name { font-size: .85rem; font-weight: 600; min-width: 9.5rem; }
.gg-kraft-sym  { font-size: .82rem; color: var(--muted); flex: 1; min-width: 6rem; }
.gg-param-lbl  { font-size: .85rem; color: var(--text); white-space: nowrap; }
.gg-param-in   { width: 80px !important; }
.gg-remove-btn {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--muted); line-height: 1; padding: .15rem .35rem;
  border-radius: 4px; transition: background .12s, color .12s;
}
.gg-remove-btn:hover { background: #fee2e2; color: #dc2626; }
.rk-sketch-wrap { border: 1px solid var(--border); border-radius: 6px; background: #fafafa; overflow: hidden; }
.btn-sec {
  display: inline-flex; align-items: center; gap: .35rem;
  background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: .42rem .95rem; font-size: .84rem; font-weight: 600;
  cursor: pointer; transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn-sec:hover { background: #f1f5f9; border-color: #cbd5e1; }
.rk-file-row { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.rk-ex-badge {
  font-size: .78rem; color: var(--muted); font-style: italic;
  padding: .2rem .55rem; background: #f1f5f9; border-radius: 4px;
}
.rk-ex-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.btn-ex {
  background: #fff; border: 1px solid var(--border); border-radius: 5px;
  padding: .35rem .85rem; font-size: .84rem; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-ex:hover { background: #eff6ff; border-color: var(--primary); color: var(--primary); }

/* ── Stoß ── */
.st-mode-lbl { font-size: .84rem; color: var(--muted); min-width: 4.5rem; }
.st-input.st-unk { background: #f1f5f9; color: var(--muted); }
