/* ===== AufgabenStudio Theme ===== */
:root {
  --head-color: #1e3a5f;
  --head-accent: #06b6d4;
  --head-gradient: linear-gradient(135deg, #1e3a5f 0%, #2d5a8e 100%);
  --div-color: #f0f9ff;
  --card-bg: #ffffff;
  --border-color: #e0e7ef;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-light: #ecfeff;
  --accent-rgb: 8,145,178;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f9ff;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Navbar ===== */
.navbar {
  background: var(--head-gradient) !important;
  box-shadow: 0 2px 12px rgba(15,23,42,.18);
  padding: 0.4rem 1rem;
  border-bottom: 2px solid var(--head-accent);
}

.navbar > .container,
.navbar > .container-fluid {
  flex-wrap: nowrap;
  gap: 12px;
  align-items: center;
}

.navbar .navbar-collapse {
  flex-grow: 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.navbar-brand .brand-favicon {
  width: 20px;
  height: 20px;
  display: block;
}

.navbar-brand .brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--head-accent), #22d3ee);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.navbar-brand .brand-text {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: #fff;
}

.navbar-brand .brand-text small {
  font-weight: 400;
  font-size: 0.65rem;
  color: rgba(255,255,255,.5);
  display: block;
  letter-spacing: 0.04em;
  line-height: 1;
  margin-top: -2px;
}

/* ===== Navbar Subject Select2 ===== */
.navbar-subject-wrapper {
  flex: 1 1 300px;
  min-width: 200px;
  max-width: none;
}

@media (max-width: 767px) {
  .navbar-subject-wrapper {
    flex: 1 1 100%;
    min-width: 100%;
    margin: 0.5rem 0 0.25rem 0;
  }
  
  /* Mobile Select2 Dropdown innerhalb Navbar halten */
  .navbar-collapse .select2-container {
    position: relative !important;
  }
  
  .navbar-collapse .select2-container .select2-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }
}

.navbar-subject-wrapper .select2-container {
  width: 100% !important;
}

.navbar-subject-wrapper .select2-container--bootstrap-5 .select2-selection {
  background: rgba(255,255,255,.12) !important;
  border: 1px solid rgba(255,255,255,.2) !important;
  border-radius: 8px !important;
  color: #fff !important;
  min-height: 36px;
  transition: all .2s;
}

.navbar-subject-wrapper .select2-container--bootstrap-5 .select2-selection:hover {
  background: rgba(255,255,255,.18) !important;
  border-color: rgba(255,255,255,.35) !important;
}

.navbar-subject-wrapper .select2-container--bootstrap-5.select2-container--focus .select2-selection,
.navbar-subject-wrapper .select2-container--bootstrap-5.select2-container--open .select2-selection {
  background: rgba(255,255,255,.22) !important;
  border-color: var(--head-accent) !important;
  box-shadow: 0 0 0 3px rgba(6,182,212,.25) !important;
}

.navbar-subject-wrapper .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  color: #fff !important;
  font-size: 0.875rem;
  padding-left: 12px;
}

@media (max-width: 767px) {
  .navbar-subject-wrapper .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    font-size: 0.8rem;
    padding-left: 10px;
  }
  
  .navbar-subject-wrapper .select2-container--bootstrap-5 .select2-selection {
    min-height: 32px;
  }
}

.navbar-subject-wrapper .select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
  color: rgba(255,255,255,.5) !important;
}

.navbar-subject-wrapper .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow b {
  border-color: rgba(255,255,255,.5) transparent transparent transparent !important;
}

/* ===== Navbar Nav Links ===== */
.navbar .nav-link {
  color: rgba(255,255,255,.8) !important;
  font-weight: 500;
  font-size: 0.875rem;
  transition: color .2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 767px) {
  .navbar .nav-link {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
  }
}

.navbar .nav-link:hover {
  color: #fff !important;
}

.navbar .nav-link .fa {
  font-size: 1rem;
}

/* ===== Dropdown Menus ===== */
.navbar .dropdown-menu {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem 0;
  margin-top: 0.5rem;
  min-width: 220px;
}

@media (max-width: 767px) {
  .navbar .dropdown-menu {
    min-width: 200px;
    font-size: 0.85rem;
  }
}

.navbar .dropdown-item {
  font-size: 0.875rem;
  padding: 0.55rem 1rem;
  color: var(--text-primary);
  transition: background .15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 767px) {
  .navbar .dropdown-item {
    font-size: 0.8rem;
    padding: 0.45rem 0.85rem;
    gap: 8px;
  }
}

.navbar .dropdown-item .fa,
.navbar .dropdown-item .menu-icon {
  width: 18px;
  text-align: center;
  font-size: 1rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.navbar .dropdown-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.navbar .dropdown-item:hover .fa,
.navbar .dropdown-item:hover .menu-icon {
  color: var(--accent);
}

.navbar .dropdown-item.disabled .fa,
.navbar .dropdown-item.disabled .menu-icon {
  color: var(--text-muted);
}

.navbar .dropdown-divider {
  margin: 0.25rem 0;
  border-color: var(--border-color);
}

/* ===== Navbar User Avatar ===== */
.navbar .user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--head-accent), #22d3ee);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .navbar .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }
}

