:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1a1d29;
  --text-muted: #6b7080;
  --border: #e3e5ec;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger-bg: #fdecec;
  --danger-text: #b3261e;
  --notice-bg: #eaf6ec;
  --notice-text: #1e7a34;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

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

.topbar {
  padding: 20px 24px;
}

.brand-mark {
  display: block;
  height: 28px;
  width: auto;
}

.hero {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 24px 24px 64px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.hero-copy {
  flex: 1 1 380px;
  max-width: 480px;
}

.hero-copy h1 {
  font-size: 36px;
  line-height: 1.2;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.hero-copy p {
  color: var(--text-muted);
  font-size: 16px;
  margin: 0 0 20px;
}

.hero-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
}

.hero-points li {
  padding-left: 26px;
  position: relative;
}

.hero-points li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

.login-card {
  flex: 1 1 360px;
  max-width: 400px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
}

.login-card h2 {
  margin: 0 0 18px;
  font-size: 20px;
}

.form-error,
.form-notice {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 16px;
}

.form-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.form-notice {
  background: var(--notice-bg);
  color: var(--notice-text);
}

.google-btn-wrap {
  display: flex;
  justify-content: center;
  min-height: 40px;
}

.google-fallback {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

.google-fallback code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 20px 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.divider span {
  padding: 0 10px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 6px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 6px;
}

.tab-panel.active {
  display: flex;
}

.panel-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.tab-panel label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-top: 8px;
}

.tab-panel input,
.tab-panel select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

.tab-panel input:focus,
.tab-panel select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.btn {
  margin-top: 16px;
  padding: 11px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 480px) {
  .hero {
    padding: 16px 16px 40px;
    gap: 24px;
  }

  .hero-copy {
    order: 2;
  }

  .hero-copy h1 {
    font-size: 26px;
  }

  .login-card {
    order: 1;
    padding: 20px;
  }
}

/* ==========================================
   Dashboard — chat-style home screen
   ========================================== */

.app-layout {
  height: 100dvh;
  display: flex;
}

.chat-shell {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface);
}

/* Header menu/avatar — only shown on mobile; on desktop the sidebar's own
   account trigger is used instead (see the mobile block below). */
.header-icon-btn {
  display: none;
}

.avatar {
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: none;
}

.chat-main {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

/* Tile grid opened by the chat input's tools button — sits over chat-main */

.tools-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--bg);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 16px;
  padding: 24px;
  overflow-y: auto;
}

.tools-panel[hidden] {
  display: none;
}

.tools-tile {
  width: 112px;
  height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tools-tile svg {
  color: var(--primary);
}

.tools-tile:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.08);
}

.tools-tile[hidden] {
  display: none;
}

.chat-icon {
  width: 96px;
  height: auto;
  margin-bottom: 20px;
}

.chat-empty h1 {
  font-size: 22px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.chat-empty p {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 280px;
  margin: 0 auto;
}

.chat-thread {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: stretch;
  /* Not justify-content: flex-end — Chromium doesn't count end-aligned
     overflow (content pushed past the start edge) as scrollable, so a short
     conversation would render but a long one couldn't be scrolled at all.
     Bottom-alignment for short threads instead comes from this spacer, which
     only grows when there's leftover room. */
  justify-content: flex-start;
}

.chat-thread::before {
  content: "";
  flex: 1 1 auto;
  min-height: 0;
}

.chat-thread[hidden] {
  display: none;
}

/* ==========================================
   Exams list (sidebar "Exams" nav item)
   ========================================== */

.exams-list-view {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  text-align: left;
}

.exams-list-view[hidden] {
  display: none;
}

.exams-list-header {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 20px;
}

.exams-list-header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.exams-list-search {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  min-width: 220px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.exams-list-search svg {
  flex: none;
}

.exams-list-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
}

.exams-list-table {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.exams-list-table-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.exams-list-rows {
  flex: none;
  display: flex;
  flex-direction: column;
}

.exams-list-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}

.exams-list-row-icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--primary);
}

.exams-list-row-name {
  flex: 1;
  min-width: 0;
}

