:root {
  --brand: #7a2e26;
  --brand-dark: #5c211b;
  --brand-soft: #f6ece9;
  --bg: #f3f1ef;
  --card: #ffffff;
  --text: #241c1a;
  --muted: #7d726f;
  --line: #e2dbd8;
  --ok: #2e7d4f;
  --warn: #b26a00;
  --rec: #d32f2f;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.logo { font-weight: 300; letter-spacing: .3em; font-size: 20px; }
.sub { font-size: 12px; opacity: .85; letter-spacing: .05em; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.15); color: #fff; font-size: 20px; cursor: pointer;
}
.banner {
  margin: 12px 16px 0; padding: 10px 14px; border-radius: 10px;
  background: #fff4e0; color: #6b4200; font-size: 14px;
}
.banner.ok { background: #e6f4ec; color: #1d5434; }
.banner.err { background: #fdeaea; color: #8a1c1c; }
main { max-width: 760px; margin: 0 auto; padding: 4px 16px 32px; }
.card {
  background: var(--card); border-radius: 14px; padding: 14px 14px 12px;
  margin-top: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
h2 {
  margin: 0 0 10px; font-size: 15px; color: var(--brand);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
h2 small { font-weight: 400; color: var(--muted); }
h3 { margin: 12px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
input, textarea, select {
  display: block; width: 100%; margin-top: 3px;
  font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px;
  background: #fff; min-width: 0;
}
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[readonly] { background: #f7f5f4; }
textarea { resize: vertical; }
.grid2, .grid3, .grid4 { display: grid; gap: 8px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: 1fr 1.4fr 1fr; }
.grid4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 420px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 label:nth-child(2) { grid-column: span 2; grid-row: 1; }
}
.sum { font-size: 14px; padding: 4px 2px 0; }
.sum b { color: var(--brand); font-size: 17px; }
.hint { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }

.mic-field { position: relative; }
.mic-field input, .mic-field textarea { padding-right: 44px; }
.memo-card { border: 2px solid var(--brand); }
.memo-card textarea { margin-top: 4px; font-size: 15px; }
.auswerten { width: 100%; margin-top: 8px; padding: 11px; }
.auto { font-weight: 400; color: var(--ok); font-size: 11px; }
.breit { width: 100%; }
.qr-knopf { display: block; margin: 12px auto 0; }
.qr { display: grid; place-items: center; padding: 14px; margin-top: 10px; background: #fff; border-radius: 10px; }
.ergebnis { margin-top: 12px; }
.erg-block { margin-top: 10px; }
.erg-block h3 { margin: 0 0 6px; color: var(--brand); font-size: 14px; }
.erg-zeile { display: grid; grid-template-columns: 1fr 86px; gap: 6px; margin-bottom: 6px; }
.erg-zeile.kopf { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.erg-zeile.drei { grid-template-columns: repeat(3, 1fr); }
.erg-zeile label { margin: 0; }
.erg-zeile > .erg-feld:only-child { grid-column: 1 / -1; }
.erg-feld {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; background: #fff;
  color: var(--text); font-size: 15px; min-height: 42px; margin-top: 3px;
}
.erg-feld.klein { text-align: center; }
.erg-feld.leer { color: var(--muted); font-style: italic; }
.erg-summe { font-size: 14px; padding: 2px 2px 0; }
.erg-summe b { color: var(--brand); font-size: 17px; }
.mic {
  position: absolute; right: 4px; bottom: 4px;
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand); cursor: pointer;
  display: grid; place-items: center;
}
.mic svg { width: 18px; height: 18px; }
.mic.rec, .memo.rec { background: var(--rec); color: #fff; }

.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: 1fr 86px 34px; gap: 6px; align-items: end; }
.row input { margin-top: 0; }
.row .del {
  height: 42px; border: 0; background: transparent; color: var(--muted);
  font-size: 22px; cursor: pointer;
}
.add {
  margin-top: 10px; width: 100%; padding: 10px; border-radius: 9px;
  border: 1px dashed var(--line); background: #fff; color: var(--brand);
  font: inherit; font-weight: 600; cursor: pointer;
}
.link {
  border: 0; background: none; color: var(--brand); font: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;
}
.memo {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--brand); color: #fff; font: inherit; font-weight: 700; font-size: 17px;
}
.memo .dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; }
.memo.rec .dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.sig-wrap { margin-top: 8px; }
.sig-head { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sig {
  width: 100%; height: 140px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff repeating-linear-gradient(transparent 0 108px, var(--line) 108px 109px, transparent 109px 140px);
  touch-action: none;
}

.actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; margin-top: 16px; }
.primary, .secondary {
  padding: 14px 12px; border-radius: 12px; font: inherit; font-weight: 700; cursor: pointer;
}
.primary { background: var(--brand); color: #fff; border: 0; }
.primary:disabled { opacity: .6; }
.secondary { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }

.list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.list li:last-child { border-bottom: 0; }
.list a { color: var(--brand); }
.muted { color: var(--muted); }

dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg { padding: 18px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