/* ===== Navbar Info Button ===== */
.navbar .btn-nav-info {
  background: rgba(255,255,255,.2);
  border: 2px solid rgba(255,255,255,.4);
  color: #fff;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all .2s;
  font-size: 1.2rem;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .navbar .btn-nav-info {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 1rem;
    margin-left: 0.5rem !important;
  }
}

.navbar .btn-nav-info:hover {
  background: var(--head-accent);
  border-color: var(--head-accent);
  color: #fff;
}

/* ===== Sub-Topbar (Eye-Button, Info) ===== */
.tm-subtopbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  box-shadow: var(--shadow-sm);
}

/* ===== Cards & Panels ===== */
.tm-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  transition: box-shadow .2s;
}

.tm-card:hover {
  box-shadow: var(--shadow-md);
}

.tm-card-header {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* ===== Offcanvas ===== */
.offcanvas {
  border-right: 2px solid var(--head-accent) !important;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
}

.offcanvas-header {
  background: var(--head-gradient);
  color: #fff;
  padding: 1rem 1.25rem;
}

.offcanvas-header .offcanvas-title {
  font-weight: 700;
  font-size: 1rem;
}

.offcanvas-header .btn-close {
  filter: brightness(0) invert(1);
}

.offcanvas-body {
  padding: 1.25rem;
  background: #fff;
}

.offcanvas-body .input-group {
  margin-bottom: 0.75rem !important;
}

.offcanvas-body .input-group-text {
  background: var(--accent-light);
  border-color: var(--border-color);
  color: var(--accent);
  min-width: 42px;
  justify-content: center;
}

.offcanvas-body .form-control,
.offcanvas-body .form-select {
  border-color: var(--border-color);
  font-size: 0.875rem;
}

.offcanvas-body .form-control:focus,
.offcanvas-body .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.15);
}

/* ===== Toolbar Buttons ===== */
.tm-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px 0;
}

.tm-toolbar .btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-secondary);
  transition: all .15s;
}

.tm-toolbar .btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.tm-toolbar .btn.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tm-toolbar .btn.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.tm-toolbar-separator {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 4px;
}

/* ===== Subject Selector Row ===== */
.tm-topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.tm-topbar .input-group-text {
  background: var(--accent-light);
  border-color: var(--border-color);
  color: var(--accent);
}

.tm-topbar .form-select {
  border-color: var(--border-color);
}

.tm-topbar .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.15);
}

.tm-info-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--div-color);
  padding: 4px 10px;
  border-radius: 20px;
}

/* ===== DataTable Styling ===== */
.example td {
  padding: 2px 5px;
  font-size: 0.72rem;
  line-height: 1.2;
  vertical-align: middle;
}

.example th {
  padding: 5px 6px;
  font-size: 0.73rem;
  font-weight: 800;
  color: #334155;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  border-bottom: 2px solid var(--border-color) !important;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: normal;
}

.example tbody tr {
  transition: background .1s;
  cursor: pointer;
}

.example tbody tr:hover {
  background: var(--accent-light) !important;
}

.example tbody tr.selected {
  background: rgba(var(--accent-rgb),.12) !important;
}

.test-overview td {
  padding: 4px 6px;
  font-size: 0.75rem;
}

.test-overview th {
  padding: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ===== Test Panel ===== */
.tm-test-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem;
}

.tm-test-panel select[multiple] {
  font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fafbfc;
}

.tm-test-panel select[multiple]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.15);
}

.tm-test-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 0;
}

.tm-test-info strong {
  color: var(--text-primary);
}

/* ===== Hints & Info Row ===== */
.tm-info-row {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.tm-info-row .form-control {
  border-color: var(--border-color);
  font-size: 0.875rem;
}

.tm-info-row .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.15);
}

/* ===== Editor Area ===== */
.tm-editor-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.tm-editor-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

/* ===== Primary Button Override ===== */
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ===== Footer ===== */
footer {
  background: var(--head-color) !important;
  color: rgba(255,255,255,.7);
  margin-top: 1.5rem;
}

footer .row {
  background: transparent !important;
}

footer p {
  color: rgba(255,255,255,.6);
  font-size: 0.8rem;
  margin: 0;
}

footer a {
  color: rgba(255,255,255,.7) !important;
  text-decoration: none;
  font-size: 0.8rem;
  transition: color .2s;
}

footer a.tm-footer-link {
  color: #c7f9ff !important;
  font-weight: 600;
}

footer a:hover {
  color: #fff !important;
}

footer .bs-icon {
  background: rgba(255,255,255,.1) !important;
  color: rgba(255,255,255,.7) !important;
  transition: background .2s;
}

footer .bs-icon:hover {
  background: var(--accent) !important;
  color: #fff !important;
}

