:root {
  --marine-blue: #0c3b5d;
  --marine-deep: #062842;
  --marine-light: #cde6ff;
  --sand: #f4f0ea;
  --accent: #1cb0f6;
  --success: #1bd1a5;
  --danger: #ff6b6b;
  --text: #0f1c2e;
  --muted: #5c7080;
  --border: #d8e2ec;
  --shadow: 0 14px 40px rgba(0, 40, 73, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--sand);
  min-height: 97vh;
}

.marine-bg {
  background: radial-gradient(circle at 20% 20%, rgba(28, 176, 246, 0.2), transparent 25%),
    radial-gradient(circle at 80% 0%, rgba(12, 59, 93, 0.15), transparent 35%),
    radial-gradient(circle at 50% 80%, rgba(27, 209, 165, 0.16), transparent 30%),
    var(--sand);
}

h1, h2, h3 {
  margin: 0;
}

p {
  margin: 0.4rem 0;
  color: var(--muted);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  font-size: 0.95rem;
}

.btn.primary {
  background: linear-gradient(135deg, var(--marine-blue), var(--accent));
  color: #fff;
  box-shadow: var(--shadow);
}

.btn.small {
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
}

.btn.ghost {
  background: rgba(12, 59, 93, 0.06);
  color: var(--marine-blue);
  border: 1px solid rgba(12, 59, 93, 0.1);
}

.btn:hover {
  transform: translateY(-1px);
}

.auth-container {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: #fff;
  border-radius: 18px;
  padding: 2rem;
  width: min(420px, 100%);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 1rem;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--marine-blue), var(--accent));
  color: #fff;
  font-size: 1.4rem;
  box-shadow: var(--shadow);
}

.form {
  display: grid;
  gap: 0.75rem;
}

.form label {
  font-weight: 700;
  color: var(--marine-blue);
}

.form input, .chat-input textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fdfdfd;
  font-size: 1rem;
  transition: border 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.form input:focus, .chat-input textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(28, 176, 246, 0.25);
}

.form-message {
  min-height: 1.2rem;
  font-size: 0.95rem;
  color: var(--danger);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(12, 59, 93, 0.08);
}

.chat-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 1.5rem;
  min-height: calc(98vh - 120px);
  align-items: start;
}

.chat-area {
  display: grid;
  grid-template-rows: 1fr auto;
   height: calc(96vh - 120px);
  gap: 0.8rem;
}

.session-sidebar {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 0.75rem;
  border: 1px solid rgba(12, 59, 93, 0.08);
  max-height: calc(96vh - 120px);
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.session-header h2 {
  margin: 0;
  color: var(--marine-blue);
}

.session-search input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fdfdfd;
}

.session-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.session-card {
  border: 1px solid rgba(12, 59, 93, 0.08);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: #fff;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.session-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(12, 59, 93, 0.08);
}

.session-card.active {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(28, 176, 246, 0.15);
}

.session-title {
  font-weight: 700;
  color: var(--marine-blue);
}

.session-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.session-preview {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
  line-height: 1.3;
}

.chat-panel {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 0.75rem;
  overflow-y: auto;

}

.chat-window {
  padding: 1rem;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(12, 59, 93, 0.05), rgba(12, 59, 93, 0.01));
  border: 1px solid rgba(12, 59, 93, 0.05);
  min-height: auto;
}

