* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f7fb;
  color: #1f2937;
  line-height: 1.5;
}

.wrap {
  max-width: 980px;
  margin: 40px auto;
  padding: 0 20px;
}

.admin-wrap {
  max-width: min(1380px, calc(100vw - 32px));
}

.admin-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-page-header h1 {
  margin-bottom: 0;
}

.admin-role-note {
  margin-top: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
}

.admin-heading-link {
  display: inline-block;
  margin-left: 6px;
  color: #6b7280;
  font-size: 0.72rem;
  font-weight: 600;
}

.admin-page-header form {
  margin: 0;
}

.admin-header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.admin-header-actions .button-link,
.admin-header-actions button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

h1 {
  margin: 0 0 10px;
  font-size: 1.9rem;
}

h3 {
  margin-top: 18px;
  margin-bottom: 8px;
  font-size: 1rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eaf1ff;
  color: #1d4ed8;
  font-size: 0.92rem;
  font-weight: 600;
}

.section-title {
  margin: 26px 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
}

.aufgabe-box,
.hinweis-box,
.originaltext-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
}

textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
  resize: vertical;
  min-height: 160px;
}

.text-input,
select.text-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
  background: #ffffff;
}

.text-input:focus,
select.text-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-label {
  display: block;
  margin: 16px 0 6px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-weight: 700;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  white-space: nowrap;
}

.inline-toggle input {
  margin: 0;
}

.admin-header-actions[data-teacher-results-only="1"] > a {
  display: none;
}

.course-result-group {
  margin: 24px 0 34px;
  padding-top: 18px;
  border-top: 10px solid #eef4ff;
}

.course-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.course-result-header .section-title {
  margin: 0;
}

.course-analysis-button {
  line-height: 1.25;
  text-align: center;
}

.result-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.result-action-button {
  width: 104px;
  text-align: center;
  white-space: nowrap;
}

.rating-symbol {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.rating-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: middle;
}

textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.word-counter {
  margin-top: 8px;
  font-size: 0.95rem;
  color: #4b5563;
}

.word-limit-msg {
  margin-top: 6px;
  font-size: 0.92rem;
  color: #b91c1c;
  display: none;
}

.actions {
  margin-top: 22px;
}

.end-actions {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.top-actions {
  margin-top: 0;
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.top-actions form {
  margin: 0;
  display: flex;
}

.top-actions .button-link,
.top-actions button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
}

button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: #1d4ed8;
}

.button-link {
  display: inline-block;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  background: #2563eb;
  color: #fff;
  text-decoration: none;
}

.button-link:hover {
  background: #1d4ed8;
}

.secondary-link {
  background: #0f766e;
}

.secondary-link:hover {
  background: #115e59;
}

.email-form {
  margin: 0;
}

.secondary-button {
  background: #0f766e;
}

.secondary-button:hover {
  background: #115e59;
}

.photo-action-button {
  background: #64748b;
}

.photo-action-button:hover,
.photo-action-button:focus {
  background: #475569;
}

.photo-action-button.ready {
  background: #0f766e;
}

.photo-action-button.ready:hover,
.photo-action-button.ready:focus {
  background: #115e59;
}

.photo-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
}

.photo-action-row button {
  min-height: 48px;
}

.image-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  min-width: 220px;
}

.image-preview-actions button,
.photo-remove-action {
  min-height: 48px;
}

.hilfe-block {
  margin-top: 16px;
}

.help-button {
  background: #0f766e;
}

.help-button:hover {
  background: #115e59;
}

.redemittel-box {
  margin-top: 10px;
}

.msg {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 0.97rem;
}

.msg.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.msg.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.small-note {
  margin-top: 10px;
  color: #6b7280;
  font-size: 0.92rem;
}

.small-warning {
  color: #92400e;
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  padding: 8px 10px;
  border-radius: 6px;
}

.recaptcha-box {
  margin-top: 18px;
}

.feedback-pre {
  white-space: pre-line;
}

.auswertung-box {
  margin-top: 10px;
}

.bewertung-zusammenfassung {
  margin-top: 16px;
}

.ki-hinweis,
.lernfokus-box,
.translation-box {
  border-left: 4px solid #0f766e;
  margin: 14px 0;
  padding: 10px 12px;
  background: #f0fdfa;
}

.translation-box {
  border-left-color: #4b5563;
  background: #f8fafc;
}