/* ===== Select2 Overrides ===== */
.select2-container--bootstrap-5 .select2-selection {
  border-color: var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
}

.select2-container--bootstrap-5 .select2-selection--single:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.15) !important;
}

/* ===== Utility ===== */
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }

.tm-section-gap {
  padding: 0.75rem 1rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--div-color);
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ===== Main Tabs ===== */
.tm-main-tabs {
  border-bottom: 2px solid var(--border-color);
}

.tm-main-tabs .nav-link {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tm-main-tabs .nav-link:hover {
  color: var(--accent);
  border-bottom-color: rgba(var(--accent-rgb), .3);
  background: transparent;
}

.tm-main-tabs .nav-link.active {
  color: var(--accent);
  background: var(--card-bg);
  border-color: transparent;
  border-bottom-color: var(--accent);
}

.tm-main-tabs .nav-link .fa {
  font-size: 0.95rem;
}

/* Editor-Aktionen direkt in der Tab-Zeile (spart vertikalen Platz im Editor) */
.tm-editor-tab-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 4px;
}

.tm-editor-tab-actions .tm-tb-btn {
  margin-top: 2px;
}

/* ===== Tab Content ===== */
.tm-tab-content {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.tm-panel-inner {
  padding: 0.75rem;
}

/* ===== Toolbar Row ===== */
.tm-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  gap: 6px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

/* DataTables controls inline with toolbar */
#qe-choice2 .dataTables_length,
#qe-choice2 .dataTables_filter,
#qe-choice2 .dt-length,
#qe-choice2 .dt-search {
  display: inline;
  font-size: 0.82rem;
}

#qe-choice2 .dataTables_length label,
#qe-choice2 .dataTables_filter label,
#qe-choice2 .dt-length label,
#qe-choice2 .dt-search label {
  display: inline-flex;
  align-items: center;
  font-weight: 400;
  margin: 0;
  font-size: 0.82rem;
}

#qe-choice2 .dataTables_length select,
#qe-choice2 .dt-length select {
  display: inline-block;
  width: auto;
  height: 24px;
  padding: 0 20px 0 6px;
  font-size: 0.78rem;
  margin: 0 4px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: #fff;
  background-image: none;
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  vertical-align: middle;
}

#qe-choice2 .dataTables_filter input,
#qe-choice2 .dt-search input {
  padding: 1px 8px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-left: 4px;
}

#qe-choice2 .dataTables_filter label input,
#qe-choice2 .dt-search label input {
  margin-left: 6px;
}

#qe-choice2 .dataTables_wrapper > .row:first-child {
  margin-top: 4px;
  margin-bottom: 0;
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

#qe-choice2 .dataTables_wrapper > .row:first-child * {
  pointer-events: auto;
}

#qe-choice2 .dataTables_wrapper > .row:first-child > div:first-child {
  padding-left: 0;
  display: flex;
  align-items: center;
}

#qe-choice2 .dataTables_wrapper > .row:first-child > div:last-child {
  padding-right: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  text-align: right;
}

#qe-choice2 .dataTables_wrapper > .row:last-child,
.tm-subject-overview-modal .dataTables_wrapper > .row:last-child {
  margin-top: 6px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px;
}

#qe-choice2 .dataTables_wrapper > .row:last-child > div,
.tm-subject-overview-modal .dataTables_wrapper > .row:last-child > div {
  width: auto;
  max-width: none;
  flex: 0 0 auto;
  padding-left: 0;
  padding-right: 0;
}

#qe-choice2 .dataTables_wrapper .dataTables_info,
.tm-subject-overview-modal .dataTables_wrapper .dataTables_info {
  white-space: nowrap;
}

#qe-choice2 .dataTables_wrapper .dataTables_paginate,
.tm-subject-overview-modal .dataTables_wrapper .dataTables_paginate {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

#qe-choice2 .tm-toolbar-right .dataTables_length,
#qe-choice2 .tm-toolbar-right .dataTables_filter,
#qe-choice2 .tm-toolbar-right .dt-length,
#qe-choice2 .tm-toolbar-right .dt-search {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

#qe-choice2 .tm-toolbar-right .dataTables_length + .dataTables_filter,
#qe-choice2 .tm-toolbar-right .dt-length + .dt-search,
#qe-choice2 .tm-toolbar-right .dataTables_length + .dt-search,
#qe-choice2 .tm-toolbar-right .dt-length + .dataTables_filter {
  margin-left: 14px;
}

.tm-toolbar-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.tm-toolbar-status {
  display: flex;
  align-items: center;
  min-height: 28px;
  flex: 1;
}

#qe-choice2 .tm-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  justify-content: flex-end;
}

#qe-choice2 .tm-toolbar-right .tm-dt-length-host,
#qe-choice2 .tm-toolbar-right .tm-dt-search-host {
  display: inline-flex;
  align-items: center;
}

#qe-choice2 .tm-legend-btn {
  color: var(--text-secondary);
  border-color: var(--border-color);
}

