/* Erhard – Karopapier-Optik. Kein Rot. */
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/static/vendor/fonts/schibsted-grotesk-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/static/vendor/fonts/schibsted-grotesk-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/static/vendor/fonts/schibsted-grotesk-latin-600-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/static/vendor/fonts/schibsted-grotesk-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/static/vendor/fonts/caveat-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/static/vendor/fonts/caveat-latin-700-normal.woff2) format("woff2"); }

:root {
  --paper: #FCFDFE;
  --grid: #E7EDF5;
  --ink: #222834;
  --muted: #586172;
  --blue: #1D3B8B;
  --marker: #FFE45C;
  --bubble: #EEF3FB;
  --white: #FFFFFF;
  --line: #D5DEEB;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; overflow-x: hidden; }
body {
  font-family: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px; line-height: 1.5; color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  min-height: 100vh; min-height: 100dvh;
}
.page {
  max-width: 640px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(var(--nav-h) + var(--safe-b) + 24px);
}
a { color: var(--blue); }
h1, h2, h3 { line-height: 1.2; }
mark { background: linear-gradient(transparent 12%, var(--marker) 12%, var(--marker) 88%, transparent 88%); color: inherit; padding: 0 .15em; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Kopf */
.hero { position: relative; text-align: left; margin: 8px 0 12px; }
.brand { font-family: "Caveat", cursive; font-weight: 700; color: var(--blue); font-size: 56px; margin: 0; letter-spacing: .5px; }
.brand.small { font-size: 34px; }
.sub { margin: 2px 0 0; color: var(--muted); }
.sub.small { font-size: 14px; }
.corner { position: absolute; right: 0; top: 4px; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; }
.hand { font-family: "Caveat", cursive; font-weight: 700; font-size: 28px; color: var(--blue); margin: 20px 0 6px; }
.termin { font-weight: 600; margin: 4px 0 14px; font-size: 17px; }
.topbar { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.topbar .back { font-size: 34px; text-decoration: none; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; margin-left: -8px; }

/* Karten, Formulare */
.card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: 0 1px 2px rgba(29, 59, 139, .06); }
.form label { display: block; font-weight: 600; margin: 10px 0 4px; }
input, textarea { font: inherit; color: inherit; }
.form input, textarea {
  width: 100%; font-size: 17px; padding: 10px 12px; min-height: 44px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--white);
}
input:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
textarea { resize: none; line-height: 1.4; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
.msg-warn { background: var(--marker); color: var(--ink); border-radius: 8px; padding: 8px 12px; margin: 10px 0 0; }
.notice h2 { margin-top: 0; }
.notice p { margin: 0 0 12px; }

/* Knöpfe – mindestens 44 px */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 16px;
  font: inherit; font-weight: 600; font-size: 16px;
  border-radius: 10px; border: 1.5px solid var(--blue);
  background: var(--white); color: var(--blue); cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn.primary { background: var(--blue); color: var(--white); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:active { transform: translateY(1px); }
.btn.icon { padding: 0; width: 44px; }
.btn.icon svg { width: 24px; height: 24px; }
form .btn.primary[type=submit] { margin-top: 4px; }
.form .btn.primary { width: 100%; margin-top: 8px; }

/* Fragen */
.ask textarea { min-height: 72px; }
.ask-row.tools { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.ask .send { margin-left: auto; margin-top: 0; }
.photo-name { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.modes .btn { width: 100%; padding: 0 8px; }
.preview { display: block; max-width: 100%; max-height: 180px; border-radius: 8px; margin-top: 8px; border: 1px solid var(--line); }
.preview.small { max-height: 90px; margin: 0 0 6px; }
.recent ul { list-style: none; padding: 0; margin: 0; }
.recent li a {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 12px; margin-bottom: 6px;
  background: var(--white); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.tag { flex: none; font-size: 13px; font-weight: 600; color: var(--blue); background: var(--bubble); border-radius: 6px; padding: 2px 8px; }

/* Untere Navigation */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(252, 253, 254, .97); border-top: 1px solid var(--line);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 44px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.bottomnav a .ico { font-size: 20px; line-height: 1.1; }
.bottomnav a.active { color: var(--blue); }
.bottomnav a.active .ico { background: var(--marker); border-radius: 8px; padding: 0 10px; }
body.typing .bottomnav { display: none; }

/* Chat */
.chatpage .page { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 96px); }
body.chatpage.typing .page { padding-bottom: 110px; }
.log { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 100%; min-width: 0; }
.msg.user { align-self: flex-end; max-width: 88%; background: var(--white); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant { align-self: stretch; background: var(--bubble); border-radius: 14px 14px 14px 4px; padding: 10px 14px; overflow-wrap: anywhere; }
.msg.user img { display: block; max-width: 100%; max-height: 260px; border-radius: 8px; margin-bottom: 6px; }
.msg.note { align-self: stretch; background: var(--marker); border-radius: 10px; padding: 8px 12px; font-size: 15px; }
.msg p { margin: 0 0 .6em; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { padding-left: 1.3em; margin: 0 0 .6em; }
.msg h1, .msg h2, .msg h3, .msg h4 { font-size: 1.05em; margin: .8em 0 .3em; }
.msg strong { font-weight: 700; }
.msg pre { overflow-x: auto; background: var(--white); padding: 8px; border-radius: 8px; font-size: 14px; }
.msg code { font-size: .92em; }
.msg blockquote { margin: 0 0 .6em; padding-left: 10px; border-left: 3px solid var(--blue); color: var(--muted); }
.msg hr { border: 0; border-top: 1px dashed var(--line); }
.scrollbox { overflow-x: auto; overflow-y: hidden; max-width: 100%; -webkit-overflow-scrolling: touch; margin: .4em 0 .6em; padding: 4px 2px; }
.math-display { background: rgba(255, 255, 255, .7); border-radius: 8px; }
.math-display .katex-display { margin: 0; }
.math-inline { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; }
.scrollbox table { border-collapse: collapse; font-size: 15px; }
.scrollbox th, .scrollbox td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.katex { font-size: 1.08em; }
.status { color: var(--muted); font-style: italic; margin: 10px 2px; }
.typing-dots::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.composer {
  position: fixed; left: 0; right: 0; z-index: 15;
  bottom: calc(var(--nav-h) + var(--safe-b));
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px; background: rgba(252, 253, 254, .98); border-top: 1px solid var(--line);
}
body.typing .composer { bottom: 0; padding-bottom: calc(8px + var(--safe-b)); }
.composer-main { flex: 1; min-width: 0; }
.composer textarea { max-height: 40vh; min-height: 44px; }
@media (min-width: 680px) { .composer { left: 50%; transform: translateX(-50%); max-width: 640px; } }
.scrollbox, .scrollbox * { overflow-wrap: normal; word-break: normal; }
.scrollbox th, .scrollbox td { white-space: nowrap; }

/* Schritt 2: Thema, Hausübung, Schnellknöpfe, Admin */
.field-label { display: block; font-weight: 600; margin: 12px 0 4px; }
.select {
  width: 100%; min-height: 44px; font: inherit; font-size: 16px; color: var(--ink);
  padding: 8px 36px 8px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231D3B8B' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center / 12px;
  -webkit-appearance: none; appearance: none;
}
.topic-row .field-label { margin-top: 12px; }
.btn.wide { width: 100%; margin-top: 14px; }
.big-photo { width: 100%; min-height: 64px; font-size: 18px; gap: 10px; }
.big-photo svg { width: 28px; height: 28px; }
.gallery-link { display: flex; align-items: center; justify-content: center; min-height: 44px; color: var(--blue); text-decoration: underline; cursor: pointer; font-size: 15px; }
.topic-tag { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar .tag { flex-shrink: 1; }
.composer { flex-direction: column; align-items: stretch; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.chatpage.hue .page { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 150px); }
.admin-section .card { margin-bottom: 12px; }
.topic-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topic-head h3 { margin: 0; font-size: 18px; }
.tag.marker { background: var(--marker); color: var(--ink); }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 14px; }
.files { list-style: none; padding: 0; margin: 10px 0; }
.files li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.fname { min-width: 0; overflow-wrap: anywhere; font-size: 15px; }
.upload { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.upload input[name=label], .row input { flex: 1 1 160px; min-width: 0; min-height: 44px; font-size: 16px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
details.danger { margin-top: 10px; color: var(--muted); }
details.danger summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }

/* Schritt 3: Aufgabenkarten */
.msg.task { align-self: stretch; background: var(--white); border: 1.5px solid var(--blue); border-radius: 14px; padding: 10px 14px; overflow-wrap: anywhere; }
.task-head { font-family: "Caveat", cursive; font-weight: 700; font-size: 24px; color: var(--blue); margin: 0 0 6px; }
.task-item { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 8px; }
.task-label { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.task-label::before { content: ""; display: inline-block; width: 10px; height: 10px; background: var(--marker); border-radius: 2px; margin-right: 6px; }
.task-pages img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; cursor: zoom-in; }
.msg.user img { cursor: zoom-in; }
.bank-task h3 { margin: 4px 0 6px; font-size: 17px; }
.bank-task details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--blue); font-weight: 600; }
.tag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 15px; }
.check input { width: 20px; height: 20px; flex: none; }
.pager { justify-content: space-between; margin: 12px 0; }
.filters .row { flex-wrap: nowrap; }

/* Schritt 4: Ziel, Admin */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.actions .btn { width: 100%; padding: 0 8px; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.types { list-style: none; padding: 0; margin: 0; }
.types li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.types li:last-child { border-bottom: 0; }
.types .typ { flex: 1; min-width: 0; }
.types small { display: block; color: var(--muted); font-size: 13px; }
.types .count { font-weight: 600; color: var(--blue); }
.st { flex: none; display: inline-block; min-width: 56px; text-align: center; font-size: 13px; font-weight: 700; border-radius: 6px; padding: 2px 8px; }
.st-sitzt { background: var(--blue); color: var(--white); }
.st-ueben { background: var(--marker); color: var(--ink); }
.st-offen { background: var(--white); color: var(--muted); border: 1.5px solid var(--line); }
.scroll-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-table table { border-collapse: collapse; font-size: 14px; width: max-content; min-width: 100%; }
.scroll-table th, .scroll-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.scroll-table td.wrap { white-space: normal; min-width: 180px; max-width: 280px; }
.admin-section { margin-top: 18px; }
.admin-section textarea { min-height: 160px; font-size: 15px; }
.pw { font-size: 22px; font-weight: 700; background: var(--marker); padding: 6px 10px; border-radius: 8px; display: inline-block; }
input[type=date] { min-height: 44px; font: inherit; font-size: 16px; padding: 6px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--white); }
.admin-nav { gap: 6px; }
.admin-nav .btn { flex: 1 1 30%; }
.recent .when { margin-left: auto; flex: none; color: var(--muted); font-size: 13px; padding-left: 8px; }
details > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
