: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);
}

/* ── Field rows ── */
.flbl {
  min-width: 34px; 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.invalid { border-color: #f87171; }
.finput:disabled { cursor: not-allowed; opacity: .7; }
.khint { font-size: .75rem; color: var(--muted); }

/* ── Proc select ── */
.proc-sel {
  border: 1px solid var(--border); border-radius: 5px;
  padding: .38rem .5rem; font-size: .85rem; color: var(--text);
  background: #fff; outline: none; min-width: 215px; cursor: pointer;
}
.proc-sel:focus { border-color: var(--primary); }

/* ── ZA Grid ── */
.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; }

/* ── BC equation block ── */
.bc-eq-block {
  display: flex; flex-direction: column; gap: .55rem;
  padding: .65rem .9rem;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 6px;
}
.bc-eq-row {
  display: flex; align-items: baseline; gap: .7rem;
  font-size: 1rem; line-height: 1.7;
}
.bc-section-lbl {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
  margin: 1rem 0 .35rem;
}
.bc-error { color: #ef4444; font-size: .88rem; margin-top: .5rem; }

/* ── Step card header ── */
.step-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .85rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.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;
}
.btn-remove-step:hover { background: #fee2e2; color: #ef4444; }

/* ── 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; }

/* ── Summary table ── */
.summary-table {
  width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: .3rem;
}
.summary-table th {
  text-align: left; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: .3rem .6rem;
  border-bottom: 1px solid var(--border);
}
.summary-table td { padding: .35rem .6rem; border-bottom: 1px solid #f1f5f9; }
.summary-table tr:last-child td { border-bottom: none; }

/* ── Schwingungen specific ── */
.k-list { display: flex; flex-direction: column; gap: .4rem; margin: .35rem 0 .2rem; }
.k-row { display: flex; align-items: center; gap: .45rem; }
.mass-subsection {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
  margin: .75rem 0 .3rem;
}
.bef-row { display: flex; align-items: center; gap: .5rem; margin-top: .65rem; flex-wrap: wrap; }

.result-section { margin: .9rem 0 .4rem; }
.result-section-lbl {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--primary);
  margin-bottom: .45rem;
}
.result-box {
  background: #f0fdf4; border: 1px solid #86efac;
  border-radius: 6px; padding: .6rem 1rem; margin: .5rem 0;
}
.result-row { display: flex; align-items: baseline; gap: .5rem; padding: .18rem 0; }
.result-lbl { font-size: .8rem; color: var(--muted); min-width: 9rem; }

.case-box {
  display: inline-block; padding: .3rem .75rem; border-radius: 5px;
  font-size: .85rem; font-weight: 600; margin: .4rem 0;
}
.case-schwingung { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.case-grenz      { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.case-kriech     { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.matrix-block {
  display: inline-block; margin: .3rem .5rem .3rem 0;
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 5px; padding: .4rem .65rem;
  font-size: .9rem; vertical-align: middle;
}
.matrix-lbl { font-size: .78rem; color: var(--muted); margin-bottom: .2rem; }

.eigenform-row { display: flex; align-items: flex-start; gap: .65rem; flex-wrap: wrap; margin: .4rem 0; }
.eigenform-chip {
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 6px; padding: .35rem .65rem; font-size: .85rem;
}
.eigenform-chip-lbl { font-size: .72rem; color: var(--muted); margin-bottom: .15rem; }

.bc-chart-wrap {
  margin-top: .85rem;
  overflow-x: auto;
}
.bc-chart-wrap canvas {
  display: block;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Datei-laden button ── */
.btn-datei-laden {
  display: inline-flex; align-items: center;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: .4rem .85rem; font-size: .85rem;
  cursor: pointer; transition: background .12s, border-color .12s;
  user-select: none;
}
.btn-datei-laden:hover { background: #e2e8f0; border-color: #94a3b8; }

@media(max-width: 600px) { .sb { display: none; } }