.originaltext-box {
  line-height: 1.7;
  white-space: normal;
}

.fehler-markierung {
  padding: 0 2px;
  border-radius: 3px 3px 0 0;
}

.fehler-markierung-grammatik {
  background: #fee2e2;
  color: #991b1b;
  border-bottom: 2px solid #dc2626;
}

.fehler-markierung-rechtschreibung {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 2px solid #f59e0b;
}

.fehler-markierung-wortschatz_stil {
  background: #dcfce7;
  color: #166534;
  border-bottom: 2px solid #22c55e;
}

.fehler-markierung-satzbau {
  background: #dbeafe;
  color: #1e40af;
  border-bottom: 2px solid #2563eb;
}

.fehler-legende {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 6px 0 10px;
  color: #374151;
  font-size: 0.92rem;
  font-weight: 600;
}

.fehler-legende-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fehler-legende-farbe {
  width: 16px;
  height: 10px;
  border-radius: 999px;
  border-bottom: 2px solid currentColor;
}

.fehler-legende-grammatik {
  background: #fee2e2;
  color: #dc2626;
}

.fehler-legende-rechtschreibung {
  background: #fef3c7;
  color: #f59e0b;
}

.fehler-legende-wortschatz_stil {
  background: #dcfce7;
  color: #22c55e;
}

.fehler-legende-satzbau {
  background: #dbeafe;
  color: #2563eb;
}

.fehler-kategorie-heading {
  display: inline-block;
  padding-bottom: 3px;
  border-bottom: 3px solid #d1d5db;
}

.fehler-kategorie-grammatik {
  border-bottom-color: #dc2626;
}

.fehler-kategorie-rechtschreibung {
  border-bottom-color: #f59e0b;
}

.fehler-kategorie-wortschatz_stil {
  border-bottom-color: #22c55e;
}

.fehler-kategorie-satzbau {
  border-bottom-color: #2563eb;
}

.teilblock {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.teilblock:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.fehler-tabelle {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  margin-bottom: 24px;
  background: #fff;
}

.fehler-tabelle th,
.fehler-tabelle td {
  border: 1px solid #d1d5db;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.fehler-tabelle th {
  background: #eef2ff;
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  position: relative;
}

.table-scroll-top {
  width: 100%;
  height: 16px;
  margin-bottom: 6px;
  overflow-x: auto;
  overflow-y: hidden;
}

.table-scroll-top-inner {
  height: 1px;
}

.admin-list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 10px;
}

.column-picker {
  position: relative;
  flex: 0 0 auto;
}

.column-picker-button {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.column-picker-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  width: 240px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
}

.column-picker-title {
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #374151;
}

.column-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2937;
}

.column-toggle input {
  margin: 0;
}

.admin-table {
  width: 100%;
  min-width: 1120px;
  table-layout: fixed;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.95rem;
}

.admin-table th,
.admin-table td {
  border: 1px solid #d1d5db;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.admin-table td {
  overflow-wrap: anywhere;
}

.admin-table th {
  background: #eef2ff;
  font-weight: 700;
  position: relative;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

.table-sort-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.table-sort-button:hover,
.table-sort-button:focus {
  background: transparent;
  color: inherit;
}

.table-sort-button::after {
  content: "↕";
  font-size: 0.8rem;
  color: #64748b;
}

.table-sort-button[data-sort-direction="asc"]::after {
  content: "↑";
  color: #1d4ed8;
}

.table-sort-button[data-sort-direction="desc"]::after {
  content: "↓";
  color: #1d4ed8;
}

.table-filter-row th {
  background: #f8fafc;
  padding: 8px;
}

.table-filter-input {
  min-width: 84px;
  padding: 8px 10px;
  font-size: 0.88rem;
}

.table-empty-row td {
  text-align: center;
  color: #64748b;
  font-style: italic;
}

.admin-table .col-id {
  width: 54px;
}

.admin-table .col-code {
  width: 180px;
}

.admin-table .col-title {
  width: 220px;
}

.admin-table .col-buch {
  width: 145px;
}

.admin-table .col-short {
  width: 82px;
}

.admin-table .col-number {
  width: 110px;
}

.admin-table .col-long {
  width: 240px;
}

.admin-table .col-niveau,
.admin-table .col-status {
  width: 74px;
}

.admin-table td[data-column-key="verlinkt"] {
  white-space: nowrap;
}

.admin-table .col-autor {
  width: 100px;
}

.admin-table .col-pruefung {
  width: 150px;
}

.admin-table .col-actions {
  width: 130px;
}

.table-action {
  font-weight: 700;
  color: #1d4ed8;
}

.table-menu-button {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 0;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.table-menu-button:hover,
.table-menu-button:focus {
  background: transparent;
  color: inherit;
}

.table-menu-button:focus-visible {
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}

.table-menu-button span {
  font-size: 0.8rem;
}

.table-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% - 1px);
  left: 6px;
  width: min(220px, calc(100vw - 32px));
  padding: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
  white-space: normal;
}

