/* Lehrgangstool – mobil zuerst, ruhig, gut lesbar */
:root {
  --accent: #b3261e;
  --accent-ink: #fff;
  --bg: #f4f3f1;
  --surface: #ffffff;
  --ink: #1b1b1a;
  --ink-2: #5d5b57;
  --line: #e2dfda;
  --line-2: #cfcbc4;
  --ok: #1f7a3f;
  --ok-bg: #e7f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --err: #a8201a;
  --err-bg: #fbe9e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
small, .muted { color: var(--ink-2); }
code { background: #efede9; padding: .1em .35em; border-radius: 4px; font-size: .9em; overflow-wrap: anywhere; }

/* ---------- Kopfzeile & Navigation */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; padding: .55rem 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .85rem; font-weight: 800; flex: none; }
.brand img { height: 30px; width: auto; max-width: 90px; object-fit: contain; }
.org-switch { margin-left: auto; }
.org-switch select { min-height: 38px; padding: .3rem 2rem .3rem .6rem; font-size: .9rem; max-width: 46vw; }
.menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; flex: none; }
.menu-btn span, .menu-btn span::before, .menu-btn span::after { display: block; width: 18px; height: 2px; background: var(--ink); position: relative; content: ""; }
.menu-btn span::before { position: absolute; top: -6px; } .menu-btn span::after { position: absolute; top: 6px; }
.nav { display: none; border-top: 1px solid var(--line); background: var(--surface); }
.nav.open { display: block; }
.nav a, .nav button { display: block; width: 100%; text-align: left; padding: .85rem 16px; color: var(--ink); text-decoration: none; border: 0; border-bottom: 1px solid var(--line); background: none; font: inherit; cursor: pointer; }
.nav a.active { color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav .nav-sep { padding: .6rem 16px .3rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
@media (min-width: 960px) {
  .menu-btn { display: none; }
  .org-switch { margin-left: 0; }
  .nav { display: block !important; border-top: 0; }
  .nav-inner { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: .1rem; padding: 0 10px; }
  .nav a, .nav button { width: auto; border: 0; padding: .6rem .55rem; font-size: .9rem; border-radius: 6px; }
  .nav form { display: contents; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
  .nav .nav-sep { display: none; }
  .nav .nav-right { margin-left: auto; }
}

/* ---------- Layout */
main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }
.narrow { max-width: 640px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; flex: 1 1 260px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } .span-2 { grid-column: span 2; } }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row-end { justify-content: flex-end; }
.spacer { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* ---------- Formulare */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.hint { font-size: .85rem; color: var(--ink-2); margin-top: .25rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=tel], input[type=file], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: .62rem .7rem; min-height: 46px;
}
input[type=file] { padding: .5rem; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 1px; border-color: var(--accent); }
input[type=color] { width: 64px; height: 46px; border: 1px solid var(--line-2); border-radius: 8px; padding: 3px; background: #fff; }
.check { display: flex; gap: .65rem; align-items: flex-start; font-weight: 400; padding: .55rem 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: .1rem 0 0; flex: none; accent-color: var(--accent); }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.choice label { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; padding: .4rem .7rem; text-align: center; line-height: 1.25; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font-weight: 600; cursor: pointer; margin: 0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice input:checked + span { color: var(--accent); }
.choice label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 7%, #fff); }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font-weight: 700; margin-bottom: .5rem; padding: 0; }

/* ---------- Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(.93); border-color: var(--accent); }
.card-danger { border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }
.card-danger h2 { color: var(--err); }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, #fff); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 36px; padding: .35rem .7rem; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
@media (max-width: 559px) { .actions-stack .btn { width: 100%; } }

/* ---------- Hinweise & Marker */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: .75rem; border: 1px solid; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, #fff); }
.flash-error { background: var(--err-bg); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, #fff); }
.flash-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, #fff); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #ecebe8; color: var(--ink-2); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-accent { background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); }

/* ---------- Tabellen: auf dem Handy als Karten */
.table-wrap { width: 100%; overflow-x: auto; }
table.tabelle { width: 100%; border-collapse: collapse; font-size: .94rem; }
.tabelle th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); font-weight: 700; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.tabelle td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tabelle tr:last-child td { border-bottom: 0; }
@media (max-width: 759px) {
  .tabelle thead { display: none; }
  .tabelle, .tabelle tbody, .tabelle tr, .tabelle td { display: block; width: 100%; }
  .tabelle tr { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .75rem; margin-bottom: .6rem; background: #fff; }
  .tabelle td { border: 0; padding: .3rem 0; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
  .tabelle td::before { content: attr(data-label); font-weight: 600; color: var(--ink-2); text-align: left; flex: none; max-width: 45%; }
  .tabelle td[data-label=""]::before { display: none; }
  .tabelle td.td-main { font-weight: 700; font-size: 1.02rem; text-align: left; display: block; }
  .tabelle td.td-main::before { display: none; }
  .tabelle td.td-actions { justify-content: flex-start; flex-wrap: wrap; }
  .tabelle td.empty { display: block; text-align: center; }
  .tabelle td.empty::before { display: none; }
  .tabelle td.td-actions::before { display: none; }
}

/* ---------- Session-Karten */
.list-cards { display: grid; gap: 12px; }
@media (min-width: 760px) { .list-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .list-cards { grid-template-columns: repeat(3, 1fr); } }
.sess { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.sess:hover { border-color: var(--line-2); }
.sess h3 { margin: .25rem 0 .2rem; font-size: 1.05rem; }
.sess .meta { font-size: .88rem; color: var(--ink-2); }
.stat { font-size: 1.6rem; font-weight: 800; line-height: 1; }

/* ---------- QR */
.qr-box { text-align: center; }
.qr-box img { width: 100%; max-width: 280px; height: auto; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.qr-full { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #fff; padding: 20px; }
.qr-full img { width: min(78vh, 92vw); height: auto; image-rendering: pixelated; }
.qr-full h1 { font-size: clamp(1.4rem, 4vw, 2.6rem); margin: 0 0 .5rem; }

/* ---------- Unterschriftsfeld */
.sigpad { border: 1px solid var(--line-2); border-radius: 10px; background: #fff; position: relative; touch-action: none; }
.sigpad canvas { display: block; width: 100%; height: 190px; border-radius: 10px; cursor: crosshair; touch-action: none; }
.sigpad .sig-line { position: absolute; left: 6%; right: 6%; bottom: 42px; border-top: 1px dashed #b9b4ac; pointer-events: none; }
.sigpad .sig-x { position: absolute; left: 4%; bottom: 46px; color: #b9b4ac; font-size: 1.1rem; pointer-events: none; }
.sigpad .sig-hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #a19c94; font-size: .85rem; pointer-events: none; }
.sigpad.signed .sig-hint { display: none; }
.sig-img { max-height: 80px; max-width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }

/* ---------- Öffentliches Formular */
.public-head { background: var(--surface); border-bottom: 3px solid var(--accent); }
.public-head .inner { max-width: 640px; margin: 0 auto; padding: 14px 16px; display: flex; gap: 12px; align-items: center; }
.public-head img { max-height: 54px; max-width: 120px; object-fit: contain; }
.public-head .org { font-weight: 700; }
.public-head .sub { font-size: .9rem; color: var(--ink-2); }
.step { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: .9rem; flex: none; }
.step h2 { margin: 0; }
.datenschutz { font-size: .85rem; color: var(--ink-2); background: #f8f7f5; border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; max-height: 180px; overflow: auto; }
.sticky-submit { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 10px; }

/* ---------- Editor */
.editor { display: grid; gap: 16px; }
@media (min-width: 1000px) { .editor { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } .editor-side { position: sticky; top: 120px; max-height: calc(100vh - 140px); overflow: auto; } }
.page-wrap { background: #dcd8d2; border-radius: 10px; padding: 12px; overflow: hidden; }
.page { position: relative; width: 100%; aspect-ratio: 595 / 842; background: #fff; background-size: 100% 100%; box-shadow: 0 2px 12px rgba(0,0,0,.15); margin: 0 auto; max-width: 820px; user-select: none; touch-action: none; overflow: hidden; }
.el { position: absolute; border: 1px dashed rgba(60, 90, 160, .45); color: #222; overflow: hidden; line-height: 1.3; white-space: pre-wrap; word-break: break-word; cursor: move; touch-action: none; }
.el.sel { border: 2px solid #2f5bd3; z-index: 5; background: rgba(47, 91, 211, .05); }
.el.zus { border-color: rgba(200, 120, 0, .7); }
.el .handle { position: absolute; right: -1px; bottom: -1px; width: 18px; height: 18px; background: #2f5bd3; border-radius: 3px 0 3px 0; cursor: nwse-resize; display: none; touch-action: none; }
.el.sel .handle { display: block; }
.el.linie { border: 0; border-top: 1.5px solid #555; height: 6px !important; }
.el.linie.sel { border-top: 2px solid #2f5bd3; }
.el.platz { display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11px; color: #4b5d8c; background: rgba(47,91,211,.06); font-family: var(--font); }
.el img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.prop-grid .field { margin-bottom: .4rem; }
.ph-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.ph-list button { font-size: .78rem; padding: .25rem .5rem; border: 1px solid var(--line-2); background: #fff; border-radius: 999px; cursor: pointer; }
.toolbar { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }

/* ---------- Diverses */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .94rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
details summary { cursor: pointer; font-weight: 600; padding: .4rem 0; }
.empty { text-align: center; color: var(--ink-2); padding: 2rem 1rem; }
.footer { text-align: center; font-size: .8rem; color: var(--ink-2); padding: 1rem; }
dialog { border: 0; border-radius: 12px; padding: 0; max-width: min(520px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .dlg { padding: 20px; }
iframe.preview { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
@media (max-width: 759px) { iframe.preview { height: 60vh; } }
.hide-mobile { display: none; }
@media (min-width: 760px) { .hide-mobile { display: initial; } .only-mobile { display: none; } }

/* Anwesenheit */
.tage-tabs { display: flex; gap: .4rem; overflow-x: auto; padding: 0 0 .6rem; margin-bottom: .4rem; -webkit-overflow-scrolling: touch; }
.tage-tabs a { flex: none; display: flex; flex-direction: column; align-items: center; min-width: 76px; padding: .45rem .6rem; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem; }
.tage-tabs a small { font-weight: 400; color: var(--ink-2); font-size: .78rem; }
.tage-tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tage-tabs a.active small { color: var(--accent-ink); opacity: .9; }
.anw-zeile { display: flex; align-items: center; gap: .8rem; padding: .7rem .2rem; border-top: 1px solid var(--line); cursor: pointer; min-height: 56px; transition: background .3s; }
.anw-zeile:first-of-type { border-top: 0; }
.anw-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.anw-name .muted { font-size: .85rem; }
.anw-zeile input { width: 30px; height: 30px; flex: none; accent-color: var(--ok); cursor: pointer; }
.anw-zeile.speichert { opacity: .6; }
.anw-zeile.gespeichert { background: var(--ok-bg); }
.tage-liste { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .6rem; border: 1px solid var(--line-2); border-radius: 999px; font-weight: 400; cursor: pointer; }
.tag-chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.anw-tage { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .2rem; }
.anw-tag { font-size: .72rem; padding: .05rem .4rem; border-radius: 6px; background: #ecebe8; color: var(--ink-2); white-space: nowrap; }
.anw-tag.da { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.anw-zelle { white-space: nowrap; }
@media (max-width: 759px) { .anw-zelle .anw-tage { justify-content: flex-end; } .tabelle td select { max-width: 62% !important; } }
