/* style.css - Premium Warm Editorial Design System + AI Chat & Exam Simulation */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,400&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-page: #f6f4f0;
  --bg-card: #ffffff;
  --bg-header: #1a1a18;
  --text-primary: #1c1c1a;
  --text-muted: #6c6a62;
  --border-color: #e9e6e0;
  --border-focus: #1a1a18;
  --surface: #ffffff;
  
  /* Module Accent Colors */
  --accent-ges: #18564a;
  --accent-ges-bg: #eaf2f0;
  --accent-lab: #4e3496;
  --accent-lab-bg: #f1eefa;
  --accent-kra: #a84113;
  --accent-kra-bg: #faf2ee;
  
  /* Ampel-System */
  --status-rot: #cc352b;
  --status-rot-bg: #fdeced;
  --status-gelb: #ca7911;
  --status-gelb-bg: #fef3e3;
  --status-gruen: #1e8c56;
  --status-gruen-bg: #e3f6ee;
  --status-blau: #1b5bc6;
  --status-blau-bg: #e6effe;
  
  --shadow-soft: 0 4px 20px rgba(28, 28, 26, 0.03);
  --shadow-medium: 0 8px 30px rgba(28, 28, 26, 0.06);
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-serif: 'Fraunces', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --nav-height-mobile: 62px;
  --sidebar-width-desktop: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  padding-bottom: var(--nav-height-mobile); /* Space for mobile nav */
}

/* Layout Containers */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px 12px;
  transition: var(--transition-smooth);
}

/* Top bar (Header) */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.brand span {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-btn, 
.ai-chat-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
}

.settings-btn:hover, 
.ai-chat-toggle-btn:hover {
  border-color: var(--border-focus);
}

.pulse-indicator {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--status-gruen);
  box-shadow: 0 0 8px var(--status-gruen);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
}

.avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1a1a18;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.7rem;
}

/* Mobile Bottom Tab Navigation */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: var(--nav-height-mobile);
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.02);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 500;
  flex: 1;
  height: 100%;
  gap: 3px;
  transition: var(--transition-smooth);
  border-top: 2px solid transparent;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
  transition: var(--transition-smooth);
}

.nav-item:hover {
  color: var(--text-primary);
}

.nav-item.active {
  color: var(--text-primary);
  font-weight: 600;
  border-top: 2px solid var(--text-primary);
}

.nav-item.active svg {
  stroke: var(--text-primary);
}

/* Cards & Layout Panels */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}

/* Section Headings */
.section-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* View Sections */
.view-section {
  display: none;
  animation: viewFadeIn 0.3s ease-out forwards;
}

.view-section.active {
  display: block;
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- DASHBOARD VIEW --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* Countdown Card */
.exam-cards-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.exam-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition-smooth);
}

.exam-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-medium);
}

.exam-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exam-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--exam-color, var(--text-muted));
}

.exam-label {
  font-weight: 600;
  font-size: 0.92rem;
}

.exam-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.exam-countdown {
  text-align: right;
}

.exam-days {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--exam-color, var(--text-primary));
}

.exam-days-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.exam-days.urgent {
  color: var(--status-rot);
}

/* Progress bar in dashboard card */
.exam-progress-wrapper {
  margin-top: 10px;
  width: 100%;
}

.exam-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.exam-progress-bar {
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.exam-progress-fill {
  height: 100%;
  background: var(--exam-color);
  border-radius: 2px;
  transition: width 0.4s ease-out;
}

/* Dashboard Progress & Stats */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stat-card-value {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 2px;
}

.stat-circle-wrapper {
  position: relative;
  width: 68px;
  height: 68px;
  margin-bottom: 6px;
}

.stat-circle-wrapper svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.stat-circle-wrapper circle {
  fill: none;
  stroke-width: 5;
}

.stat-circle-wrapper .bg {
  stroke: var(--border-color);
}

.stat-circle-wrapper .progress {
  stroke: var(--text-primary);
  stroke-linecap: round;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  transition: stroke-dashoffset 0.8s ease-in-out;
}

.stat-card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Study planner bar */
.dashboard-progress-breakdown {
  margin-top: 14px;
  width: 100%;
}

.progress-title-mini {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-segmented-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--border-color);
  margin-bottom: 8px;
}

.progress-segment {
  height: 100%;
  transition: width 0.4s ease-out;
}

.progress-segment.rot { background-color: var(--status-rot); }
.progress-segment.gelb { background-color: var(--status-gelb); }
.progress-segment.gruen { background-color: var(--status-gruen); }
.progress-segment.blau { background-color: var(--status-blau); }

.progress-legend-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 12px;
}

.legend-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.legend-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-color-dot.rot { background-color: var(--status-rot); }
.legend-color-dot.gelb { background-color: var(--status-gelb); }
.legend-color-dot.gruen { background-color: var(--status-gruen); }
.legend-color-dot.blau { background-color: var(--status-blau); }

