/* NotenApp – Mobile-first, große Touch-Ziele, Dark Mode, eckig (border-radius 0) */

:root {
  --navy: #1B3A5C;
  --akzent: #2E86C1;
  --bg: #f4f6f9;
  --fl: #ffffff;          /* Fläche */
  --fl2: #eef2f7;
  --text: #17212b;
  --muted: #5b6b7c;
  --linie: #d5dde6;
  --gefahr: #b42318;
  --ok: #1e7b45;
  --warn-bg: #fff4dc;
  --warn-linie: #e3a008;
  --fokus: #2E86C1;
  --top: var(--navy);
  --top-text: #fff;
  --touch: 48px;
  --abstand: 16px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --fl: #17212c;
    --fl2: #1f2b38;
    --text: #e6edf3;
    --muted: #9aabbc;
    --linie: #2c3a49;
    --gefahr: #f97066;
    --ok: #4ade80;
    --warn-bg: #3a2e12;
    --warn-linie: #b7791f;
    --akzent: #5aa9e6;
    --fokus: #5aa9e6;
    --top: #0b2340;
  }
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 var(--schrift);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1rem 0 .25rem; }
p { margin: 0 0 .5rem; }
a { color: var(--akzent); }
:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.fehlertext { color: var(--gefahr); min-height: 1.2em; }
pre.small { white-space: pre-wrap; }

/* ---------- Rahmen ---------- */

.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; padding: env(safe-area-inset-top) var(--abstand) 0;
  background: var(--top); color: var(--top-text);
}
.brand { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; display: inline-block;
  background: linear-gradient(90deg, #8b1a1a 0 16.6%, #c2410c 0 33.3%, #d97706 0 50%, #a3a30d 0 66.6%, #4d9b2f 0 83.3%, #86d36b 0);
  border: 2px solid #fff;
}
main {
  flex: 1; width: 100%; max-width: 860px; margin: 0 auto;
  padding: var(--abstand) var(--abstand) calc(84px + env(safe-area-inset-bottom));
  outline: none;
}
main:focus-visible { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--fl); border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; color: var(--muted); text-decoration: none; font-size: .75rem;
}
.nav-item.active { color: var(--akzent); font-weight: 600; box-shadow: inset 0 3px 0 var(--akzent); }

@media (min-width: 900px) {
  .bottomnav { position: sticky; top: 56px; bottom: auto; order: -1; grid-template-columns: repeat(4, max-content); justify-content: center; border-top: 0; border-bottom: 1px solid var(--linie); }
  .topbar { order: -2; }
  .topbar + main { order: 1; }
  .nav-item { flex-direction: row; gap: 8px; padding: 0 20px; font-size: .95rem; min-height: 48px; }
  .nav-item.active { box-shadow: inset 0 -3px 0 var(--akzent); }
  main { padding-bottom: 40px; }
}

/* ---------- Icons (CSS-Masken, keine externen Dateien) ---------- */