.message {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.message .meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.message .bubble {
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-shadow: 0 6px 20px rgba(12, 59, 93, 0.08);
}

.message.user .bubble {
  background: linear-gradient(135deg, rgba(28, 176, 246, 0.12), rgba(27, 209, 165, 0.1));
  border: 1px solid rgba(28, 176, 246, 0.25);
  margin-left: auto;
}

.message.bot .bubble {
  background: #fff;
  border: 1px solid rgba(12, 59, 93, 0.08);
}

.message pre {
  background: #0f1c2e;
  color: #e8f1fb;
  padding: 0.75rem;
  border-radius: 10px;
  overflow-x: auto;
}

.message code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.loading {
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: rgba(28, 176, 246, 0.1);
  border-radius: 12px;
  color: var(--marine-blue);
  border: 1px solid rgba(28, 176, 246, 0.25);
}

.loading[hidden] {
  display: none !important;
}

.loading.active {
  display: flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(12, 59, 93, 0.15);
  border-top-color: var(--marine-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Quiz Page */
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.2rem;
}

.muted {
  color: var(--muted);
}

.quiz-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.quiz-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  padding: 1.5rem;
}

.quiz-panel {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  border: 1px solid rgba(12, 59, 93, 0.08);
}

.quiz-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.quiz-panel__header h3 {
  color: var(--marine-blue);
  margin-top: 0.2rem;
}

.topic-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.topic-input input {
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  min-width: 220px;
}

.quiz-questions {
  display: grid;
  gap: 1rem;
}

.question-card {
  background: #fff;
  border: 1px solid rgba(12, 59, 93, 0.08);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 8px 22px rgba(12, 59, 93, 0.06);
}

.question-title {
  font-weight: 700;
  color: var(--marine-blue);
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.badge {
  background: rgba(28, 176, 246, 0.14);
  color: var(--marine-blue);
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
}

.options {
  display: grid;
  gap: 0.55rem;
}

.quiz-block {
  display: grid;
  gap: 0.75rem;
}

.question-card.inline {
  box-shadow: none;
  border: 1px solid rgba(12, 59, 93, 0.1);
}

.quiz-result {
  font-weight: 600;
  color: var(--marine-blue);
}

.quiz-corrections {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
  font-weight: 400;
}

.option-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: center;
  border: 1px solid var(--border);
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  background: #fdfdfd;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.option-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(12, 59, 93, 0.06);
}

.option-card input {
  display: none;
}

.radio-marker {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.radio-marker::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.option-card.selected .radio-marker,
.option-card input:checked + .radio-marker {
  border-color: var(--accent);
}

.option-card.selected .radio-marker::after,
.option-card input:checked + .radio-marker::after {
  opacity: 1;
}

.option-text {
  font-weight: 600;
  color: var(--text);
}

.quiz-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.result-panel {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  border: 1px solid rgba(12, 59, 93, 0.08);
  height: fit-content;
}

.result-summary {
  margin-bottom: 1rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.percentage {
  background: linear-gradient(135deg, var(--marine-blue), var(--accent));
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-weight: 800;
}

.result-list {
  display: grid;
  gap: 0.65rem;
}

.result-item {
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  background: #fdfdfd;
}

.result-item.correct {
  border-color: rgba(27, 209, 165, 0.35);
  background: rgba(27, 209, 165, 0.08);
}

.result-item.incorrect {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.08);
}

.question-card.is-correct {
  border-color: rgba(27, 209, 165, 0.4);
}

.question-card.is-incorrect {
  border-color: rgba(255, 107, 107, 0.5);
}

.correct-answer {
  border-color: rgba(27, 209, 165, 0.7) !important;
  background: rgba(27, 209, 165, 0.08) !important;
}

.incorrect-answer {
  border-color: rgba(255, 107, 107, 0.7) !important;
  background: rgba(255, 107, 107, 0.08) !important;
}

.fade-in {
  animation: fadeIn 0.35s ease-in;
}

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

@media (max-width: 1024px) {
  .quiz-grid {
    grid-template-columns: 1fr;
  }

  .topic-input {
    width: 100%;
  }

  .topic-input input {
    width: 100%;
  }
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: auto;
}

.suggestions h3 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.9rem;
  color: var(--marine-blue);
}

.video-section {
  background: linear-gradient(145deg, rgba(239, 248, 255, 0.85), rgba(196, 201, 205, 0.75));
  border: 1px solid rgba(28, 176, 246, 0.3);
  border-radius: 14px;
  padding: 0.75rem;
  box-shadow: 0 10px 30px rgba(6, 40, 66, 0.25);
  color: #e8f1fb;
}

.media-section {
  background: #f7fbff;
  border: 1px solid rgba(12, 59, 93, 0.08);
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow: 0 6px 16px rgba(6, 40, 66, 0.08);
}

.video-list {
  display: flex;
   flex-wrap: wrap;    
  flex-direction: row;
  gap: 0.75rem;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.video-thumb {
  /* display: grid;
  grid-template-columns: 150px 1fr; */
  display: flex;
  flex-direction: column;    /*  title goes BELOW video */
  width: 220px;  
  gap: 0.65rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.5rem;
  transition: transform 0.12s ease, box-shadow 0.2s ease, border 0.2s ease;
}

.video-thumb:hover {
  transform: translateY(-2px);
  border-color: rgba(28, 176, 246, 0.5);
  box-shadow: 0 14px 30px rgba(12, 59, 93, 0.35);
}

.video-thumb img { 
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.video-thumb-title {
  font-weight: 700;
  color: var(--marine-blue);
  line-height: 1.3;
  text-align: center
}

.question-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top:5px;
}

.video-card {
  background: #fff;
  border: 1px solid rgba(12, 59, 93, 0.08);
  border-radius: 12px;
  overflow: hidden;
  width: 160px;
  box-shadow: 0 6px 16px rgba(12, 59, 93, 0.06);
  text-decoration: none;
  color: inherit;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.media-card {
  background: #fff;
  border: 1px solid rgba(12, 59, 93, 0.1);
  border-radius: 10px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.media-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(12, 59, 93, 0.12);
}

.media-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(12, 59, 93, 0.08);
}

.media-card .media-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--marine-blue);
}