#qe-choice2 .tm-toolbar-right .tm-dt-search-right,
#qe-choice2 .tm-toolbar-right .dataTables_filter,
#qe-choice2 .tm-toolbar-right .dt-search {
  margin-left: auto;
}

/* ===== Toolbar Buttons (small icon buttons) ===== */
.tm-tb-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1;
  background: var(--card-bg);
  color: var(--accent);
  border: 1.5px solid var(--accent);
  transition: all .15s ease;
}

.tm-tb-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), .25);
}

.tm-tb-btn:active {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.tm-tb-btn:disabled, .tm-tb-btn.disabled {
  background: #f8fafc;
  color: var(--text-muted);
  border-color: var(--border-color);
  opacity: .5;
  pointer-events: none;
}

/* Transfer-Buttons (Pfeil rechts/links) */
.tm-tb-btn.tm-transfer-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.tm-tb-btn.tm-transfer-btn:hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.1);
}

.tm-tab-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* ===== DataTable Wrapper ===== */
.tm-datatable-wrap {
  font-size: 0.8rem;
  width: 100%;
  overflow-x: auto;
}

.tm-datatable-wrap table.dataTable {
  width: 100% !important;
  table-layout: auto;
  min-width: 800px;
}

.tm-datatable-wrap table.dataTable thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 10;
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
}

/* DataTables scrollHead auch sticky machen */
.tm-datatable-wrap .dataTables_scrollHead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.tm-datatable-wrap .dataTables_scrollHead table thead th {
  background: #f8fafc;
}

#qe-choice2 .dataTables_scrollBody {
  overflow-x: auto !important;
  max-height: 132px !important;
}

@media (max-width: 991px) {
  #qe-choice2 .dataTables_scrollBody {
    max-height: 250px !important;
  }
}

@media (max-width: 576px) {
  #qe-choice2 .dataTables_scrollBody {
    max-height: 300px !important;
  }
}

#quest-details .tm-tag-select-stack .select2-container {
  width: 100% !important;
}

.tm-tag-select-dropdown {
  min-width: 260px !important;
}

#quest-details .select2-container--open,
#quest-details .select2-dropdown,
#quest-details .tm-tag-select-dropdown {
  z-index: 2500 !important;
}

.tm-tag-select-dropdown .select2-results__option {
  font-size: 0.82rem;
}

/* Panel-Layout */
#qe-choice2 {
  overflow: visible;
}

/* ===== Hint Boxes ===== */
.tm-hint-box {
  background: var(--div-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin: 0 4px;
}

/* ===== Info Panel (rechte Seite) ===== */
.tm-info-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  position: sticky;
  top: 10px;
  overflow: visible;
}

#quest-details {
  position: relative;
  z-index: 20;
}

.tm-info-panel-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}

/* Inline Meta Badges (Punkte / Dauer / Niveau / KA) */
.tm-inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0.5rem 0 0.6rem;
  border-bottom: 1px solid var(--border-color);
}

.tm-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--div-color);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
  cursor: default;
}

.tm-meta-badge .fa {
  color: var(--accent);
  font-size: 0.72rem;
}

.tm-inline-input {
  width: 36px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0;
  -moz-appearance: textfield;
  appearance: textfield;
}

.tm-inline-input::-webkit-outer-spin-button,
.tm-inline-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tm-inline-input:focus {
  outline: none;
  background: rgba(var(--accent-rgb), 0.1);
  border-radius: 4px;
}

.tm-meta-check {
  cursor: pointer;
}

.tm-meta-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Detail Labels */
.tm-detail-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.tm-detail-label .fa {
  width: 13px;
  text-align: center;
  color: var(--accent);
  font-size: 0.68rem;
}

/* Compact row: Autor + Rechte inline */
.tm-info-compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.78rem;
}

.tm-author-info {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-author-info .fa {
  color: var(--accent);
  margin-right: 3px;
}

.tm-compact-select {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tm-compact-select .fa {
  color: var(--accent);
  font-size: 0.72rem;
}

.tm-compact-select .form-select-sm {
  width: auto;
  min-width: 70px;
  padding: 1px 24px 1px 6px;
  font-size: 0.75rem;
}

/* Status section - hide when empty */
.tm-info-status:empty {
  display: none;
}

.tm-info-section {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-color);
}

.tm-info-section:last-child {
  border-bottom: none;
}

/* Compact form controls inside info panel */
.tm-info-panel .form-control-sm,
.tm-info-panel .form-select-sm {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

.tm-info-panel .form-check {
  padding-top: 2px;
}

.tm-info-panel .form-check-label {
  margin-bottom: 0;
}

.tm-info-panel .input-group-sm .btn {
  font-size: 0.8rem;
}

/* ===== KA Info Badges (inline neben Buttons) ===== */
.tm-ka-info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tm-ka-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--div-color);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.tm-ka-badge .fa {
  color: var(--accent);
  font-size: 0.68rem;
}

/* KA Detail Grid (rechte Seite bei Tab Klassenarbeit) */
.tm-ka-detail-grid {
  padding: 0.5rem 0;
}

.tm-ka-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.tm-ka-detail-item:last-child {
  border-bottom: none;
}

.tm-ka-detail-item .fa {
  color: var(--accent);
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
}

.tm-ka-detail-item .tm-ka-label {
  color: var(--text-secondary);
  font-weight: 600;
  min-width: 50px;
}

.tm-ka-detail-item .tm-ka-value {
  color: var(--text-primary);
  font-weight: 700;
}

#ka-details {
  margin-top: 0;
}

