/* Study-and-Learn Retro Theme */

/* Font faces — single source of truth in fonts.css */
@import url("fonts.css");

:root {
  --az-dark: #0a1628;
  --az-darker: #050b14;
  --az-blue: #1e3a5f;
  --az-blue-2: #102742;
  --az-cyan: #00b4d8;
  --az-cyan-light: #90e0ef;
  --az-silver: #caf0f8;
  --az-muted: rgba(202, 240, 248, 0.72);
  --az-border: rgba(0, 180, 216, 0.35);
  --az-glow: rgba(0, 180, 216, 0.25);
  --az-success: #7ee787;
  --az-warning: #ffd166;
  --az-danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* Dark theme body */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top left, rgba(0, 180, 216, 0.14), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(144, 224, 239, 0.08), transparent 35rem),
    linear-gradient(180deg, var(--az-dark), var(--az-darker));
  color: var(--az-silver);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Scanlines overlay effect */
.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025),
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: screen;
  opacity: 0.25;
}

/* Navigation */
.az-navbar {
  background: linear-gradient(180deg, rgba(30, 58, 95, 0.98), rgba(10, 22, 40, 0.94));
  border-bottom: 2px solid var(--az-cyan);
  box-shadow: 0 0 24px rgba(0, 180, 216, 0.14);
  backdrop-filter: blur(10px);
}

.az-navbar .container-fluid {
  padding-left: 0;
  padding-right: 0;
}

.brand-logo {
  width: 53px;
  height: 53px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px var(--az-glow));
  margin-left: 8px;
}

.brand-title {
  color: var(--az-cyan-light);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: "Retrograde Bold", sans-serif;
}

/* Container */
.container {
  margin-top: 2rem;
  max-width: 900px;
}

/* Headings */
h1, .hero-title {
  color: #fff;
  font-weight: 900;
  letter-spacing: -0.04em;
  text-shadow: 0 0 16px rgba(0, 180, 216, 0.45);
  font-family: "Retrograde Bold", sans-serif;
  text-align: center;
  margin-bottom: 2rem;
}

h2, .section-title {
  color: var(--az-cyan-light);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-family: "BoldPixels", sans-serif;
}

