@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap');

/* ── EMERALD / MINT THEME ─────────────────── */
:root {
  /* Gemeinsame Farben für alle drei Portale */
  --primary:           #047857;
  --primary-container: #065f46;
  --primary-fixed:     #d1fae5;
  --primary-fixed-dim: #a7d8bc;
  --on-primary:        #ffffff;
  --on-primary-container: #a7d8bc;

  /* Secondary */
  --secondary:           #526e5f;
  --secondary-container: #dceade;
  --on-secondary:        #ffffff;
  --on-secondary-container: #456453;

  /* Tertiary */
  --tertiary-fixed:    #e1eddc;
  --on-tertiary-fixed: #315847;

  /* Surfaces */
  --background:               #e3efe7;
  --surface:                  #e3efe7;
  --surface-card:             #ffffff;
  --surface-container-lowest: #ffffff;
  --surface-container-low:    #f0f7f2;
  --surface-container:        #e6f2e9;
  --surface-container-high:   #dceadf;
  --surface-container-highest:#d2e3d6;
  --surface-dim:              #c6dbcc;

  /* Text / Outline */
  --on-surface:         #163d30;
  --on-surface-variant: #315847;
  --outline:            #64816f;
  --outline-variant:    #b3d2bf;

  /* Semantic */
  --success:       #2e7d32;
  --success-light: #e8f5e9;
  --error:         #ba1a1a;
  --error-light:   #ffdad6;
  --warning-light: #fdf6b2;
  --warning-text:  #723b13;

  /* Legacy aliases (JS + other pages) */
  --primary-light:  var(--primary-fixed);
  --primary-hover:  var(--primary-container);
  --success-light-old: #def7ec;
  --danger:         var(--error);
  --danger-light:   var(--error-light);
  --text:           var(--on-surface);
  --text-2:         var(--on-surface-variant);
  --text-muted:     var(--secondary);
  --border:         var(--outline-variant);
  --bg:             var(--background);

  /* Shape */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  /* Dezenter grüner Schimmer entlang der abgerundeten Flächen */
  --edge-glow: 0 0 0 1px rgba(4,120,87,.035), 0 2px 8px rgba(4,120,87,.06);
  --shadow-sm: 0 0 0 1px rgba(4,120,87,.035), 0 2px 8px rgba(4,120,87,.07);
  --shadow:    0 0 0 1px rgba(4,120,87,.04), 0 4px 14px rgba(4,120,87,.08);
  --shadow-lg: 0 0 0 1px rgba(4,120,87,.04), 0 12px 32px rgba(4,120,87,.10);

  /* Layout */
  --header-h:  64px;
  --sidebar-w: 72px;
}

/* ── RESET ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--background);
  color: var(--on-surface);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.student-portal, .teacher-portal {
  --surface-card: #f7fbf8;
  --surface-container-lowest: #f7fbf8;
  background: #f5f6f7;
}

/* ── MATERIAL SYMBOLS ────────────────────────────── */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  font-size: 22px;
  line-height: 1;
}
.material-symbols-outlined.filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ── APP HEADER ──────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 200;
  background: var(--surface-card);
  border-bottom: 1px solid var(--outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow-sm);
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-brand-icon {
  color: var(--primary);
  font-size: 28px;
}

.app-brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
}

.app-search input {
  border: none;
  background: transparent;
  font-size: 0.85rem;
  color: var(--on-surface);
  font-family: inherit;
  outline: none;
  width: 160px;
}

.app-search input::placeholder { color: var(--outline); }
.app-search .material-symbols-outlined { color: var(--secondary); font-size: 18px; }

.app-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 999px;
  color: var(--secondary);
  display: flex;
  align-items: center;
  transition: background .15s;
}
.app-icon-btn:hover { background: var(--surface-container-low); }

.app-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ── SIDEBAR ─────────────────────────────────────── */
.app-sidebar {
  position: fixed;
  left: 0;
  top: var(--header-h);
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  z-index: 100;
  background: var(--surface-card);
  border-right: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0;
}