/* ===== Zusammenstellung DnD refinements ===== */
.tm-questtest-dnd-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7fafc !important;
  border-color: #d9e2ec !important;
}

.tm-questtest-dnd-list {
  --tm-quest-row-height: 34px;
  max-height: calc(var(--tm-quest-row-height) * 6);
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.tm-questtest-dnd-list .tm-questtest-item {
  min-height: var(--tm-quest-row-height);
}

.tm-questtest-empty {
  margin-top: 6px;
  border: 1px solid #d8e4f0;
  border-radius: 10px;
  background: linear-gradient(135deg, #f8fbff 0%, #f1f6fd 100%);
  padding: 1rem 1.1rem;
  color: #334e68;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  text-align: center;
}

.tm-questtest-empty__icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e6f1ff;
  color: #1976a5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.tm-questtest-empty__title {
  font-weight: 700;
  color: #102a43;
  margin-bottom: 0.25rem;
}

.tm-questtest-empty__text {
  font-size: 0.9rem;
  color: #486581;
}

.tm-questtest-item--task {
  background: #ffffff;
  border-left: 3px solid #67b26f;
}

.tm-questtest-item--break {
  background: #f8fafc;
  border-left: 3px solid #94a3b8;
}

.tm-questtest-item--task.active,
.tm-questtest-item--break.active {
  color: #102a43;
  background: #e6f1ff;
}

/* ===== KI-Assistent Panel ===== */
.tm-ai-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 300px;
}

.tm-ai-panel-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  margin: 0;
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(8,145,178,.06) 0%, rgba(6,182,212,.03) 100%);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tm-ai-panel-title .fa {
  color: var(--accent);
  font-size: 1.1rem;
}

.tm-ai-quickbar {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.tm-ai-actions-btn,
.tm-ai-chip {
  font-size: 0.75rem;
  white-space: nowrap;
  line-height: 1.2;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
}

.tm-ai-actions-btn .fa,
.tm-ai-chip .fa {
  margin-right: 4px;
}

.tm-ai-actions-menu {
  min-width: 250px;
  max-width: 320px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  z-index: 1080;
}

.tm-ai-actions-menu .dropdown-item {
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: normal;
}

.tm-ai-actions-menu .dropdown-item .fa {
  width: 16px;
  text-align: center;
  color: var(--accent);
}

.tm-ai-chat {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  max-height: 400px;
}

.tm-ai-message {
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  max-width: 90%;
}

.tm-ai-message p {
  margin: 0;
}

.tm-ai-system {
  background: var(--div-color);
  color: var(--text-secondary);
  align-self: flex-start;
  border-left: 3px solid var(--accent);
}

.tm-ai-user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-radius: var(--radius-sm) var(--radius-sm) 2px var(--radius-sm);
}

.tm-ai-input {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border-color);
}

.tm-ai-transfer {
  padding: 0.45rem 0.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tm-ai-transfer .btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  line-height: 1.2;
}

.tm-ai-input .form-control {
  font-size: 0.82rem;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.tm-ai-input .btn {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
}

/* ===== Modal Styles ===== */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  background: var(--head-gradient) !important;
  color: #fff;
  border-bottom: none;
  padding: 1rem 1.5rem;
}

.modal-header .modal-title {
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.7;
}

.modal-header .btn-close:hover {
  opacity: 1;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  background: var(--div-color);
}

.modal-footer .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.modal-footer .btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.modal-footer .btn-secondary {
  border-radius: var(--radius-sm);
}

/* Modal form labels */
.modal-body label.control-label,
.modal-body label.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 0.5rem;
}

.modal-body .input-group {
  margin-bottom: 0.75rem !important;
}

.modal-body .input-group-text {
  background: var(--div-color);
  border-color: var(--border-color);
  color: var(--accent);
}

/* Modal link footer (Login/Registration toggle) */
.modal .tm-modal-link-footer {
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  font-size: 0.85rem;
  text-align: right;
  color: var(--text-secondary);
}

.modal .tm-modal-link-footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.modal .tm-modal-link-footer a:hover {
  text-decoration: underline;
}

/* Modal helper blocks for compact, cleaner confirmation dialogs */
.tm-modal-lead {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.65rem;
}

.tm-modal-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 0.55rem 0.7rem;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  background: #eff6ff;
  color: #1e3a5f;
  font-size: 0.86rem;
}