/* Cards/Panels */
.az-panel,
.form-section {
  background: linear-gradient(135deg, rgba(30, 58, 95, 0.86), rgba(16, 39, 66, 0.72));
  border: 1px solid var(--az-border);
  border-radius: 18px;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Form controls */
.form-control, .form-select {
  background: rgba(5, 11, 20, 0.6);
  border: 1px solid var(--az-border);
  color: var(--az-silver);
  border-radius: 8px;
}

.form-control:focus, .form-select:focus {
  background: rgba(5, 11, 20, 0.8);
  border-color: var(--az-cyan);
  color: var(--az-silver);
  box-shadow: 0 0 8px var(--az-glow);
}

.form-label {
  color: var(--az-cyan-light);
  font-weight: 700;
  font-family: "Retrograde Bold", sans-serif;
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.form-text {
  color: var(--az-muted);
  font-size: 0.85rem;
}

/* Buttons */
.btn-primary {
  background: var(--az-cyan);
  border-color: var(--az-cyan);
  color: var(--az-dark);
  font-weight: 800;
  border-radius: 8px;
}

.btn-primary:hover {
  background: var(--az-cyan-light);
  border-color: var(--az-cyan-light);
  color: var(--az-dark);
  box-shadow: 0 0 12px var(--az-glow);
}

.btn-success {
  background: var(--az-success);
  border-color: var(--az-success);
  color: var(--az-dark);
  font-weight: 800;
  border-radius: 8px;
}

.btn-success:hover {
  background: #9af5a7;
  border-color: #9af5a7;
  color: var(--az-dark);
  box-shadow: 0 0 12px rgba(126, 231, 135, 0.4);
}

.btn-outline-primary {
  color: var(--az-cyan-light);
  border-color: var(--az-cyan);
  border-radius: 8px;
}

.btn-outline-primary:hover {
  background: var(--az-cyan);
  color: var(--az-dark);
}

/* Alerts */
.alert {
  border-radius: 8px;
  border: 1px solid;
}

.alert-success {
  background: rgba(126, 231, 135, 0.15);
  border-color: var(--az-success);
  color: var(--az-success);
}

.alert-danger {
  background: rgba(255, 107, 107, 0.15);
  border-color: var(--az-danger);
  color: var(--az-danger);
}

.alert-info {
  background: rgba(0, 180, 216, 0.15);
  border-color: var(--az-cyan);
  color: var(--az-cyan);
}

/* Chip/Badge */
.badge {
  background: rgba(0, 180, 216, 0.2);
  color: var(--az-cyan-light);
  border: 1px solid var(--az-border);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font-weight: 700;
  font-family: "PressStart2P", "Courier New", monospace;
  font-size: 0.65em;
}

.filename-badge {
  background: var(--az-cyan);
  color: var(--az-dark);
  font-weight: 800;
  font-family: "PressStart2P", "Courier New", monospace;
  font-size: 0.6em;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 100%;
}

.file-list-item {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

/* Results cards */
.card {
  background: linear-gradient(135deg, rgba(30, 58, 95, 0.86), rgba(16, 39, 66, 0.72));
  border: 1px solid var(--az-border);
  border-radius: 18px;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header {
  background: linear-gradient(180deg, rgba(30, 58, 95, 0.98), rgba(16, 39, 66, 0.86));
  border-bottom: 1px solid var(--az-border);
  color: var(--az-cyan-light);
  font-weight: 800;
  font-family: "BoldPixels", sans-serif;
  padding: 1rem 1.5rem;
}

.card-body {
  background: rgba(10, 22, 40, 0.5);
  color: var(--az-silver);
  padding: 1.5rem;
}

/* Module items */
.module-item {
  background: rgba(5, 11, 20, 0.6);
  border: 1px solid var(--az-border);
  border-left: 4px solid var(--az-cyan);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.module-item h5 {
  color: var(--az-cyan-light);
  font-weight: 700;
  font-family: "BoldPixels", sans-serif;
}

/* Relevance indicators */
.relevance-strong {
  color: var(--az-success);
  font-weight: 900;
}

.relevance-partial {
  color: var(--az-warning);
  font-weight: 900;
}

.relevance-weak {
  color: var(--az-danger);
  font-weight: 900;
}

/* Partial match warning banner */
.partial-warning-banner {
  background: rgba(255, 209, 102, 0.1);
  border: 1px solid var(--az-warning);
  border-left: 4px solid var(--az-warning);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--az-warning);
  font-size: 0.9rem;
  line-height: 1.5;
}

.partial-warning-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* Weak match feedback card */
.results-card-weak .card-header {
  border-bottom-color: var(--az-danger);
}

.results-card-weak .card-header h2 {
  color: var(--az-danger);
}

.weak-feedback-content {
  text-align: center;
}

.weak-feedback-main {
  color: var(--az-silver);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.weak-feedback-section {
  background: rgba(5, 11, 20, 0.5);
  border: 1px solid var(--az-border);
  border-left: 4px solid var(--az-danger);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  text-align: left;
}

.weak-feedback-section h4 {
  color: var(--az-danger);
  font-family: "BoldPixels", sans-serif;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.weak-feedback-section p {
  color: var(--az-silver);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
}

.weak-feedback-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Loading spinner */
.spinner-border {
  color: var(--az-cyan);
}

/* Hex accent */
.hex-accent {
  display: inline-block;
  width: 11px;
  height: 11px;
  background: var(--az-cyan);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  box-shadow: 0 0 8px var(--az-cyan);
  margin: 0 0.3rem;
}

/* Footer */
.az-footer {
  color: var(--az-cyan-light);
  background: linear-gradient(180deg, rgba(16, 39, 66, 0.75), rgba(5, 11, 20, 0.98));
  border-top: 2px solid var(--az-cyan);
  padding: 0.6rem 0;
  margin-top: auto;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.az-footer .container {
  margin-top: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }
  
  h1 {
    font-size: 1.8rem;
  }
  
  .az-panel, .form-section {
    padding: 1rem;
    border-radius: 12px;
  }
}

/* ===== MARKDOWN RENDERING FIXES ===== */
.markdown-content p { margin-bottom: 0.8rem; line-height: 1.65; }
.markdown-content ul, .markdown-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.markdown-content li { margin-bottom: 0.4rem; }
.markdown-content strong { color: var(--az-cyan-light); }
.markdown-content h4, .markdown-content h5 { color: var(--az-cyan); margin: 1rem 0 0.5rem; }
.markdown-content br { display: block; margin: 0.3rem 0; }
.raw-md { white-space: pre-wrap; } /* Fallback before JS parses */

/* ===== RELEVANCE LABEL COLOR RESTORATION ===== */
.card-body h3.relevance-strong { color: var(--az-success) !important; text-shadow: 0 0 8px rgba(126, 231, 135, 0.3); }
.card-body h3.relevance-partial { color: var(--az-warning) !important; text-shadow: 0 0 8px rgba(255, 209, 102, 0.3); }
.card-body h3.relevance-weak   { color: var(--az-danger) !important; text-shadow: 0 0 8px rgba(255, 107, 107, 0.3); }

/* ===== Multi-File Upload List ===== */
.file-item {
    background: rgba(5, 11, 20, 0.6);
    border: 1px solid var(--az-border);
    border-left: 3px solid var(--az-cyan);
    border-radius: 6px;
    transition: all 0.2s ease;
}
.file-item:hover {
    background: rgba(5, 11, 20, 0.8);
    transform: translateX(4px);
}
.file-item small {
    color: var(--az-muted);
    font-family: 'Segoe UI', sans-serif;
}
.remove-btn {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

/* ===== SECTION DIVIDER ===== */
.section-divider {
    border-color: var(--az-border);
    opacity: 0.5;
    margin: 1.5rem 0;
}

/* ===== CURRENT GOAL ===== */
.current-goal-section {
    border: 1px solid rgba(0, 180, 216, 0.2);
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.06), rgba(16, 39, 66, 0.5));
}
.current-goal-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.15rem 0.25rem;
}
.goal-text {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--az-cyan-light);
    font-family: "BoldPixels", sans-serif;
}

/* ===== RESULTS META ===== */
.results-meta {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    align-items: flex-start;
    width: 100%;
}
.goal-badge {
    background: rgba(0, 180, 216, 0.1);
    color: var(--az-cyan-light);
    border: 1px solid var(--az-border);
    font-weight: 600;
    font-size: 0.85em;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== RESULTS GRID ===== */
.results-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.results-card-summary { order: 1; }
.results-card-relevance { order: 2; }
.results-card-path { order: 3; }

.relevance-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.relevance-indicator h3 {
    margin: 0;
    font-family: "BoldPixels", sans-serif;
    font-size: 1.3em;
}
.relevance-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
}
.relevance-strong .relevance-dot {
    background: var(--az-success);
    box-shadow: 0 0 10px rgba(126, 231, 135, 0.5);
}
.relevance-partial .relevance-dot {
    background: var(--az-warning);
    box-shadow: 0 0 10px rgba(255, 209, 102, 0.5);
}
.relevance-weak .relevance-dot {
    background: var(--az-danger);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}
.relevance-details {
    padding-left: 0.5rem;
}
.relevance-section {
    margin-bottom: 1rem;
}
.relevance-section h4 {
    color: var(--az-cyan);
    font-weight: 700;
    font-size: 0.95em;
    margin-bottom: 0.4rem;
}

/* ===== MODULE TIMELINE ===== */
.module-timeline {
    position: relative;
    padding-left: 2rem;
}
.module-timeline::before {
    content: '';
    position: absolute;
    left: 0.85rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 2px;
    background: linear-gradient(to bottom, var(--az-cyan), var(--az-cyan-light), transparent);
    opacity: 0.5;
}
.module-timeline-item {
    position: relative;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.module-timeline-item:last-child { margin-bottom: 0; }
.module-number {
    position: absolute;
    left: -2rem;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background: var(--az-cyan);
    color: var(--az-dark);
    font-weight: 900;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    font-family: "PressStart2P", "Courier New", monospace;
    font-size: 0.55em;
}
.module-item-enhanced {
    flex: 1;
    background: rgba(5, 11, 20, 0.6);
    border: 1px solid var(--az-border);
    border-left: 4px solid var(--az-cyan);
    border-radius: 12px;
    padding: 0.8rem 1rem;
}
.module-item-enhanced h5 {
    color: var(--az-cyan-light);
    font-weight: 700;
    font-family: "BoldPixels", sans-serif;
    margin-bottom: 0.3rem;
}
.module-effort {
    color: var(--az-muted);
    font-size: 0.85em;
}

/* ===== GENERATE LESSONS ===== */
.generate-lessons-section {
    border-top: 1px solid var(--az-border);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    text-align: center;
}
.btn-accent {
    background: linear-gradient(135deg, var(--az-cyan), #0096c7);
    border: none;
    color: var(--az-dark);
    font-weight: 900;
    font-family: "BoldPixels", sans-serif;
    font-size: 1.2em;
    padding: 1rem 2rem;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(0, 180, 216, 0.35);
    letter-spacing: 0.03em;
    transition: all 0.3s;
}
.btn-accent:hover {
    background: linear-gradient(135deg, var(--az-cyan-light), var(--az-cyan));
    color: var(--az-dark);
    box-shadow: 0 8px 32px rgba(0, 180, 216, 0.5);
    transform: translateY(-2px);
}
.generate-info {
    color: var(--az-muted);
    font-size: 0.85em;
    margin-top: 0.5rem;
}

/* ===== LESSONS PAGE ===== */
.lessons-progress {
    background: rgba(30, 58, 95, 0.4);
    border: 1px solid var(--az-border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
}
.progress-header {
    margin-bottom: 0.5rem;
    color: var(--az-cyan-light);
    font-weight: 700;
}
.progress-enhanced {
    height: 10px;
    background: rgba(5, 11, 20, 0.6);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar-custom {
    background: linear-gradient(90deg, var(--az-cyan), var(--az-success));
    border-radius: 999px;
    transition: width 0.5s ease;
}

.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.lesson-card {
    transition: all 0.3s;
}
.lesson-card:hover:not(.lesson-locked) {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 180, 216, 0.2);
}
.lesson-card.lesson-locked {
    opacity: 0.5;
    filter: grayscale(0.4);
}
.lesson-card.lesson-completed {
    border-color: var(--az-success);
}
.lesson-card-header {
    margin-bottom: 0.75rem;
}
.lesson-module-number {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--az-cyan);
    color: var(--az-dark);
    font-weight: 900;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "PressStart2P", "Courier New", monospace;
    font-size: 0.55em;
}
.lesson-locked .lesson-module-number {
    background: var(--az-muted);
}
.lesson-completed .lesson-module-number {
    background: var(--az-success);
}
.lesson-status-badges {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}
.badge-passed {
    background: rgba(126, 231, 135, 0.2);
    color: var(--az-success);
    border: 1px solid var(--az-success);
}
.badge-failed {
    background: rgba(255, 209, 102, 0.15);
    color: var(--az-warning);
    border: 1px solid var(--az-warning);
}
.badge-locked {
    background: rgba(202, 240, 248, 0.1);
    color: var(--az-muted);
    border: 1px solid var(--az-muted);
}
.badge-difficulty {
    display: inline-block;
    font-size: 0.7em;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.3rem;
    font-family: "BoldPixels", sans-serif;
}
.badge-difficulty-easy {
    background: rgba(126, 231, 135, 0.15);
    color: var(--az-success);
    border: 1px solid var(--az-success);
}
.badge-difficulty-normal {
    background: rgba(0, 180, 216, 0.15);
    color: var(--az-cyan-light);
    border: 1px solid var(--az-cyan-light);
}
.badge-difficulty-hard {
    background: rgba(255, 107, 107, 0.15);
    color: var(--az-danger);
    border: 1px solid var(--az-danger);
}
.badge-tts {
    display: inline-block;
    font-size: 0.7em;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.3rem;
    font-family: "BoldPixels", sans-serif;
    background: rgba(126, 231, 135, 0.15);
    color: var(--az-success);
    border: 1px solid var(--az-success);
}
.badge-tts-off {
    background: rgba(202, 240, 248, 0.08);
    color: var(--az-muted);
    border: 1px solid var(--az-muted);
}
.lesson-title {
    color: var(--az-cyan-light);
    font-weight: 800;
    font-family: "BoldPixels", sans-serif;
    margin-bottom: 0.4rem;
    font-size: 1.1em;
}
.lesson-effort {
    color: var(--az-muted);
    font-size: 0.85em;
    margin-bottom: 0.75rem;
}
.lesson-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    font-size: 0.8em;
    color: var(--az-muted);
}
.lesson-actions {
    margin-top: auto;
}

/* ===== ACTION BUTTONS ===== */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ===== ROBOT MASCOT ===== */
#robot-mascot {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 120px;
    height: 120px;
    z-index: 1000;
    cursor: pointer;
    filter: drop-shadow(0 10px 20px rgba(0, 180, 216, 0.4));
}

/* State-based glow tints so users can see when the mascot is
   idle vs processing vs celebrating vs in an error state. The GIF
   itself is the only motion — no CSS transforms are applied. */
#robot-mascot.mascot-state-busy {
    filter: drop-shadow(0 10px 22px rgba(0, 180, 216, 0.65))
            drop-shadow(0 0 8px rgba(0, 180, 216, 0.45));
}

#robot-mascot.mascot-state-happy {
    filter: drop-shadow(0 10px 22px rgba(126, 231, 135, 0.6))
            drop-shadow(0 0 10px rgba(126, 231, 135, 0.4));
}

#robot-mascot.mascot-state-error {
    filter: drop-shadow(0 10px 22px rgba(255, 70, 80, 0.65))
            drop-shadow(0 0 10px rgba(255, 130, 60, 0.45));
}

