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

:root {
  --yellow:   #F5C200;
  --yellow-d: #d4a800;
  --dark:     #171717;
  --dark2:    #2a2a2a;
  --sidebar:  #212121;
  --text:     #0d0d0d;
  --muted:    #8e8ea0;
  --border:   #e5e5e5;
  --border-s: rgba(255,255,255,.08);
  --bg:       #f7f7f8;
  --white:    #ffffff;
  --radius:   12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  color: var(--text) !important;
  background: var(--white) !important;
  line-height: 1.6 !important;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────── */
.wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  background: var(--white);
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 16px 14px;
}

.sidebar-brand-name {
  color: var(--white);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.2px;
}

.sidebar-brand-sub {
  color: rgba(255,255,255,.3);
  font-size: 11px;
  margin-top: 2px;
  padding-left: 2px;
}

/* ── New Chat Button ─────────────────────────── */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 10px 8px;
  padding: 9px 13px;
  border-radius: 8px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.new-chat-btn span {
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
  color: rgba(255,255,255,.5);
}

.new-chat-btn:hover {
  background: rgba(255,255,255,.07);
  color: var(--white);
}

/* ── Nav Items ───────────────────────────────── */
.sidebar-nav, .sidebar-nav-bottom {
  padding: 6px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  border-radius: 8px;
  margin: 1px 10px;
  transition: background .12s, color .12s;
  border-left: none;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
}

.nav-item.active {
  background: rgba(255,255,255,.1);
  color: var(--white);
  font-weight: 500;
}

.nav-icon { width: 18px; text-align: center; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-nav-bottom {
  margin-top: auto;
  border-top: 1px solid var(--border-s);
  flex-shrink: 0;
  padding-top: 8px;
}

/* ── Sidebar Footer ──────────────────────────── */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-s);
  flex-shrink: 0;
}

.sidebar-footer-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.admin-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.4);
  text-decoration: none;
  font-size: 13px;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}

.admin-link:hover {
  background: rgba(255,255,255,.14);
  color: var(--yellow);
}

.sidebar-user {
  color: rgba(255,255,255,.45);
  font-size: 12px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255,255,255,.3);
  font-size: 12px;
  text-decoration: none;
  transition: color .15s;
  padding: 2px 0;
}

.logout-btn:hover { color: rgba(255,255,255,.6); }

/* ── Page / Content ──────────────────────────── */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 44px 28px 80px;
}

.page-greeting {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 28px;
  letter-spacing: -.4px;
}

/* ── Stats ───────────────────────────────────── */
.stats {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 130px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: box-shadow .2s;
}

.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }

.stat-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
  letter-spacing: -.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.card-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
}

.card-body {
  color: #444;
  font-size: 14px;
  line-height: 1.7;
}

.card-body p { margin-bottom: 8px; }
.card-body p:last-child { margin-bottom: 0; }
.card-body ul { padding-left: 20px; }
.card-body li { margin-bottom: 4px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: .15s;
}

.btn-primary {
  background: var(--yellow);
  color: var(--dark);
}

.btn-primary:hover { background: var(--yellow-d); }

/* ── Chat Layout ─────────────────────────────── */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--white);
}

.chat-header {
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -.1px;
}

.clear-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  transition: .15s;
}

.clear-btn:hover { border-color: #aaa; color: var(--text); }

/* ── Messages ────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0 16px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  gap: 16px;
  margin-bottom: 4px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  padding: 10px 28px;
  transition: background .1s;
}

.msg:hover { background: rgba(0,0,0,.015); }

.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg.user .msg-avatar { background: var(--dark); color: var(--yellow); }
.msg.assistant .msg-avatar { background: var(--yellow); color: var(--dark); }

/* ChatGPT-Stil: User kompakt, Assistant flach */
.msg-bubble {
  font-size: 15px;
  line-height: 1.7;
  max-width: 82%;
}

.msg.user .msg-bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 18px 18px 6px 18px;
  padding: 12px 18px;
  font-size: 14px;
  line-height: 1.6;
}

.msg.assistant .msg-bubble {
  background: transparent;
  color: var(--text);
  padding: 4px 0;
}

/* Streaming cursor */
.streaming::after {
  content: '▌';
  color: var(--yellow);
  animation: blink .7s step-end infinite;
  margin-left: 1px;
}

@keyframes blink { 50% { opacity: 0; } }

/* HR in Antworten */
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Markdown in bubbles */
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble code {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  background: rgba(0,0,0,.06);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,.08);
}
.msg.user .msg-bubble code { background: rgba(0,0,0,.08); }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 8px 0; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble p { margin-bottom: 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble h2, .msg-bubble h3 { font-size: 15px; font-weight: 700; margin: 14px 0 6px; }

/* Typing indicator */
.typing { display: flex; gap: 5px; padding: 10px 2px; }

.typing span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce .9s infinite;
}

.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .6; }
  30% { transform: translateY(-7px); opacity: 1; }
}

/* ── Input Area ──────────────────────────────── */
.chat-input-area {
  padding: 12px 28px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--white) 70%, transparent);
  flex-shrink: 0;
}