.tm-modal-note .fa {
  margin-top: 2px;
}

.tm-modal-note-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
  margin-bottom: 0.65rem;
}

.tm-modal-list {
  max-height: 170px;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  padding: 0.45rem 0.6rem;
}

.tm-modal-bullets {
  margin: 0.45rem 0 0.65rem;
  padding-left: 1.1rem;
  color: var(--text-primary);
}

.tm-modal-bullets li {
  margin-bottom: 0.2rem;
}

/* Subject modal family */
.tm-subject-overview-modal .modal-dialog {
  max-width: 980px;
}

.tm-subject-overview-modal #datatbl_sub-oview {
  width: 100% !important;
}

.tm-subject-overview-modal .modal-body {
  padding-top: 1.1rem;
}

.tm-subject-overview-modal .modal-footer,
.tm-subject-prop-modal .modal-footer,
.tm-subject-check-modal .modal-footer,
.tm-subject-delete-check-modal .modal-footer {
  gap: 0.45rem;
}

.tm-subject-prop-modal .modal-dialog {
  max-width: 760px;
}

.tm-subject-prop-modal #sub-mod-body {
  padding-top: 0.15rem;
}

.tm-subject-check-modal .modal-dialog,
.tm-subject-delete-check-modal .modal-dialog {
  max-width: 620px;
}

/* Specific confirmation modals */
.tm-question-change-modal .modal-dialog,
.tm-delete-modal .modal-dialog,
.tm-session-end-modal .modal-dialog {
  max-width: 560px;
}

.tm-question-change-modal .modal-header,
.tm-delete-modal .modal-header,
.tm-session-end-modal .modal-header {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

/* Login error */
.modal #login-error,
.modal #registr_error {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
  padding: 0 0.5rem;
}

/* ===== User Statistics Modal ===== */
.tm-usr-stat-modal .modal-dialog {
  max-width: 780px;
}

/* ===== Info Modal ===== */
.tm-info-modal .modal-dialog {
  max-width: 840px;
}

.tm-info-content {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.tm-info-hero {
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  background: linear-gradient(120deg, #eff6ff 0%, #f0f9ff 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.tm-info-version {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.tm-info-copy {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.tm-info-datehint {
  font-size: 0.74rem;
  font-weight: 700;
  color: #0c4a6e;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
}

.tm-info-stack {
  display: grid;
  gap: 0.65rem;
}

.tm-info-lib-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.68rem 0.8rem;
  box-shadow: var(--shadow-sm);
}

.tm-info-lib-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tm-info-lib-ver {
  color: var(--accent);
  font-weight: 800;
}

.tm-info-lib-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.tm-test-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--div-color);
  width: fit-content;
  margin-bottom: 0.6rem;
}

.tm-test-meta-label {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}

.tm-test-meta-value {
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 700;
}

.tm-date-group .tm-date-input {
  border-right: 0;
}

.tm-date-open {
  min-width: 44px;
}

.tm-date-help {
  margin-top: 0.2rem;
  margin-bottom: 0.45rem;
}

/* ===== User Properties Modal ===== */
.tm-user-prop-modal .modal-dialog {
  max-width: 840px;
}

.tm-user-prop-form {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.tm-user-prop-form .form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.tm-user-prop-form .form-control,
.tm-user-prop-form .form-select {
  border-radius: var(--radius-sm);
}

.tm-user-prop-form .form-control:focus,
.tm-user-prop-form .form-select:focus {
  border-color: #67e8f9;
  box-shadow: 0 0 0 0.2rem rgba(var(--accent-rgb), 0.14);
}

.tm-user-prop-password-note {
  margin-top: 0.9rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid #bae6fd;
  background: #ecfeff;
  color: #0f4c5c;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
}

.tm-user-prop-password-note .fa {
  color: var(--accent);
  margin-top: 2px;
}

.tm-user-pass-panel {
  margin-top: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  padding: 0.75rem;
}

.tm-user-pass-rules {
  margin-top: 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.5rem 0.6rem;
}

.tm-pass-rule-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.tm-pass-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.2rem 0.9rem;
}

.tm-pass-rule {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.tm-pass-rule .fa {
  margin-right: 4px;
}

#usr_prop_pass_error {
  margin-top: 0.55rem;
}

@media (max-width: 768px) {
  .tm-pass-rule-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Tag Modal ===== */
.tm-tag-modal .modal-dialog {
  max-width: 1100px;
}

.tm-tag-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tm-tag-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.75rem;
}

.tm-tag-toolbar > div:first-child {
  flex: 1;
}

.tm-tag-help {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--div-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.55rem;
  white-space: nowrap;
}

.tm-tag-grid-wrap {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.75rem;
  max-height: 56vh;
  overflow: auto;
}

.tm-tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.35rem;
}

.tm-tag-item {
  margin-bottom: 0;
}

.tm-tag-item .form-control {
  font-size: 0.86rem;
}