#robot-mascot.mascot-state-idle {
    filter: drop-shadow(0 10px 20px rgba(0, 180, 216, 0.4));
}

#speech-bubble {
    --crt-bg: #000000;
    --crt-fg: #33ff66;
    --crt-fg-dim: rgba(51, 255, 102, 0.55);
    --crt-glow: rgba(51, 255, 102, 0.45);
    --crt-bezel: #1a1a1a;
    --crt-bezel-edge: #2a2a2a;
    --crt-bezel-padding: 14px;
    --crt-screen-inset: 10px;
    --crt-text-line: 14.4px;   /* 9px * 1.6 line-height */
    --crt-text-max-lines: 5;    /* 5-line cap gives 4 full lines of text plus
                                   descender headroom so the last line is not
                                   clipped by the scanline/screen surface */

    position: fixed;
    bottom: 175px;
    right: 80px;
    width: 200px;
    aspect-ratio: 4 / 3;
    background: var(--crt-bezel);
    border: 3px solid var(--crt-bezel-edge);
    border-radius: 14px;
    padding: var(--crt-bezel-padding);
    color: var(--crt-fg);
    font-family: "PressStart2P", "Courier New", monospace;
    font-size: 9px;
    line-height: 1.6;
    letter-spacing: 0.4px;
    box-shadow:
        0 10px 26px rgba(0, 0, 0, 0.7),
        0 0 20px var(--crt-glow),
        inset 0 0 18px rgba(0, 0, 0, 0.85);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    z-index: 1001;
    overflow: hidden;
}

