/* ADHS-Digital – Mobile-first, große Tap-Flächen, hell/dunkel */
:root {
  --bg: #f4f6f9; --card: #ffffff; --text: #1b1f24; --muted: #5d6673; --line: #d9dee5;
  --primary: #1d4e89; --primary-text: #ffffff; --primary-soft: #e3ecf7;
  --accent: #2a9d8f; --danger: #b42318; --danger-soft: #fde8e6; --warn: #b7791f; --warn-soft: #fff4dc; --ok: #1e7f4f; --ok-soft: #e3f5ea;
  --sel: #1d4e89; --sel-text: #fff; --radius: 14px; --tap: 48px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --v0: #e8eef5; --v1: #cfe3f2; --v2: #f7d9b5; --v3: #f2b8ad;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f1419; --card: #171d25; --text: #e8edf3; --muted: #99a4b2; --line: #2a3340; --primary: #6ea8e6; --primary-text: #0f1419; --primary-soft: #1b2a3d; --sel: #6ea8e6; --sel-text: #0f1419; --danger: #ff8a80; --danger-soft: #3a1c1a; --warn: #f2c261; --warn-soft: #3a2d12; --ok: #7dd3a0; --ok-soft: #14301f; --v0: #202a36; --v1: #1f3a55; --v2: #5a3d16; --v3: #6b2420; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 17px; line-height: 1.45; background: var(--bg); color: var(--text); min-height: 100dvh; }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
p { margin: 0 0 .8rem; }
a { color: var(--primary); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; word-break: break-all; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; left: -9999px; }
.container { max-width: 860px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.narrow { max-width: 460px; }
.center { margin: 10vh auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; min-height: 52px; }
.topbar .brand { font-weight: 700; }
.topbar .brand a { color: inherit; text-decoration: none; }
.topbar .case { margin-left: auto; color: var(--muted); font-size: .9rem; }
.topbar .back { text-decoration: none; font-weight: 600; white-space: nowrap; }
.topbar .form-title-bar { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { font-size: .8rem; color: var(--muted); min-width: 80px; text-align: right; }
.save-state.err { color: var(--danger); }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid var(--line); }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.alert.success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.big { width: 100%; font-size: 1.1rem; min-height: 56px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
form.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 160px; }
label { display: block; font-weight: 600; font-size: .95rem; }
label small { display: block; font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); margin-top: 4px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .opt:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }
.pin-input { font-size: 2rem; letter-spacing: .5em; text-align: center; min-height: 64px; }
.pin-form { display: flex; flex-direction: column; gap: 14px; }

/* Portal */
.form-list { list-style: none; padding: 0; margin: 0; counter-reset: f; }
.form-entry .form-title { font-weight: 700; font-size: 1.1rem; }
.form-entry .form-sub { color: var(--muted); font-size: .9rem; }
.form-entry .form-meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.sub-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.sub-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sub-list .who { font-weight: 600; min-width: 70px; }
.sub-list .status { color: var(--muted); font-size: .9rem; flex: 1; }
.sub-list .status.completed { color: var(--ok); }
.sub-list .btn { margin-left: auto; }
.start-form { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; flex-wrap: wrap; }
.start-form label { flex: 1 1 160px; margin: 0; }
.start-form .btn { flex: 0 0 auto; }
.consent p { font-size: .98rem; }

/* Progress */
.progress { height: 5px; background: var(--line); position: sticky; top: 52px; z-index: 4; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* Fill */
.fill .instructions { white-space: pre-line; }
.fill .page-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: .9rem; margin: 4px 0 10px; }
.fill .section-title { color: var(--primary); font-weight: 700; margin: 6px 0 10px; font-size: 1.05rem; }
.fill .section-intro { color: var(--muted); font-size: .95rem; margin-bottom: 10px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.item.missing { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.item.info { background: transparent; box-shadow: none; border-style: dashed; color: var(--muted); }
.item .q { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.item .num { color: var(--muted); font-weight: 600; min-width: 2.2em; font-size: .9rem; padding-top: 2px; }
.item .text { flex: 1; font-weight: 500; }
.item .hint { display: block; color: var(--muted); font-size: .9rem; font-weight: 400; margin-top: 4px; }
.item .optional { color: var(--muted); font-size: .8rem; font-weight: 400; }
.opts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.opts.vertical { grid-template-columns: 1fr; }
.opt { min-height: var(--tap); padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: .98rem; cursor: pointer; display: flex; align-items: center; gap: 10px; text-align: left; -webkit-tap-highlight-color: transparent; }
.opt .v { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .9rem; flex: 0 0 auto; }
.opt[aria-pressed="true"] { background: var(--sel); color: var(--sel-text); border-color: var(--sel); }
.opt[aria-pressed="true"] .v { background: rgba(255,255,255,.25); color: inherit; }
.opt.na { border-style: dashed; color: var(--muted); }
.opt:disabled { cursor: default; opacity: .75; }
.rowblock { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.rowblock:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.rowblock .rowlabel { font-weight: 600; margin-bottom: 8px; }
.intensity { margin-top: 10px; }
.intensity .scale-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.intensity .opts { grid-template-columns: repeat(9, 1fr); gap: 5px; }
.intensity .opt { padding: 0; justify-content: center; min-height: 44px; border-radius: 10px; }
.describe { margin-top: 10px; }
.describe label { font-weight: 500; color: var(--muted); }
.unit { display: flex; gap: 8px; align-items: center; }
.unit input { flex: 1; }
.unit .seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.unit .seg .opt { border: 0; border-radius: 0; min-height: var(--tap); padding: 0 14px; }
.unit .suffix { color: var(--muted); white-space: nowrap; }
.sentence .stem { font-style: italic; margin-bottom: 6px; }
.table-act .none { margin-bottom: 10px; }
.table-act .trow { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.table-act .trow .rl { font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.table-act .rating { margin-top: 8px; }
.table-act .rating .rlabel { font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.marklist .opt { white-space: normal; }
.nav { display: flex; gap: 10px; margin-top: 18px; }
.nav .btn { flex: 1; }
.nav .spacer { flex: 1; }
.done { text-align: center; padding: 30px 10px; }
.done h1 { font-size: 1.8rem; }
.loading { color: var(--muted); text-align: center; padding: 30px; }
.missing-box { margin-bottom: 12px; }

/* Kind-Modus */
.mode-single body, body.mode-single { font-size: 19px; }
.mode-single .fill .item { border: 0; box-shadow: none; background: transparent; padding: 0; }
.mode-single .item .q { flex-direction: column; gap: 6px; margin-bottom: 20px; }
.mode-single .item .text { font-size: 1.35rem; font-weight: 600; line-height: 1.35; }
.mode-single .item .num { font-size: .85rem; }
.mode-single .opts { grid-template-columns: 1fr; gap: 12px; }
.mode-single .opt { min-height: 64px; font-size: 1.15rem; padding: 14px 16px; border-width: 2px; border-radius: 16px; }
.mode-single .opt .v { width: 34px; height: 34px; font-size: 1rem; }
.mode-single .intensity .opts { grid-template-columns: repeat(9, 1fr); gap: 6px; }
.mode-single .intensity .opt { min-height: 54px; font-size: 1.05rem; }
.mode-single .stem-info { color: var(--muted); font-size: 1rem; margin-bottom: 8px; }
.mode-single .rowblock .rowlabel { font-size: 1.15rem; color: var(--primary); }
.mode-single .nav { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); }
.mode-single .dots { color: var(--muted); font-size: .95rem; text-align: center; margin-bottom: 10px; }
.mode-single .practice-badge { display: inline-block; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 2px 10px; font-size: .85rem; margin-bottom: 8px; }

/* Admin */
.admin body, body.admin { font-size: 15.5px; }
.admin-bar nav { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.admin-bar nav a { text-decoration: none; font-weight: 600; color: var(--muted); }
.admin-bar nav a.active { color: var(--primary); }
.admin-main { max-width: 1100px; }
.two-col { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1.4fr 1fr; } }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.table.small { font-size: .85rem; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .btn { margin-left: 4px; }
.table.links code.link { display: inline-block; max-width: 100%; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pin-display { font-size: 1.6rem; font-weight: 800; letter-spacing: .25em; font-family: ui-monospace, Menlo, monospace; }
.danger-zone { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.assign fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 12px; padding: 10px 14px; }
.assign legend { font-weight: 700; padding: 0 6px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; padding: 6px 0; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 0; }
details.card summary { cursor: pointer; font-weight: 600; }
.eval-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.eval-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.flags { border-color: var(--danger); background: var(--danger-soft); }
.flags h2 { color: var(--danger); }
.table.answers tr.sec th { background: var(--primary-soft); color: var(--primary); padding-top: 12px; }
.table.answers td.num { color: var(--muted); white-space: nowrap; width: 4em; }
.table.answers td.ans { width: 32%; }
.table.answers tr.hidden-item { opacity: .55; }
.table.answers tr.flagged td { background: var(--danger-soft); }
.table.answers .free { margin-top: 4px; font-style: italic; color: var(--muted); }
.mini { margin: 0; padding-left: 0; list-style: none; }
.mini li { padding: 2px 0; }
.mini .rowlab { color: var(--muted); margin-right: 6px; }
.val { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--v0); }
.val[data-level="1"] { background: var(--v1); }
.val[data-level="2"] { background: var(--v2); }
.val[data-level="3"] { background: var(--v3); }
.val.text { background: transparent; padding: 0; }
.scores td.num { font-size: 1.05rem; }
.scores input { min-height: 34px; padding: 4px 8px; margin: 0; width: 100%; }
.print-only { display: none; }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .topbar, .no-print, .admin-bar, .btn, form.inline, .back { display: none !important; }
  .print-only { display: table-cell; }
  .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 14pt; break-inside: avoid; }
  .table th, .table td { padding: 3pt 4pt; }
  .table.answers tr.hidden-item { opacity: 1; color: #777; }
  .val { border: 1px solid #ccc; }
  a { color: inherit; text-decoration: none; }
}
@media (max-width: 600px) {
  .table.links td, .table.links th { display: block; }
  .table .actions { text-align: left; white-space: normal; }
  .eval-head .actions { width: 100%; }
}

/* ---- Admin: Fallseite, Links, Feinschliff */
.admin .container { padding: 20px 24px 40px; }
.admin h1 { font-size: 1.6rem; letter-spacing: -0.01em; margin: 2px 0 8px; }
.admin h2 { font-size: 1.05rem; margin: 0; }
.admin .card { padding: 20px 22px; border-radius: 16px; margin-bottom: 18px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .back { display: inline-block; margin-bottom: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill.muted-pill { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.btn.ghost { background: transparent; }
.admin .btn { min-height: 40px; padding: 8px 14px; border-radius: 10px; font-size: .92rem; }
.admin .btn.small { min-height: 34px; padding: 5px 12px; font-size: .85rem; }
.admin .btn.primary:hover { filter: brightness(1.08); }
.flash { border-left: 4px solid var(--ok); }
.link-list { display: flex; flex-direction: column; }
.link-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.link-row:first-child { border-top: 0; padding-top: 4px; }
.link-row.empty .link-main { color: var(--muted); }
.role-badge { display: inline-block; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.role-badge.role-kind { background: #e6f4ee; color: #1e7f4f; }
.role-badge.role-arzt { background: #f3e9fb; color: #6b3fa0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .role-badge.role-kind { background: #14301f; color: #7dd3a0; } :root:not([data-theme="light"]) .role-badge.role-arzt { background: #2a1d3d; color: #c9a7f0; } }
.input-copy { display: flex; gap: 8px; align-items: center; }
.input-copy input { flex: 1; min-height: 40px; margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; color: var(--muted); background: var(--bg); }
.link-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.table.clean th { border-bottom: 2px solid var(--line); text-transform: uppercase; letter-spacing: .04em; font-size: .75rem; }
.table.clean td { padding: 10px 8px; }
.table.clean tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.assign fieldset { border-radius: 12px; }
.check span { line-height: 1.3; }
code { overflow-wrap: anywhere; }
.danger-zone { border-top: 0; margin-top: 4px; text-align: right; }
@media (max-width: 760px) {
  .link-row { grid-template-columns: 1fr; gap: 8px; }
  .link-actions { justify-content: flex-start; }
  .input-copy { flex-wrap: wrap; }
  .input-copy input { flex-basis: 100%; }
}

/* ---- Portal: Fortschritt, abgeschlossene Bögen */
.overall { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; color: var(--muted); font-size: .95rem; }
.overall progress { flex: 1; height: 8px; accent-color: var(--accent); }
details.done-list { margin-top: 10px; }
details.done-list summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 10px 4px; }
details.done-list .form-entry { opacity: .85; }
/* ---- Abschluss */
.check-mark { width: 84px; height: 84px; border-radius: 50%; background: var(--ok-soft); margin: 0 auto 16px; position: relative; }
.check-mark::after { content: ""; position: absolute; left: 30px; top: 16px; width: 20px; height: 40px; border: solid var(--ok); border-width: 0 6px 6px 0; transform: rotate(45deg); }
.mode-single .fill .check-mark { width: 120px; height: 120px; }
.mode-single .fill .check-mark::after { left: 44px; top: 24px; width: 28px; height: 56px; border-width: 0 8px 8px 0; }
.btn.speak::before { content: "🔊"; margin-right: 4px; }
.section-title.muted { color: var(--muted); font-size: .9rem; font-weight: 600; }
/* ---- Auswertung: Filter + fixierte Köpfe */
.filter-high { margin-bottom: 10px; }
.table.answers.only-high tbody tr:not(.sec):not(:has(.val[data-level="2"], .val[data-level="3"])) { display: none; }
.table.scores thead th, .table.answers tr.sec th { position: sticky; top: 52px; background: var(--card); z-index: 1; }
.table.answers tr.sec th { background: var(--primary-soft); }
.intro-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.intro-sub { color: var(--muted); margin-bottom: 14px; }
.instructions-box h2 { margin-top: 10px; font-size: 1rem; color: var(--primary); }
.instructions-box .instructions { font-size: 1rem; line-height: 1.55; margin-bottom: 16px; }