/* Daily Planner checklist */
.planner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.planner-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-page);
  padding: 3px 8px;
  border-radius: 4px;
}

.planner-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.planner-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg-card);
  transition: var(--transition-smooth);
}

.planner-item:hover {
  border-color: var(--border-focus);
}

.planner-item.completed {
  background: #fafafa;
}

.planner-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-muted);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  margin-top: 2px;
  background: #fff;
}

.planner-item.completed .planner-checkbox {
  background: var(--text-primary);
  border-color: var(--text-primary);
}

.planner-checkbox svg {
  width: 10px;
  height: 10px;
  stroke: #fff;
  stroke-width: 4;
  opacity: 0;
  transition: var(--transition-smooth);
}

.planner-item.completed .planner-checkbox svg {
  opacity: 1;
}

.planner-text-group {
  display: flex;
  flex-direction: column;
}

.planner-task-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: var(--transition-smooth);
}

.planner-item.completed .planner-task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Premium dynamic checklist tag badges */
.planner-task-tag {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 5px;
  width: fit-content;
  transition: var(--transition-smooth);
  background: var(--border-color);
  color: var(--text-muted);
}

.planner-task-tag.tag-gesund {
  background: var(--accent-ges-bg) !important;
  color: var(--accent-ges) !important;
}

.planner-task-tag.tag-labor {
  background: var(--accent-lab-bg) !important;
  color: var(--accent-lab) !important;
}

.planner-task-tag.tag-krank {
  background: var(--accent-kra-bg) !important;
  color: var(--accent-kra) !important;
}

.planner-task-tag.tag-fehlerliste {
  background: var(--status-rot-bg) !important;
  color: var(--status-rot) !important;
}

.planner-task-tag.tag-wiederholung {
  background: var(--status-gelb-bg) !important;
  color: var(--status-gelb) !important;
}

.planner-task-tag.tag-bachelorarbeit {
  background: var(--status-blau-bg) !important;
  color: var(--status-blau) !important;
}

/* --- MODULE DETAILS (Split layout) --- */
.module-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.module-sidebar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.module-sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar-item-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-item-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.sidebar-item-btn.active {
  background: var(--active-bg);
  border-color: var(--active-color);
  color: var(--active-color);
  font-weight: 600;
}

.sidebar-item-dot {
  font-size: 0.65rem;
  line-height: 1;
}

/* Module Active Container */
.module-content-pane {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Module Top Header Panel */
.topic-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 4px solid var(--active-color);
}

.topic-header-meta {
  display: flex;
  flex-direction: column;
}

.topic-module-name {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.topic-heading {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1px;
}

.topic-rating-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  margin-top: 4px;
}

.rating-chip {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 5px;
}

.rating-chip:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.rating-chip.active {
  background: var(--status-bg);
  color: var(--status-color);
  border-color: var(--status-color);
  font-weight: 600;
}

/* Switch tabs inside topic (Lernkarten, Quiz, Rechner) */
.view-tabs-container {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
}

.view-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.view-tab-btn:hover {
  color: var(--text-primary);
}

.view-tab-btn.active {
  background: var(--active-color);
  color: #ffffff;
  font-weight: 600;
}

/* --- FLASHCARD ELEMENT --- */
.deck-progress-bar-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.deck-progress-bar {
  flex-grow: 1;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  margin: 0 12px;
  overflow: hidden;
}

.deck-progress-fill {
  height: 100%;
  background: var(--active-color);
  width: 0;
  transition: width 0.3s ease-out;
}

/* 3D Flip Card */
.card-3d-wrapper {
  perspective: 1200px;
  width: 100%;
  max-width: 600px;
  height: 250px;
  margin: 0 auto;
  cursor: pointer;
}

.card-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-3d.flipped {
  transform: rotateY(180deg);
}

.card-side {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-soft);
}

.card-side.front {
  background: #ffffff;
  z-index: 2;
}

.card-side.back {
  background: #fbfbf9;
  border: 1.5px solid var(--border-color);
  transform: rotateY(180deg);
}

.card-side-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.8px;
}

.card-main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-question-text {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  text-align: center;
}

.card-answer-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
  overflow-y: auto;
  max-height: 140px;
  white-space: pre-line;
}

.card-answer-text::-webkit-scrollbar {
  width: 4px;
}
.card-answer-text::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.card-tip-drawer {
  margin-top: 10px;
  background: var(--status-gelb-bg);
  border-left: 3px solid var(--status-gelb);
  border-radius: 0 4px 4px 0;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: #63430c;
  font-style: italic;
}

