:root {
    --ink: #20213a;
    --muted: #6f7188;
    --primary: #5d5bd8;
    --primary-dark: #4846b9;
    --soft: #f0efff;
    --page: #f7f8fc;
    --card: #fff;
    --line: #e6e7ef;
    --success: #1f9d71;
    --danger: #d64d68;
    --shadow: 0 18px 50px rgba(38, 39, 75, .09);
    font-family: Inter, ui-rounded, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--page); line-height: 1.55; }
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.08; letter-spacing: -.04em; }
h2 { letter-spacing: -.025em; }
.site-header { min-height: 72px; padding: 12px max(20px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.93); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.brand, .header-user { display: flex; align-items: center; gap: 12px; font-weight: 750; }
.brand-mark { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, #766ff1, #4f4bc5); box-shadow: 0 8px 18px rgba(93,91,216,.25); }
.header-user { font-size: .92rem; color: var(--muted); }
.link-button { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 5px; }
.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 38px 0 70px; }
.hero { padding: 42px 0 35px; max-width: 760px; }
.dashboard-hero { padding-bottom: 25px; }
.hero h1 { margin-bottom: 14px; }
.eyebrow { color: var(--primary); font-weight: 800; text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; margin-bottom: 10px; }
.muted { color: var(--muted); }
.section-heading, .admin-title, .test-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.section-heading h2, .admin-title h1, .test-head h1 { margin-bottom: 0; }
.section-heading > span { color: var(--muted); font-size: .9rem; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(275px, 1fr)); gap: 20px; }
.learning-filter-panel { margin-bottom: 36px; background: white; border: 1px solid var(--line); border-radius: 24px; padding: clamp(20px, 4vw, 32px); box-shadow: 0 10px 35px rgba(35,36,70,.05); }
.filter-step + .filter-step { margin-top: 26px; padding-top: 26px; border-top: 1px solid var(--line); }
.filter-step-title { margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.filter-step-title > div { display: grid; }
.filter-step-title small { color: var(--muted); font-weight: 500; }
.step-number { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 11px; background: var(--soft); color: var(--primary); font-weight: 850; }
.class-picker, .subject-filter { display: flex; flex-wrap: wrap; gap: 10px; }
.class-button, .subject-filter-button { min-height: 46px; padding: 9px 17px; border: 1.5px solid var(--line); border-radius: 13px; background: white; color: var(--ink); font-weight: 750; cursor: pointer; transition: .16s ease; }
.class-button:hover, .subject-filter-button:hover { border-color: #b9b7ec; background: #fafaff; }
.class-button.is-active, .subject-filter-button.is-active { border-color: var(--primary); background: var(--primary); color: white; box-shadow: 0 7px 15px rgba(93,91,216,.2); }
.dashboard-tests { scroll-margin-top: 95px; }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 20px; box-shadow: 0 8px 30px rgba(35,36,70,.045); display: flex; gap: 16px; transition: .2s ease; }
.set-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.subject-badge { flex: 0 0 48px; height: 48px; border-radius: 16px; background: var(--soft); color: var(--primary); display: grid; place-items: center; font-weight: 850; text-transform: uppercase; }
.set-card-body { min-width: 0; flex: 1; }
.set-card h3 { margin: 7px 0; font-size: 1.2rem; }
.set-card p { color: var(--muted); font-size: .92rem; min-height: 44px; }
.progress-summary { margin: 16px 0 12px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.progress-stat { min-width: 0; padding: 11px; display: flex; align-items: center; gap: 9px; border-radius: 14px; background: #f7f7fb; }
.progress-stat-icon { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 10px; color: white; font-weight: 850; }
.grade-stat .progress-stat-icon { background: #e8a838; }
.mastered-stat .progress-stat-icon { background: var(--success); }
.progress-stat > span:last-child { min-width: 0; display: grid; line-height: 1.2; }
.progress-stat small { color: var(--muted); font-size: .65rem; font-weight: 700; }
.progress-stat strong { font-size: 1.08rem; }
.progress-stat em { overflow: hidden; color: var(--muted); font-size: .65rem; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.mastery-bar { height: 7px; margin-bottom: 14px; overflow: hidden; border-radius: 99px; background: #e8e9f0; }
.mastery-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #33b786, #6bd0aa); }
.meta-row, .set-facts { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .78rem; }
.set-facts { padding: 10px 0 18px; border-top: 1px solid var(--line); }
.btn { border: 0; border-radius: 13px; min-height: 46px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; cursor: pointer; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: white; background: var(--primary); box-shadow: 0 8px 18px rgba(93,91,216,.2); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #ececf3; color: var(--ink); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.btn-large { min-height: 55px; font-size: 1.05rem; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.login-wrap { min-height: calc(100vh - 150px); display: grid; place-items: center; }
.login-card { width: min(460px, 100%); padding: clamp(28px, 6vw, 48px); background: white; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); text-align: center; }
.hero-icon { width: 60px; height: 60px; margin: 0 auto 20px; border-radius: 20px; display: grid; place-items: center; font-size: 1.7rem; color: #fff; background: linear-gradient(135deg, #f59f75, #6b60e7); }
.stack-form { display: grid; gap: 10px; margin-top: 25px; text-align: left; }
.stack-form .btn { margin-top: 10px; }
label { font-weight: 700; font-size: .9rem; }
.input { width: 100%; border: 1.5px solid #dfe0ea; background: white; border-radius: 13px; padding: 12px 14px; color: var(--ink); outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(93,91,216,.1); }
.input-large { min-height: 55px; font-size: 1.08rem; }
.quiet-link { display: inline-block; margin-top: 25px; color: var(--muted); font-size: .85rem; }
.auth-switch { margin: 22px 0 0; color: var(--muted); font-size: .9rem; }
.auth-switch a { color: var(--primary); font-weight: 800; }
.alert { padding: 15px 18px; border-radius: 14px; margin-bottom: 22px; }
.alert ul { margin-bottom: 0; }
.alert-success { background: #e5f8f1; color: #147352; }
.alert-error { background: #fff0f2; color: #a62e49; }
.empty-state { padding: 50px 25px; text-align: center; color: var(--muted); background: white; border: 1px dashed #d3d4df; border-radius: 22px; }
.empty-state > span { font-size: 2.5rem; }
.history-section, .review-section { margin-top: 50px; }
.table-card, .panel { background: white; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.history-row { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-row small, .table-row small { display: block; color: var(--muted); }
.score-pill, .counter-pill { padding: 7px 11px; border-radius: 99px; background: var(--soft); color: var(--primary); font-weight: 800; white-space: nowrap; }
.test-head { align-items: center; }
.test-head h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); }
.test-head-actions { display: flex; align-items: center; gap: 10px; }
.test-head-actions form { margin: 0; }
.test-cancel-button { color: #a62e49; background: #fff0f3; }
.progress-track { height: 9px; background: #e5e5ef; border-radius: 99px; overflow: hidden; margin-bottom: 28px; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #6c65e7, #8b83f4); transition: width .25s ease; }
.question-card { display: none; min-height: 440px; background: white; border: 1px solid var(--line); border-radius: 26px; padding: clamp(24px, 5vw, 48px); box-shadow: var(--shadow); }
.question-card.is-active { display: block; animation: appear .22s ease; }
@keyframes appear { from { opacity: 0; transform: translateY(7px); } }
.question-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 30px; }
.question-number { color: var(--primary); font-weight: 800; }
.difficulty { padding: 6px 10px; border-radius: 99px; font-size: .75rem; font-weight: 800; background: #f0f1f5; }
.difficulty-leicht { color: #167753; background: #e6f7f0; }
.difficulty-schwer { color: #a13d55; background: #fff0f3; }
.question-text { font-size: clamp(1.3rem, 3.5vw, 2rem); line-height: 1.4; margin-bottom: 30px; }
.cloze-text { font-weight: 700; }
.cloze-slot { min-width: 132px; min-height: 43px; margin: 4px 5px; padding: 4px; display: inline-flex; vertical-align: middle; align-items: center; justify-content: center; border: 2px dashed #aaa8df; border-radius: 11px; background: #fafaff; }
.cloze-slot.is-filled { border-style: solid; border-color: var(--primary); background: var(--soft); }
.cloze-placeholder { color: #9a9bae; font-size: .72rem; font-weight: 600; }
.cloze-slot.is-filled .cloze-placeholder { display: none; }
.cloze-bank { min-height: 76px; padding: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; border: 1.5px solid var(--line); border-radius: 16px; background: #f8f8fc; }
.cloze-token { padding: 9px 13px; border: 1.5px solid #cac9ed; border-radius: 11px; background: white; color: var(--ink); font-weight: 750; cursor: grab; box-shadow: 0 3px 9px rgba(38,39,75,.06); }
.cloze-token:hover { border-color: var(--primary); }
.cloze-token.is-dragging { opacity: .45; }
.cloze-slot .cloze-token { cursor: pointer; box-shadow: none; }
.inline-input { width: 150px; max-width: 45vw; border: 0; border-bottom: 3px solid var(--primary); padding: 4px 8px; text-align: center; outline: none; }
.choice-list { display: grid; gap: 12px; }
.choice-two { grid-template-columns: repeat(2, 1fr); }
.choice-option { min-height: 58px; padding: 14px 16px; display: flex; align-items: center; gap: 13px; border: 1.5px solid var(--line); border-radius: 15px; cursor: pointer; transition: .15s; }
.choice-option:hover { border-color: #b7b5ee; background: #fafaff; }
.choice-option:has(input:checked) { border-color: var(--primary); background: var(--soft); }
.choice-option input { position: absolute; opacity: 0; }
.choice-control { width: 22px; height: 22px; flex: 0 0 22px; border: 2px solid #c3c4d0; border-radius: 7px; background: white; }
input[type="radio"] + .choice-control { border-radius: 50%; }
.choice-option input:checked + .choice-control { border: 6px solid var(--primary); }
.answer-label { display: grid; gap: 9px; }
.answer-area { resize: vertical; min-height: 130px; }
.matching-grid { display: grid; gap: 12px; }
.match-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; padding: 12px; background: #fafafe; border-radius: 14px; }
.match-row > span { color: var(--muted); font-weight: 500; }
.instruction { color: var(--muted); }
.sortable-list { padding: 0; margin: 0; list-style: none; display: grid; gap: 10px; counter-reset: order; }
.sortable-item { counter-increment: order; display: flex; align-items: center; gap: 12px; padding: 13px; border: 1.5px solid var(--line); border-radius: 14px; background: white; cursor: grab; }
.sortable-item::before { content: counter(order); width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--soft); color: var(--primary); font-weight: 800; }
.sortable-item.is-dragging { opacity: .45; }
.drag-handle { color: #a7a8b7; }
.sortable-label { flex: 1; }
.sort-buttons { display: flex; gap: 5px; }
.sort-buttons button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: #eeeef5; cursor: pointer; }
.test-navigation { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.test-navigation .btn { min-width: 130px; }
.result-hero { display: flex; align-items: center; justify-content: center; gap: clamp(30px, 7vw, 80px); padding: 40px 0; }
.result-ring { --score: 0; flex: 0 0 190px; width: 190px; height: 190px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--primary) calc(var(--score) * 1%), #e8e8f2 0); position: relative; }
.result-ring::after { content: ""; position: absolute; inset: 16px; border-radius: 50%; background: white; }
.result-ring > div { position: relative; z-index: 1; display: grid; text-align: center; }
.result-ring strong { font-size: 2.25rem; }
.result-ring span { color: var(--muted); }
.grade-badge { display: inline-block; padding: 9px 16px; border-radius: 99px; background: #fff0d7; color: #8d5f14; font-weight: 850; }
.review-list { display: grid; gap: 14px; }
.review-card { padding: 20px; border: 1px solid var(--line); border-left-width: 5px; border-radius: 16px; background: white; display: flex; gap: 16px; }
.review-correct { border-left-color: var(--success); }
.review-wrong { border-left-color: var(--danger); }
.review-status { flex: 0 0 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: white; font-weight: 900; background: var(--danger); }
.review-correct .review-status { background: var(--success); }
.review-card h3 { margin: 5px 0 12px; }
.review-card p { margin-bottom: 7px; }
.explanation { padding: 11px 13px; background: #f7f7fb; border-radius: 10px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { padding: 22px; display: grid; background: white; border: 1px solid var(--line); border-radius: 18px; }
.stat-card strong { font-size: 1.8rem; }
.stat-card span { color: var(--muted); }
.admin-title { align-items: center; margin-bottom: 28px; }
.admin-title h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.admin-actions, .task-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-actions form, .task-actions form { margin: 0; }
.admin-table { overflow-x: auto; }
.table-head, .table-row { min-width: 720px; display: grid; grid-template-columns: 2fr 1fr .6fr .6fr; align-items: center; gap: 18px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.table-head { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; background: #fafafe; }
.table-row:last-child { border-bottom: 0; }
.status { padding: 5px 9px; border-radius: 99px; font-size: .75rem; background: #eeeef3; }
.status-ready { color: #147352; background: #e5f8f1; }
.status-failed { color: #a62e49; background: #fff0f2; }
.status-processing { color: #84601c; background: #fff5dc; }
.form-grid { padding: clamp(22px, 4vw, 36px); display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; overflow: visible; }
.form-grid label { display: grid; gap: 8px; }
.span-2 { grid-column: span 2; }
.upload-box { padding: 30px; border: 2px dashed #c9c8e8; border-radius: 18px; text-align: center; place-items: center; cursor: pointer; background: #fafaff; }
.upload-box input { max-width: 100%; }
.upload-box small { color: var(--muted); }
.upload-icon { font-size: 2rem; color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }
.task-preview { padding: 22px; overflow: visible; }
.task-actions { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); justify-content: flex-end; }
.task-editor small { color: var(--muted); font-weight: 500; }
.compact-form { width: min(560px, 100%); padding: clamp(22px, 4vw, 36px); overflow: visible; }
.code-input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.5; }
.checkbox-label { display: flex !important; align-items: center; gap: 10px; }
.checkbox-label input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.correct-answer { color: #147352; }
.danger-zone { margin-top: 45px; padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-color: #f1c6cf; overflow: visible; }
.danger-zone h2 { margin-bottom: 5px; color: #a62e49; }
.danger-zone p { margin-bottom: 0; color: var(--muted); }
@media (max-width: 700px) {
    .site-header { min-height: 62px; }
    .header-user > span { display: none; }
    .page-shell { width: min(100% - 22px, 1180px); padding-top: 25px; }
    .hero { padding-top: 20px; }
    .set-card { border-radius: 19px; }
    .learning-filter-panel { border-radius: 19px; }
    .class-picker, .subject-filter { display: grid; grid-template-columns: repeat(2, 1fr); }
    .class-button, .subject-filter-button { width: 100%; padding-inline: 9px; }
    .progress-summary { grid-template-columns: 1fr; }
    .section-heading, .admin-title { align-items: stretch; flex-direction: column; }
    .admin-title .btn { width: 100%; }
    .admin-actions { width: 100%; flex-direction: column; align-items: stretch; }
    .admin-actions form, .admin-actions .btn, .admin-actions button { width: 100%; }
    .question-card { min-height: 485px; border-radius: 20px; padding: 22px 17px; }
    .test-head { align-items: flex-start; }
    .test-head-actions { align-items: flex-end; flex-direction: column; }
    .question-top { margin-bottom: 22px; }
    .choice-two, .stat-grid { grid-template-columns: 1fr; }
    .match-row { grid-template-columns: 1fr; gap: 6px; }
    .match-row > span { display: none; }
    .test-navigation { position: sticky; bottom: 8px; padding: 10px; background: rgba(247,248,252,.93); border-radius: 17px; backdrop-filter: blur(9px); }
    .test-navigation .btn { min-width: 0; flex: 1; }
    .result-hero { align-items: flex-start; flex-direction: column; padding-top: 15px; }
    .result-ring { align-self: center; width: 165px; height: 165px; flex-basis: 165px; }
    .history-row { align-items: flex-start; flex-direction: column; gap: 8px; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .danger-zone { align-items: stretch; flex-direction: column; }
    .danger-zone .btn { width: 100%; }
}
