:root {
  --bg: #f4f6f8; --card: #fff; --text: #1d2430; --muted: #5d6878; --line: #d6dce3;
  --accent: #c62828; --accent-soft: #fde4e4; --primary: #1f5fa8; --ok: #2e7d32; --bad: #c62828;
  --region: #e9edf2; --region-line: #9aa6b4; --region-hover: #cfe0f5;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 1.55rem; margin: 8px 0 6px; }
h2 { font-size: 1.15rem; margin-top: 24px; }
a { color: var(--primary); }
.hint { color: var(--muted); margin: 4px 0 14px; }
.req { color: var(--accent); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: #1d2430; color: #fff; }
.top a, .top .linkbtn { color: #fff; text-decoration: none; margin-left: 16px; }
.brand { font-weight: 700; margin-left: 0 !important; }
.top nav { display: flex; align-items: center; }

fieldset { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px 18px; margin: 0 0 18px; }
legend { font-weight: 700; padding: 0 8px; font-size: 1.05rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.fld.wide { grid-column: 1 / -1; }
.fld input, .fld select, .fld textarea {
  font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.fld.err input, .fld.err select, .fld.err textarea, .fld.err-js input { border-color: var(--bad); background: #fff6f6; }
.errmsg { color: var(--bad); }

.btn { font: inherit; display: inline-block; padding: 9px 18px; border-radius: 6px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--primary); }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.linkbtn { font: inherit; background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; text-decoration: underline; }
.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 8px; }
.actions.secondary { justify-content: flex-start; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.check { display: flex; align-items: center; gap: 6px; }

.flash { padding: 10px 14px; border-radius: 6px; margin: 0 0 14px; background: #e8f0fb; }
.flash.ok { background: #e6f4e7; color: #1b5e20; }
.flash.error { background: #fdecec; color: #8e1c1c; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .8rem; }
.badge.good { background: #e6f4e7; color: #1b5e20; }
.badge.bad { background: #fdecec; color: #8e1c1c; }

/* Körperschema */
.injury { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 24px; align-items: start; }
.bodymap svg { width: 100%; max-width: 300px; display: block; margin: 0 auto; user-select: none; }
.bodymap .hint { font-size: .85rem; }
.region { fill: var(--region); stroke: var(--region-line); stroke-width: 1.4; cursor: pointer; transition: fill .12s; }
.region:hover { fill: var(--region-hover); }
.region:focus { outline: none; }
.region:focus-visible { stroke: var(--primary); stroke-width: 3; }
.region.on { fill: var(--accent); stroke: #8e1c1c; }
.region.on:hover { fill: #e04848; }
.side { font: 700 20px system-ui, sans-serif; fill: #9aa6b4; }
.maptools { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.regions { border-collapse: collapse; width: 100%; font-size: .88rem; margin-bottom: 10px; }
.regions th, .regions td { padding: 3px 8px; border-bottom: 1px solid #eef1f4; text-align: center; }
.regions th:first-child, .regions td:first-child { text-align: left; }
.regions th { color: var(--muted); font-weight: 600; }
.regions input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.chip { font: inherit; font-size: .82rem; background: var(--accent-soft); color: #8e1c1c; border: 1px solid #f3b9b9; border-radius: 14px; padding: 2px 10px; cursor: pointer; }

/* Karten, Listen */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.narrow .fld { margin-bottom: 12px; }
.copy { display: flex; gap: 8px; margin-bottom: 12px; }
.copy input { flex: 1; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
.listhead { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
.listhead h1 { margin-right: auto; }
.search { display: flex; gap: 6px; }
.search input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; min-width: 240px; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list th, table.list td { padding: 8px 10px; border-bottom: 1px solid #eef1f4; text-align: left; vertical-align: top; }
table.list th { background: #eef2f6; font-size: .85rem; color: var(--muted); }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #f7f9fc; }
.small { font-size: .85rem; color: var(--muted); }
.meta p { color: var(--muted); margin: 0 0 14px; }

@media (max-width: 720px) {
  .injury { grid-template-columns: 1fr; }
  .bodymap svg { max-width: 240px; }
}
@media print {
  .top, .actions, .actions.secondary, .maptools, .hint, #draft-note, .chips { display: none !important; }
  body { background: #fff; }
  fieldset { break-inside: avoid; }
}

/* Auswahl-Pills */
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill { position: relative; cursor: pointer; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--text); font-size: .88rem; transition: background .12s; }
.pill:hover span { border-color: var(--primary); }
.pill input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.pill input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.pill-other { font: inherit; font-size: .88rem; padding: 5px 12px; border: 1px dashed var(--line); border-radius: 16px; min-width: 160px; flex: 1 1 160px; max-width: 320px; }
.pill-other:focus { outline: 2px solid var(--primary); border-style: solid; }
.fld small { font-weight: normal; }

/* Koordinaten */
.coord-row { display: flex; gap: 8px; }
.coord-row input { flex: 1; }
.coord-row .btn { white-space: nowrap; }
.coord-info { min-height: 1.2em; font-size: .85rem; }
.coord-info.good { color: #1b5e20; }
.coord-info.bad { color: var(--bad); }
@media (max-width: 560px) { .coord-row { flex-direction: column; } }
@media print { .pill input:not(:checked) + span { display: none; } .pill-other:placeholder-shown { display: none; } #geo { display: none; } }