.sidebar-items { display: flex; flex-direction: column; gap: 0.25rem; width: 100%; padding: 0 0.4rem; }
.sidebar-bottom { margin-top: auto; width: 100%; padding: 0.4rem; }

.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0.55rem 0.4rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--secondary);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  transition: background .15s, color .15s;
  width: 100%;
}

.sidebar-item:hover { background: var(--surface-container); color: var(--on-surface); }

.sidebar-item span.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sidebar-item.active {
  background: var(--secondary-container);
  color: var(--on-surface);
}

.sidebar-item.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ── APP MAIN ────────────────────────────────────── */
.app-main {
  padding-top: calc(var(--header-h) + 2rem);
  padding-left: calc(var(--sidebar-w) + 1.5rem);
  padding-right: 1.5rem;
  padding-bottom: 3rem;
  max-width: calc(var(--sidebar-w) + 1200px);
}

/* ── DEMO BANNER ─────────────────────────────────── */
.demo-banner {
  position: fixed;
  top: var(--header-h);
  left: var(--sidebar-w);
  right: 0;
  z-index: 90;
  background: var(--warning-light);
  border-bottom: 1px solid #f3d173;
  padding: 0.45rem 1.5rem;
  font-size: 0.8rem;
  color: var(--warning-text);
  text-align: center;
}

.demo-banner + .app-main { padding-top: calc(var(--header-h) + 2.5rem + 32px); }

/* ── CONTEXT BAR ─────────────────────────────────── */
.context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.context-timer {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--secondary);
  font-size: 0.825rem;
  font-weight: 500;
}

/* ── CARD ────────────────────────────────────────── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title .icon {
  width: 28px;
  height: 28px;
  background: var(--primary-fixed);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.card-title .material-symbols-outlined {
  color: var(--primary);
  font-size: 20px;
}

/* ── FORM ────────────────────────────────────────── */
:where(.aufgabe-box, .answer-wrapper, .btn-ghost, .register-button,
       .chat-box, .chat-eingabe, .verlauf-item) {
  box-shadow: var(--edge-glow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--on-surface-variant);
  margin-bottom: 0.4rem;
}

select, textarea, input[type="text"], input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--on-surface);
  background: var(--surface-card);
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  box-shadow: var(--edge-glow);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2374777f' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

select:focus, textarea:focus, input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, .12);
}

textarea {
  resize: vertical;
  min-height: 130px;
  line-height: 1.6;
}

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.25rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .1s;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 1px 2px rgba(4,120,87,.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-container);
  box-shadow: 0 3px 8px rgba(4,120,87,.35);
}

.btn-ghost {
  background: transparent;
  color: var(--on-surface-variant);
  border-color: var(--outline-variant);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-container-low); border-color: var(--outline); }

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 1px 2px rgba(46,125,50,.3);
}
.btn-success:hover:not(:disabled) { background: #1b5e20; }

.btn-group {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* ── TASK BOX ────────────────────────────────────── */
.task-header {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.aufgabe-box {
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.375rem;
  line-height: 1.75;
  font-size: 0.925rem;
  color: var(--on-surface-variant);
}

.hinweis-box {
  background: var(--warning-light);
  border: 1px solid #f3d173;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.125rem;
  font-size: 0.875rem;
  color: var(--warning-text);
  margin-top: 0.875rem;
  display: flex;
  gap: 0.5rem;
}

/* ── ANSWER AREA ─────────────────────────────────── */
.antwort-modus { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.antwort-modus [aria-pressed="true"] { background: var(--primary-fixed); border-color: var(--primary); color: var(--primary-container); }
#antwort-text { min-height: 200px; white-space: pre-wrap; }
#antwort-text[aria-invalid="true"] { border-color: var(--error); }
.antwort-zeichen { text-align: right; font-size: .75rem; color: var(--secondary); margin-top: .4rem; }
.antwort-feldfehler { color: var(--error); font-size: .825rem; margin-top: .4rem; }

.answer-wrapper {
  background: var(--surface-container-lowest);
  border: 1.5px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  transition: box-shadow .15s, border-color .15s;
}

.answer-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, .10);
}

.answer-wrapper textarea {
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  box-shadow: none;
}
.answer-wrapper textarea:focus {
  border: none;
  box-shadow: none;
}

.answer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--outline-variant);
  background: var(--surface-container-low);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.word-count {
  font-size: 0.78rem;
  color: var(--secondary);
  font-weight: 500;
}

.answer-actions { display: flex; gap: 0.5rem; }

/* ── FEEDBACK CARD ───────────────────────────────── */
.feedback-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--outline-variant);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.feedback-header {
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.feedback-header.korrekt { background: var(--success-light); border-bottom: 1px solid #a5d6a7; }
.feedback-header.falsch  { background: var(--error-light);   border-bottom: 1px solid #ffb4ab; }

.feedback-icon { font-size: 1.5rem; line-height: 1; }
.feedback-title { font-weight: 700; font-size: 0.95rem; }
.feedback-header.korrekt .feedback-title { color: var(--success); }
.feedback-header.falsch  .feedback-title { color: var(--error); }

.punkte-badge {
  margin-left: auto;
  background: var(--surface-card);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--outline-variant);
  color: var(--on-surface-variant);
}

/* Feedback panel header */
.feedback-panel-header {
  background: var(--primary-container);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.feedback-panel-header .material-symbols-outlined { color: var(--primary-fixed-dim); }
.feedback-panel-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--on-primary);
}

.feedback-body {
  padding: 1.375rem 1.5rem;
  background: var(--surface-card);
}

/* Feedback und Verbesserung nacheinander lesen */
.feedback-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem;
}