.exams-list-row-title {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exams-list-row-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exams-list-row-modified {
  flex: none;
  font-size: 13px;
  color: var(--text-muted);
}

.exams-list-empty {
  padding: 24px 4px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

.exams-list-empty[hidden] {
  display: none;
}

/* ==========================================
   Exam detail (row click inside exams list)
   ========================================== */

.exam-detail-view {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  text-align: left;
  overflow-y: auto;
}

.exam-detail-view[hidden] {
  display: none;
}

.exam-detail-back {
  flex: none;
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

.exam-detail-back:hover {
  color: var(--text);
}

.exam-detail-header {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.exam-detail-icon {
  flex: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--primary);
}

.exam-detail-headtext {
  flex: 1 1 220px;
  min-width: 0;
}

.exam-detail-headtext h1 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.exam-detail-meta {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.exam-detail-actions {
  flex: none;
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.exam-detail-btn {
  padding: 9px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.exam-detail-btn:hover {
  background: var(--bg);
}

.exam-detail-btn-primary {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
}

.exam-detail-btn-primary:hover {
  background: var(--primary-hover);
}

.exam-detail-body {
  flex: 1 1 auto;
  min-height: 0;
}

.exam-detail-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.exam-detail-count-badge {
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.exam-attempt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}

.exam-attempt-avatar {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.exam-attempt-info {
  flex: 1;
  min-width: 0;
}

.exam-attempt-name {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.exam-attempt-date {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.exam-attempt-score {
  flex: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.reports-kid-filter {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.reports-kid-filter label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.reports-kid-filter select {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
  min-width: 180px;
}

.reports-card {
  flex: 1 1 auto;
  min-height: 0;
}

.reports-subject {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 16px;
  overflow: hidden;
}

/* Horizontal-scroll hint for the attempts table on narrow screens — a
   faint fade at the right edge signals there's more to swipe to, since
   there's no visible scrollbar on touch devices. */
@media (max-width: 640px) {
  .reports-subject::after {
    content: "";
    position: absolute;
    top: 41px;
    right: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--surface));
  }
}

.reports-subject-title {
  margin: 0;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.reports-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.reports-table {
  /* Fixed layout instead of the browser's default auto layout, which was
     handing almost all the width to the Topic column (the widest cell
     drives auto layout) and squeezing every Attempt column into a sliver
     on the far right, leaving a big dead gap between them. Only the Topic
     column gets an explicit width (below); the Attempt columns split
     whatever's left evenly, so they fill the card edge-to-edge when there
     are few of them and — thanks to the min-width on their cells, further
     down — fall back to a fixed width plus horizontal scroll once there
     are too many to fit. */
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.reports-col-topic {
  width: 240px;
}

.reports-table th,
.reports-table td {
  padding: 10px 16px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

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

.reports-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.reports-table th.reports-attempt-col,
.reports-table td.reports-attempt-col {
  min-width: 110px;
  text-align: center;
}

.reports-table td.reports-topic-cell {
  color: var(--text);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.reports-topic-name {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.reports-type-list,
.reports-score-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.reports-type-line {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 15px;
}

.reports-score-cell {
  color: var(--text-muted);
}

.reports-score-line {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 15px;
}

.reports-score-empty {
  color: var(--text-muted);
  font-weight: 400;
}

.reports-score-na {
  color: var(--text-muted);
  font-weight: 600;
}

/* ==========================================
   Take Exam (Student role — Start Exam button
   in the exam detail view)
   ========================================== */

.exam-take-answersheet {
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.exam-take-answersheet[hidden] {
  display: none;
}

.exam-take-answersheet-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.exam-take-answersheet-actions {
  display: flex;
}

.exam-take-answersheet-actions .exam-detail-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.exam-take-answersheet .attach-file-chips {
  padding: 12px 0 0;
}

.exam-take-questions {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 18px;
}

.exam-take-question {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.exam-take-question-text {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.exam-take-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-take-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.exam-take-option input {
  flex: none;
}

.exam-take-answer-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.exam-take-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.exam-take-results[hidden] {
  display: none;
}

.exam-take-score-card {
  padding: 20px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.exam-take-score-value {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.exam-take-score-label {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.exam-take-review-item {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.exam-take-review-item.correct {
  background: var(--notice-bg);
  border-color: transparent;
}

.exam-take-review-item.incorrect {
  background: var(--danger-bg);
  border-color: transparent;
}

.exam-take-review-question {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.exam-take-review-answer {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.exam-take-review-answer.correct {
  color: var(--notice-text);
}

.exam-take-review-answer.incorrect {
  color: var(--danger-text);
}

/* display:none by default — only used for the Print button (built on
   demand, then revealed via the @media print rules below for
   window.print()). Download PDF is built separately with jsPDF's text
   APIs, not from this element — see buildExamPdf() in dashboard.js. */
.exam-print-area {
  display: none;
  width: 720px;
  padding: 24px;
  background: #fff;
  color: #000;
}

.exam-print-area h1 {
  font-size: 20px;
  margin: 0 0 6px;
}

.exam-print-meta {
  color: #555;
  font-size: 13px;
  margin: 0 0 20px;
}

.exam-print-area ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.exam-print-area ul {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: #333;
}

@media print {
  body > *:not(#examPrintArea) {
    display: none !important;
  }

  .exam-print-area {
    display: block !important;
    position: static;
    left: 0;
    width: auto;
  }
}

.chat-bubble {
  align-self: flex-end;
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  max-width: 80%;
  font-size: 14px;
  text-align: left;
}

.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
}

.exam-paper-card {
  align-self: flex-start;
  flex-shrink: 0;
  width: 100%;
  max-width: 360px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.06);
}

.exam-summary-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.exam-summary-icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg);
  color: var(--primary);
}

.exam-summary-text {
  min-width: 0;
}

.exam-summary-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.exam-summary-meta {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.exam-summary-meta + .exam-summary-meta {
  margin-top: 4px;
}

.exam-summary-viewbtn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.exam-summary-viewbtn:hover {
  background: var(--primary-hover);
}

.exam-paper-details[hidden] {
  display: none;
}

.exam-paper-questions {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exam-paper-questions > li {
  font-size: 14px;
  color: var(--text);
}

.exam-paper-questions > li > p {
  margin: 0;
}

.exam-paper-options {
  margin: 6px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
  list-style: none;
}

.exam-options-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 10px 0;
}

.exam-options-bar[hidden] {
  display: none;
}

.exam-options-select {
  flex: 1;
  min-width: 0;
  padding: 10px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
}

.attach-file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 10px 0;
}

.attach-file-chips[hidden] {
  display: none;
}

.attach-file-chip {
  position: relative;
  flex: none;
  width: 76px;
  height: 76px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}

.attach-file-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-file-chip-doc {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 8px;
}

.attach-file-chip-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.attach-file-chip-name {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 11px;
  line-height: 1.25;
  color: var(--text);
  word-break: break-word;
}

.attach-file-chip-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.attach-file-chip-remove:hover {
  background: rgba(0, 0, 0, 0.75);
}

.chat-inputbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  margin: 0 16px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.06);
  overflow: hidden;
}

.chat-inputbar[hidden] {
  display: none;
}

.chat-inputbar-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 12px;
}

.exam-options-error {
  margin: 0;
  padding: 0 14px 8px;
  font-size: 12px;
  color: var(--danger-text);
}

.exam-options-error[hidden] {
  display: none;
}

.chat-inputbar input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 14px;
  padding: 10px 6px;
  background: transparent;
  color: var(--text);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

.send-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ==========================================
   Sidebar — nav, recents, account footer
   ========================================== */

.side-drawer {
  flex: 0 0 auto;
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-topbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 4px;
}

.sidebar-search {
  flex: 0 0 auto;
  padding: 0 4px 4px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

.sidebar-search input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.sidebar-nav {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 8px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.sidebar-item[hidden] {
  display: none;
}

.sidebar-item svg {
  flex: none;
  color: var(--text-muted);
}

.sidebar-item:hover {
  background: var(--bg);
}

.sidebar-recents {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section-label {
  margin: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.sidebar-recents-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.recent-row {
  display: flex;
  align-items: center;
  border-radius: 8px;
}

.recent-row:hover,
.recent-row:focus-within {
  background: var(--bg);
}

.recent-row.active {
  background: var(--bg);
}

.recent-item {
  flex: 1;
  min-width: 0;
  padding: 8px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-row.active .recent-item {
  font-weight: 600;
}

.recent-menu-btn {
  flex: none;
  width: 26px;
  height: 26px;
  margin-right: 4px;
  border: none;
  background: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}

.recent-menu-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.kid-delete-btn {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  color: var(--danger-text);
  cursor: pointer;
}

.kid-delete-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger-text);
}

.sidebar-recents-empty {
  margin: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.recent-menu {
  position: fixed;
  z-index: 85;
  width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.15);
  padding: 4px;
  display: flex;
  flex-direction: column;
}

.recent-menu[hidden] {
  display: none;
}

.recent-menu-delete,
.recent-menu-delete svg {
  color: var(--danger-text);
}

.kid-menu-confirm {
  padding: 8px;
}

.kid-menu-confirm p {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
}

.kid-menu-confirm-actions {
  display: flex;
  gap: 6px;
}

.kid-menu-confirm-actions button {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.kid-menu-confirm-actions button.recent-menu-delete {
  border-color: var(--danger-text);
}

.kid-menu-confirm-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.sidebar-footer {
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.account-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.account-trigger:hover {
  background: var(--bg);
}

.account-trigger .avatar {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.account-trigger-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.account-trigger-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-trigger-sub {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-popup {
  position: fixed;
  z-index: 80;
  width: 224px;
  max-width: calc(100vw - 24px);
  left: 12px;
  bottom: 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.15);
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.account-popup[hidden] {
  display: none;
}

.popup-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.popup-profile .avatar {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.popup-profile-text {
  min-width: 0;
}

.popup-name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.popup-handle {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.popup-item svg {
  flex: none;
  color: var(--text-muted);
}

button.popup-item:hover {
  background: var(--bg);
}

.popup-coins {
  cursor: default;
}

.popup-coins-balance {
  margin-left: auto;
  font-weight: 700;
  color: var(--text);
}

/* Upgrade-plan modal — lists the admin-configured subscription plans */

.plans-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.plans-modal-overlay[hidden] {
  display: none;
}

.plans-modal {
  width: 100%;
  max-width: 1080px;
  max-height: min(720px, calc(100vh - 32px));
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 48px rgba(16, 24, 40, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.plans-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.plans-modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.plans-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
}

.plans-modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.plans-modal-body {
  padding: 24px;
  background: var(--bg);
  overflow-y: auto;
}

.plans-modal-state {
  margin: 0;
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.plans-modal-state-error {
  color: var(--danger-text);
}

.plans-purchase-status {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  background: #ecfdf3;
  color: #0a7a3e;
}

.plans-purchase-status[hidden] {
  display: none;
}

.plans-purchase-status-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.plans-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.plan-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.plan-card-recommended {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  box-shadow: 0 0 0 1px var(--primary);
}

.plan-card-badge {
  position: absolute;
  top: 18px;
  right: 20px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 15%, var(--surface));
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.plan-card-eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plan-card-name {
  margin: 4px 0 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.plan-card-details {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  min-height: 20px;
}

.plan-card-price {
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.plan-card-price-amount {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.plan-card-price-period {
  font-size: 13px;
  color: var(--text-muted);
}

.plan-card-btn {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.plan-card-btn:hover {
  opacity: 0.88;
}

.plan-card-recommended .plan-card-btn {
  background: var(--primary);
  color: #fff;
}

.plan-card-recommended .plan-card-btn:hover {
  background: var(--primary-hover);
  opacity: 1;
}

.plan-card-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.plan-card-discount {
  display: inline-block;
  margin: -8px 0 16px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 11px;
  font-weight: 700;
  align-self: flex-start;
}

.plan-card-features {
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-card-feature {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.plan-card-feature svg {
  flex: none;
  margin-top: 2px;
  color: var(--primary);
}

/* Settings modal — Account / Billing / Coins, in a left-nav + content layout */

.settings-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.settings-modal-overlay[hidden] {
  display: none;
}

.settings-modal {
  position: relative;
  width: 100%;
  max-width: 820px;
  height: min(600px, calc(100vh - 32px));
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 48px rgba(16, 24, 40, 0.25);
  display: flex;
  overflow: hidden;
}

.settings-modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
}

.settings-modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.settings-modal-nav {
  flex: 0 0 200px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 56px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}

.settings-nav-item svg {
  flex: none;
}

.settings-nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.settings-nav-item[aria-current="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.settings-modal-content {
  flex: 1 1 auto;
  padding: 24px 28px;
  overflow-y: auto;
}

.settings-panel-title {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.settings-panel[hidden] {
  display: none;
}

.settings-info-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.settings-info-row dt {
  font-size: 12px;
  color: var(--text-muted);
}

.settings-info-row dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.settings-status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.settings-status-active {
  background: #ecfdf3;
  color: #0a7a3e;
}

.settings-status-inactive {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.settings-danger-zone {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.settings-danger-zone h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger-text);
}

.settings-danger-zone p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 42ch;
}

.settings-danger-btn {
  padding: 8px 14px;
  border: 1px solid var(--danger-text);
  border-radius: 20px;
  background: transparent;
  color: var(--danger-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.settings-danger-btn:hover {
  background: var(--danger-bg);
}

.settings-deactivate-confirm {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--danger-bg);
}

.settings-deactivate-confirm p {
  margin: 0 0 10px;
  color: var(--danger-text);
  font-weight: 600;
}

.settings-deactivate-confirm-actions {
  display: flex;
  gap: 8px;
}

.settings-section-title {
  margin: 24px 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.settings-section-title:first-of-type {
  margin-top: 0;
}

.settings-current-plan-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-current-plan-name {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.settings-current-plan-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.settings-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}

.settings-history-main {
  min-width: 0;
}

.settings-history-title {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.settings-history-sub {
  margin: 0;
  color: var(--text-muted);
}

.settings-history-amount {
  flex: none;
  font-weight: 700;
  color: var(--text);
}

.settings-history-amount-credit {
  color: #0a7a3e;
}

.settings-history-amount-debit {
  color: var(--danger-text);
}

.settings-coins-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.settings-coins-stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.settings-coins-stat-label {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.settings-coins-stat-value {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

@media (max-width: 640px) {
  .settings-modal {
    flex-direction: column;
    height: min(680px, calc(100vh - 32px));
  }

  .settings-modal-nav {
    flex: none;
    flex-direction: row;
    padding: 52px 12px 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }

  .settings-nav-item span {
    white-space: nowrap;
  }

  .settings-modal-content {
    padding: 20px;
  }
}

/* Suggestion chips above the input bar (empty state only) */

.chat-suggestions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  margin: 0 16px 8px;
}

.chat-suggestions[hidden] {
  display: none;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}

.suggestion-item[hidden] {
  display: none;
}

.suggestion-item:hover {
  background: var(--surface);
  color: var(--text);
}

.suggestion-item svg {
  flex: none;
}

/* Live "as you type" suggestions above the input bar */

.typeahead-suggestions {
  flex: 0 0 auto;
  margin: 0 16px 8px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.06);
}

.typeahead-suggestions[hidden] {
  display: none;
}

.typeahead-label {
  margin: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.typeahead-list {
  display: flex;
  flex-direction: column;
}

.typeahead-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.typeahead-item:hover {
  background: var(--bg);
}

/* Desktop-only: collapse the sidebar to an icon rail */

@media (min-width: 641px) {
  .side-drawer.collapsed {
    width: 64px;
  }

  .side-drawer.collapsed .sidebar-topbar {
    flex-direction: column;
    gap: 4px;
  }

  .side-drawer.collapsed .sidebar-search,
  .side-drawer.collapsed .sidebar-recents,
  .side-drawer.collapsed .sidebar-item span,
  .side-drawer.collapsed .account-trigger-text {
    display: none;
  }

  .side-drawer.collapsed .sidebar-item,
  .side-drawer.collapsed .account-trigger {
    justify-content: center;
  }
}

/* Mobile: sidebar becomes a slide-in overlay opened from the header
   hamburger, matching the ChatGPT app shell. The header avatar keeps
   opening the account popup directly, same as desktop. */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 25, 0.4);
  z-index: 65;
}

.sidebar-overlay[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .header-icon-btn {
    display: flex;
  }

  .side-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 82vw;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(16, 24, 40, 0.15);
  }

  .side-drawer.mobile-open {
    transform: translateX(0);
  }

  /* The account trigger lives inside the sidebar on every breakpoint now,
     so the popup's default (bottom-left, anchored to the sidebar footer)
     position already lands in the right place here too — no override
     needed, just make sure it paints above the open sidebar (see z-index
     on .account-popup below). */

  .chat-main {
    padding: 16px;
  }

  .chat-inputbar {
    margin: 0 8px 12px;
  }

  .chat-suggestions {
    margin: 0 8px 8px;
  }

  .reports-kid-filter select {
    flex: 1;
    min-width: 0;
  }

  .reports-table th,
  .reports-table td {
    padding: 9px 12px;
  }

  .reports-col-topic {
    width: 160px;
  }

  .reports-table th.reports-attempt-col,
  .reports-table td.reports-attempt-col {
    min-width: 90px;
  }
}