.media-card .media-meta {
  font-size: 0.9rem;
  color: #3d4b5f;
}

.video-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(12, 59, 93, 0.1);
}

.video-card img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}

.video-card .video-info {
  padding: 0.6rem 0.7rem;
  font-size: 0.9rem;
  color: var(--text);
}

.question-button {
  background: rgba(12, 59, 93, 0.08);
  border: 1px solid rgba(12, 59, 93, 0.12);
  color: var(--marine-blue);
  border-radius: 12px;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.question-button:hover {
  background: rgba(28, 176, 246, 0.1);
  transform: translateY(-1px);
}

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 16px;
  padding: 0.75rem;
  box-shadow: var(--shadow);
 position: sticky;   /* ✅ makes it stick */
  bottom: 0;          /* ✅ sticks to bottom */
  z-index: 5;

  margin-top: 0;}

.chat-input textarea {
  resize: vertical;
  min-height: 52px;
  max-height: 180px;
}

/* CSS FOR VIDEO MODAL */
.video-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.video-modal.hidden {
  display: none;
}

.video-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.video-container {
  position: relative;
  width: 80%;
  max-width: 900px;
  margin: 5% auto;
  background: #000;
  border-radius: 10px;
  z-index: 2;
}

.video-container video {
  width: 100%;
  max-height: 80vh;
  border-radius: 10px;
  pointer-events: auto;
}

.video-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
   z-index: 10;   
}


/* for image view  */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.image-modal.hidden {
  display: none;
}

.image-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.image-container {
  position: relative;
  margin: 5% auto;
  max-width: 90%;
  max-height: 85vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
}

.image-container img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 10px;
  user-select: none;
  pointer-events: auto;
}

.image-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  z-index: 10;
}

/* pdf view */
.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.pdf-modal.hidden {
  display: none;
}

.pdf-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.pdf-container {
  position: relative;
  width: 85%;
  height: 85vh;
  margin: 3% auto;
  background: #111;
  border-radius: 8px;
  z-index: 2;
}

.pdf-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.pdf-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  z-index: 10;
}


/* ---------------- WELCOME CARD ---------------- */
.welcome-card {
   min-height: 340px; 
  max-width: 520px;
  margin: 3rem auto 1rem auto;
  background: #ffffff;
  border-radius: 18px;
  padding: 2rem 1.75rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(12, 59, 93, 0.12);
  border: 1px solid rgba(12, 59, 93, 0.08);
}

.welcome-icons {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  margin-bottom: 1rem;
}

.welcome-icons img {
  width: 42px;
  height: 42px;
}

.welcome-card h2 {
   font-size: 1.9rem;
  margin: 0.75rem 0 0.25rem;
  color: var(--marine-blue);
}

.welcome-card h3 {
  margin: 0.25rem 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.welcome-card p {
    font-size: 1.05rem;
  line-height: 1.65;
  max-width: 560px;
  margin: 0 auto;
}





/* for loader */
.thinking-loader {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
}

.thinking-loader[hidden] {
  display: none;
}

.thinking-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: #ffffff;
  border: 1px solid rgba(12, 59, 93, 0.1);
  border-radius: 14px;
  padding: 0.65rem 0.9rem;
  box-shadow: 0 6px 20px rgba(12, 59, 93, 0.08);
  font-weight: 600;
  color: var(--marine-blue);
  max-width: 80%;
}

.thinking-bubble .emoji {
  font-size: 1.2rem;
}

.thinking-bubble .dots::after {
  content: '';
  animation: dots 1.4s infinite;
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}



@media (max-width: 720px) {
  .chat-shell {
    grid-template-columns: 1fr;
  }

  .session-sidebar {
    max-height: none;
    grid-template-rows: auto auto auto;
  }

  .chat-area {
    grid-template-rows: auto 1fr auto;
  }

  .chat-input {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    max-height: none;
  }

  .chat-window {
    max-height: 50vh;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}