.feedback-col-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.feedback-col-title.strengths { color: var(--success); }
.feedback-col-title.improvements { color: var(--primary); }
.feedback-col-title .material-symbols-outlined { font-size: 16px; }

.feedback-text {
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--on-surface-variant);
}

.verbesserung-box {
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--on-surface-variant);
}

/* KI-Chips */
.ki-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }

.ki-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  background: var(--tertiary-fixed);
  color: var(--on-tertiary-fixed);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* ── BADGES ──────────────────────────────────────── */
.badges { display: flex; gap: 0.45rem; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary  { background: var(--primary-container); color: var(--on-primary); }
.badge-blue     { background: var(--primary-fixed); color: var(--primary); }
.badge-neutral  { background: var(--surface-container); color: var(--on-surface-variant); border: 1px solid var(--outline-variant); }

/* ── LOADING ─────────────────────────────────────── */
.loading-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--secondary);
  font-size: 0.875rem;
  padding: 1.5rem 0;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--outline-variant);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── ERROR ───────────────────────────────────────── */
.error-box {
  background: var(--error-light);
  border: 1px solid #ffb4ab;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.125rem;
  font-size: 0.875rem;
  color: var(--error);
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

/* ── ZWEI-SPALTEN LAYOUT ─────────────────────────── */
.aufgabe-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}

.aufgabe-haupt { min-width: 0; }

.aufgabe-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
}

@media (max-width: 900px) {
  .aufgabe-layout { grid-template-columns: 1fr; }
  .aufgabe-sidebar { position: static; }
}

/* ── CHAT ────────────────────────────────────────── */
.student-portal .app-main:has(#lernen-view:not(.hidden) .chat-msg) {
  max-width: calc(var(--sidebar-w) + 1600px);
}

.student-portal .aufgabe-sidebar { min-width: 0; }

.student-portal .aufgabe-layout:has(.chat-msg) .aufgabe-sidebar {
  position: static;
}

.student-portal .aufgabe-layout:has(.chat-msg) .chat-verlauf {
  max-height: none;
  overflow-y: visible;
}

.student-portal .chat-msg { min-width: 0; }
.student-portal .chat-msg-ki { max-width: 100%; width: 100%; }
.student-portal .chat-msg-text { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.student-portal .chat-msg-ki .chat-msg-text { width: 100%; }
.student-portal .chat-eingabe { min-width: 0; min-height: 64px; }

@media (min-width: 901px) {
  .student-portal .aufgabe-layout:has(.chat-msg) {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  }
}

.chat-verlauf {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100vh - 340px);
  min-height: 160px;
  overflow-y: auto;
  padding: 0.25rem 0 0.5rem;
  margin-bottom: 0.75rem;
}