.input-form {
  display: flex;
  align-items: flex-end;
  max-width: 720px;
  margin: 0 auto;
  background: var(--white);
  border: 1.5px solid #d9d9d9;
  border-radius: 16px;
  padding: 10px 10px 10px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  transition: border-color .2s, box-shadow .2s;
}

.input-form:focus-within {
  border-color: #bbb;
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
}

.input-form textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 2px 0;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 160px;
  line-height: 1.55;
  color: var(--text);
}

.input-form textarea::placeholder { color: #aaa; }

.send-btn {
  width: 36px;
  height: 36px;
  background: var(--dark);
  color: var(--white);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}

.send-btn:hover { background: var(--dark2); transform: scale(1.05); }
.send-btn:active { transform: scale(.97); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* ── Mikrofon-Button ─────────────────────────── */
.mic-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
  margin-right: 4px;
}

.mic-btn:hover { background: var(--bg); color: var(--text); }

.mic-btn.recording {
  background: #dc2626;
  color: #fff;
  animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

/* ── Login Page ──────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
}

.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 44px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 80px rgba(0,0,0,.4);
}

.login-logo { text-align: center; margin-bottom: 32px; }

.login-brand { font-size: 28px; font-weight: 800; color: var(--dark); letter-spacing: -.5px; }
.login-brand span { color: var(--yellow); }
.login-brand-sub { font-size: 12px; color: var(--muted); margin-top: 5px; }

.login-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }

.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

.form-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border .15s, box-shadow .15s;
  background: var(--white);
}

.form-input:focus {
  border-color: var(--dark);
  box-shadow: 0 0 0 3px rgba(23,23,23,.07);
}

.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.login-btn {
  width: 100%;
  background: var(--dark);
  color: var(--white);
  border: none;
  border-radius: 9px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  letter-spacing: .1px;
}

.login-btn:hover { background: var(--dark2); }
.login-btn:active { transform: scale(.99); }
.login-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Kontakt ─────────────────────────────────── */
.contact-list { list-style: none; padding: 0; }

.contact-list li {
  padding: 9px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.contact-list li:last-child { border-bottom: none; }

/* ── Mermaid Diagramme ───────────────────────── */
.mermaid-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin: 14px 0;
  overflow-x: auto;
  text-align: center;
  contain: style layout;
}
.mermaid-block svg { max-width: 100%; height: auto; }

/* ── Mobile ──────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  background: var(--dark);
  border: none;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--yellow);
  border-radius: 1px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 999;
  backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    left: -270px;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: left .25s ease;
    width: 260px;
  }

  .sidebar.open { left: 0; }
  .sidebar-overlay.open { display: block; }

  .content { margin-left: 0; }
  .chat-layout { flex-direction: column; }

  .conv-sidebar {
    display: none;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 998;
    width: 260px;
    background: var(--bg);
  }

  .conv-sidebar.open { display: flex; }
  .page { padding: 60px 16px 40px; }
  .stats { flex-direction: column; }
  .msg-bubble { max-width: 90%; }
  .admin-table { font-size: 13px; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
  .action-cell { display: flex; flex-wrap: wrap; gap: 4px; }
  .msg { padding: 8px 16px; }
  .chat-input-area { padding: 10px 14px 18px; }
  .input-form { border-radius: 14px; }
}

/* ── Conversation sidebar ────────────────────── */
.chat-layout {
  display: flex;
  height: 100vh;
}

.conv-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conv-new-btn {
  margin: 12px;
  padding: 10px;
  background: var(--dark);
  color: var(--white);
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.conv-new-btn:hover { background: var(--dark2); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 1px;
  transition: background .1s;
}

.conv-item:hover { background: #e8e8e8; }
.conv-item.active { background: var(--white); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

.conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.conv-delete {
  display: none;
  background: none;
  border: none;
  color: #999;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

.conv-item:hover .conv-delete { display: block; }

.conv-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

@media (max-width: 768px) { .conv-toggle { display: block; } }

/* ── Message actions ─────────────────────────── */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity .15s;
}

.msg:hover .msg-actions { opacity: 1; }
.msg.assistant:last-child .msg-actions { opacity: 0.6; }
.msg.assistant:last-child:hover .msg-actions { opacity: 1; }

.msg-action-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  transition: background .1s, color .1s, border-color .1s;
}

.msg-action-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

/* ── Admin tables ────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }

.admin-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}

.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.admin-table tbody tr:hover { background: var(--bg); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-admin    { background: #dbeafe; color: #1e40af; }
.badge-user     { background: #f3f4f6; color: #4b5563; }
.badge-active   { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

.btn-sm {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  transition: .1s;
}

.btn-sm:hover { background: var(--bg); }
.btn-warn    { border-color: #f59e0b; color: #92400e; }
.btn-warn:hover { background: #fef3c7; }
.btn-danger  { border-color: #ef4444; color: #991b1b; }
.btn-danger:hover { background: #fee2e2; }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }

.admin-links { display: flex; gap: 10px; margin-top: 20px; }
.text-muted { color: var(--muted); font-size: 12px; }

/* ── Flash messages ──────────────────────────── */
.flash {
  padding: 12px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  animation: flash-slide-in .3s ease-out;
}

@keyframes flash-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-success { background: #f0fdf4; color: #166534; }
.flash-error   { background: #fef2f2; color: #dc2626; }

/* ── Training-Leiste ─────────────────────────── */
.training-bar {
  padding: 7px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}

.training-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}

.training-btn:hover {
  background: var(--bg);
  border-color: #ccc;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.training-btn-danger {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.training-btn-danger:hover { background: #fee2e2; border-color: #f87171; }

.training-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 200;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  width: 290px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.14);
}

.training-panel.open { display: block; }

/* ── Quick-Start-Buttons ─────────────────────── */
.quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0 6px;
  max-width: 720px;
  margin: 0 auto;
  transition: opacity .25s ease;
}

.quick-buttons.fade-out { opacity: 0; pointer-events: none; }

.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.quick-btn:hover {
  background: var(--dark);
  color: var(--white);
  border-color: var(--dark);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* ── Analyse-Modal ───────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: 16px;
  padding: 30px;
  width: 100%;
  max-width: 520px;
  margin: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  animation: modal-in .2s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Analyse-Modal Fullscreen ────────────────── */
.modal-box-fullscreen {
  background: var(--white);
  border-radius: 16px;
  padding: 30px;
  width: 92vw;
  max-width: 1000px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  animation: modal-in .2s ease-out;
}

@media (max-width: 600px) {
  .modal-box-fullscreen {
    width: 98vw;
    height: 95vh;
    border-radius: 10px;
    padding: 18px;
  }
}

/* ── Lernstatistiken ─────────────────────────── */
.stats-chart { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding: 8px 0 0; }

.stats-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.stats-bar-label { font-size: 11px; color: var(--muted); min-height: 16px; }

.stats-bar-outer {
  flex: 1;
  width: 100%;
  background: var(--bg);
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: flex-end;
}

.stats-bar-inner {
  width: 100%;
  background: var(--yellow);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height .4s cubic-bezier(.4,0,.2,1);
}

.stats-bar-week { font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; }

.topic-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.topic-label { width: 90px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.topic-bar-outer { flex: 1; background: var(--bg); border-radius: 4px; height: 10px; overflow: hidden; }
.topic-bar-inner { height: 100%; background: var(--dark); border-radius: 4px; min-width: 4px; }
.topic-count { width: 28px; text-align: right; font-size: 12px; color: var(--muted); }

.recent-list { list-style: none; padding: 0; }
.recent-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.recent-list li:last-child { border-bottom: none; }
.recent-question { font-size: 13px; color: var(--text); margin-bottom: 3px; }
.recent-date { font-size: 11px; color: var(--muted); }

/* ── Conversation list in sidebar ────────────── */
.conv-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-bottom: 1px solid var(--border-s);
}

.conv-section-label {
  padding: 10px 14px 6px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.conv-section .conv-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }

.conv-section .conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 7px;
  margin-bottom: 1px;
  transition: background .1s;
}

.conv-section .conv-item:hover { background: rgba(255,255,255,.07); }
.conv-section .conv-item.active { background: rgba(255,255,255,.11); }

.conv-section .conv-item-link {
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.conv-section .conv-item.active .conv-item-link { color: var(--white); font-weight: 500; }

.conv-section .conv-delete-btn {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,.25);
  font-size: 15px;
  cursor: pointer;
  padding: 0 4px;
}

.conv-section .conv-item:hover .conv-delete-btn { display: block; }
.conv-section .conv-delete-btn:hover { color: rgba(255,255,255,.6); }

/* ── Conv section header with plus button ────── */
.conv-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 12px;
}

.conv-new-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.4);
  text-decoration: none;
  font-size: 16px;
  font-weight: 300;
  line-height: 1;
  transition: background .15s, color .15s;
}

.conv-new-plus:hover { background: rgba(255,255,255,.16); color: var(--white); }

/* ── Focus States ────────────────────────────── */
button:focus-visible,
.btn:focus-visible,
.msg-action-btn:focus-visible,
.send-btn:focus-visible,
.training-btn:focus-visible,
.quick-btn:focus-visible,
.login-btn:focus-visible,
.clear-btn:focus-visible,
.new-chat-btn:focus-visible,
.conv-new-plus:focus-visible,
.nav-item:focus-visible,
.logout-btn:focus-visible,
.admin-link:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.form-input:focus-visible,
.input-form textarea:focus-visible { outline: none; }

/* ── Scrollbar Styling ───────────────────────── */
.chat-messages::-webkit-scrollbar,
.conv-section .conv-list::-webkit-scrollbar { width: 5px; }

.chat-messages::-webkit-scrollbar-track,
.conv-section .conv-list::-webkit-scrollbar-track { background: transparent; }

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.12);
  border-radius: 99px;
}

.conv-section .conv-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.12);
  border-radius: 99px;
}

/* ── Touch targets (mobile) ──────────────────── */
@media (max-width: 768px) {
  .msg-action-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}