/* Inner "screen" surface that holds the text and scanlines. */
#speech-bubble::before {
    content: "";
    position: absolute;
    inset: var(--crt-screen-inset);
    border-radius: 8px;
    background: var(--crt-bg);
    box-shadow:
        inset 0 0 14px rgba(51, 255, 102, 0.18),
        inset 0 0 4px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 0;
}

/* CRT scanlines + subtle screen vignette overlay. */
#speech-bubble::after {
    content: "";
    position: absolute;
    top: var(--crt-screen-inset);
    left: var(--crt-screen-inset);
    right: var(--crt-screen-inset);
    bottom: var(--crt-screen-inset);
    border-radius: 8px;
    background:
        repeating-linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0.0) 0px,
            rgba(0, 0, 0, 0.0) 2px,
            rgba(0, 0, 0, 0.35) 3px,
            rgba(0, 0, 0, 0.35) 4px
        ),
        radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.6) 100%);
    pointer-events: none;
    z-index: 2;
    mix-blend-mode: multiply;
}

#speech-bubble.active {
    opacity: 1;
    visibility: visible;
}

/* Pointer/tail of the bubble (still a bezel arrow). */
#speech-bubble .bubble-tail {
    position: absolute;
    bottom: -10px;
    right: 24px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: var(--crt-bezel-edge);
    z-index: 0;
}

    /* Vertical flex layout so the progress bar stays pinned to the bottom
    of the CRT screen and the typewriter text fills the 5-line cap above it. */