.chat-verlauf:empty::before {
  content: "Noch keine Fragen gestellt. Frage z. B. nach einem Hinweis oder einer Erklärung.";
  color: var(--secondary);
  font-size: 0.85rem;
  font-style: italic;
  display: block;
  padding: 0.5rem 0;
}

.chat-msg { display: flex; flex-direction: column; max-width: 88%; }
.chat-msg-user { align-self: flex-end; align-items: flex-end; }
.chat-msg-ki   { align-self: flex-start; align-items: flex-start; }

.chat-msg-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-msg-text {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.55;
}

.chat-msg-user .chat-msg-text {
  background: var(--primary);
  color: var(--on-primary);
  border-bottom-right-radius: 4px;
}

.chat-msg-ki .chat-msg-text {
  background: var(--surface-container-low);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  border-bottom-left-radius: 4px;
}

.chat-eingabe-wrap { display: flex; gap: 0.5rem; align-items: flex-end; }

.chat-eingabe {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--on-surface);
  background: var(--surface-card);
  transition: border-color .15s;
  line-height: 1.4;
}
.chat-eingabe:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(4,120,87,.1); }
.chat-senden { padding: 0.55rem 1.1rem; align-self: flex-end; }

.chat-dots { display: inline-flex; gap: 4px; align-items: center; }
.chat-dots span {
  width: 6px; height: 6px;
  background: var(--secondary);
  border-radius: 50%;
  animation: chatBounce 1.2s infinite ease-in-out;
}
.chat-dots span:nth-child(2) { animation-delay: .2s; }
.chat-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes chatBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1;   }
}

/* ── CODE ────────────────────────────────────────── */
.code-block {
  margin: 0.75rem 0;
  border-radius: var(--radius-sm);
  overflow: auto;
  font-size: 0.85rem;
}

.inline-code {
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-family: 'Fira Mono', 'Consolas', monospace;
  font-size: 0.875em;
  color: #be185d;
}

mjx-container { overflow-x: auto; max-width: 100%; }

/* ── MUSTER BOX ──────────────────────────────────── */
.muster-box {
  background: var(--success-light);
  border: 1px solid #a5d6a7;
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.375rem;
  font-size: 0.9rem;
  line-height: 1.75;
  color: #1b5e20;
}

/* ── PROMPT SECTION ──────────────────────────────── */
.prompt-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--secondary);
  cursor: pointer;
  padding: 0.3rem 0;
  font-family: inherit;
  transition: color .15s;
}
.prompt-toggle-btn:hover { color: var(--primary); }

.prompt-section {
  margin-top: 1rem;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.prompt-section-header {
  background: var(--surface-container-low);
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--secondary);
  border-bottom: 1px solid var(--outline-variant);
}

.prompt-box {
  background: #142d24;
  color: #d8e9df;
  padding: 1.125rem 1.25rem;
  font-family: 'Fira Mono', 'Consolas', 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-x: auto;
  margin: 0;
}

/* ── VERLAUF ─────────────────────────────────────── */
.verlauf-item {
  padding: 0.875rem 1rem;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--surface-card);
}