.tm-tag-item .form-control.tm-tag-changed {
  background-color: #fff3cd;
  border-color: #ffc107;
}

.tm-tag-item .form-control.tm-tag-empty-warning {
  background-color: #f8d7da;
  border-color: #dc3545;
}

.tm-tag-check {
  background: var(--div-color);
}

.tm-tag-badge {
  background: var(--div-color);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  min-width: 42px;
  justify-content: center;
}

/* ===== Grade Scale Modal ===== */
.tm-grade-modal .modal-dialog {
  max-width: 980px;
}

.tm-grade-content {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.tm-grade-hero {
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  background: linear-gradient(120deg, #eff6ff 0%, #f8fbff 100%);
  padding: 0.75rem 0.9rem;
}

.tm-grade-hero-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}

.tm-grade-hero-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.tm-grade-table-wrap {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: 58vh;
  background: #fff;
}

.tm-grade-head-grid .form-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tm-grade-top-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 0.25rem;
}

.tm-grade-grid {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.65rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 0.7rem;
}

.tm-grade-item {
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: center;
  gap: 0.45rem;
}

.tm-grade-item label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.tm-grade-item .form-control {
  font-size: 0.82rem;
  min-height: 30px;
  padding: 0.2rem 0.45rem;
}

#grade-scale-status {
  min-height: 1.1rem;
}

@media (max-width: 767.98px) {
  .tm-grade-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Modal Footer Button System ===== */
.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.modal-footer .btn {
  min-width: 96px;
  border-radius: 10px;
}

.modal-footer .btn-outline-secondary,
.modal-footer .btn-default {
  order: 1;
  color: #62707d;
  border-color: #7a8793;
  background: #f5f8fb;
}

.modal-footer .btn-outline-danger,
.modal-footer .btn-danger {
  order: 2;
  color: #dc3545;
  border-color: #dc3545;
  background: #fff;
}

.modal-footer .btn-secondary {
  order: 3;
  color: #fff;
  border-color: #6c7a89;
  background: #6c7a89;
}

.modal-footer .btn-outline-primary {
  order: 3;
}

.modal-footer .btn-primary {
  order: 4;
  color: #fff;
  border-color: #1b95b7;
  background: #1b95b7;
}

.modal-footer .btn-primary:hover,
.modal-footer .btn-primary:focus {
  border-color: #177f9c;
  background: #177f9c;
}

/* Neu-Buttons: dezenter grüner Rahmen */
.modal-footer .btn[id*="new"],
#grade-scale-new {
  color: #4f7f5c;
  border-color: #9ec7aa;
  background: #f7fcf8;
}

.modal-footer .btn[id*="new"]:hover,
.modal-footer .btn[id*="new"]:focus,
#grade-scale-new:hover,
#grade-scale-new:focus {
  color: #3e6549;
  border-color: #86b895;
  background: #eef8f1;
}

.usr-stat-modal-content {
  padding: 0.2rem;
}

.usr-stat-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.usr-stat-hero {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: linear-gradient(120deg, #ecfeff 0%, #f0f9ff 100%);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
}

.usr-stat-hero-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--head-gradient);
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.usr-stat-hero-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.usr-stat-hero-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.usr-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.usr-stat-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.75rem 0.85rem;
  box-shadow: var(--shadow-sm);
}