#speech-bubble {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

#bubble-text {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    display: block;
    min-height: 0;
    max-height: calc(var(--crt-text-line) * var(--crt-text-max-lines));
    overflow: hidden;
    margin: 0;
    padding: 8px 10px 6px 10px;
    color: var(--crt-fg);
    text-shadow:
        0 0 4px var(--crt-glow),
        0 0 10px var(--crt-glow);
    white-space: pre-wrap;
    word-break: break-word;
}

#bubble-text .bubble-caret {
    display: inline-block;
    width: 0.55em;
    height: 1em;
    background: var(--crt-fg);
    margin-left: 1px;
    vertical-align: text-bottom;
    box-shadow: 0 0 6px var(--crt-glow);
    animation: bubble-caret-blink 0.7s steps(2, start) infinite;
}

@keyframes bubble-caret-blink {
    to { visibility: hidden; }
}

/* ===== IN-BUBBLE PROGRESS BAR (CRT themed, pinned to bottom) ===== */
.bubble-progress {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    margin: 0 10px 8px 10px;
    padding-top: 6px;
    border-top: 1px solid var(--crt-fg-dim);
}

.bubble-progress-track {
    height: 5px;
    background: rgba(51, 255, 102, 0.12);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--crt-fg-dim);
}

.bubble-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--crt-fg), #b6ffb9);
    border-radius: 999px;
    transition: width 0.5s ease;
    box-shadow: 0 0 6px var(--crt-glow);
}