.verlauf-item:hover { border-color: var(--primary); background: var(--primary-fixed); }
.verlauf-item-meta  { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.verlauf-item-text  { font-size: 0.825rem; color: var(--secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verlauf-datum      { font-size: 0.75rem; color: var(--secondary); margin-left: auto; white-space: nowrap; }
.verlauf-leer       { text-align: center; color: var(--secondary); font-size: 0.875rem; padding: 2rem 0; }

.alle-aufgaben-item { padding: 0.875rem 0; border-bottom: 1px solid var(--outline-variant); }
.alle-aufgaben-item:first-child { padding-top: 0; }
.alle-aufgaben-item:last-child  { border-bottom: none; padding-bottom: 0; }

/* ── LOGIN PAGE ──────────────────────────────────── */
.login-page {
  --background: #f0f9f3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--on-surface);
  background: linear-gradient(135deg, #cfe5d8 0%, #e3efe7 50%, #d4e1ce 100%);
}

.login-page .btn-primary { box-shadow: 0 2px 5px rgba(4, 120, 87, .18); }
.login-page .btn-primary:hover:not(:disabled) { box-shadow: 0 4px 10px rgba(4, 120, 87, .24); }
.login-page input:not([aria-invalid="true"]),
.login-page select:not([aria-invalid="true"]) { background-color: #f7fcf9; }
.login-page input::placeholder { color: var(--outline); }
.login-page input:not([aria-invalid="true"]):focus,
.login-page select:not([aria-invalid="true"]):focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, .13);
}
.login-page .eye-btn:focus-visible,
.login-page .login-submit:focus-visible {
  outline: 2px solid var(--primary-container);
  outline-offset: 3px;
}

.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-wrap { width: 100%; max-width: 518px; }

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.login-logo-icon {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(4,120,87,.22);
}

.login-logo-icon .material-symbols-outlined {
  color: var(--on-primary);
  font-size: 32px;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 48;
}

.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--on-surface); text-align: center; }
.login-logo p  { font-size: 0.85rem; color: var(--secondary); margin-top: 0.3rem; }

.login-card {
  background: var(--surface-card);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: 2rem 2rem 1.75rem;
  box-shadow: var(--shadow-lg);
}

.login-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: 1.5rem;
  text-align: center;
}

.rolle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.5rem; }

.rolle-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.75rem;
  border: 2px solid var(--outline-variant);
  border-radius: var(--radius);
  background: var(--background);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  font-family: inherit;
}

.rolle-btn:hover { border-color: var(--primary-fixed-dim); background: var(--primary-fixed); }

.rolle-btn.aktiv {
  border-color: var(--primary);
  background: var(--primary-fixed);
  box-shadow: 0 0 0 3px rgba(4,120,87,.10);
}

.rolle-btn .material-symbols-outlined { font-size: 28px; color: var(--primary); font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 36; }
.rolle-btn.aktiv .material-symbols-outlined { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 36; }
.rolle-emoji { font-size: 1.75rem; line-height: 1; }
.rolle-label { font-size: 0.82rem; font-weight: 600; color: var(--on-surface-variant); }
.rolle-btn.aktiv .rolle-label { color: var(--primary); }

.passwort-bereich { overflow: hidden; max-height: 0; opacity: 0; transition: max-height .3s ease, opacity .25s ease; }
.passwort-bereich.sichtbar { max-height: 340px; opacity: 1; }

.input-wrap { position: relative; }

.input-wrap input {
  width: 100%;
  padding: 0.65rem 2.75rem 0.65rem 0.9rem;
  border: 1.5px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--on-surface);
  background: var(--surface-card);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.input-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(4,120,87,.12); }
.input-wrap input::placeholder { color: var(--outline); }

.eye-btn {
  position: absolute; right: 0.7rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1rem;
  color: var(--secondary); padding: 0.2rem; line-height: 1;
}

.eye-btn svg { display: block; }
.eye-btn .eye-slash { display: none; }
.eye-btn[aria-pressed="true"] .eye-slash { display: inline; }

.login-submit { width: 100%; padding: 0.75rem; font-size: 0.95rem; font-weight: 600; justify-content: center; border-radius: var(--radius-sm); margin-top: 1.125rem; }

.registration-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  width: 100%;
  margin-top: 24px;
  font-family: 'Geist', 'Inter', sans-serif;
}

.registration-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-transform: uppercase;
}

.registration-divider::before,
.registration-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--outline-variant);
}

.registration-details { width: 100%; }

.register-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  list-style: none;
  cursor: pointer;
  border-radius: 10px;
}

.register-cta::-webkit-details-marker { display: none; }

.register-hint {
  color: var(--on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  line-height: 18px;
  text-align: center;
}

.register-button {
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid var(--primary);
  border-radius: 10px;
  color: var(--primary-container);
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
}

.register-cta:hover .register-button { background: var(--primary-fixed); }
.register-cta:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }
.registration-form { margin-top: 24px; }