.table-menu button {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 7px 8px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
  color: #111827;
  font-size: 0.86rem;
  text-align: left;
}

.table-menu button:hover,
.table-menu button:focus {
  background: #e5eefc;
  color: #111827;
}

.table-menu label {
  display: block;
  margin: 8px 0 6px;
  font-size: 0.82rem;
  color: #374151;
  font-weight: 700;
}

.table-menu input {
  width: 100%;
  margin-top: 4px;
  padding: 7px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
}

.code-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.code-button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.copy-link-button {
  padding: 5px 7px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #111827;
  font-size: 0.78rem;
  font-weight: 700;
}

.copy-link-button:hover,
.copy-link-button:focus {
  background: #e5eefc;
  color: #111827;
}

.copy-link-button:disabled {
  cursor: default;
  opacity: 0.75;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-actions .small-button {
  min-width: 92px;
  text-align: center;
  white-space: nowrap;
}

.admin-actions form {
  margin: 0;
}

.small-muted {
  color: #64748b;
  font-size: 0.88rem;
}

.small-button {
  padding: 7px 10px;
  font-size: 0.88rem;
}

.button-link.small-button {
  padding: 7px 10px;
  font-size: 0.88rem;
}

.danger-button {
  background: #b91c1c;
}

.danger-button:hover {
  background: #991b1b;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.status-active {
  background: #ecfdf5;
  color: #065f46;
}

.status-inactive {
  background: #f3f4f6;
  color: #4b5563;
}

.drop-zone {
  margin-bottom: 14px;
  padding: 18px;
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  background: #eff6ff;
  text-align: center;
  cursor: pointer;
  transition: 0.2s ease;
}

.drop-zone.dragover {
  background: #dbeafe;
  border-color: #2563eb;
}

.drop-zone-small {
  font-size: 0.9rem;
  color: #6b7280;
}

@media (max-width: 640px) {
  .wrap {
    margin: 20px auto;
  }

  .card {
    padding: 18px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .fehler-tabelle th,
  .fehler-tabelle td {
    padding: 8px;
    font-size: 0.92rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .end-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .end-actions button,
  .end-actions .button-link {
    width: 100%;
    text-align: center;
  }
}

.upload-box {
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid #dbe3f0;
  border-radius: 8px;
  background: #f8fafc;
}

.image-preview-wrap {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.image-preview-button {
  padding: 0;
  background: transparent;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  line-height: 0;
  cursor: zoom-in;
}

.image-preview-button:hover,
.image-preview-button:focus {
  background: transparent;
  border-color: #0f766e;
}

.image-preview-button img {
  display: block;
  width: 150px;
  max-height: 110px;
  object-fit: cover;
}

.uploaded-image-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.result-image-button img {
  width: 220px;
  max-height: 170px;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.78);
}

.image-modal.is-visible {
  display: flex;
}

.image-modal-dialog {
  position: relative;
  max-width: min(96vw, 1100px);
  max-height: 92vh;
}

.image-modal-dialog img {
  display: block;
  max-width: 100%;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.image-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  background: #fff;
  color: #111827;
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.image-modal-close:hover,
.image-modal-close:focus {
  background: #e5eefc;
  color: #111827;
}

.upload-label {
  display: inline-block;
  margin-bottom: 8px;
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.45);
}

.loading-overlay.is-visible {
  display: flex;
}

.loading-dialog {
  width: min(360px, 100%);
  padding: 22px;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  border: 4px solid #d1fae5;
  border-top-color: #0f766e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .wrap {
    margin: 0;
    max-width: none;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }

  form,
  .no-print,
  .upload-box,
  .loading-overlay {
    display: none !important;
  }
}