@media (max-width: 768px) {
    #robot-mascot {
        width: 80px;
        height: 80px;
        bottom: 16px;
        right: 16px;
    }
    #speech-bubble {
        width: 170px;
        bottom: 120px;
        right: 44px;
        padding: 10px;
        font-size: 8px;
        --crt-screen-inset: 8px;
    }
    #bubble-text {
        padding: 6px 8px 4px 8px;
    }
    .bubble-progress {
        margin: 0 8px 6px 8px;
    }
    .bubble-progress-track {
        height: 4px;
    }
}

/* ===== RESPONSIVE ENHANCEMENTS ===== */
@media (max-width: 768px) {
    .lessons-grid {
        grid-template-columns: 1fr;
    }
    .results-meta {
        align-items: flex-start;
    }
    .action-buttons {
        justify-content: center;
    }
    .goal-badge {
        max-width: 100%;
    }
}

/* ===== FACEBOOK-STYLE INTRO LAYOUT ===== */
.fb-layout-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    min-height: 70vh;
    padding: 2rem 0;
}

.fb-hero-col {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.fb-auth-col {
    flex: 0.8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fb-auth-col h1 {
    margin-bottom: 1rem;
    text-align: center;
}

.hero-image {
    max-width: 100%;
    height: auto;
    border-radius: 18px;
    border: 2px solid var(--az-border);
    box-shadow: 0 0 40px var(--az-glow), 0 14px 42px rgba(0, 0, 0, 0.28);
    margin-bottom: 1.5rem;
}

.hero-tagline {
    color: var(--az-muted);
    font-size: 1.1rem;
    max-width: 500px;
    line-height: 1.6;
}

.auth-card {
    background: var(--az-darker);
    border: 1px solid var(--az-cyan);
    border-radius: 18px;
    box-shadow: 0 0 24px var(--az-glow), 0 14px 42px rgba(0, 0, 0, 0.28);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
}

.auth-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--az-cyan), transparent);
    margin: 1.5rem 0;
    opacity: 0.5;
}

/* ===== NAVBAR AVATAR ===== */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--az-cyan);
    object-fit: cover;
    box-shadow: 0 0 10px var(--az-glow);
    transition: all 0.3s ease;
    margin-right: 8px;
}

.user-avatar:hover {
    box-shadow: 0 0 16px var(--az-cyan);
    transform: scale(1.05);
}

/* ===== RETRO DROPDOWN MENU ===== */
.retro-dropdown-menu {
    background: var(--az-darker);
    border: 1px solid var(--az-border);
    box-shadow: 0 0 10px var(--az-glow), 0 8px 24px rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 0.5rem 0;
}

.retro-dropdown-menu .dropdown-item {
    color: var(--az-silver);
    font-weight: 600;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.retro-dropdown-menu .dropdown-item:hover,
.retro-dropdown-menu .dropdown-item:focus {
    background: var(--az-blue-2);
    color: var(--az-cyan);
}

.retro-dropdown-menu .dropdown-item.active,
.retro-dropdown-menu .dropdown-item:active {
    background: var(--az-blue-2);
    color: var(--az-cyan);
}

.retro-dropdown-menu .dropdown-divider {
    border-top: 1px solid var(--az-border);
    opacity: 0.6;
    margin: 0.4rem 0;
}

.user-avatar-toggle {
    text-decoration: none;
    outline: none;
    border-radius: 50%;
    display: inline-flex;
    transition: all 0.3s ease;
}

.user-avatar-toggle:hover .user-avatar,
.user-avatar-toggle:focus .user-avatar {
    box-shadow: 0 0 16px var(--az-cyan);
    transform: scale(1.05);
}

/* ===== RESPONSIVE LAYOUT ===== */
@media (max-width: 992px) {
    .fb-layout-container {
        flex-direction: column;
        gap: 2rem;
        min-height: auto;
    }

    .fb-hero-col,
    .fb-auth-col {
        flex: none;
        width: 100%;
    }

    .hero-image {
        max-width: 80%;
    }
}

/* ===== DASHBOARD ===== */
.cap-warning-banner {
    background: rgba(255, 209, 102, 0.1);
    border: 1px solid var(--az-warning);
    border-left: 4px solid var(--az-warning);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--az-warning);
    font-size: 0.95rem;
    line-height: 1.5;
}