.registration-form [aria-invalid="true"] {
  border-color: #b42318;
  background-color: #fffafa;
}
.registration-form [aria-invalid="true"]:focus {
  outline: 2px solid #b42318;
  outline-offset: 2px;
  box-shadow: none;
}
.registration-form .field-error {
  margin: 6px 0 0;
  color: #b42318;
  font-size: 13px;
  line-height: 1.5;
}
.registration-form .field-error::before { content: '! '; font-weight: 700; }
.registration-form .field-error[hidden] { display: none; }
.registration-form #name-hilfe,
.registration-form #passwort-hilfe {
  margin-top: 6px;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.5;
}
.registration-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.registration-message:empty { display: none; }
.registration-message::before { flex: none; font-weight: 700; }
.registration-message--error { color: #912018; background: #fff4f2; border-color: #fecdca; }
.registration-message--error::before { content: '!'; }
.registration-message--success { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.registration-message--success::before { content: '✓'; }
.registration-message--pending { color: var(--on-surface-variant); background: var(--background); border-color: var(--outline-variant); }

.demo-hint {
  margin-top: 1.25rem;
  background: var(--background);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  color: var(--secondary);
  line-height: 1.7;
}
.demo-hint strong { color: var(--on-surface-variant); font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 0.25rem; }
.demo-hint code   { background: var(--surface-container); border-radius: 4px; padding: 0.1rem 0.35rem; font-size: 0.78rem; color: var(--primary); }

.login-footer { text-align: center; margin-top: 1.5rem; font-size: 0.75rem; color: var(--secondary); }

/* ── UTILS ───────────────────────────────────────── */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.divider { border: none; border-top: 1px solid var(--outline-variant); margin: 1.25rem 0; }
.back-link { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--secondary); text-decoration: none; font-size: 0.825rem; font-weight: 500; margin-bottom: 1.75rem; transition: color .15s; }
.back-link:hover { color: var(--primary); }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 600px) {
  :root { --sidebar-w: 0px; }
  .app-sidebar { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .app-main { padding-left: 1rem; padding-right: 1rem; }
  .app-search { display: none; }
  .login-card { padding: 1.5rem 1.25rem; }
  .rolle-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .aufgabe-layout { grid-template-columns: 1fr; }
  .aufgabe-sidebar { position: static; }
  .chat-verlauf { max-height: 300px; }
}

/* ── DATEI-UPLOAD ────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--surface);
}
.upload-zone:hover, .upload-zone-drag {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.upload-zone-aktiv {
  border-color: var(--accent);
  border-style: solid;
}
.upload-zone-icon {
  font-size: 2.5rem;
  color: var(--secondary);
  display: block;
  margin-bottom: .5rem;
}
.upload-zone-text {
  margin: 0;
  font-weight: 500;
  color: var(--primary);
  font-size: .95rem;
}
.upload-zone-hint {
  margin: .25rem 0 0;
  font-size: .8rem;
  color: var(--secondary);
}
.datei-preview {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .75rem;
  padding: .6rem .9rem;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.datei-name {
  font-weight: 500;
  font-size: .875rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.datei-groesse {
  font-size: .775rem;
  color: var(--secondary);
  white-space: nowrap;
}
.datei-entfernen {
  padding: .2rem .4rem;
  color: var(--secondary);
}

/* ── PRINT (PDF-Export) ──────────────────────────── */
@media print {
  @page {
    margin: 0;
  }
  #print-container {
    padding: 1.5cm 2cm;
  }
}