.icon { width: 24px; height: 24px; display: inline-block; background: currentColor; -webkit-mask: var(--i) center/contain no-repeat; mask: var(--i) center/contain no-repeat; }
.icon-home { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'><path d='M3 11l9-7 9 7v9H14v-6h-4v6H3z'/></svg>"); }
.icon-groups { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'><circle cx='8' cy='8' r='3'/><circle cx='17' cy='9' r='2.5'/><path d='M2 20c0-4 3-6 6-6s6 2 6 6M14 20c0-3 1.5-5 3-5s5 1 5 5'/></svg>"); }
.icon-calendar { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'><rect x='3' y='5' width='18' height='16'/><path d='M3 10h18M8 3v4M16 3v4'/></svg>"); }
.icon-settings { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'><circle cx='12' cy='12' r='3'/><path d='M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1'/></svg>"); }
.icon-lock { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'><rect x='4' y='11' width='16' height='10'/><path d='M8 11V7a4 4 0 0 1 8 0v4'/></svg>"); }

/* ---------- Bausteine ---------- */

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-end { justify-content: flex-end; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 520px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crumb { font-size: .875rem; color: var(--muted); margin: 0; }
.crumb a { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--touch); padding: 0 18px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--text); background: var(--fl); border: 1px solid var(--linie);
}
.btn:hover { border-color: var(--akzent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--akzent); border-color: var(--akzent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #06121e; } }
.btn-danger { color: var(--gefahr); border-color: currentColor; background: transparent; }
.btn-link { background: none; border: 0; color: var(--akzent); padding: 0 8px; font-weight: 500; }
.btn-block { width: 100%; }
.btn-big { min-height: 60px; font-size: 1.05rem; }
.btn-small { min-height: 40px; padding: 0 12px; font-size: .875rem; }
.btn-icon { min-height: 44px; width: 44px; padding: 0; background: transparent; border: 0; color: inherit; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-weight: 600; font-size: .9rem; }
.hint { color: var(--muted); font-size: .8rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--fl);
  border: 1px solid var(--linie); min-height: var(--touch); padding: 8px 12px; width: 100%;
}
textarea { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--akzent); flex: none; }
input[type=file] { border: 0; padding: 0; min-height: 0; width: auto; }
.row select { width: auto; flex: 1; }
.check { display: flex; gap: 10px; align-items: center; min-height: var(--touch); }

.notice { background: var(--fl2); border-left: 4px solid var(--akzent); padding: 10px 14px; }
.notice-warn { background: var(--warn-bg); border-left-color: var(--warn-linie); }
.notice p:last-child { margin: 0; }
.empty { padding: 20px; text-align: center; color: var(--muted); background: var(--fl); border: 1px dashed var(--linie); }
.empty .btn { margin-top: 8px; }
.steps li { margin: 8px 0; font-size: 1.05rem; }

.list { list-style: none; margin: 0; padding: 0; background: var(--fl); border: 1px solid var(--linie); }
.list > li + li { border-top: 1px solid var(--linie); }
.list-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 60px; padding: 8px 14px;
  color: inherit; text-decoration: none; background: none; border: 0; font: inherit; text-align: left;
}
a.list-item:hover, button.list-item:hover { background: var(--fl2); cursor: pointer; }
.list-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list-main > * { overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: .75rem; padding: 2px 8px; background: var(--fl2); border: 1px solid var(--linie); white-space: nowrap; }
.st-bewertet { color: var(--ok); }
.st-übersprungen { text-decoration: line-through; color: var(--muted); }

.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 2px; padding: 14px; background: var(--fl); border: 1px solid var(--linie); border-left: 4px solid var(--akzent); color: inherit; text-decoration: none; min-height: 88px; }
.card:hover { border-color: var(--akzent); }

.section { background: var(--fl); border: 1px solid var(--linie); }
.section > summary { padding: 12px 14px; cursor: pointer; font-weight: 600; min-height: var(--touch); }
.section > .list { border-width: 1px 0 0; }
.section > p { padding: 0 14px 12px; }
.section-box { background: var(--fl); border: 1px solid var(--linie); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.section-box h2 { margin-top: 0; }

.tabs { display: flex; border-bottom: 1px solid var(--linie); overflow-x: auto; }
.tab { padding: 12px 16px; min-height: var(--touch); color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 600; }
.tab.active { color: var(--akzent); box-shadow: inset 0 -3px 0 var(--akzent); }

.avatar {
  --hue: 200;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; font-weight: 700; font-size: .9rem;
  color: #fff; background: hsl(var(--hue) 45% 40%);
}
.avatar-l { width: 96px; height: 96px; font-size: 2rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--linie); background: var(--fl); }
.table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.table th, .table td { padding: 6px 8px; border-bottom: 1px solid var(--linie); text-align: left; white-space: nowrap; }
.table th select { min-width: 150px; min-height: 40px; }

/* ---------- Anmeldung ---------- */

.auth { min-height: 100dvh; display: flex; align-items: flex-start; justify-content: center; padding: max(24px, env(safe-area-inset-top)) 16px 24px; background: var(--top); }
.auth-card { width: 100%; max-width: 440px; background: var(--fl); padding: 24px 20px; margin-top: 4vh; display: flex; flex-direction: column; gap: 14px; }
.auth-wide { max-width: 720px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; }
.lock-icon { width: 40px; height: 40px; background: var(--akzent); -webkit-mask: var(--i) center/contain no-repeat; mask: var(--i) center/contain no-repeat;
  --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'><rect x='4' y='11' width='16' height='10'/><path d='M8 11V7a4 4 0 0 1 8 0v4'/></svg>"); }
.pin-input { font-size: 2rem; letter-spacing: .5em; text-align: center; min-height: 64px; }

.print-sheet { border: 1px solid var(--linie); padding: 16px; background: var(--fl); }
.recovery-body { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.recovery-words { flex: 1; min-width: 240px; margin: 0; padding-left: 2.2em; columns: 2; column-gap: 2em; font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; }
@media (min-width: 560px) { .recovery-words { columns: 3; } }
.recovery-words li { padding: 2px 0; break-inside: avoid; }
.recovery-qr { image-rendering: pixelated; background: #fff; padding: 4px; }

/* ---------- Dialoge, Meldungen ---------- */

dialog.modal { margin: auto; width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--linie); padding: 0; background: var(--fl); color: var(--text); }
dialog.modal::backdrop { background: rgb(0 0 0 / .5); }
dialog.modal form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
dialog.modal h2 { margin: 0; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 1000;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
  max-width: calc(100% - 32px); padding: 12px 18px; background: #17212b; color: #fff; border-left: 4px solid var(--ok);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-fehler { border-left-color: #f97066; }
.update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 1001; display: flex; gap: 12px; align-items: center; justify-content: center; padding: 8px; background: var(--warn-bg); color: var(--text); }

/* ---------- Druck: nur das Wiederherstellungsblatt ---------- */

@media print {
  body.printing * { visibility: hidden; }
  body.printing .print-sheet, body.printing .print-sheet * { visibility: visible; }
  body.printing .print-sheet { position: absolute; left: 0; top: 0; width: 100%; border: 0; color: #000; background: #fff; }
  body.printing dialog.modal { position: static; border: 0; }
}
