:root {
    --blue: #1a5fa8;
    --blue-light: #e8f1fb;
    --blue-mid: #3a7fd4;
    --green: #2d7a4f;
    --green-light: #e6f4ed;
    --amber: #9a5a0a;
    --amber-light: #fef3e2;
    --red: #c0392b;
    --red-light: #fdecea;
    --gray-50: #f8f8f6;
    --gray-100: #f0eeea;
    --gray-200: #e2dfda;
    --gray-400: #9e9b94;
    --gray-600: #5a5750;
    --gray-900: #1a1916;
    --white: #ffffff;
    --sidebar-w: 220px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* ── Top bar ── */
  .topnav {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
  }
  .brand { display: flex; align-items: center; gap: 10px; }
  .brand-dot {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--blue); display: flex; align-items: center;
    justify-content: center; color: white; font-size: 13px; font-weight: 600;
  }
  .brand-name { font-size: 15px; font-weight: 600; color: var(--gray-900); }
  .brand-tag { font-size: 11px; color: var(--gray-400); margin-left: 2px; }
  .topnav-right { display: flex; align-items: center; gap: 12px; }
  .avatar-sm {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--blue); color: white;
    font-size: 11px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
  }
  .notif-btn {
    background: none; border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); padding: 5px 10px;
    font-size: 12px; color: var(--gray-600); cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: background 0.15s;
  }
  .notif-btn:hover { background: var(--gray-50); }

  /* ── Layout ── */
  .layout { display: flex; flex: 1; overflow: hidden; }

  /* ── Sidebar ── */
  .sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex; flex-direction: column;
    flex-shrink: 0;
    padding: 12px 10px;
  }
  .nav-section-label {
    font-size: 10px; font-weight: 600; color: var(--gray-400);
    text-transform: uppercase; letter-spacing: 0.07em;
    padding: 14px 8px 6px;
  }
  .nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13.5px; color: var(--gray-600);
    margin-bottom: 1px; transition: all 0.12s; border: 1px solid transparent;
    text-decoration: none;
  }
  .nav-item:hover { background: var(--gray-50); color: var(--gray-900); }
  .nav-item.active {
    background: var(--blue-light); color: var(--blue);
    font-weight: 500; border-color: rgba(26,95,168,0.15);
  }
  .nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
  .nav-badge {
    margin-left: auto; background: var(--blue); color: white;
    font-size: 10px; font-weight: 600; padding: 1px 6px;
    border-radius: 99px; min-width: 18px; text-align: center;
  }
  .sidebar-footer {
    margin-top: auto; border-top: 1px solid var(--gray-200); padding-top: 12px;
  }
  .user-card {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    cursor: pointer; transition: background 0.12s;
  }
  .user-card:hover { background: var(--gray-50); }
  .user-name { font-size: 13px; font-weight: 500; color: var(--gray-900); }
  .user-sub { font-size: 11px; color: var(--gray-400); }

  /* ── Main content ── */
  .main { flex: 1; overflow-y: auto; padding: 24px 28px; }

  /* ── Page header ── */
  .page-header { margin-bottom: 22px; }
  .page-title { font-size: 20px; font-weight: 600; color: var(--gray-900); }
  .page-sub { font-size: 13px; color: var(--gray-400); margin-top: 3px; }

  /* ── Stat cards ── */
  .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
  .stat-card {
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius); padding: 14px 16px;
    box-shadow: var(--shadow);
  }
  .stat-num { font-size: 26px; font-weight: 600; color: var(--gray-900); font-family: 'DM Mono', monospace; }
  .stat-label { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
  .stat-delta { font-size: 11px; margin-top: 6px; color: var(--green); font-weight: 500; }

  /* ── Section ── */
  .section-title {
    font-size: 13px; font-weight: 600; color: var(--gray-600);
    margin-bottom: 10px; display: flex; align-items: center;
    justify-content: space-between;
  }
  .link-btn { font-size: 12px; color: var(--blue); cursor: pointer; font-weight: 400; }
  .link-btn:hover { text-decoration: underline; }

  /* ── Cards ── */
  .card {
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px;
    box-shadow: var(--shadow); cursor: pointer; transition: all 0.15s;
  }
  .card:hover { border-color: var(--blue-mid); box-shadow: var(--shadow-md); transform: translateY(-1px); }
  .card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .card-title { font-size: 14px; font-weight: 500; color: var(--gray-900); margin-bottom: 4px; }
  .card-meta { font-size: 12px; color: var(--gray-400); }

  /* ── Badges ── */
  .badge {
    display: inline-block; font-size: 11px; font-weight: 500;
    padding: 2px 8px; border-radius: 99px; flex-shrink: 0;
  }
  .badge-blue { background: var(--blue-light); color: var(--blue); }
  .badge-green { background: var(--green-light); color: var(--green); }
  .badge-amber { background: var(--amber-light); color: var(--amber); }
  .badge-gray { background: var(--gray-100); color: var(--gray-600); }

  /* ── Buttons ── */
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; cursor: pointer;
    font-family: 'DM Sans', sans-serif; transition: all 0.12s;
    border: 1px solid var(--gray-200); background: var(--white); color: var(--gray-900);
  }
  .btn:hover { background: var(--gray-50); }
  .btn-primary {
    background: var(--blue); color: white; border-color: var(--blue);
  }
  .btn-primary:hover { background: #1550a0; }
  .btn-sm { padding: 5px 10px; font-size: 12px; }

  /* ── Module Hub ── */
  .module-card {
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius); margin-bottom: 10px;
    box-shadow: var(--shadow); overflow: hidden;
  }
  .module-header {
    padding: 14px 16px; display: flex; align-items: center;
    justify-content: space-between; cursor: pointer;
    transition: background 0.12s;
  }
  .module-header:hover { background: var(--gray-50); }
  .module-title { font-size: 14px; font-weight: 600; color: var(--gray-900); margin-bottom: 4px; }
  .module-tags { display: flex; gap: 6px; flex-wrap: wrap; }
  .module-body { border-top: 1px solid var(--gray-100); padding: 0 16px; }
  .resource-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0; border-bottom: 1px solid var(--gray-100);
    font-size: 13px; gap: 12px;
  }
  .resource-row:last-child { border-bottom: none; }
  .resource-icon {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    background: var(--red-light); color: var(--red);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
  }
  .resource-name { color: var(--gray-900); flex: 1; }
  .resource-uploader { font-size: 11px; color: var(--gray-400); }
  .resource-size { font-size: 11px; color: var(--gray-400); font-family: 'DM Mono', monospace; }
  .dl-btn {
    font-size: 11px; color: var(--blue); cursor: pointer;
    padding: 4px 8px; border-radius: var(--radius-sm);
    border: 1px solid var(--blue-light); background: var(--blue-light);
    font-family: 'DM Sans', sans-serif; font-weight: 500;
    transition: background 0.12s;
  }
  .dl-btn:hover { background: #d0e4f7; }
  .upload-zone {
    border: 2px dashed var(--gray-200); border-radius: var(--radius);
    padding: 24px; text-align: center; color: var(--gray-400);
    font-size: 13px; cursor: pointer; margin-bottom: 16px;
    transition: all 0.15s;
  }
  .upload-zone:hover { border-color: var(--blue-mid); color: var(--blue); background: var(--blue-light); }

  /* ── Peer Matching ── */
  .peer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
  .peer-card {
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius); padding: 14px 16px;
    box-shadow: var(--shadow); transition: all 0.15s;
  }
  .peer-card:hover { border-color: var(--blue-mid); transform: translateY(-1px); box-shadow: var(--shadow-md); }
  .peer-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
  .peer-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; flex-shrink: 0;
  }
  .peer-name { font-size: 14px; font-weight: 600; color: var(--gray-900); }
  .peer-sem { font-size: 11px; color: var(--gray-400); margin-top: 1px; }
  .peer-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
  .tag {
    font-size: 11px; padding: 2px 7px; border-radius: 99px;
    background: var(--gray-100); color: var(--gray-600);
  }
  .online-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #27ae60;
    display: inline-block; margin-right: 4px;
  }
  .offline-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--gray-400);
    display: inline-block; margin-right: 4px;
  }

  /* ── Chat / KI ── */
  .chat-layout { display: flex; flex-direction: column; height: calc(100vh - 52px - 48px); }
  .chat-messages {
    flex: 1; overflow-y: auto; padding: 4px 0 16px;
    display: flex; flex-direction: column; gap: 12px;
  }
  .msg { max-width: 75%; }
  .msg-user { align-self: flex-end; }
  .msg-bot { align-self: flex-start; }
  .msg-sender { font-size: 11px; color: var(--gray-400); margin-bottom: 4px; padding: 0 4px; }
  .msg-bubble {
    padding: 10px 14px; border-radius: 14px;
    font-size: 14px; line-height: 1.55;
  }
  .msg-user .msg-bubble { background: var(--blue); color: white; border-bottom-right-radius: 4px; }
  .msg-bot .msg-bubble {
    background: var(--white); color: var(--gray-900);
    border: 1px solid var(--gray-200); border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
  }
  .chat-footer {
    border-top: 1px solid var(--gray-200); padding-top: 14px;
    display: flex; gap: 10px; flex-shrink: 0;
  }
  .chat-input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); font-size: 14px;
    font-family: 'DM Sans', sans-serif; color: var(--gray-900);
    background: var(--white); outline: none; transition: border 0.15s;
  }
  .chat-input:focus { border-color: var(--blue); }
  .typing { display: flex; gap: 4px; padding: 10px 14px; align-items: center; }
  .typing span {
    width: 7px; height: 7px; background: var(--gray-400);
    border-radius: 50%; animation: bounce 1.2s infinite;
  }
  .typing span:nth-child(2) { animation-delay: 0.2s; }
  .typing span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

  /* ── Views ── */
  .view { display: none; }
  .view.active { display: block; }
  #view-chat.active { display: flex; flex-direction: column; }

  /* ── Scrollbar ── */
  ::-webkit-scrollbar { width: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 10px; }

  /* ── Animations ── */
  @keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
  .card, .stat-card, .module-card, .peer-card { animation: fadeUp 0.25s ease both; }

  /* ── Search bar ── */
  .search-bar {
    display: flex; align-items: center; gap: 10px;
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); padding: 8px 14px;
    margin-bottom: 16px; box-shadow: var(--shadow);
  }
  .search-bar input {
    border: none; outline: none; flex: 1;
    font-size: 13px; font-family: 'DM Sans', sans-serif;
    color: var(--gray-900); background: transparent;
  }
  .search-bar input::placeholder { color: var(--gray-400); }

  /* ── Filter pills ── */
  .filter-row { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
  .filter-pill {
    padding: 5px 12px; border-radius: 99px; font-size: 12px;
    font-weight: 500; cursor: pointer; border: 1px solid var(--gray-200);
    background: var(--white); color: var(--gray-600); transition: all 0.12s;
    font-family: 'DM Sans', sans-serif;
  }
  .filter-pill:hover, .filter-pill.active { background: var(--blue); color: white; border-color: var(--blue); }

  /* ── Activity feed ── */
  .activity-item {
    display: flex; gap: 10px; padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
  }
  .activity-item:last-child { border-bottom: none; }
  .activity-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--blue); margin-top: 5px; flex-shrink: 0;
  }
  .activity-text { font-size: 13px; color: var(--gray-900); line-height: 1.5; }
  .activity-time { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

  /* ── Suggested questions ── */
  .suggestion-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
  .chip {
    font-size: 12px; padding: 6px 12px; border-radius: 99px;
    background: var(--blue-light); color: var(--blue);
    cursor: pointer; border: 1px solid rgba(26,95,168,0.15);
    transition: background 0.12s; font-family: 'DM Sans', sans-serif;
  }
  .chip:hover { background: #d2e7f8; }

/* ════════════════════════════════════════════
   MOBILE / RESPONSIVE (bis 768px)
   ════════════════════════════════════════════ */

/* Hamburger-Button: überall sichtbar */
.hamburger {
  display: inline-flex;
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-900);
  line-height: 1;
}

/* Overlay hinter der mobilen Sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
}

/* Desktop: Sidebar einklappbar */
@media (min-width: 769px) {
  .layout.sidebar-collapsed .sidebar { display: none; }
}

@media (max-width: 768px) {

  /* Sidebar wird zum Slide-in-Panel */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }

  /* Hauptbereich nutzt volle Breite + scrollt sauber */
  body { height: 100dvh; }
  .main { padding: 16px 14px 60px; -webkit-overflow-scrolling: touch; }
  .chat-layout { height: auto; }
  #view-chat.active { min-height: calc(100dvh - 140px); }
  .chat-messages { max-height: none; }

  /* Topbar kompakter */
  .topnav { padding: 0 12px; }
  .brand-tag { display: none; }

  /* Statistik-Karten: 2 Spalten statt 4 */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-num { font-size: 20px; }

  /* Dashboard-Spalten untereinander */
  .content-columns,
  #view-dashboard .main > div[style*="grid"],
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Peer-Karten: 1 Spalte */
  .peer-grid { grid-template-columns: 1fr; }

  /* Chat-Nachrichten breiter */
  .msg { max-width: 92%; }

  /* Seiten-Header mit Button: umbrechen */
  .page-header { flex-wrap: wrap; gap: 10px; }
  .page-title { font-size: 17px; }

  /* Tabellen/Ressourcen-Zeilen: umbrechen erlauben */
  .resource-row { flex-wrap: wrap; }
  .resource-name { min-width: 60%; }

  /* Formulare im Admin: untereinander */
  #view-admin div[style*="grid-template-columns:80px"] {
    grid-template-columns: 1fr !important;
  }

  /* Modul-Header nicht überlaufen */
  .module-title { font-size: 13px; }
  .filter-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .filter-pill { flex-shrink: 0; }
}

/* Sehr kleine Geräte */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .btn { font-size: 12px; padding: 6px 10px; }
}