/* Gemeinsame Verlaufskarten für Studierende und Lehrende */
.verlauf-liste { display: flex; flex-direction: column; gap: 1rem; padding: 0 1.25rem 1.25rem; }
.verlauf-row { padding: 1.125rem; border: 1px solid var(--outline-variant); border-radius: var(--radius); background: var(--surface-card); box-shadow: var(--edge-glow); min-width: 0; }
.verlauf-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.verlauf-fach { font-weight: 600; color: var(--on-surface); }
.verlauf-meta { font-size: .75rem; color: var(--secondary); margin-top: .3rem; }
.verlauf-punkte { padding: .35rem .65rem; border-radius: 999px; background: var(--primary-fixed); color: var(--primary-container); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.verlauf-feedback { margin-top: 1rem; }
.verlauf-feedback > summary { display: inline-flex; align-items: center; gap: .5rem; padding: .6rem .85rem; border: 1px solid var(--outline-variant); border-radius: 8px; color: var(--primary-container); background: var(--surface-container-low); font-size: .825rem; font-weight: 600; cursor: pointer; list-style: none; }
.verlauf-feedback > summary::-webkit-details-marker { display: none; }
.verlauf-feedback > summary:hover { background: var(--primary-fixed); }
.verlauf-feedback > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.verlauf-feedback .feedback-schliessen { display: none; }
.verlauf-feedback[open] .feedback-oeffnen { display: none; }
.verlauf-feedback[open] .feedback-schliessen { display: inline; }
.verlauf-feedback-inhalt { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.verlauf-feedback-teil { padding: 1rem; border-radius: 10px; background: #f7f9f8; border: 1px solid var(--outline-variant); min-width: 0; }
.verlauf-feedback-teil.verbesserung { background: var(--surface-container-low); }
.verlauf-feedback-teil h3 { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--on-surface); margin: 0 0 .75rem; }
.verlauf-feedback-text { font-size: .875rem; line-height: 1.75; overflow-wrap: anywhere; color: var(--on-surface-variant); }
.verlauf-feedback-text pre { max-width: 100%; overflow-x: auto; }
@media (max-width: 720px) { .verlauf-feedback-inhalt { grid-template-columns: 1fr; } }

#alle-aufgaben-liste.verlauf-liste { padding: 0; }
.verlauf-aufgabenstellung { grid-column: 1 / -1; }

/* Auch gespeicherte studentische Bewertungen untereinander darstellen. */
.student-portal .verlauf-feedback-inhalt { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.student-portal .verlauf-feedback-text { font-size: .95rem; line-height: 1.85; }
.student-portal :is(.feedback-text, .verbesserung-box, .verlauf-feedback-text) {
  overflow-wrap: anywhere;
}
.student-portal :is(.feedback-text, .verbesserung-box, .verlauf-feedback-text) li + li {
  margin-top: .75rem;
}
.student-portal :is(.feedback-text, .verbesserung-box, .verlauf-feedback-text) :is(p, pre, ul, ol) {
  margin-block: .85rem;
}
.student-portal :is(.feedback-text, .verbesserung-box, .verlauf-feedback-text) pre {
  max-width: 100%;
  overflow-x: auto;
}

/* Lesbare Abschnitte für bereits vorhandene Titel im KI-Feedback. */
.verbesserung-schritte { display: grid; gap: 1rem; }
.verbesserung-schritt {
  padding: 1rem 1.125rem;
  background: var(--surface-card);
  border: 1px solid var(--outline-variant);
  border-left: 3px solid var(--primary-fixed-dim);
  border-radius: 10px;
  min-width: 0;
}
.verbesserung-schritt h4 {
  margin: 0 0 .6rem;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--primary-container);
}
.verbesserung-schritt > div, .verbesserung-einleitung { max-width: 72ch; }
@media (max-width: 600px) {
  .verbesserung-schritt { padding: .85rem; }
}

.feedback-lesetext { max-width: 72ch; min-width: 0; line-height: 1.85; }
.feedback-lesetext h4 { font-size: 1rem; color: var(--on-surface); margin: 1.25rem 0 .65rem; }
.feedback-lesetext > :first-child { margin-top: 0 !important; }
.feedback-lesetext > :last-child { margin-bottom: 0 !important; }
.feedback-lesetext :is(ul, ol) { padding-left: 1.6rem; }
.feedback-lesetext li { padding-left: .3rem; }
.feedback-lesetext li::marker { color: var(--primary-container); font-weight: 600; }
.feedback-formel { overflow-x: auto; margin: 1rem 0; padding-block: .25rem; }