.cap-warning-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.path-card {
    transition: all 0.3s;
}

.path-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 180, 216, 0.2);
}

.path-title {
    color: var(--az-cyan-light);
    font-weight: 800;
    font-family: "BoldPixels", sans-serif;
    margin-bottom: 0.4rem;
    font-size: 1.1em;
}

.path-goal {
    color: var(--az-muted);
    font-size: 0.85em;
    margin-bottom: 1rem;
}

.path-progress {
    background: rgba(30, 58, 95, 0.4);
    border: 1px solid var(--az-border);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
}

.path-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.8em;
    color: var(--az-muted);
    margin-bottom: 1rem;
}

.path-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-danger-cancel {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid var(--az-danger);
    color: var(--az-danger);
    font-weight: 700;
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    transition: all 0.2s;
}

.btn-danger-cancel:hover {
    background: var(--az-danger);
    color: var(--az-dark);
    box-shadow: 0 0 12px rgba(255, 107, 107, 0.4);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: rgba(30, 58, 95, 0.4);
    border: 1px solid var(--az-border);
    border-radius: 18px;
    margin-bottom: 1.5rem;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--az-cyan-light);
    font-family: "BoldPixels", sans-serif;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--az-muted);
    margin-bottom: 1.5rem;
}

/* ===== DASHBOARD TABS ===== */
.dashboard-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.dashboard-tab {
    background: rgba(0, 180, 216, 0.08);
    border: 1px solid var(--az-border);
    border-radius: 999px;
    color: var(--az-muted);
    font-family: "PressStart2P", "Courier New", monospace;
    font-size: 0.55em;
    padding: 0.4rem 1.2rem;
    text-decoration: none;
    transition: all 0.2s;
}

.dashboard-tab:hover {
    background: rgba(0, 180, 216, 0.15);
    color: var(--az-cyan-light);
}

.dashboard-tab.active {
    background: rgba(0, 180, 216, 0.22);
    border-color: var(--az-cyan);
    color: var(--az-cyan-light);
    box-shadow: 0 0 10px var(--az-glow);
}

/* ===== PATH CARD VARIANTS ===== */
.path-completed {
    border-color: rgba(126, 231, 135, 0.3);
}

.path-cancelled {
    opacity: 0.7;
}

.badge-completed {
    background: rgba(126, 231, 135, 0.15);
    border: 1px solid var(--az-success);
    color: var(--az-success);
    font-size: 0.7em;
}

.badge-cancelled {
    background: rgba(202, 240, 248, 0.1);
    border: 1px solid var(--az-muted);
    color: var(--az-muted);
    font-size: 0.7em;
}