.usr-stat-label {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.usr-stat-label .fa {
  color: var(--accent);
}

.usr-stat-value {
  margin-top: 0.2rem;
  font-size: 1.5rem;
  line-height: 1.1;
  font-weight: 800;
  color: var(--text-primary);
}

.usr-stat-meta {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.usr-stat-footnote {
  font-size: 0.76rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.usr-stat-footnote .fa {
  color: var(--accent);
}

/* ===== Unsaved Changes Indicator ===== */
@keyframes tm-pulse-save {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

.tm-tb-btn.tm-unsaved {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: tm-pulse-save 1.5s ease-in-out infinite;
  position: relative;
}

.tm-tb-btn.tm-unsaved:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.tm-unsaved-bar {
  display: none;
  align-items: center;
  gap: 6px;
  background: linear-gradient(90deg, #fef2f2, #fff1f2);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  margin-bottom: 0;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 600;
  color: #b91c1c;
  transition: all .3s ease;
}

.tm-unsaved-bar.active {
  display: flex;
}

.tm-unsaved-bar .fa {
  font-size: 0.8rem;
  color: var(--danger);
}

.tm-unsaved-bar .tm-unsaved-text {
  flex: 1;
}

/* ===== Responsive ===== */
@media (max-width: 576px) {
  .tm-toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .tm-toolbar-buttons,
  .tm-toolbar-status,
  .tm-toolbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .tm-toolbar-right {
    margin-left: 0;
    margin-top: 6px;
  }

  .tm-datatable-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .example {
    font-size: 0.7rem;
  }

  .example td {
    padding: 3px 4px;
    font-size: 0.68rem;
  }

  .example th {
    padding: 4px 5px;
    font-size: 0.68rem;
  }

  .tm-main-tabs .nav-link {
    font-size: 0.8rem;
    padding: 0.5rem 0.8rem;
  }

  .tm-panel-inner {
    padding: 0.5rem;
  }
}

@media (max-width: 768px) {
  .navbar {
    padding: 0.3rem 0.75rem;
  }
  
  .navbar-brand .brand-text {
    font-size: 1rem;
  }
  
  .navbar-brand .brand-icon {
    width: 30px;
    height: 30px;
  }
  
  .navbar-brand .brand-favicon {
    width: 18px;
    height: 18px;
  }
  
  .navbar-toggler {
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
  }
  
  .navbar-collapse {
    margin-top: 0.5rem;
  }
  
  .navbar-nav {
    gap: 0.25rem;
  }
  
  #qe-choice2 .dataTables_wrapper > .row:first-child {
    margin-top: 6px;
  }

  #qe-choice2 .dataTables_wrapper > .row:first-child > div:first-child,
  #qe-choice2 .dataTables_wrapper > .row:first-child > div:last-child {
    padding-left: 0;
    padding-right: 0;
    display: block;
  }

  #qe-choice2 .dataTables_wrapper > .row:last-child,
  .tm-subject-overview-modal .dataTables_wrapper > .row:last-child {
    flex-wrap: wrap;
    gap: 6px;
  }

  #qe-choice2 .dataTables_wrapper .dataTables_paginate,
  .tm-subject-overview-modal .dataTables_wrapper .dataTables_paginate {
    margin-left: 0;
    text-align: left;
  }

  .tm-topbar .row > div {
    margin-bottom: 0.5rem;
  }
  .navbar-subject-wrapper {
    min-width: 120px;
    max-width: 100%;
    margin: 0.5rem 0;
  }

  .usr-stat-grid {
    grid-template-columns: 1fr;
  }

  .tm-info-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .tm-tag-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tm-tag-help {
    white-space: normal;
  }

  .tm-editor-tab-actions {
    margin-left: auto;
    padding-right: 0;
  }
}

@media (max-width: 991px) {
  .tm-info-panel {
    margin-top: 1rem;
    position: static;
  }
  .tm-ai-panel {
    margin-top: 1rem;
    min-height: 250px;
  }
  .tm-ai-quickbar {
    flex-wrap: wrap;
    overflow: visible;
  }

  #qe-choice .col-lg-8,
  #qe-choice .col-lg-4,
  #qe-choice .col-xl-9,
  #qe-choice .col-xl-3 {
    width: 100%;
    max-width: 100%;
  }

  #editor-row .col-lg-8,
  #editor-row .col-lg-4,
  #editor-row .col-xl-9,
  #editor-row .col-xl-3 {
    width: 100%;
    max-width: 100%;
  }
}

/* ===== Side-by-Side Editor Layout ===== */
#editor-sidebyside-container,
#main-sidebyside-container {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.tm-sidebyside-row {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
}

.tm-sidebyside-col {
  flex: 1;
  min-width: 0;
  padding: 0;
  position: relative;
  border-right: 1px solid var(--border-color);
}

.tm-sidebyside-col:last-child {
  border-right: none;
}

.tm-sidebyside-header {
  background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tm-sidebyside-header .fa {
  color: var(--accent);
  font-size: 0.95rem;
}

.tm-sidebyside-editor,
.tm-sidebyside-main {
  padding: 0.75rem;
  overflow-x: auto;
}

/* Verhindert Tabellenumbrüche in Side-by-Side-Ansicht */
.tm-sidebyside-main table {
  table-layout: auto;
  width: 100%;
  min-width: 600px;
}

.tm-sidebyside-main select#questtest {
  width: 100%;
  display: block;
  min-width: 100%;
  box-sizing: border-box;
}

/* Container für Select-Element mit Scrollbalken */
.tm-sidebyside-main #t-choice {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Schlagwort-Text in Klassenarbeit kürzen */
.tm-questtest-tag {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  display: inline-block;
}

/* Numerische Spalten rechtsbündig */
.tm-questtest-num {
  text-align: right;
  display: inline-block;
}

/* Zusatzinfos als Accordion im Side-by-Side-Modus */
.tm-sidebyside-accordion {
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
}

.tm-sidebyside-accordion-header {
  background: #f8fafc;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: background .2s;
  user-select: none;
}

.tm-sidebyside-accordion-header:hover {
  background: #f1f5f9;
}

.tm-sidebyside-accordion-header .fa {
  color: var(--accent);
  transition: transform .2s;
}

.tm-sidebyside-accordion-header.collapsed .fa-chevron-down {
  transform: rotate(-90deg);
}

.tm-sidebyside-accordion-body {
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
}

/* Responsive: Spalten stapeln auf kleinen Bildschirmen */
@media (max-width: 767px) {
  .tm-sidebyside-col {
    flex: 0 0 100%;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  
  .tm-sidebyside-col:last-child {
    border-bottom: none;
  }
}