.card-click-tip {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-rating-footer-group {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.card-rating-btn {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.card-rating-btn.rot:hover { color: var(--status-rot); border-color: var(--status-rot); background: var(--status-rot-bg); }
.card-rating-btn.rot.selected { background: var(--status-rot); color: #fff; border-color: var(--status-rot); }

.card-rating-btn.gelb:hover { color: var(--status-gelb); border-color: var(--status-gelb); background: var(--status-gelb-bg); }
.card-rating-btn.gelb.selected { background: var(--status-gelb); color: #fff; border-color: var(--status-gelb); }

.card-rating-btn.gruen:hover { color: var(--status-gruen); border-color: var(--status-gruen); background: var(--status-gruen-bg); }
.card-rating-btn.gruen.selected { background: var(--status-gruen); color: #fff; border-color: var(--status-gruen); }

.card-rating-btn.blau:hover { color: var(--status-blau); border-color: var(--status-blau); background: var(--status-blau-bg); }
.card-rating-btn.blau.selected { background: var(--status-blau); color: #fff; border-color: var(--status-blau); }

.card-nav-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  font-weight: 600;
  font-size: 0.8rem;
}

.card-nav-arrow-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.card-nav-arrow-btn:hover {
  border-color: var(--border-focus);
}

.card-nav-arrow-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

/* --- QUIZ ELEMENT --- */
.quiz-active-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-question-card {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.5;
}

.quiz-answers-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-answer-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.quiz-answer-btn:hover {
  border-color: var(--border-focus);
}

.quiz-answer-index {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--text-muted);
  width: 20px;
}

.quiz-answer-btn.correct {
  background: var(--status-gruen-bg) !important;
  border-color: var(--status-gruen) !important;
  color: var(--status-gruen) !important;
  font-weight: 600;
}
.quiz-answer-btn.correct .quiz-answer-index {
  color: var(--status-gruen);
}

.quiz-answer-btn.incorrect {
  background: var(--status-rot-bg) !important;
  border-color: var(--status-rot) !important;
  color: var(--status-rot) !important;
  font-weight: 600;
}
.quiz-answer-btn.incorrect .quiz-answer-index {
  color: var(--status-rot);
}

.quiz-explanation-card {
  background: #fbfbf9;
  border-left: 3px solid var(--active-color);
  padding: 14px;
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  line-height: 1.45;
  animation: slideDownFade 0.25s ease-out forwards;
}

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

.primary-action-btn {
  background: var(--text-primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.primary-action-btn:hover {
  background: #333330;
}

.secondary-action-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.secondary-action-btn:hover {
  background: var(--bg-page);
}

/* --- RECHNER (Practice / Solver) --- */
.rechner-modes-header {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.rechner-mode-tab {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.rechner-mode-tab.active {
  background: var(--active-bg);
  border-color: var(--active-color);
  color: var(--active-color);
}

/* Practice Mode (Selbsttest) */
.practice-given-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.given-pill {
  background: var(--bg-page);
  border: 1.5px dashed var(--border-color);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
}

.given-pill-num {
  font-weight: 700;
}

.rechner-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
}

.rechner-input {
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  width: 120px;
  text-align: center;
  transition: var(--transition-smooth);
}

.rechner-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.rechner-unit {
  font-weight: 600;
  font-size: 0.95rem;
}

.rechner-feedback {
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  display: none;
}

.rechner-feedback.correct {
  display: block;
  background: var(--status-gruen-bg);
  border: 1px solid var(--status-gruen);
  color: var(--status-gruen);
}

.rechner-feedback.incorrect {
  display: block;
  background: var(--status-rot-bg);
  border: 1px solid var(--status-rot);
  color: var(--status-rot);
}

/* Solver Mode (Formel-Rechner) */
.solver-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.solver-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.solver-field input {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  background: #ffffff;
  outline: none;
  transition: var(--transition-smooth);
}

.solver-field input:focus {
  border-color: var(--border-focus);
}

.rechenweg-drawer {
  background: var(--bg-page);
  border-left: 3px solid var(--active-color);
  padding: 14px;
  border-radius: 0 8px 8px 0;
  margin-top: 14px;
  display: none;
}

.rechenweg-drawer.active {
  display: block;
}

.rechenweg-drawer-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.rechenweg-step {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #3e3d38;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.rechenweg-step:last-child {
  border-bottom: none;
}

.rechenweg-result-label {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--active-color);
  margin-top: 12px;
}

/* --- FEHLERLISTE VIEW --- */
.fehler-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.fehler-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.fehler-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
}

.fehler-table th, 
.fehler-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

.fehler-table th {
  background: #fbfbf9;
  font-weight: 600;
  color: var(--text-muted);
}

.fehler-table tr:last-child td {
  border-bottom: none;
}

.fehler-badge-topic {
  background: var(--status-rot-bg);
  color: var(--status-rot);
  border: 1px solid rgba(203, 53, 43, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.fehler-cell-wrong {
  color: var(--status-rot);
  font-weight: 500;
}

.fehler-cell-correct {
  color: var(--status-gruen);
  font-weight: 500;
}

.fehler-resolve-btn {
  background: var(--status-rot-bg);
  border: 1px solid rgba(203, 53, 43, 0.15);
  color: var(--status-rot);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.fehler-resolve-btn:hover {
  background: var(--status-rot);
  color: #fff;
  border-color: var(--status-rot);
}

.fehler-empty-screen {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
}

.fehler-empty-screen svg {
  width: 36px;
  height: 36px;
  stroke: var(--text-muted);
  margin-bottom: 10px;
}


/* ==================== FLOATING AI CHAT SIDEBAR ==================== */
.ai-chat-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 460px;
  height: 100vh;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 25px rgba(28, 28, 26, 0.05);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-sidebar.open {
  transform: translateX(0);
}

.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fbfbf9;
}

.chat-logo-avatar {
  font-size: 1.25rem;
}

.chat-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-close-btn:hover {
  color: var(--text-primary);
}

.chat-body-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.84rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-bubble.assistant {
  background: #f1ede8;
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-bubble.user {
  background: var(--status-blau-bg);
  color: #113c84;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

/* Typing indicator dots */
.chat-typing-indicator {
  align-self: flex-start;
  background: #f1ede8;
  padding: 8px 12px;
  border-radius: 12px;
  border-bottom-left-radius: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 16px;
  margin-bottom: 12px;
}

.chat-typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: bounceTyping 1.3s infinite ease-in-out;
}

.chat-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounceTyping {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.chat-quick-actions {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  border-top: 1px solid var(--border-color);
  background: #fbfbf9;
  scrollbar-width: none;
}

.chat-quick-actions::-webkit-scrollbar {
  display: none;
}

.chat-chip-btn {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.chat-chip-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  gap: 8px;
}

.chat-text-input {
  flex-grow: 1;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  background: #fafafa;
}

.chat-text-input:focus {
  border-color: var(--border-focus);
  background: #ffffff;
}

.chat-submit-btn {
  background: var(--text-primary);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.chat-submit-btn:hover {
  background: #333330;
}


/* ==================== SYSTEM SETTINGS MODAL ==================== */
.settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(28, 28, 26, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-modal {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-medium);
  animation: modalPop 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  overflow: hidden;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.settings-modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fbfbf9;
}

.settings-modal-header h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
}

.settings-modal-body {
  padding: 20px 16px;
}

.status-connection-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fafafa;
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.status-badge-dot.connected {
  background-color: var(--status-gruen);
  box-shadow: 0 0 6px var(--status-gruen);
}

.status-badge-dot.error {
  background-color: var(--status-rot);
  box-shadow: 0 0 6px var(--status-rot);
}


/* Collapse button hidden by default on mobile – only shown on desktop */
.nav-collapse-toggle-btn {
  display: none;
}

/* --- RESPONSIVE LAYOUT (Desktop Upgrade) --- */
@media (min-width: 768px) {
  body {
    padding-bottom: 0;
    padding-left: var(--sidebar-width-desktop);
    transition: padding-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding-right 0.3s ease;
  }
  
  body.chat-sidebar-open {
    padding-right: 460px;
  }
  
  .ai-chat-sidebar {
    width: 460px !important;
  }
  
  .app-container {
    padding: 40px 48px;
    max-width: 1400px;
    margin: 0 auto;
  }
  
  header {
    margin-bottom: 32px;
    padding-bottom: 18px;
  }
  
  .brand h1 {
    font-size: 1.75rem;
  }
  
  /* Sidebar style desktop navigation */
  .nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width-desktop);
    height: 100vh;
    border-top: none;
    border-right: 1px solid var(--border-color);
    flex-direction: column;
    justify-content: flex-start;
    padding: 30px 16px;
    gap: 8px;
    box-shadow: none;
    background: #ffffff;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .nav-bar::before {
    content: 'AyaLearning';
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    width: 100%;
    text-align: left;
    padding: 0 12px;
    margin-bottom: 2px;
    transition: opacity 0.2s ease;
  }

  .nav-bar::after {
    content: 'PRÜFUNGSVORBEREITUNG 2026';
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    width: 100%;
    text-align: left;
    padding: 0 12px;
    margin-bottom: 24px;
    transition: opacity 0.2s ease;
  }
  
  .nav-item {
    flex: none;
    width: 100%;
    flex-direction: row;
    padding: 11px 14px;
    border-radius: 8px;
    gap: 11px;
    font-size: 0.92rem;
    justify-content: flex-start;
    height: auto;
    border-top: none;
    border-left: 2px solid transparent;
    transition: var(--transition-smooth), justify-content 0s, padding 0s;
  }
  
  .nav-item.desktop-only-nav {
    display: flex !important;
  }
  
  .nav-item svg {
    width: 21px;
    height: 21px;
  }
  
  .nav-item.active {
    background: #faf8f5;
    border-top: none;
    border-left: 2px solid var(--text-primary);
  }

  /* COLLAPSIBLE SIDEBAR RULES */
  .nav-collapse-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-top: auto;
    transition: var(--transition-smooth);
    outline: none;
    align-self: center;
  }

  .nav-collapse-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-focus);
    background: var(--bg-page);
  }

  body.sidebar-collapsed {
    padding-left: 76px !important;
  }

  body.sidebar-collapsed .nav-bar {
    width: 76px !important;
    padding: 30px 12px !important;
  }

  body.sidebar-collapsed .nav-bar::before,
  body.sidebar-collapsed .nav-bar::after {
    opacity: 0 !important;
    pointer-events: none;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  body.sidebar-collapsed .nav-item span {
    display: none !important;
  }

  body.sidebar-collapsed .nav-item {
    justify-content: center !important;
    padding: 12px 0 !important;
    border-left: none !important;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    margin: 0 auto;
    gap: 0;
  }
  
  body.sidebar-collapsed .nav-item.active {
    background: #faf8f5 !important;
    box-shadow: inset 0 0 0 1.5px var(--text-primary);
  }
  
  body.dark-theme.sidebar-collapsed .nav-item.active {
    background: #1e1e1a !important;
    box-shadow: inset 0 0 0 1.5px var(--text-primary);
  }
  
  body.sidebar-collapsed .nav-collapse-toggle-btn svg {
    transform: rotate(180deg);
  }
  
  /* Grid dashboard widgets */
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    align-items: start;
    gap: 20px;
  }
  
  .dashboard-span-full {
    grid-column: span 2;
  }
  
  .exam-cards-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
  
  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  
  /* Module layouts - side-by-side topics sidebar + content pane */
  .module-layout {
    display: grid;
    grid-template-columns: 210px 1fr;
    align-items: start;
    gap: 20px;
  }
  
  .module-sidebar {
    flex-direction: column;
    overflow-x: visible;
    position: sticky;
    top: 24px;
    border-right: 1px solid var(--border-color);
    padding-right: 12px;
    padding-bottom: 0;
  }
  
  .sidebar-item-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 12px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    white-space: normal;
    text-align: left;
    gap: 8px;
    word-break: break-word;
  }
  
  .sidebar-item-btn:hover {
    background: #fbfbf9;
    border-color: var(--border-color);
  }
  
  .sidebar-item-btn.active {
    background: var(--active-bg);
    border-color: var(--active-bg);
    color: var(--active-color);
  }
  
  /* Flashcard visual enhancements on desktop */
  .card-3d-wrapper {
    height: 310px;
  }
  
  .card-question-text {
    font-size: 1.45rem;
  }
  
  .card-answer-text {
    font-size: 1.05rem;
    max-height: 200px;
  }
  
  .solver-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* ============================================================
   XP / LEVEL / ACHIEVEMENT SYSTEM
   ============================================================ */

/* Level badge in header */
.level-badge {
  background: var(--surface);
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: 0.2px;
  margin-right: 4px;
  transition: border-color 0.2s;
}

/* XP level card */
.xp-level-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.xp-level-name {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.xp-total {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.xp-bar {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #34d399, #22c55e);
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.xp-next-text {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Achievements */
.achievements-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.achievements-title-row > span:first-child {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}

.achievements-title-row > span:last-child {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
}

.achievement-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  background: var(--surface);
  cursor: default;
  transition: transform 0.2s, box-shadow 0.2s;
  text-align: center;
}

.achievement-badge.earned {
  border-color: #22c55e;
  background: #f0fdf4;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.achievement-badge.earned:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.2);
}

.achievement-emoji {
  font-size: 1.55rem;
  line-height: 1;
}

.achievement-label {
  font-size: 0.61rem;
  color: var(--text-muted);
  line-height: 1.25;
  font-weight: 500;
}

.achievement-badge.locked .achievement-emoji {
  filter: grayscale(1) opacity(0.3);
}

.achievement-badge.locked .achievement-label {
  opacity: 0.35;
}

/* XP Toast notification */
.xp-toast {
  position: fixed;
  bottom: 80px;   /* above mobile nav */
  right: 20px;
  background: var(--card-bg, #fff);
  border: 1.5px solid #22c55e;
  border-radius: 14px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 9998;
  min-width: 130px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.xp-toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.xp-toast.achievement {
  border-color: #f59e0b;
}

#xp-toast-amount {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: #16a34a;
}

.xp-toast.achievement #xp-toast-amount {
  color: #d97706;
}

#xp-toast-reason {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Level Up Modal */
.levelup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.levelup-card {
  background: var(--card-bg, #fff);
  border-radius: 22px;
  padding: 44px 36px 36px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  animation: levelupPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes levelupPop {
  from { transform: scale(0.75) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.levelup-emoji {
  font-size: 4.5rem;
  margin-bottom: 14px;
  line-height: 1;
  animation: levelupBounce 0.6s 0.3s ease both;
}

@keyframes levelupBounce {
  0%   { transform: scale(0.8); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.levelup-subtitle {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.levelup-level {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.levelup-name {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Simulation: neutral answer selection (not misleading green) */
.quiz-answer-btn.sim-selected {
  border-color: var(--text-primary) !important;
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  font-weight: 600;
}

/* Dark mode support for earned badge */
@media (prefers-color-scheme: dark) {
  .achievement-badge.earned {
    background: rgba(34, 197, 94, 0.1);
  }
  .xp-toast {
    background: var(--card-bg, #1e2025);
  }
  .levelup-card {
    background: var(--card-bg, #1e2025);
  }
}

/* ============================================================
   AESTHETIC UPGRADES: LOGIN PORTAL, WARM DARK MODE & MOTIVATIONAL TOASTS
   ============================================================ */

/* Full-Screen Login Overlay */
.login-overlay-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: var(--transition-smooth);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 36px 28px;
  width: 90%;
  max-width: 380px;
  box-shadow: var(--shadow-medium);
  text-align: center;
  animation: modalScaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-brand {
  margin-bottom: 20px;
}

.login-brand h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.login-brand span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  display: block;
}

.login-form {
  text-align: left;
}

.login-form label {
  transition: var(--transition-smooth);
}

.login-form input[type="password"] {
  background-color: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
  transition: var(--transition-smooth);
}

.login-form input[type="password"]:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 3px rgba(28, 28, 26, 0.05);
}

/* Floating Motivational Toast */
.motivational-toast {
  position: fixed;
  bottom: calc(var(--nav-height-mobile) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-medium);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
  max-width: 90vw;
  width: 360px;
}

.motivational-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast-emoji {
  font-size: 1.8rem;
  flex-shrink: 0;
  animation: toastWiggle 1.2s ease-in-out infinite alternate;
}

.toast-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.toast-body {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.3;
}

@keyframes toastWiggle {
  from { transform: rotate(-8deg); }
  to { transform: rotate(8deg); }
}

/* Personalized Welcome Banner */
.personalized-welcome-banner {
  background: linear-gradient(135deg, var(--accent-ges), #0f2b5c);
  color: #ffffff;
  padding: 22px 26px;
  border-radius: 14px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-medium);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  animation: bannerSlideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bannerSlideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-title {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.welcome-subtitle {
  font-size: 0.88rem;
  opacity: 0.92;
  line-height: 1.45;
  max-width: 85%;
}

.welcome-decorations {
  position: absolute;
  right: 12px;
  bottom: -15px;
  font-size: 5rem;
  opacity: 0.14;
  pointer-events: none;
  user-select: none;
  animation: floatDeco 3s ease-in-out infinite alternate;
}

@keyframes floatDeco {
  from { transform: translateY(0) rotate(-5deg); }
  to { transform: translateY(-6px) rotate(5deg); }
}

/* Premium Warm Dark Theme Variables Override */
body.dark-theme {
  --bg-page: #131311;
  --bg-card: #1c1c19;
  --bg-header: #0d0d0c;
  --text-primary: #eae8df;
  --text-muted: #959287;
  --border-color: #2b2b27;
  --border-focus: #eae8df;
  --surface: #1c1c19;
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.2);
  --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.35);

  /* Warm Dark Module Accent Overrides (Brighter active text) */
  --accent-ges: #56ab91;  
  --accent-lab: #a78bfa;  
  --accent-kra: #fb923c;  

  --accent-ges-bg: #112d27;
  --accent-lab-bg: #231b40;
  --accent-kra-bg: #4c200c;

  /* Warm Dark Status Color Overrides (High-contrast text) */
  --status-rot: #ff6b6b;
  --status-rot-bg: #3c1412;
  --status-gelb: #f59e0b;
  --status-gelb-bg: #3d2306;
  --status-gruen: #4ade80;
  --status-gruen-bg: #0f3520;
  --status-blau: #60a5fa;
  --status-blau-bg: #0c234e;
}

/* Dark Mode Specific Component Tweaks */
body.dark-theme .planner-item.completed {
  background: #181816;
}

body.dark-theme .login-form input {
  background-color: #1c1c19 !important;
  color: #eae8df !important;
  box-shadow: 0 0 0 3px rgba(234, 232, 223, 0.02);
}

body.dark-theme .quiz-answer-btn.sim-selected {
  background: #252521 !important;
}

body.dark-theme .chat-bubble.assistant {
  background: #22221e;
}

body.dark-theme .chat-bubble.user {
  background: var(--active-color);
  color: #fff;
}

/* Fix high-contrast card side front and back in dark mode */
body.dark-theme .card-side.front {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

body.dark-theme .card-side.back {
  background: #181816 !important;
  border-color: var(--border-color) !important;
}

/* Fix input colors globally in dark mode for Rechner fields */
body.dark-theme .solver-field input,
body.dark-theme .rechner-input {
  background-color: #131311 !important;
  color: #eae8df !important;
  border-color: var(--border-color) !important;
}

body.dark-theme .rechenweg-step {
  color: #eae8df !important;
  border-bottom-color: rgba(255, 255, 255, 0.05) !important;
}

body.dark-theme .card-tip-drawer {
  color: #fbd38d !important;
}

/* Fix Study Copilot elements background and text in dark mode */
body.dark-theme .chat-quick-actions {
  background: #181816 !important;
}

body.dark-theme .chat-chip-btn {
  background: #252522 !important;
  color: var(--text-muted) !important;
  border-color: var(--border-color) !important;
}

body.dark-theme .chat-chip-btn:hover {
  color: var(--text-primary) !important;
  border-color: var(--text-primary) !important;
}

body.dark-theme .chat-input-area {
  background: #1c1c19 !important;
}

body.dark-theme .chat-text-input {
  background: #151513 !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

body.dark-theme .chat-text-input:focus {
  background: #181816 !important;
}

body.dark-theme .chat-submit-btn {
  background: var(--text-primary) !important;
  color: var(--bg-card) !important;
}

body.dark-theme .chat-submit-btn:hover {
  background: #d4d1c4 !important;
}

body.dark-theme .settings-modal {
  background: var(--bg-card) !important;
}

body.dark-theme .settings-modal-header {
  background: #181816 !important;
}

body.dark-theme .status-connection-badge {
  background: #181816 !important;
}

body.dark-theme .planner-checkbox {
  background: #131311 !important;
}

/* ============================================================
   GUIDED TOUR & TUTORIAL STYLING
   ============================================================ */

/* Dim overlay – just a subtle scrim, doesn't contain the card */
.tour-dim-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 8, 0.30);
  z-index: 9998;
  animation: fadeIn 0.2s ease;
  pointer-events: none;
}

/* The tour card floats independently – JS positions it near the target */
.tour-card {
  position: fixed;
  z-index: 10001;
  width: calc(100vw - 32px);
  max-width: 400px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 24px 28px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--text-primary);
  transition: top 0.35s cubic-bezier(0.4,0,0.2,1), left 0.35s cubic-bezier(0.4,0,0.2,1), bottom 0.35s cubic-bezier(0.4,0,0.2,1);
  animation: tourCardIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes tourCardIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

body.dark-theme .tour-card {
  background: rgba(24, 24, 20, 0.93);
  border-color: rgba(255,255,255,0.10);
}

/* Directional arrow that points from the card to the highlighted element */
.tour-arrow {
  position: absolute;
  width: 14px;
  height: 14px;
  background: inherit;
  border: inherit;
  border-right: none;
  border-bottom: none;
  display: none; /* shown by JS via data-arrow attribute */
}

.tour-card[data-arrow="up"] .tour-arrow {
  display: block;
  top: -8px;
  left: 32px;
  transform: rotate(45deg);
  border-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.92);
}
body.dark-theme .tour-card[data-arrow="up"] .tour-arrow {
  border-color: rgba(255,255,255,0.10);
  background: rgba(24,24,20,0.93);
}

.tour-card[data-arrow="down"] .tour-arrow {
  display: block;
  bottom: -8px;
  left: 32px;
  transform: rotate(225deg);
  border-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.92);
}
body.dark-theme .tour-card[data-arrow="down"] .tour-arrow {
  border-color: rgba(255,255,255,0.10);
  background: rgba(24,24,20,0.93);
}

.tour-card[data-arrow="left"] .tour-arrow {
  display: block;
  top: 24px;
  left: -8px;
  transform: rotate(-45deg);
  border-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.92);
}

.tour-card[data-arrow="right"] .tour-arrow {
  display: block;
  top: 24px;
  right: -8px;
  transform: rotate(135deg);
  border-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.92);
}

.tour-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tour-step-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--active-color, var(--text-primary));
  background: var(--active-bg, var(--border-color));
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.tour-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.tour-text {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.tour-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}

/* Highlighted target – glows above the dim overlay */
.tour-highlight {
  position: relative;
  z-index: 9999 !important;
  outline: 3px solid #18564a !important;
  outline-offset: 6px;
  border-radius: 10px;
  box-shadow: 0 0 0 8px rgba(24,86,74,0.12), 0 0 28px rgba(24,86,74,0.4) !important;
  animation: tourPulse 2.2s ease-in-out infinite;
}

@keyframes tourPulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(24,86,74,0.12), 0 0 28px rgba(24,86,74,0.4) !important; }
  50%       { box-shadow: 0 0 0 12px rgba(24,86,74,0.06), 0 0 40px rgba(24,86,74,0.55) !important; }
}

body.dark-theme .tour-highlight {
  outline-color: #2dd4a4 !important;
  box-shadow: 0 0 0 8px rgba(45,212,164,0.12), 0 0 32px rgba(45,212,164,0.5) !important;
}

/* ============================================================
   WORD BREAKING & TEXT OVERFLOW WRAPPING
   ============================================================ */

.card-answer-text, 
.card-question-text, 
.quiz-question-card, 
.planner-task-title,
.rechenweg-step,
.quiz-answer-btn,
.quiz-answer-btn span,
.rechner-practice-given,
.rechner-practice-question {
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  hyphens: auto;
}

/* ============================================================
   MOBILE RESPONSIVENESS AND BUTTON RE-SPACING
   ============================================================ */

@media (max-width: 480px) {
  /* Fix header button wrapping */
  .brand h1 {
    font-size: 1.15rem !important;
  }
  
  .brand span {
    font-size: 0.6rem !important;
    letter-spacing: 0.04em !important;
  }
  
  #app-user-name {
    display: none !important; /* Hide guest/Aya name in topbar to fit buttons */
  }
  
  .user-badge {
    padding: 6px !important;
    border-radius: 50% !important;
  }
  
  .header-right {
    gap: 6px !important;
  }

  .settings-btn, 
  .ai-chat-toggle-btn {
    width: 30px !important;
    height: 30px !important;
  }
  
  /* Prevent rating buttons overlapping on mobile screens */
  .card-rating-footer-group {
    gap: 4px !important;
  }
  
  .card-rating-btn {
    padding: 8px 2px !important;
    font-size: 0.64rem !important;
    gap: 2px !important;
  }
}

/* ============================================================
   DARK THEME HIGH-CONTRAST ACCENT CORRECTIONS
   ============================================================ */

body.dark-theme .primary-action-btn {
  background-color: #eae8df !important;
  color: #131311 !important;
}

body.dark-theme .primary-action-btn:hover {
  background-color: #d4d1c4 !important;
}

body.dark-theme .quiz-explanation-card {
  background-color: #22221e !important;
  color: #eae8df !important;
  border-left-color: var(--active-color) !important;
}

body.dark-theme .sidebar-item-btn.active {
  color: #ffffff !important;
  font-weight: 700 !important;
}

/* Flawless Dark Mode Desktop Navigation & Sidebar Overrides */
body.dark-theme .nav-bar {
  background: var(--bg-card) !important;
  border-right-color: var(--border-color) !important;
}
body.dark-theme .nav-bar::before {
  color: var(--text-primary) !important;
}
body.dark-theme .nav-bar::after {
  color: var(--text-muted) !important;
}
body.dark-theme .nav-item {
  color: var(--text-muted) !important;
}
body.dark-theme .nav-item:hover {
  color: var(--text-primary) !important;
}
body.dark-theme .nav-item.active {
  background: #1e1e1a !important;
  color: var(--text-primary) !important;
  border-left-color: var(--text-primary) !important;
}
body.dark-theme .nav-item.active svg {
  stroke: var(--text-primary) !important;
}
body.dark-theme .sidebar-item-btn {
  color: var(--text-muted) !important;
}
body.dark-theme .sidebar-item-btn:hover {
  background: #1e1e1a !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}
body.dark-theme .sidebar-item-btn.active {
  background: var(--active-bg, #1a2e26) !important;
  color: var(--active-color, var(--accent-ges)) !important;
  border-color: var(--active-color, var(--accent-ges)) !important;
  font-weight: 700 !important;
}

/* Chatbot Sidebar Dark Mode Improvements */
body.dark-theme .ai-chat-sidebar {
  background: var(--bg-card) !important;
  border-left-color: var(--border-color) !important;
  box-shadow: -4px 0 30px rgba(0,0,0,0.5) !important;
}
body.dark-theme .chat-header {
  background: #181816 !important;
  border-bottom-color: var(--border-color) !important;
}
body.dark-theme .chat-body-messages {
  background: var(--bg-page) !important;
}
body.dark-theme .chat-bubble.assistant {
  background: #1c1c19 !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
}
body.dark-theme .chat-bubble.user {
  background: var(--active-color, var(--status-blau)) !important;
  color: #ffffff !important;
}
body.dark-theme .chat-typing-indicator {
  background: #1c1c19 !important;
  border: 1px solid var(--border-color) !important;
}
body.dark-theme .chat-typing-indicator span {
  background: var(--text-muted) !important;
}
body.dark-theme .chat-quick-actions {
  background: #181816 !important;
  border-top-color: var(--border-color) !important;
}
body.dark-theme .chat-chip-btn {
  background: #252522 !important;
  color: var(--text-muted) !important;
  border-color: var(--border-color) !important;
}
body.dark-theme .chat-chip-btn:hover {
  background: #32322d !important;
  color: var(--text-primary) !important;
  border-color: var(--text-primary) !important;
}
body.dark-theme .chat-input-area {
  background: #181816 !important;
  border-top-color: var(--border-color) !important;
}
body.dark-theme .chat-text-input {
  background: #131311 !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}
body.dark-theme .chat-text-input:focus {
  border-color: var(--border-focus) !important;
}
body.dark-theme .chat-submit-btn {
  background: var(--text-primary) !important;
  color: var(--bg-card) !important;
}
body.dark-theme .chat-submit-btn:hover {
  background: #eae8df !important;
}


