:root {
    --ink: #1b1b1f;
    --muted: #5a5a66;
    --bg: #fafaf7;
    --surface: #ffffff;
    --border: #d9d9d2;
    --accent: #1a5fbf;
    --accent-ink: #ffffff;
    --warning-bg: #fff7d6;
    --warning-border: #d6b100;
    --ok-bg: #e7f5ec;
    --ok-border: #3a8a5c;
    --danger: #a8201a;
    --radius: 6px;
    --gap: 1rem;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { font-size: 17px; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header .brand {
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
    color: var(--ink);
}

.site-header nav a {
    margin-left: 1rem;
    color: var(--accent);
    text-decoration: none;
}

main {
    max-width: 780px;
    margin: 2rem auto;
    padding: 0 1.25rem;
}

h1 { font-size: 1.6rem; margin-top: 0; }
h2 { font-size: 1.2rem; }

p.lead { color: var(--muted); }

.callout {
    border: 1px solid var(--border);
    border-inline-start-width: 5px; /* RTL: Balken rechts */
    background: var(--surface);
    padding: 0.9rem 1rem;
    margin: 1.25rem 0;
    border-radius: var(--radius);
}
.callout.warning { border-inline-start-color: var(--warning-border); background: var(--warning-bg); }
.callout.ok { border-inline-start-color: var(--ok-border); background: var(--ok-bg); }
.callout.disclaimer { border-inline-start-color: var(--accent); background: var(--surface); font-size: 1.05rem; }
.callout ul { margin: 0.5rem 0 0 1.2rem; }
.callout code { background: rgba(0,0,0,0.05); padding: 0 0.25rem; border-radius: 3px; }

.upload-form, .confirm-form {
    background: var(--surface);
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.upload-form p, .confirm-form p { margin: 0 0 0.75rem; }

button, .button {
    display: inline-block;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}
button.secondary, .button.secondary {
    background: transparent;
    color: var(--accent);
}
button.link {
    background: transparent;
    border: 0;
    color: var(--accent);
    padding: 0;
    text-decoration: underline;
    cursor: pointer;
}
button.link.danger { color: var(--danger); }
button.danger:not(.link) { background: var(--danger); border-color: var(--danger); }

.actions { display: flex; gap: 0.75rem; margin-top: 1rem; align-items: center; }
form.inline { display: inline; }
.site-header nav button.nav-link { font-size: inherit; margin-left: 1rem; text-decoration: none; }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.code-form input[type="email"], .code-form input[type="text"] {
    width: 100%; max-width: 24rem; padding: 0.5rem; font-size: 1rem;
    border: 1px solid var(--border); border-radius: var(--radius);
}

.text-preview { margin: 1rem 0; }
.text-preview .reading {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 320px;
    overflow: auto;
}

.upload-form input[type="text"], .confirm-form input[type="text"] {
    display: block;
    width: 100%;
    max-width: 32rem;
    padding: 0.5rem 0.6rem;
    font: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.upload-form .helptext { display: block; color: var(--muted); font-size: 0.9rem; }

.language-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.6rem;
}
.language-list li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.language-list a {
    display: block;
    padding: 0.9rem 1rem;
    font-size: 1.25rem;
    text-decoration: none;
    color: var(--ink);
}
.language-list a:hover { background: var(--bg); }

.qr-section { margin-top: 2rem; }
.qr-section .qr { max-width: 220px; height: auto; display: block; background: white; padding: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); }
.link-label code { word-break: break-all; }

/* Lesetext (Übersetzung, Leichte Sprache, Vorschau): echte Absätze. */
.reading { overflow-wrap: break-word; }
.reading p { margin: 0 0 1em; }
.reading p:last-child { margin-bottom: 0; }
.reading > h2:first-child { margin-top: 0; }

.parent-read .reading {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    font-size: 1.1rem;
    line-height: 1.65;
    max-width: 38em; /* ca. 65–75 Zeichen pro Zeile */
}
/* Arabische Schrift braucht mehr Zeilenhöhe und etwas mehr Größe. */
.parent-read:is(:lang(ar), :lang(fa), :lang(ps)) .reading:not(:lang(de)) {
    font-size: 1.2rem;
    line-height: 1.9;
}
.parent-read .simple { margin-top: 1.5rem; }
.parent-read .nav-back { margin-top: 2rem; }
.parent-read .loading { color: var(--muted); font-style: italic; }

.docs-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.docs-table th, .docs-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.docs-table code { font-size: 0.85rem; }
.docs-table .doc-title { display: block; font-weight: 600; }
.docs-table .doc-id { display: block; font-size: 0.72rem; color: var(--muted); word-break: break-all; }
.docs-table td.actions { flex-wrap: wrap; margin-top: 0; }

.site-footer {
    max-width: 780px;
    margin: 3rem auto 2rem;
    padding: 1rem 1.25rem 0;
    color: var(--muted);
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
}
.site-footer .legal-links a { color: var(--muted); text-decoration: none; }
.site-footer .legal-links a:hover { text-decoration: underline; }

.legal h1 { margin-bottom: 1rem; }
.legal h2 { margin-top: 2rem; font-size: 1.15rem; }
.legal h3 { margin-top: 1.25rem; font-size: 1.02rem; }
.legal ul { padding-left: 1.25rem; }
.legal code { background: rgba(0,0,0,0.05); padding: 0 0.25rem; border-radius: 3px; }

/* Druckvorlage (/d/<uuid>/print/) */
.print-sheet {
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    margin-top: 1.5rem;
}
.print-qr { width: 60%; max-width: 300px; height: auto; display: block; margin: 0 auto 1rem; }
.scan-hints { list-style: none; padding: 0; margin: 0 auto; max-width: 34rem; }
.scan-hints li { margin: 0.35rem 0; font-size: 1.05rem; line-height: 1.5; text-align: center; }
.scan-hints li:lang(ar), .scan-hints li:lang(fa), .scan-hints li:lang(ps) { font-size: 1.15rem; }
.print-link { margin: 1rem 0 0; }
.print-link code { font-size: 0.85rem; word-break: break-all; }

/* Schmale Bildschirme (Eltern kommen per Smartphone) */
@media (max-width: 480px) {
    html { font-size: 16px; }
    main { margin: 1.25rem auto; padding: 0 0.9rem; }
    .site-header { padding: 0.75rem 0.9rem; flex-wrap: wrap; gap: 0.25rem 1rem; }
    .site-header nav a { margin-left: 0; margin-right: 1rem; }
    .parent-read .reading { padding: 0.9rem; }
    .docs-table thead { display: none; }
    .docs-table tr { display: block; border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
    .docs-table td { display: block; border: 0; padding: 0.2rem 0.75rem; }
}

@media print {
    @page { size: A4; margin: 15mm; }
    html { font-size: 12pt; }
    body { background: #fff; color: #000; }
    .site-header, .site-footer, .no-print { display: none !important; }
    main { max-width: none; margin: 0; padding: 0; }
    /* Kompakt auf die obere Seitenhälfte (≈ 130 mm) — so taugt es auch als halbe Seite. */
    .print-sheet {
        border: 0;
        padding: 0;
        margin: 0;
        break-inside: avoid;
    }
    .print-qr { width: 60mm; max-width: none; margin-bottom: 5mm; }
    .scan-hints li { font-size: 11pt; margin: 1.2mm 0; line-height: 1.35; }
    .scan-hints li:lang(ar), .scan-hints li:lang(fa), .scan-hints li:lang(ps) { font-size: 12pt; }
    .print-link { margin-top: 4mm; }
    .print-link code { font-size: 9pt; }
}
