:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #667085;
    --primary: #4057d6;
    --primary-dark: #3043ad;
    --border: #dce2ee;
    --danger: #b42318;
    --warning: #b54708;
    --success: #067647;
    --radius: 18px;
    --shadow: 0 12px 30px rgba(28, 39, 73, 0.08);
}

* { box-sizing: border-box; }
html { min-height: 100%; -webkit-text-size-adjust: 100%; }
button, a, label, input { -webkit-tap-highlight-color: transparent; }
button, .button, .option-card { touch-action: manipulation; }
body {
    margin: 0;
    min-height: 100dvh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
}
a { color: var(--primary); }
.shell { width: min(1080px, calc(100% - 32px)); margin-inline: auto; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.site-header { background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.header-inner { min-height: 66px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 900; text-decoration: none; color: var(--text); font-size: 1.15rem; display: grid; line-height: 1.05; }
.brand small { color: var(--muted); font-size: .68rem; font-weight: 700; margin-top: 4px; letter-spacing: .02em; }
.version { color: var(--muted); font-size: .86rem; }
main.shell { padding-block: 34px 60px; }
.site-footer { color: var(--muted); padding: 22px 0 calc(34px + env(safe-area-inset-bottom)); font-size: .88rem; }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(22px, 4vw, 38px);
    margin-bottom: 24px;
}
.narrow { max-width: 650px; }
.hero, .result-hero { display: grid; grid-template-columns: 1fr auto; gap: 30px; align-items: center; }
.hero h1, .result-hero h1 { margin: 4px 0 12px; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.05; }
.lead { font-size: 1.12rem; color: #3b455b; max-width: 720px; }
.diagnostic-title { margin: 0 0 12px; font-size: clamp(1.2rem, 2.5vw, 1.65rem); color: var(--primary-dark); }
.eyebrow { color: var(--primary); font-weight: 800; letter-spacing: .07em; text-transform: uppercase; font-size: .78rem; }
.hero-facts { display: grid; gap: 10px; min-width: 170px; }
.hero-facts div { background: #eef1ff; border-radius: 14px; padding: 12px 16px; }
.hero-facts strong, .hero-facts span { display: block; }
.hero-facts strong { font-size: 1.25rem; }
.hero-facts span { color: var(--muted); font-size: .82rem; }
.grid-2, .grid-3 { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.small-card { padding: 24px; }
.small-card h3 { margin-top: 0; }
.stack { display: grid; gap: 12px; }
label { font-weight: 700; }
input[type="text"], input:not([type]), .large-input {
    width: 100%; min-height: 54px; padding: 14px 16px; border: 1px solid #bfc8da; border-radius: 12px; font: inherit; font-size: 16px; background: #fff;
}
input:focus { outline: 3px solid rgba(64, 87, 214, .18); border-color: var(--primary); }
.field-hint, .muted { color: var(--muted); font-size: .9rem; }
.button {
    appearance: none; border: 0; border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 800;
    min-height: 52px; background: var(--primary); color: #fff; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.button:hover { background: var(--primary-dark); }
.button:disabled { opacity: .65; cursor: wait; }
.button-secondary { background: #eef1f7; color: var(--text); border: 1px solid var(--border); }
.button-secondary:hover { background: #e1e6ef; }
.actions { display: flex; gap: 12px; align-items: center; }
.actions form { margin: 0; }
.wrap { flex-wrap: wrap; }
.alert { padding: 15px 18px; border-radius: 12px; margin-bottom: 22px; border: 1px solid; }
.alert-error { background: #fff1f0; color: var(--danger); border-color: #f6c6c2; }
.alert-warning { background: #fff7ed; color: var(--warning); border-color: #fed7aa; }
.alert-success { background: #ecfdf3; color: var(--success); border-color: #abefc6; }
.progress-panel { margin-bottom: 22px; position: sticky; top: 0; z-index: 20; padding: 12px 0 10px; background: rgba(244,246,251,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.progress-meta { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.progress-track, .bar { height: 12px; background: #e5e9f2; border-radius: 999px; overflow: hidden; }
.progress-fill, .bar span { height: 100%; display: block; background: var(--primary); border-radius: inherit; }
.question-card { max-width: 900px; margin-inline: auto; }
.question-topline, .competency-heading, .competency-details { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.pill { padding: 6px 10px; border-radius: 999px; background: #eef1ff; color: var(--primary-dark); font-size: .82rem; font-weight: 800; }
.question-prompt { font-size: clamp(1.65rem, 4vw, 2.5rem); margin: 26px 0 10px; }
.instruction { color: var(--muted); margin-bottom: 22px; }
.option-list { display: grid; gap: 12px; }
.option-card { display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 15px 17px; border: 2px solid var(--border); border-radius: 14px; cursor: pointer; font-size: 1.03rem; user-select: none; -webkit-user-select: none; transition: border-color .15s ease, background .15s ease, transform .08s ease; }
.option-card:hover { border-color: var(--primary); background: #f8f9ff; }
.option-card:active { transform: scale(.995); }
.option-card.is-selected, .option-card:has(input:checked) { border-color: var(--primary); background: #eef1ff; box-shadow: 0 0 0 2px rgba(64,87,214,.10); }
.option-card input { width: 20px; height: 20px; accent-color: var(--primary); }
.question-actions { justify-content: space-between; margin-top: 28px; position: sticky; bottom: 0; z-index: 10; padding: 14px 0 max(4px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 24%); }
.score-ring {
    --score: 0;
    width: 145px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
    background: conic-gradient(var(--primary) calc(var(--score) * 1%), #e5e9f2 0);
    position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 13px; background: white; border-radius: 50%; }
.score-ring span { position: relative; font-size: 1.8rem; font-weight: 900; }
.competency-list { display: grid; gap: 14px; }
.competency-row { padding: 18px; border: 1px solid var(--border); border-left-width: 7px; border-radius: 14px; }
.competency-row h3 { margin: 0; }
.competency-row p { margin: 3px 0 0; color: var(--muted); }
.competency-heading > strong { font-size: 1.35rem; }
.competency-details { margin-top: 8px; color: var(--muted); font-size: .84rem; flex-wrap: wrap; }
.status-critical { border-left-color: #d92d20; }
.status-uncertain { border-left-color: #f79009; }
.status-mostly_secure { border-left-color: #2e90fa; }
.status-secure { border-left-color: #12b76a; }
.gap-note, .mixed-note, .strength-note { margin: 10px 0 0; color: #3b455b; font-size: .9rem; }
.mixed-note { border-left: 3px solid #f79009; padding-left: 10px; }
.strength-note { border-left: 3px solid #12b76a; padding-left: 10px; }
.recommendation-main { font-size: 1.35rem; font-weight: 900; color: var(--primary-dark); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
    .hero, .result-hero, .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .hero-facts { grid-template-columns: repeat(3, 1fr); min-width: 0; }
    .hero-facts div { padding: 10px; }
    .score-ring { width: 120px; }
    .question-topline, .progress-meta { align-items: flex-start; }
}

@media (max-width: 520px) {
    .shell { width: min(100% - 20px, 1040px); }
    main.shell { padding-top: 20px; }
    .card { padding: 20px; border-radius: 15px; }
    .hero-facts { grid-template-columns: 1fr; }
    .actions { align-items: stretch; flex-direction: column; }
    .actions > *, .actions form, .actions form button { width: 100%; }
    .question-actions { flex-direction: row; }
    .question-actions > * { width: auto; flex: 1; }
    .competency-heading { align-items: flex-start; }
}

@media print {
    @page { margin: 12mm; }
    body { background: white; font-size: 10.5pt; }
    .site-header, .site-footer, .no-print { display: none !important; }
    main.shell { padding: 0; width: 100%; }
    .card { box-shadow: none; padding: 14px 16px; margin-bottom: 10px; break-inside: auto; }
    .result-hero, .grid-2 { display: block; }
    .result-hero h1 { font-size: 24pt; }
    .result-hero .lead { font-size: 11pt; }
    .score-ring { width: 90px; float: right; margin: -78px 0 8px 18px; }
    .competency-list { gap: 8px; }
    .competency-row { padding: 10px 12px; break-inside: avoid; }
    .competency-row h3 { font-size: 13pt; }
    .bar { height: 7px; }
    .grid-2 .card { break-inside: avoid; }
    .alert { padding: 10px 12px; margin-bottom: 10px; }
}

input[type="password"], input[type="file"] {
    width: 100%; min-height: 54px; padding: 14px 16px; border: 1px solid #bfc8da; border-radius: 12px; font: inherit; font-size: 16px; background: #fff;
}
.check-row { display: flex; gap: 12px; align-items: flex-start; font-weight: 600; }
.check-row input { width: 20px; height: 20px; margin-top: 3px; flex: 0 0 auto; accent-color: var(--primary); }
.top-gap { margin-top: 18px; }
.summary-list { display: grid; gap: 8px; }
.summary-list > div { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.summary-list dt { font-weight: 800; }
.summary-list dd { margin: 0; }
code { background: #f1f3f8; padding: .12em .35em; border-radius: 5px; }


/* Tablet-Optimierung, insbesondere iPad Air im Hoch- und Querformat */
@media (min-width: 700px) and (max-width: 1200px) {
    .shell { width: min(94%, 1040px); }
    main.shell { padding-top: 28px; }
    .card { padding: clamp(28px, 4vw, 42px); }
    .question-card { max-width: 920px; }
    .question-prompt { font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.18; }
    .option-list { gap: 14px; }
    .option-card { min-height: 64px; padding: 17px 19px; font-size: 1.08rem; }
    .option-card input { width: 24px; height: 24px; }
    .button { min-height: 56px; padding-inline: 22px; }
    .large-input { min-height: 60px; font-size: 18px; }
}

@media (orientation: landscape) and (min-width: 900px) and (max-width: 1400px) {
    .question-card { max-width: 980px; }
    .hero { grid-template-columns: minmax(0, 1fr) 240px; }
}

.character-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.character-key {
    appearance: none;
    min-width: 46px;
    min-height: 46px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #f7f8fc;
    color: var(--text);
    font: inherit;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
}
.character-key:active { transform: scale(.97); }
.orthography-note { border-left: 3px solid #2e90fa; padding-left: 10px; margin-top: 10px; color: #3b455b; font-size: .9rem; }

@media (min-width: 700px) and (max-width: 1200px) {
    .character-key { min-width: 52px; min-height: 52px; font-size: 1.2rem; }
}