/* ===== BUTTON VARIANTS ===== */
.btn-complete {
    background: rgba(126, 231, 135, 0.15);
    border: 1px solid var(--az-success);
    color: var(--az-success);
    font-weight: 700;
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    font-family: "BoldPixels", sans-serif;
    font-size: 0.78em;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-complete:hover {
    background: var(--az-success);
    color: var(--az-dark);
    box-shadow: 0 0 12px rgba(126, 231, 135, 0.4);
}

.btn-delete {
    background: rgba(255, 107, 107, 0.08);
    border: 1px solid rgba(255, 107, 107, 0.4);
    color: var(--az-danger);
    font-weight: 700;
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    font-family: "BoldPixels", sans-serif;
    font-size: 0.75em;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-delete:hover {
    background: var(--az-danger);
    color: var(--az-dark);
    box-shadow: 0 0 14px rgba(255, 107, 107, 0.5);
}

.btn-export {
    background: rgba(0, 180, 216, 0.12);
    border: 1px solid rgba(0, 180, 216, 0.3);
    color: var(--az-cyan);
    font-weight: 700;
    border-radius: 8px;
    padding: 0.3rem 0.7rem;
    font-family: "BoldPixels", sans-serif;
    font-size: 0.75em;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.2s;
}

.btn-export:hover {
    background: rgba(0, 180, 216, 0.25);
    color: var(--az-cyan-light);
    box-shadow: 0 0 10px var(--az-glow);
}

/* ===== ADMIN PANEL ===== */
.admin-table {
    border: 1px solid var(--az-border);
    border-radius: 12px;
    overflow: hidden;
}

.admin-table thead th {
    background: var(--az-blue-2);
    color: var(--az-cyan-light);
    font-family: "BoldPixels", sans-serif;
    font-size: 0.8em;
    border-bottom: 2px solid var(--az-cyan);
}

.admin-table tbody td {
    color: var(--az-silver);
    vertical-align: middle;
}

.badge-admin {
    background: rgba(0, 180, 216, 0.2);
    color: var(--az-cyan);
    border: 1px solid var(--az-cyan);
}

.badge-user {
    background: rgba(202, 240, 248, 0.1);
    color: var(--az-silver);
    border: 1px solid var(--az-border);
}

.btn-outline-warning {
    color: var(--az-warning);
    border-color: var(--az-warning);
    border-radius: 8px;
}

.btn-outline-warning:hover {
    background: var(--az-warning);
    color: var(--az-dark);
}

.btn-warning {
    background: var(--az-warning);
    border-color: var(--az-warning);
    color: var(--az-dark);
    font-weight: 700;
    border-radius: 8px;
}

.btn-warning:hover {
    background: #ffe08a;
    border-color: #ffe08a;
    color: var(--az-dark);
}

/* ===== ACCESS DENIED ===== */
.access-denied-section {
    text-align: center;
    padding: 3rem 1rem;
    background: rgba(255, 209, 102, 0.05);
    border: 1px solid var(--az-warning);
    border-radius: 18px;
    margin-top: 2rem;
}

.access-denied-text {
    color: var(--az-muted);
    font-size: 1.1em;
    max-width: 600px;
    margin: 0 auto 2rem auto;
    line-height: 1.6;
}

.access-denied-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== RETRO CONFIRM MODAL (overrides Bootstrap modal) ===== */
/* A single shared modal (#confirm-modal) gates destructive actions
   (Cancel / Abandon, Delete). Bootstrap 5 provides the show/hide,
   focus-trap, ESC, and click-outside behavior; this block restyles
   the dialog to echo the mascot CRT speech-bubble look: pure black
   screen, green terminal text for the title, silver body text. */
.retro-confirm-modal .modal-content {
    background: #000000;
    border: 2px solid #33ff66;
    border-radius: 14px;
    box-shadow:
        0 0 20px rgba(51, 255, 102, 0.45),
        0 12px 40px rgba(0, 0, 0, 0.8);
    color: var(--az-silver);
}

.retro-confirm-modal .modal-header {
    border-bottom: 1px solid rgba(51, 255, 102, 0.35);
    padding: 1.1rem 1.4rem 0.85rem;
}

.retro-confirm-modal .modal-title {
    /* Echo the mascot speech-bubble CRT terminal look: pure black
       background, phosphor-green text, PressStart2P pixel font, soft
       green glow. Body text below stays silver for readability. */
    color: #33ff66;
    font-family: "PressStart2P", "Courier New", monospace;
    font-size: 0.82rem;
    letter-spacing: 0.4px;
    line-height: 1.5;
    text-shadow: 0 0 8px rgba(51, 255, 102, 0.45);
}

.retro-confirm-modal .modal-body {
    padding: 1.1rem 1.4rem;
    color: var(--az-silver);
    font-size: 0.95rem;
    line-height: 1.55;
    white-space: pre-line;
}

.retro-confirm-modal .modal-footer {
    border-top: 1px solid rgba(51, 255, 102, 0.35);
    padding: 0.85rem 1.4rem 1.1rem;
    gap: 0.6rem;
}

.retro-confirm-modal .btn-close {
    filter: invert(1) sepia(1) saturate(8) hue-rotate(60deg) brightness(1.4);
    opacity: 0.9;
}

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

/* Confirm button tinted by variant (danger / warning) */
.retro-confirm-btn-confirm.btn-danger {
    background: var(--az-danger);
    border: 1px solid var(--az-danger);
    color: var(--az-dark);
    font-weight: 700;
    border-radius: 8px;
    font-family: "BoldPixels", sans-serif;
    font-size: 0.8em;
}

.retro-confirm-btn-confirm.btn-danger:hover {
    box-shadow: 0 0 14px rgba(255, 107, 107, 0.5);
    filter: brightness(1.08);
}

.retro-confirm-btn-cancel {
    background: transparent;
    border: 1px solid var(--az-border);
    color: var(--az-cyan-light);
    border-radius: 8px;
    font-family: "BoldPixels", sans-serif;
    font-size: 0.8em;
    padding: 0.45rem 0.9rem;
}

.retro-confirm-btn-cancel:hover {
    border-color: var(--az-cyan);
    box-shadow: 0 0 8px var(--az-glow);
}