* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; margin: 0; background: #f5f6fa; color: #222; }
header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background: #2c3e50; color: white; }
header button { background: #e74c3c; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; }
.card { background: white; margin: 20px auto; padding: 20px; max-width: 900px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.auth-card { max-width: 360px; text-align: center; margin-top: 60px; }
.auth-card input, .auth-card button { width: 100%; padding: 10px; margin: 6px 0; box-sizing: border-box; }
.hidden { display: none !important; }
.row { margin: 10px 0; display: flex; flex-direction: column; gap: 4px; }
select, input, textarea { padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; font-family: inherit; }
textarea { min-height: 60px; width: 100%; }
button { cursor: pointer; padding: 8px 14px; border-radius: 4px; border: 1px solid #ccc; background: #3498db; color: white; }
button:hover { opacity: .9; }
.error { color: #e74c3c; min-height: 20px; }
.tabs { display: flex; gap: 8px; padding: 16px 24px 0; max-width: 900px; margin: 0 auto; }
.tab-btn { background: #eee; color: #333; }
.tab-btn.active { background: #2c3e50; color: white; }
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #eee; vertical-align: top; }
form label { font-weight: 600; margin-top: 8px; display: block; }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.option-grid > div { display: flex; flex-direction: column; gap: 4px; }
.checkbox-label { display: inline-block; margin-right: 12px; font-weight: normal; }
.question-text { font-size: 18px; margin: 16px 0; white-space: pre-wrap; }
.option-btn { display: block; width: 100%; text-align: left; margin: 6px 0; background: #ecf0f1; color: #222; border: 1px solid #ccc; white-space: pre-wrap; }
.option-btn.selected { border-color: #3498db; border-width: 2px; }
.option-btn.correct { background: #d9f7df; color: #155724; border-color: #77c889; }
.option-btn.incorrect { background: #ffe0e0; color: #8a1f1f; border-color: #e59a9a; }
.ist-clock { font-variant-numeric: tabular-nums; font-size: 13px; color: #d7e7f7; background: rgba(255,255,255,.12); padding: 5px 8px; border-radius: 4px; }

/* Login refinements */
.login-card { position: relative; padding-top: 34px; }
.back-home-link { position: absolute; top: 14px; left: 18px; font-size: 13px; color: #2874a6; text-decoration: none; }
.login-eyebrow { color: #2874a6; margin-top: 8px; }
.login-intro { color: #5c6770; font-size: 14px; line-height: 1.5; margin: 0 0 16px; }
.login-footer { display: flex; justify-content: center; gap: 14px; margin-top: 18px; font-size: 12px; }
.login-footer a { color: #5c6770; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Public landing and legal pages */
.public-page { min-height: 100vh; display: flex; flex-direction: column; }
.public-login-link, .primary-link { display: inline-block; padding: 9px 15px; border-radius: 4px; background: #3498db; color: white; text-decoration: none; }
.hero-card { max-width: 980px; margin: 42px auto 24px; padding: 48px; border-radius: 12px; color: white; background: linear-gradient(125deg, #2c3e50, #2874a6); }
.hero-card h2 { max-width: 650px; font-size: 38px; margin: 8px 0 12px; }
.hero-card p:not(.eyebrow) { max-width: 680px; font-size: 18px; line-height: 1.6; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 1.4px; color: #b9dcf5; }
.primary-link { margin-top: 10px; background: #f1c40f; color: #4a3b00; font-weight: 700; }
.public-section, .legal-card { width: min(980px, calc(100% - 32px)); margin: 20px auto; }
.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.feature-grid article, .muted-section { padding: 20px; background: white; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.feature-grid h3 { margin-top: 0; }
.muted-section { margin-bottom: 40px; }
.legal-card { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.1); line-height: 1.65; }
.legal-card h3 { margin-top: 28px; }
.public-footer { margin-top: auto; padding: 20px 24px; background: #233140; color: #d7e7f7; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.public-footer nav, .public-footer { display: flex; align-items: center; }
.public-footer nav { gap: 16px; }
.public-footer a { color: #d7e7f7; }
@media (max-width: 640px) { .hero-card { width: calc(100% - 20px); margin-top: 16px; padding: 28px 20px; } .hero-card h2 { font-size: 29px; } .feature-grid { grid-template-columns: 1fr; } }

/* Signed-in learner experience */
.learner-app { min-height: 100vh; background: radial-gradient(circle at 10% 5%, #e1f3ff 0, transparent 27%), radial-gradient(circle at 96% 18%, #e9e2ff 0, transparent 29%), #f7f9fc; }
.learner-app .user-header { min-height: 78px; padding: 12px clamp(16px, 4vw, 48px); background: linear-gradient(120deg, #173b5f, #245b86 56%, #3679a6); box-shadow: 0 4px 16px rgba(20, 54, 83, .2); }
.user-brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(135deg, #f6cb4c, #f39b32); color: #563500; font-size: 21px; box-shadow: 0 3px 10px rgba(0,0,0,.18); }
.user-brand h1 { margin: 0; font-size: clamp(18px, 2.2vw, 23px); letter-spacing: .1px; }
.user-brand p { margin: 2px 0 0; color: #cce6f7; font-size: 12px; letter-spacing: .4px; }
.learner-app .header-right { gap: 11px; }
.welcome-user { color: #f1f8fd; font-weight: 600; font-size: 14px; }
.learner-app .profile-icon-btn { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.32); box-shadow: none; }
.logout-stack { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.learner-app #logoutBtn { background: #e95c62; box-shadow: 0 2px 8px rgba(94, 14, 19, .22); }
.learner-app .ist-clock { display: block; color: #d7ecfa; background: transparent; padding: 0; border-radius: 0; font-size: 11px; white-space: nowrap; }
.learner-app .tabs { max-width: 1100px; padding: 20px 20px 0; gap: 9px; }
.learner-app .tab-btn { border: 1px solid #d9e5ee; background: rgba(255,255,255,.86); color: #426075; border-radius: 20px; padding: 8px 14px; font-weight: 600; box-shadow: 0 2px 5px rgba(35,73,101,.05); }
.learner-app .tab-btn.active { background: #245b86; border-color: #245b86; color: white; box-shadow: 0 4px 11px rgba(36,91,134,.25); }
.learner-app .tab-content > .card, .learner-app .card { border: 1px solid rgba(216,229,239,.9); border-radius: 14px; box-shadow: 0 8px 26px rgba(30,67,95,.08); }
.learner-app #selectors { border-top: 4px solid #47a0b7; }
.learner-app .collapsible-header h3 { color: #1e4e70; }
.learner-app #progressBadge { background: #e5f3f8; color: #246176; }
.learner-app .option-btn { padding: 12px 14px; border-radius: 8px; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.learner-app .option-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(43,78,102,.1); }
.learner-app button:not(.tab-btn):not(.option-btn) { border: none; box-shadow: 0 2px 7px rgba(24,70,101,.15); }
.learner-app table thead { background: #edf6fa; color: #27516c; }
.learner-app table th:first-child { border-top-left-radius: 6px; }
.learner-app table th:last-child { border-top-right-radius: 6px; }
@media (max-width: 640px) { .learner-app .user-header { align-items: flex-start; } .learner-app .header-right { width: auto; gap: 7px; } .user-brand { max-width: 100%; } .welcome-user { display: none; } .logout-stack { align-items: flex-end; } .learner-app .tabs { padding: 14px 10px 0; } }
.nav-row { display: flex; gap: 10px; margin-top: 16px; }
.attachment-img { max-width: 100%; border-radius: 4px; margin-top: 8px; }
#explanationBox, #attachmentBox { margin-top: 16px; padding: 12px; background: #f9f9f9; border-radius: 4px; white-space: pre-wrap; }
form > button { margin-top: 12px; }

/* Collapsible "Quiz Setup" section */
.collapsible-header { display: flex; justify-content: space-between; align-items: center; }
.collapsible-header h3 { margin: 0; }
.toggle-btn { background: #eee; color: #333; border: 1px solid #ccc; font-size: 13px; padding: 6px 10px; }

/* Top-right question counter badge on the quiz card */
#quiz { position: relative; padding-top: 40px; }
#progressBadge { position: absolute; top: 16px; right: 20px; font-weight: 600; color: #555; background: #ecf0f1; padding: 4px 10px; border-radius: 12px; font-size: 14px; }

/* Hint button */
.hint-btn { background: #f1c40f; color: #4a3b00; border: 1px solid #d4ac0d; margin: 10px 0; font-weight: 600; }
.hint-btn:hover { background: #f39c12; }

/* Suggest-a-correction box */
#suggestBox { margin-top: 20px; }
.link-btn { background: none; border: none; color: #3498db; padding: 4px 0; text-decoration: underline; font-size: 13px; }
.secondary-btn { background: #bbb; }
.success-msg { color: #2ecc71; font-size: 13px; margin-top: 6px; }
#suggestForm textarea { width: 100%; min-height: 60px; margin-top: 6px; }

/* Suggestions admin tab */
.status-pending { color: #e67e22; font-weight: 600; }
.status-reviewed { color: #3498db; font-weight: 600; }
.status-resolved { color: #2ecc71; font-weight: 600; }

/* Generic tab-content sections on the user side (index.html) */
.tab-content { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.tab-content > .card { max-width: 900px; }

/* ---------- Take a Test ---------- */
.test-layout { display: flex; gap: 20px; align-items: flex-start; max-width: 1100px; margin: 20px auto; padding: 0 20px; }
.test-main { flex: 1; min-width: 0; }
.test-nav { width: 260px; flex-shrink: 0; }
.test-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.test-timer { font-size: 20px; font-weight: 700; color: #e74c3c; background: #fdecea; padding: 6px 14px; border-radius: 6px; }
.submit-test-btn { background: #e74c3c; margin-top: 16px; width: 100%; }
.test-nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0; }
.nav-cell { width: 36px; height: 36px; padding: 0; background: #ecf0f1; color: #333; border: 2px solid #ccc; border-radius: 4px; font-weight: 600; }
.nav-cell.nav-answered { background: #2ecc71; color: white; border-color: #27ae60; }
.nav-cell.nav-skipped { background: #f1c40f; color: #4a3b00; border-color: #d4ac0d; }
.nav-cell.nav-current { border-color: #3498db; border-width: 3px; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 12px; margin-top: 10px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot-answered { background: #2ecc71; }
.dot-skipped { background: #f1c40f; }
.dot-unvisited { background: #ecf0f1; border: 1px solid #ccc; }
.review-item { border-bottom: 1px solid #eee; padding: 10px 0; }
.answer-correct { color: #2ecc71; }
.answer-wrong { color: #e74c3c; }
.review-explanation { color: #555; font-style: italic; white-space: pre-wrap; }

/* Users admin tab */
.badge-blocked { color: #e74c3c; font-weight: 600; }
.badge-active { color: #2ecc71; font-weight: 600; }
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 14px; }

/* Reset-password modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-box { background: white; padding: 20px; border-radius: 8px; width: 320px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-box input { width: 100%; margin: 10px 0; }
.limited-access-box { border-top: 5px solid #f1c40f; }
.limited-access-box h4 { margin-top: 0; color: #7d6608; }
.limited-access-box p { line-height: 1.5; }
#resetPasswordResult { background: #eafaf1; border: 1px solid #2ecc71; padding: 10px; border-radius: 6px; margin: 10px 0; font-size: 14px; }

/* Header profile icon + Contact Us */
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.profile-icon-btn { background: #34495e; border-radius: 50%; width: 36px; height: 36px; padding: 0; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }

/* Import/export controls */
.import-export-row { flex-direction: row; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters-row { flex-direction: row; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters-row select, .filters-row input { flex: 1 1 200px; }
.import-file-label { background: #2ecc71; color: white; padding: 8px 14px; border-radius: 4px; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; }
#importResultMsg { font-size: 13px; background: #f4f6f7; border-radius: 4px; padding: 8px; margin-top: 8px; }

/* Tables that might overflow narrow screens scroll horizontally instead of squeezing content */
.table-scroll { width: 100%; overflow-x: auto; }

/* ======================================================================
   MOBILE (phones, and the Android/iOS app webviews wrapping this site)
   ====================================================================== */
@media (max-width: 640px) {
  header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  header h1 { font-size: 18px; }
  .header-right { width: 100%; justify-content: space-between; }

  .tabs { padding: 10px 10px 0; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab-btn { flex-shrink: 0; font-size: 13px; padding: 8px 10px; }

  .tab-content { padding: 0 10px; }
  .card, .tab-content > .card { margin: 12px auto; padding: 14px; border-radius: 6px; max-width: 100%; }
  .auth-card { margin-top: 24px; }

  .option-grid { grid-template-columns: 1fr; }
  .nav-row { flex-wrap: wrap; }
  .nav-row button { flex: 1 1 auto; min-width: 100px; }

  table { font-size: 13px; }
  th, td { padding: 6px; }
  #paperTable, #bookTable, #chapterTable, #questionTable, #suggestionTable,
  #userTable, #materialTable, #materialsTable, #mySuggestionsTable {
    display: block;
  }
  #paperTable, #bookTable, #chapterTable, #questionTable, #suggestionTable,
  #userTable, #materialTable, #materialsTable, #mySuggestionsTable {
    overflow-x: auto;
    white-space: nowrap;
  }

  .import-export-row { flex-direction: column; align-items: stretch; }
  .import-export-row button, .import-file-label { width: 100%; justify-content: center; text-align: center; }
  .filters-row { flex-direction: column; align-items: stretch; }

  /* Take a Test: nav panel drops below the question instead of sitting beside it */
  .test-layout { flex-direction: column; padding: 0 10px; }
  .test-nav { width: 100%; }
  .test-nav-grid { grid-template-columns: repeat(6, 1fr); }
  .nav-cell { width: 100%; height: 40px; }
  .test-header-row { flex-wrap: wrap; gap: 8px; }
  .test-timer { font-size: 16px; }

  .modal-box { width: 100%; }

  #progressBadge { font-size: 12px; padding: 3px 8px; }
  .question-text { font-size: 16px; }
}
