/* ============================================================
   Finals Study Hub — styles
   Primary: blue (#1a56db, inherited from main site)
   Accent : teal (#0d9488) for countdown / hero
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               Arial, "Noto Sans TC", sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Google Docs sign-in warning modal ---------- */
.gdocs-modal {
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.gdocs-modal.open { opacity: 1; }
.gdocs-warn-card {
  max-width: 400px;
  width: 100%;
  margin: auto;
  padding: 28px 26px 22px;
  text-align: center;
  border-radius: 22px;
  transform: scale(0.85) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.gdocs-modal.open .gdocs-warn-card { transform: scale(1) translateY(0); }
.gdocs-warn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(66, 133, 244, 0.22);
  animation: gdocsIconIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both,
             gdocsIconBob 2.6s ease-in-out 0.8s infinite;
}
@keyframes gdocsIconIn {
  from { transform: scale(0) rotate(-90deg); opacity: 0; }
  to   { transform: scale(1) rotate(0);      opacity: 1; }
}
@keyframes gdocsIconBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.gdocs-warn-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
  animation: gdocsFadeUp 0.4s ease 0.3s both;
}
.gdocs-warn-body {
  font-size: 0.88rem;
  color: #4b5563;
  line-height: 1.55;
  margin-bottom: 18px;
  animation: gdocsFadeUp 0.4s ease 0.4s both;
}
.gdocs-warn-body strong {
  color: #1a56db;
  font-weight: 700;
  background: linear-gradient(120deg, transparent 0%, transparent 50%, #fef9c3 50%, #fef9c3 100%);
  background-size: 220% 100%;
  background-position: 100% 0;
  animation: gdocsHighlight 1s ease 0.7s both;
  padding: 0 3px;
  border-radius: 2px;
}
@keyframes gdocsHighlight {
  to { background-position: 0 0; }
}
@keyframes gdocsFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.gdocs-warn-skip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #6b7280;
  cursor: pointer;
  user-select: none;
  margin-bottom: 18px;
  animation: gdocsFadeUp 0.4s ease 0.5s both;
}
.gdocs-warn-skip input {
  width: 16px;
  height: 16px;
  accent-color: #4285f4;
  cursor: pointer;
}
.gdocs-warn-actions {
  display: flex;
  gap: 10px;
  justify-content: stretch;
  animation: gdocsFadeUp 0.4s ease 0.55s both;
}
.gdocs-warn-actions > * {
  flex: 1;
  padding: 11px 14px;
  font-size: 0.9rem;
  text-align: center;
  text-decoration: none;
}
.gdocs-warn-open {
  background: linear-gradient(135deg, #4285f4 0%, #1a56db 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s, transform 0.1s;
}
.gdocs-warn-open:hover {
  box-shadow: 0 8px 20px rgba(26, 86, 219, 0.30);
  transform: translateY(-1px);
}
.gdocs-warn-open:active { transform: translateY(0) scale(0.99); }

/* ---------- Peek mode (triple-tap site title) ----------
   Locks the page into the bottom half of the viewport so a student
   peeking at their iPad from a drawer doesn't have to crane their
   neck. The html element loses its scroll entirely; body becomes a
   fixed-position pane in the bottom 50vh with its own internal scroll.
   That way no amount of scrolling exposes the top half. */
html.peek-mode {
  background: #f0f2f5;
  height: 100vh;
  overflow: hidden;
}
body.peek-mode {
  position: fixed;
  top: 50vh;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* iOS Safari: prevent the body's own pull-to-refresh from disengaging
     the peek pane. */
  overscroll-behavior: contain;
}
body.peek-mode::before {
  content: '🤫  Peek mode — triple-tap title to exit';
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  z-index: 9999;
  pointer-events: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  animation: peekBadgeIn 0.4s 0.25s both;
}
@keyframes peekBadgeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.site-title {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.site-title.peek-pulse { animation: peekTitlePulse 0.25s ease; }
@keyframes peekTitlePulse {
  50% { transform: scale(1.06); }
}

/* ---------- Header ---------- */
.site-header {
  position: relative;
  background: linear-gradient(135deg, #0d9488 0%, #115e59 100%);
  color: #fff;
  padding: 22px 16px 26px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(13, 148, 136, 0.18);
}
.header-inner { max-width: 800px; margin: 0 auto; }
.site-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.site-tagline { font-size: 0.85rem; opacity: 0.85; margin-top: 2px; font-weight: 500; }

/* "🛡 Admin" badge — visible only when an admin session is active
   (revealed by app.js after a sessionStorage check). Clicking it
   opens the admin dashboard. */
.admin-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.30);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  z-index: 5;
}
.admin-badge:hover {
  background: rgba(255, 255, 255, 0.32);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.admin-badge:active { transform: translateY(0) scale(0.98); }
.admin-badge[hidden] { display: none; }
.admin-badge-icon { font-size: 0.95rem; line-height: 1; }
@media (max-width: 520px) {
  .admin-badge {
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    font-size: 0.72rem;
  }
  .admin-badge-icon { font-size: 0.85rem; }
}

/* ---------- Page wrap ---------- */
.page-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  padding: 22px 22px 24px;
  margin-bottom: 18px;
}

/* ---------- Countdown ---------- */
.countdown-card {
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  color: #fff;
  text-align: center;
  padding: 22px 18px 24px;
}
.countdown-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 14px;
}
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}
.countdown-unit {
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 4px 10px;
  backdrop-filter: blur(2px);
}
.countdown-unit .num {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.countdown-unit .lab {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
  opacity: 0.8;
}
.countdown-sub {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 12px;
}

/* Countdown action buttons (Timetable, Coverage) */
.countdown-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}
.countdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.01em;
  backdrop-filter: blur(3px);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.countdown-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}
.countdown-btn:active { transform: translateY(0) scale(0.98); }
.countdown-btn-icon { font-size: 1rem; }
.countdown-card.done {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}
.countdown-card.live {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
}

/* ---------- Main tabs ---------- */
.main-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  background: #fff;
  padding: 6px;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.main-tab {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: #6b7280;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.main-tab:hover { background: #f3f4f6; color: #1a56db; }
.main-tab.active {
  background: #1a56db;
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,86,219,0.25);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

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

/* ---------- Section titles ---------- */
.section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1a56db;
  margin-bottom: 6px;
}
.section-desc {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 16px;
}

/* ---------- Forms ---------- */
.form-row { margin-bottom: 14px; }
.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.8rem;
  color: #374151;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.req { color: #dc2626; }
.opt { color: #9ca3af; font-weight: 500; font-size: 0.78rem; margin-left: 4px; }

input[type="text"],
input[type="number"],
input[type="file"],
input[type="password"],
select,
textarea {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #1a1a2e;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: #1a56db;
  box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}
input[type="file"] {
  padding: 8px 10px;
  font-size: 0.85rem;
}
textarea { resize: vertical; min-height: 56px; font-family: inherit; }
.file-hint {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 4px;
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-block;
  padding: 12px 22px;
  background: #1a56db;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn-primary:hover { background: #1648c0; box-shadow: 0 4px 14px rgba(26,86,219,0.30); }
.btn-primary:active { transform: scale(0.98); background: #1340a8; }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-secondary {
  display: inline-block;
  padding: 12px 18px;
  background: #f3f4f6;
  color: #374151;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover { background: #e5e7eb; border-color: #d1d5db; }
.btn-secondary:active { transform: scale(0.98); }

.btn-fullscreen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  width: 38px;
  height: 38px;
  background: #f3f4f6;
  color: #374151;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-fullscreen:hover { background: #e5e7eb; border-color: #d1d5db; color: #111827; }
.btn-fullscreen:active { transform: scale(0.98); }
.btn-fullscreen svg { display: block; }

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: none;
}
.btn-danger:hover { background: #b91c1c; }

#upload-btn { width: 100%; margin-top: 6px; }

/* Collapsible upload card */
.upload-card { padding: 0; overflow: hidden; }
.upload-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: #1a56db;
  font-size: 0.95rem;
  font-weight: 700;
  transition: background 0.15s;
}
.upload-toggle:hover { background: #f9fafb; }
.upload-toggle-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1a56db;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.2s, background 0.15s;
}
.upload-toggle[aria-expanded="true"] .upload-toggle-icon {
  transform: rotate(45deg);
  background: #6b7280;
}
.upload-toggle-text { flex: 1; }
.upload-toggle-hint {
  font-size: 0.75rem;
  font-weight: 500;
  color: #9ca3af;
  white-space: nowrap;
}
.upload-collapse {
  padding: 4px 22px 24px;
  border-top: 1px solid #f3f4f6;
  animation: fadeIn 0.2s ease;
}
.upload-collapse > .form-row:first-child { margin-top: 14px; }
@media (max-width: 520px) {
  .upload-toggle { padding: 14px 16px; gap: 10px; }
  .upload-toggle-hint { display: none; }
  .upload-collapse { padding: 4px 16px 20px; }
}

/* ---------- Upload progress ---------- */
.upload-progress {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.upload-progress-bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0d9488, #1a56db);
  width: 0%;
  transition: width 0.15s ease;
}
.upload-progress-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: #374151;
  min-width: 44px;
  text-align: right;
}
.upload-status {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}
.upload-status.ok { color: #15803d; }
.upload-status.err { color: #b91c1c; }

/* ---------- Browse list ---------- */
.browse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.browse-filters {
  display: flex;
  gap: 8px;
}
.browse-filters select {
  width: auto;
  padding: 7px 12px;
  font-size: 0.85rem;
}
.notes-list {
  display: grid;
  gap: 10px;
}
.empty-state {
  text-align: center;
  color: #9ca3af;
  font-size: 0.9rem;
  padding: 28px 0;
}
.note-card {
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.note-card:hover {
  border-color: #1a56db;
  box-shadow: 0 4px 14px rgba(26,86,219,0.10);
}
.note-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.note-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.35;
}
.note-type {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.note-type.notes { background: #dbeafe; color: #1e40af; }
.note-type.mock_paper { background: #fef3c7; color: #92400e; }
.note-type.flashcards { background: #ede9fe; color: #5b21b6; }
.note-type.gdocs      { background: #dbeafe; color: #1e3a8a; }
.note-type.custom     { background: #d1fae5; color: #065f46; }
.note-card-gdocs {
  border-color: #c7d2fe;
}
.note-card-gdocs:hover {
  border-color: #4285f4;
  box-shadow: 0 4px 14px rgba(66, 133, 244, 0.18);
}

/* Google Docs action button.
   - Default: a Google-blue secondary button that fits next to View /
     Download.
   - .gdocs-btn-compact (set automatically when other actions are
     present): smaller padding so the row doesn't get crowded. */
.gdocs-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1f1f1f;
  letter-spacing: -0.005em;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s, background 0.15s;
}
.gdocs-btn:hover {
  border-color: #4285f4;
  background: #f0f7ff;
  box-shadow: 0 4px 12px rgba(66, 133, 244, 0.18);
}
.gdocs-btn:active { transform: scale(0.98); }
.gdocs-btn-compact {
  padding: 8px 12px;
  font-size: 0.82rem;
}
.gdocs-btn-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gdocs-btn-label {
  white-space: nowrap;
}

/* Quizlet "Flashcards" button — same compact shape as gdocs-btn but
   with the Quizlet-purple logo and a purple hover treatment. */
.quizlet-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1f1f1f;
  letter-spacing: -0.005em;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s, background 0.15s;
}
.quizlet-btn:hover {
  border-color: #4255ff;
  background: #f4f5ff;
  box-shadow: 0 4px 12px rgba(66, 85, 255, 0.18);
}
.quizlet-btn:active { transform: scale(0.98); }
.quizlet-btn-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.quizlet-btn-label { white-space: nowrap; }

/* ---------- "Off to Quizlet" redirect popup ---------- */
.quizlet-redirect-modal {
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.quizlet-redirect-modal.open { opacity: 1; }
.qr-card {
  max-width: 400px;
  width: 100%;
  margin: auto;
  padding: 32px 28px 22px;
  text-align: center;
  border-radius: 22px;
  position: relative;
  overflow: hidden;
  transform: scale(0.8) translateY(20px);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: linear-gradient(180deg, #ffffff 0%, #f4f5ff 100%);
}
.quizlet-redirect-modal.open .qr-card {
  transform: scale(1) translateY(0);
}

/* Floating sticker grid — emojis pop in from below with a stagger
   then gently bob. Eight stickers spread around the card edges so
   the popup feels celebratory without crowding the content. */
.qr-stickers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.qr-sticker {
  position: absolute;
  font-size: 24px;
  opacity: 0;
  transform: translateY(20px) scale(0.4);
  animation:
    qrStickerIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
    qrStickerBob 2.5s ease-in-out infinite;
}
.qr-s1 { top: 12px;  left: 14px;  --d: 0.08s; }
.qr-s2 { top: 24px;  right: 18px; --d: 0.18s; }
.qr-s3 { top: 80px;  left: -2px;  --d: 0.28s; }
.qr-s4 { top: 70px;  right: -4px; --d: 0.12s; }
.qr-s5 { bottom: 100px; left: 8px;  --d: 0.22s; }
.qr-s6 { bottom: 110px; right: 6px; --d: 0.34s; }
.qr-s7 { bottom: 30px; left: 30px;  --d: 0.40s; }
.qr-s8 { bottom: 14px; right: 28px; --d: 0.46s; }
.qr-sticker {
  animation-delay: var(--d, 0.1s), calc(var(--d, 0.1s) + 0.5s);
}
@keyframes qrStickerIn {
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
@keyframes qrStickerBob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50%      { transform: translateY(-4px) rotate(8deg); }
}

.qr-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  margin-bottom: 14px;
  animation: qrLogoIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s both,
             qrLogoPulse 1.6s ease-in-out 0.6s infinite;
  filter: drop-shadow(0 6px 16px rgba(66, 85, 255, 0.30));
}
@keyframes qrLogoIn {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes qrLogoPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
.qr-title {
  position: relative;
  z-index: 2;
  font-size: 1.2rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 6px;
  letter-spacing: -0.015em;
  animation: qrFadeUp 0.4s ease 0.2s both;
}
.qr-sub {
  position: relative;
  z-index: 2;
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 18px;
  animation: qrFadeUp 0.4s ease 0.3s both;
}
@keyframes qrFadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Progress bar that fills exactly over 2 seconds. */
.qr-progress {
  position: relative;
  z-index: 2;
  height: 6px;
  background: rgba(66, 85, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
  animation: qrFadeUp 0.4s ease 0.35s both;
}
.qr-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4255ff 0%, #8b5cf6 100%);
  border-radius: 999px;
  animation: qrFill 2s cubic-bezier(0.4, 0, 0.2, 1) 0.05s forwards;
}
@keyframes qrFill { to { width: 100%; } }

.qr-skip {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #6b7280;
  cursor: pointer;
  user-select: none;
  animation: qrFadeUp 0.4s ease 0.45s both;
}
.qr-skip input {
  width: 14px;
  height: 14px;
  accent-color: #4255ff;
  cursor: pointer;
}

/* Mode picker — two big abstract-colored cards */
.view-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.view-mode-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
}
.view-mode-tab::before,
.view-mode-tab::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(24px);
  z-index: -1;
  pointer-events: none;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.view-mode-tab::before {
  width: 180px; height: 180px;
  background: rgba(255, 255, 255, 0.28);
  top: -60px; right: -50px;
}
.view-mode-tab::after {
  width: 140px; height: 140px;
  background: rgba(255, 255, 255, 0.18);
  bottom: -50px; left: -30px;
}
.view-mode-tab:hover { transform: translateY(-3px); }
.view-mode-tab:hover::before { transform: translate(-10px, 10px) scale(1.1); }
.view-mode-tab:hover::after  { transform: translate(10px, -10px) scale(1.1); }
.view-mode-tab:active { transform: translateY(-1px) scale(0.99); }

/* Warm, vibrant gradient — "see everything" */
.view-mode-tab-all {
  background: linear-gradient(135deg, #fb923c 0%, #ec4899 55%, #8b5cf6 100%);
  box-shadow: 0 10px 24px rgba(236, 72, 153, 0.28);
}
.view-mode-tab-all:hover { box-shadow: 0 14px 32px rgba(236, 72, 153, 0.40); }

/* Cool, organized gradient — "navigate the tree" */
.view-mode-tab-folders {
  background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 55%, #6366f1 100%);
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.28);
}
.view-mode-tab-folders:hover { box-shadow: 0 14px 32px rgba(59, 130, 246, 0.40); }

/* Active state — inset ring + slight emphasis */
.view-mode-tab.active {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85) inset,
              0 14px 32px rgba(0, 0, 0, 0.18);
}
.view-mode-tab.active::before { transform: translate(-6px, 6px) scale(1.15); }

.view-mode-tab-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.18));
}
.view-mode-tab-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.view-mode-tab-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.view-mode-tab-sub {
  font-size: 0.78rem;
  opacity: 0.92;
  font-weight: 500;
  line-height: 1.35;
}

@media (max-width: 520px) {
  .view-mode-tabs { grid-template-columns: 1fr; gap: 10px; }
  .view-mode-tab { padding: 16px 18px; }
  .view-mode-tab-icon { font-size: 1.7rem; }
  .view-mode-tab-title { font-size: 0.98rem; }
}

/* Folder browser */
.folder-nav-header { margin-bottom: 14px; }
.folder-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.85rem;
}
.folder-crumb {
  color: #1a56db;
  text-decoration: none;
  font-weight: 700;
}
.folder-crumb:hover { text-decoration: underline; }
.folder-crumb.current {
  color: #111827;
  font-weight: 800;
}
.folder-crumb-sep {
  color: #9ca3af;
  font-weight: 600;
}
.folder-subhead {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  margin: 18px 0 10px;
}
.folder-children {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.folder-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.folder-card:hover {
  border-color: #0d9488;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.12);
}
.folder-card:active { transform: scale(0.99); }
.folder-card-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.folder-card-body {
  flex: 1;
  min-width: 0;
}
.folder-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-card-meta {
  font-size: 0.76rem;
  color: #6b7280;
  margin-top: 2px;
}
.folder-card-arrow {
  font-size: 1rem;
  color: #9ca3af;
  flex-shrink: 0;
}
.note-card-flashcards {
  border-color: #ddd6fe;
}
.note-card-flashcards:hover {
  border-color: #7c3aed;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.12);
}
.admin-card-clicks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 4px;
}
.cstat-label {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: #9ca3af;
  margin-right: 2px;
}
.cstat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  border: 1px solid;
}
.cstat-view    { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.cstat-dl      { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.cstat-gdocs   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.cstat-quizlet { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.cstat-empty   { font-style: italic; color: #9ca3af; }

.note-folder, .admin-card-folder {
  font-size: 0.78rem;
  color: #6b7280;
  background: #f3f4f6;
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  margin-top: 2px;
}
.note-meta {
  font-size: 0.78rem;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.note-meta span { white-space: nowrap; }
.note-desc {
  font-size: 0.85rem;
  color: #374151;
  margin-top: 2px;
}
.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  min-width: 0;
}
.note-actions .btn-secondary,
.note-actions .btn-primary {
  padding: 8px 14px;
  font-size: 0.82rem;
}
.note-actions .btn-fullscreen {
  width: 34px;
  height: 34px;
  padding: 6px;
}

/* ---------- Timer ---------- */
.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1.5px solid #e5e7eb;
}
.sub-tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #6b7280;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: -1.5px;
  transition: color 0.15s, border-color 0.15s;
}
.sub-tab:hover { color: #1a56db; }
.sub-tab.active { color: #1a56db; border-bottom-color: #1a56db; }

.sub-panel { display: none; }
.sub-panel.active { display: block; }

.timer-phase-label {
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1a56db;
  margin-bottom: 6px;
}
.timer-phase-label.break { color: #0d9488; }

.timer-display {
  text-align: center;
  font-size: 4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #111827;
  letter-spacing: -0.02em;
  margin: 4px 0 14px;
  line-height: 1.1;
}

.timer-cycles {
  text-align: center;
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 16px;
}

.timer-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.timer-settings {
  margin-top: 10px;
  border-top: 1px solid #f3f4f6;
  padding-top: 12px;
}
.timer-settings summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
  user-select: none;
  padding: 4px 0;
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.settings-grid label {
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
  font-weight: 700;
  color: #374151;
  gap: 4px;
}
.settings-grid input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.cd-input-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}
.cd-input-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
}
.cd-input-row input {
  width: 70px;
  padding: 8px 10px;
  text-align: center;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.lap-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid #f3f4f6;
}
.lap-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 4px;
  font-size: 0.85rem;
  border-bottom: 1px solid #f3f4f6;
  font-variant-numeric: tabular-nums;
}
.lap-list li:last-child { border-bottom: none; }
.lap-list li .lap-n { font-weight: 700; color: #6b7280; }
.lap-list li .lap-t { color: #111827; }

/* ---------- Admin ---------- */
.admin-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
.gate-card {
  max-width: 440px;
  margin: 60px auto 40px;
  padding: 36px 32px 24px;
  text-align: center;
}
.gate-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.25);
}
.gate-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.gate-desc {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 22px;
}
.gate-pw-row {
  text-align: left;
  margin-bottom: 16px;
}
.gate-pw-wrap {
  position: relative;
}
.gate-pw-wrap input {
  padding-right: 46px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
.gate-pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.gate-pw-toggle:hover { background: #f3f4f6; color: #1a56db; }
.gate-pw-toggle.on { color: #1a56db; }
.gate-caps {
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #d97706;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 6px 10px;
}
.gate-submit {
  width: 100%;
  position: relative;
  padding: 14px 20px;
  font-size: 1rem;
}
.gate-submit-spinner {
  display: none;
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: gate-spin 0.7s linear infinite;
}
.gate-submit.is-loading .gate-submit-spinner { display: block; }
@keyframes gate-spin { to { transform: translateY(-50%) rotate(360deg); } }
.gate-status {
  margin-top: 16px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  display: none;
  animation: fadeIn 0.15s ease;
}
.gate-status:empty { display: none; }
.gate-status code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  padding: 1px 5px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
}
.gate-status-info {
  display: block;
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  text-align: center;
}
.gate-status-ok {
  display: block;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
  text-align: center;
}
.gate-status-err {
  display: block;
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  line-height: 1.5;
}
.gate-back {
  display: inline-block;
  margin-top: 22px;
  font-size: 0.82rem;
  color: #6b7280;
  text-decoration: none;
  font-weight: 600;
}
.gate-back:hover { color: #0d9488; }

/* Stats dashboard tiles */
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-tile {
  background: #fff;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.04);
  border-top: 4px solid #d1d5db;
}
.stat-tile-primary { border-top-color: #1a56db; }
.stat-tile-notes   { border-top-color: #3b82f6; }
.stat-tile-mocks   { border-top-color: #f59e0b; }
.stat-tile-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 6px;
}
.stat-tile-num {
  font-size: 1.9rem;
  font-weight: 800;
  color: #111827;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* Dashboard secondary row */
.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.dashboard-half { margin-bottom: 0; padding: 18px 20px; }
.dashboard-h {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 12px;
}

.subject-breakdown, .recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.subject-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.subject-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}
.subject-name { font-weight: 600; color: #374151; }
.subject-count { font-weight: 700; color: #1a56db; }
.subject-bar {
  height: 6px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
}
.subject-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a56db, #0d9488);
  border-radius: 4px;
}

.recent-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 0;
  border-bottom: 1px dashed #f3f4f6;
}
.recent-row:last-child { border-bottom: none; }
.recent-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-meta {
  font-size: 0.75rem;
  color: #6b7280;
  display: flex;
  gap: 6px;
}
.empty-state-small {
  color: #9ca3af;
  font-size: 0.85rem;
  text-align: center;
  padding: 10px 0;
}

/* Controls bar */
.admin-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.admin-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
#admin-search {
  width: 240px;
  padding: 9px 12px;
  font-size: 0.85rem;
}

/* Card grid */
.admin-cards {
  display: grid;
  gap: 12px;
}
.admin-card {
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.admin-card:hover {
  border-color: #1a56db;
  box-shadow: 0 4px 16px rgba(26, 86, 219, 0.10);
}
.admin-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.admin-card-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.3;
  word-break: break-word;
}
.admin-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.78rem;
  color: #6b7280;
}
.admin-card-meta span { white-space: nowrap; }
.admin-card-meta strong { color: #1a56db; font-weight: 700; }
.admin-card-desc {
  font-size: 0.85rem;
  color: #374151;
  margin-top: 2px;
  line-height: 1.5;
}
.admin-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.admin-card-actions .btn-primary,
.admin-card-actions .btn-secondary {
  padding: 8px 14px;
  font-size: 0.82rem;
}
.admin-card-actions .reorder-group {
  display: inline-flex;
  gap: 2px;
  margin-right: 4px;
}
.admin-card-actions .btn-reorder {
  padding: 6px 10px;
  font-size: 1rem;
  line-height: 1;
  min-width: 36px;
}

/* Themed modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

/* Welcome popup (admin-authored, shown on hub entry) */
.welcome-popup-card {
  position: relative;
  padding: 28px 28px 22px;
  text-align: center;
  max-width: 440px;
}
.welcome-popup-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: 0;
  font-size: 1.6rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
}
.welcome-popup-close:hover { color: #475569; }
.welcome-popup-emoji {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 12px;
}
.welcome-popup-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #111827;
  margin: 0 0 14px;
}
.welcome-popup-rule {
  border: 0;
  border-top: 1.5px solid #e5e7eb;
  margin: 0 0 16px;
}
.welcome-popup-desc {
  font-size: 0.95rem;
  line-height: 1.55;
  color: #374151;
  white-space: pre-wrap;
  margin-bottom: 20px;
}
.welcome-popup-cta {
  display: inline-block;
  margin-bottom: 18px;
}
.welcome-popup-skip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #6b7280;
  cursor: pointer;
  user-select: none;
}
.welcome-popup-skip input { cursor: pointer; }
.modal-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
}
.modal-card-wide {
  max-width: 560px;
  max-height: calc(100vh - 40px);
}
.modal-card-wide .modal-card-body {
  overflow-y: auto;
}
.edit-current-file {
  font-size: 0.85rem;
  color: #374151;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  word-break: break-all;
}
.edit-current-file.empty {
  color: #9ca3af;
  font-style: italic;
}
.modal-card-header {
  background: #1a56db;
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.98rem;
  font-weight: 700;
}
.modal-card-header.modal-danger-header { background: #dc2626; }
.modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.85;
}
.modal-close:hover { opacity: 1; }
.modal-card-body {
  padding: 18px 20px 8px;
  color: #374151;
}
.modal-card-body .form-label { margin-bottom: 6px; }
.modal-card-body input[type="text"] { font-size: 0.95rem; }
.modal-meta {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #9ca3af;
}
.modal-confirm-text {
  font-size: 0.95rem;
  color: #111827;
  margin-bottom: 8px;
  line-height: 1.5;
}
.modal-confirm-text strong { color: #dc2626; font-weight: 700; word-break: break-word; }
.modal-confirm-sub {
  font-size: 0.82rem;
  color: #6b7280;
  line-height: 1.5;
}
.modal-card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
}
.modal-card-footer .btn-primary,
.modal-card-footer .btn-secondary {
  padding: 10px 18px;
  font-size: 0.88rem;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 20px 16px 32px;
  color: #9ca3af;
  font-size: 0.82rem;
}
.footer-links {
  margin-top: 6px;
  font-size: 0.78rem;
}
.footer-links a {
  color: #6b7280;
  text-decoration: none;
}
.footer-links a:hover { color: #1a56db; text-decoration: underline; }

/* ---------- Maths finder (scoped under .maths-finder) ---------- */
.maths-finder { padding: 22px 22px 18px; }
.maths-finder .form-group { margin-bottom: 18px; }
.maths-finder .step-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: #374151;
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}
.maths-finder .section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.maths-finder .tab {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.maths-finder .tab:hover {
  border-color: #1a56db;
  color: #1a56db;
  background: #eff6ff;
}
.maths-finder .tab.active {
  background: #1a56db;
  border-color: #1a56db;
  color: #fff;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.30);
}
.maths-finder .tab-ut {
  border-color: #f59e0b;
  color: #92400e;
  background: #fffbeb;
}
.maths-finder .tab-ut:hover {
  background: #fef3c7;
  border-color: #d97706;
  color: #78350f;
}
.maths-finder .tab-ut.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}
.maths-finder .select-wrap { position: relative; }
.maths-finder .select-wrap::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  pointer-events: none;
  font-size: 0.9rem;
}
.maths-finder .btn-check {
  display: block;
  width: 100%;
  padding: 14px 20px;
  margin-top: 4px;
  background: #1a56db;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.maths-finder .btn-check:hover {
  background: #1648c0;
  box-shadow: 0 4px 16px rgba(26, 86, 219, 0.35);
}
.maths-finder .btn-check:active { transform: scale(0.98); background: #1340a8; }
.maths-finder .answer-panel {
  margin-top: 22px;
  border-top: 2px solid #e5e7eb;
  padding-top: 18px;
  animation: fadeIn 0.25s ease;
}
.maths-finder .answer-header {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a56db;
  margin-bottom: 14px;
}
.maths-finder #m-steps-container { margin-bottom: 16px; }
.maths-finder .part-block { margin-bottom: 18px; }
.maths-finder .part-block:last-child { margin-bottom: 0; }
.maths-finder .part-label {
  font-weight: 700;
  font-size: 0.875rem;
  color: #374151;
  margin-bottom: 6px;
}
.maths-finder .steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.maths-finder .steps-list li {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4px 8px;
  padding: 5px 0 5px 28px;
  font-size: 0.875rem;
  color: #374151;
  border-bottom: 1px solid #f3f4f6;
  line-height: 1.55;
}
.maths-finder .steps-list li:last-child { border-bottom: none; }
.maths-finder .steps-list li::before {
  content: attr(data-n);
  position: absolute;
  left: 0;
  top: 7px;
  width: 18px;
  height: 18px;
  background: #dbeafe;
  color: #1a56db;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.maths-finder .step-work {
  flex: 1 1 auto;
  font-family: inherit;
  white-space: pre-wrap;
}
.maths-finder .step-reason {
  flex: 0 1 auto;
  color: #6b7280;
  font-style: italic;
  font-size: 0.8rem;
  white-space: normal;
  word-break: break-word;
  padding-left: 10px;
  text-align: right;
}
.maths-finder .steps-list.single-step li { padding-left: 0; }
.maths-finder .steps-list.single-step li::before { display: none; }
.maths-finder .final-answer {
  background: #fef08a;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #713f12;
  line-height: 1.5;
  border: 1px solid #fde047;
}
.maths-finder .part-final-answer {
  background: #fef08a;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.875rem;
  font-weight: 700;
  color: #713f12;
  margin-top: 6px;
  border: 1px solid #fde047;
}
.maths-finder .mcq-answer {
  display: inline-block;
  background: #fef08a;
  border: 1px solid #fde047;
  color: #713f12;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 6px 18px;
  border-radius: 8px;
}
.maths-finder .frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 2px;
  font-size: 0.85em;
  line-height: 1.2;
}
.maths-finder .frac .num {
  border-bottom: 1.5px solid currentColor;
  padding: 0 3px 1px;
  text-align: center;
  white-space: nowrap;
}
.maths-finder .frac .den {
  padding: 1px 3px 0;
  text-align: center;
  white-space: nowrap;
}
.maths-finder .diagram-img-container {
  text-align: center;
  margin: 0.75rem 0 1rem;
}
.maths-finder .diagram-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}
.maths-loader {
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
  padding: 30px 0;
}
.maths-foot {
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: center;
  margin-top: 18px;
}

/* ---------- English Speaking — group possibility (scoped .speaking-finder) ---------- */
.speaking-finder { padding: 22px 22px 18px; }
.speaking-finder .form-group { margin-bottom: 18px; }
.speaking-finder .step-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: #374151;
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}
.speaking-finder .sp-hint { font-weight: 500; color: #9ca3af; font-size: 0.78rem; }
.speaking-finder .section-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.speaking-finder .tab {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.speaking-finder .tab:hover { border-color: #1a56db; color: #1a56db; background: #eff6ff; }
.speaking-finder .tab.active {
  background: #1a56db;
  border-color: #1a56db;
  color: #fff;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.30);
}
.speaking-finder .select-wrap { position: relative; }
.speaking-finder .select-wrap::after {
  content: "\25BE";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  pointer-events: none;
  font-size: 0.9rem;
}

/* class colour accents */
.sp-badge {
  display: inline-block;
  min-width: 38px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: #6b7280;
}
.sp-badge-S3A { background: #1a56db; }
.sp-badge-S3B { background: #0d9488; }
.sp-badge-S3C { background: #7c3aed; }

/* "you" card */
.sp-result { margin-top: 4px; }
.sp-you-card {
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: #f8fafc;
  border: 1.5px solid #e5e7eb;
  border-left-width: 5px;
}
.sp-you-card.sp-cls-S3A { border-left-color: #1a56db; }
.sp-you-card.sp-cls-S3B { border-left-color: #0d9488; }
.sp-you-card.sp-cls-S3C { border-left-color: #7c3aed; }
.sp-you-line { font-size: 1rem; font-weight: 800; color: #1f2937; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sp-you-time { font-size: 0.85rem; color: #6b7280; margin-top: 6px; }

/* slot summary */
.sp-summary {
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.sp-summary-row { font-size: 0.88rem; color: #1e3a8a; margin: 2px 0; }
.sp-summary-num { font-weight: 800; font-size: 1.05rem; }
.sp-summary-mix { color: #475569; font-size: 0.8rem; margin-top: 6px; }
.sp-summary-note {
  font-size: 0.82rem;
  color: #1e40af;
  background: #dbeafe;
  border-radius: 8px;
  padding: 7px 10px;
  margin: 8px 0 4px;
  font-weight: 600;
}
.sp-dur { font-weight: 700; color: #2563eb; white-space: nowrap; }

/* candidate list */
.sp-list-head { font-size: 0.85rem; font-weight: 700; color: #374151; margin-bottom: 4px; }
.sp-list-head span { font-weight: 500; color: #9ca3af; }
.sp-list-note { font-size: 0.76rem; color: #6b7280; margin-bottom: 10px; line-height: 1.45; }
.sp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #eef0f3;
  border-radius: 12px;
  background: #fff;
}
.sp-who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.sp-no { font-weight: 800; color: #1f2937; font-size: 0.9rem; }
.sp-name { color: #374151; font-size: 0.88rem; font-weight: 600; }
.sp-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.sp-tag-diff { background: #dcfce7; color: #166534; }
.sp-tag-same { background: #f1f5f9; color: #64748b; }
.sp-meter { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.sp-bar { width: 70px; height: 9px; border-radius: 999px; background: #eef0f3; overflow: hidden; }
.sp-bar-fill { display: block; height: 100%; border-radius: 999px; transition: width 0.25s ease; }
.sp-bar-fill.is-diff { background: linear-gradient(90deg, #34d399, #059669); }
.sp-bar-fill.is-same { background: linear-gradient(90deg, #cbd5e1, #94a3b8); }
.sp-pct {
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1;
  color: #059669;
  min-width: 58px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sp-pct.is-same { color: #64748b; }
.sp-pct-unit { font-size: 0.85rem; font-weight: 700; margin-left: 1px; }
.sp-empty { text-align: center; color: #6b7280; font-size: 0.9rem; padding: 18px 0; }
.sp-foot { margin-top: 16px; }

/* English Speaking disclaimer — multi-paragraph, left-aligned for reading */
.speaking-disclaimer-desc {
  white-space: normal;
  text-align: left;
}
.speaking-disclaimer-desc p { margin: 0 0 10px; }
.speaking-disclaimer-desc p:last-child { margin-bottom: 0; }

/* ---------- In-browser viewer modal ---------- */
.viewer-modal {
  padding: 16px;
  align-items: stretch;
}
.viewer-card {
  max-width: 920px;
  width: 100%;
  max-height: calc(100vh - 32px);
  margin: auto;
  display: flex;
  flex-direction: column;
}
.viewer-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: #1a56db;
}
.viewer-header-text {
  flex: 1;
  min-width: 0;
}
.viewer-title {
  color: #fff;
  font-weight: 800;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-meta {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-download {
  display: inline-block;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background 0.15s;
  flex-shrink: 0;
}
.viewer-download:hover { background: rgba(255, 255, 255, 0.30); }
.viewer-body {
  flex: 1;
  padding: 0;
  background: #f3f4f6;
  overflow: auto;
  min-height: 300px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.viewer-loading, .viewer-error {
  margin: auto;
  padding: 30px 24px;
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
}
.viewer-error { color: #b91c1c; max-width: 480px; }
.viewer-iframe {
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: 0;
  background: #fff;
}
.viewer-img {
  max-width: 100%;
  max-height: calc(100vh - 130px);
  margin: auto;
  display: block;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.10);
}
.viewer-text {
  width: 100%;
  padding: 18px 22px;
  background: #fff;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #111827;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
}
.viewer-iframe-quizlet {
  background: #fff;
}
.viewer-quizlet-fallback {
  width: 100%;
  padding: 10px 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  font-size: 0.82rem;
  color: #6b7280;
  text-align: center;
}
.viewer-quizlet-fallback a {
  color: #7c3aed;
  font-weight: 700;
  text-decoration: none;
  margin-left: 4px;
}
.viewer-quizlet-fallback a:hover { text-decoration: underline; }

/* Admin folder tree */
.folder-tree {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.folder-tree li {
  border-bottom: 1px solid #f3f4f6;
}
.folder-tree li:last-child { border-bottom: none; }
.folder-tree li.empty-state-small {
  padding: 24px;
}
.folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 6px;
  background: #fff;
  transition: background 0.12s;
}
.folder-row:hover { background: #f9fafb; }
.folder-row-icon {
  font-size: 1rem;
  flex-shrink: 0;
}
.folder-row-name {
  font-weight: 700;
  color: #111827;
  flex: 0 0 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-row-count {
  flex: 1;
  font-size: 0.78rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.folder-row-actions button {
  padding: 6px 10px;
  font-size: 0.76rem;
}
@media (max-width: 640px) {
  .folder-row { flex-wrap: wrap; }
  .folder-row-count { flex-basis: 100%; padding-left: 24px; }
}

/* ---------- Info modal (Timetable + Coverage) ---------- */
.info-modal {
  padding: 16px;
  align-items: stretch;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.info-modal.open { opacity: 1; }
.info-card {
  max-width: 760px;
  width: 100%;
  max-height: calc(100vh - 32px);
  margin: auto;
  display: flex;
  flex-direction: column;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.info-modal.open .info-card { transform: scale(1) translateY(0); }
.info-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  color: #fff;
}
.info-header-timetable { background: linear-gradient(135deg, #0ea5e9 0%, #0369a1 100%); }
.info-header-coverage  { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); }
.info-header-text { flex: 1; min-width: 0; }
.info-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.info-sub {
  font-size: 0.78rem;
  opacity: 0.88;
  margin-top: 3px;
}
.info-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 28px;
  background: linear-gradient(180deg, #f8fafc 0%, #f0f2f5 100%);
}

/* Timetable day cards */
.day-card {
  background: #fff;
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 14px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  animation: cardSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes cardSlideIn {
  to { opacity: 1; transform: translateY(0); }
}
.day-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
}
.day-card-date { line-height: 1.15; }
.day-card-date-main {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
}
.day-card-date-day {
  font-size: 0.72rem;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.day-card-status {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.status-today    { background: #fef3c7; color: #92400e; box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.6); animation: pulseToday 2s ease-in-out infinite; }
@keyframes pulseToday {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}
.status-tomorrow { background: #fee2e2; color: #b91c1c; }
.status-future   { background: #dbeafe; color: #1e40af; }
.status-past     { background: #f3f4f6; color: #9ca3af; }
.day-past { opacity: 0.6; }
.day-tsa .day-card-head { background: linear-gradient(90deg, #ede9fe 0%, #fafafa 60%); }

.paper-list { list-style: none; padding: 0; margin: 0; }
.paper-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.15s;
}
.paper-row:last-child { border-bottom: none; }
.paper-row-clickable { cursor: pointer; }
.paper-row-clickable:hover { background: #eff6ff; }
.paper-time {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1a56db;
  width: 96px;
  white-space: nowrap;
}
.paper-body { flex: 1; min-width: 0; }
.paper-subject {
  font-size: 0.92rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.35;
}
.paper-meta {
  font-size: 0.76rem;
  color: #6b7280;
  margin-top: 2px;
}
.paper-arrow {
  flex-shrink: 0;
  opacity: 0.5;
  font-size: 0.95rem;
  transition: opacity 0.15s, transform 0.15s;
}
.paper-row-clickable:hover .paper-arrow {
  opacity: 1;
  transform: translateX(2px);
}

/* Coverage subject cards (collapsible) */
.subj-card {
  background: #fff;
  border-radius: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 14px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  animation: cardSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.subj-card[open] {
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.18);
}
.subj-card-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  outline: none;
}
.subj-card-summary::-webkit-details-marker { display: none; }
.subj-card-summary:hover { background: #faf5ff; }
.subj-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  line-height: 1;
}
.subj-summary-text { flex: 1; min-width: 0; }
.subj-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.3;
}
.subj-classes {
  font-size: 0.74rem;
  color: #6b21a8;
  font-weight: 600;
  margin-top: 2px;
}
.subj-chevron {
  flex-shrink: 0;
  font-size: 0.9rem;
  color: #9ca3af;
  transition: transform 0.2s;
}
.subj-card[open] .subj-chevron { transform: rotate(180deg); color: #6d28d9; }
.subj-card-body {
  padding: 4px 16px 16px;
  border-top: 1px solid #f3f4f6;
  animation: fadeIn 0.2s ease;
}
.subj-section { margin-top: 12px; }
.subj-section:first-child { margin-top: 14px; }
.subj-section-head {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 6px;
}
.subj-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.subj-list li {
  position: relative;
  padding: 4px 0 4px 18px;
  font-size: 0.86rem;
  color: #374151;
  line-height: 1.5;
}
.subj-list li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: #8b5cf6;
  font-weight: 700;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .stats-dashboard { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
  #admin-search { width: 100%; }
  .admin-controls { flex-direction: column; align-items: stretch; }
  .admin-bar { flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .site-title { font-size: 1.35rem; }
  .countdown-unit .num { font-size: 1.6rem; }
  .countdown-unit { padding: 10px 2px 8px; }
  .timer-display { font-size: 3.2rem; }
  .form-row-2col { grid-template-columns: 1fr; gap: 0; }
  .form-row-2col > div { margin-bottom: 14px; }
  .settings-grid { grid-template-columns: 1fr; }
  .stat-tile-num { font-size: 1.5rem; }
  .stat-tile { padding: 12px 14px; }
  .admin-card-actions .btn-primary,
  .admin-card-actions .btn-secondary { padding: 7px 10px; font-size: 0.78rem; }
  .viewer-modal { padding: 0; }
  .viewer-card { max-height: 100vh; border-radius: 0; }
  .viewer-header { padding: 10px 12px; gap: 8px; }
  .viewer-download { padding: 6px 10px; font-size: 0.75rem; }
  .info-modal { padding: 0; }
  .info-card { max-height: 100vh; border-radius: 0; }
  .info-header { padding: 14px 16px; }
  .info-body { padding: 14px 12px 24px; }
  .paper-time { width: 76px; font-size: 0.76rem; }
  .paper-subject { font-size: 0.85rem; }
  .countdown-actions { gap: 8px; }
  .countdown-btn { padding: 8px 12px; font-size: 0.78rem; }
}

/* ---------- Mobile phone polish (≤480 px) ----------
   Tightens up chrome, padding, and grid layouts specifically for
   phone widths. Tablets (≥481 px portrait) are unaffected. */
@media (max-width: 480px) {
  body { padding: 16px 12px 32px; }

  /* Header */
  .site-header { padding: 16px 12px 20px; }
  .site-title { font-size: 1.15rem; }
  .site-tagline { font-size: 0.74rem; margin-top: 1px; }
  .admin-badge { top: 9px; right: 9px; padding: 4px 9px; font-size: 0.68rem; gap: 4px; }
  .admin-badge-icon { font-size: 0.8rem; }

  /* Wrapper + cards */
  .page-wrap { padding: 14px 12px 32px; }
  .card { padding: 16px 14px 18px; margin-bottom: 12px; }

  /* Countdown */
  .countdown-card { padding: 16px 12px 18px; }
  .countdown-label { font-size: 0.72rem; margin-bottom: 10px; }
  .countdown-grid { gap: 5px; }
  .countdown-unit { padding: 7px 2px 5px; border-radius: 9px; }
  .countdown-unit .num { font-size: 1.35rem; }
  .countdown-unit .lab { font-size: 0.6rem; margin-top: 2px; }
  .countdown-sub { font-size: 0.72rem; margin-top: 10px; }
  .countdown-actions { flex-direction: column; gap: 8px; margin-top: 12px; }
  .countdown-btn {
    width: 100%;
    justify-content: center;
    padding: 9px 14px;
    font-size: 0.82rem;
  }

  /* Top-level tabs (Notes / Maths / Timer) */
  .main-tabs { padding: 4px; gap: 4px; margin-bottom: 14px; }
  .main-tab { padding: 8px 8px; font-size: 0.8rem; }

  /* View-mode picker — already 1 col under 520; tighten further */
  .view-mode-tabs { gap: 8px; margin-bottom: 14px; }
  .view-mode-tab { padding: 14px 16px; gap: 12px; }
  .view-mode-tab-icon { font-size: 1.5rem; }
  .view-mode-tab-title { font-size: 0.95rem; }
  .view-mode-tab-sub { font-size: 0.72rem; }

  /* Upload toggle */
  .upload-toggle { padding: 12px 14px; gap: 8px; font-size: 0.88rem; }
  .upload-toggle-icon { width: 26px; height: 26px; font-size: 1.1rem; }
  .upload-collapse { padding: 4px 14px 18px; }

  /* Browse filters — stack vertically; selects fill width */
  .browse-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .browse-filters { flex-direction: column; gap: 6px; width: 100%; }
  .browse-filters select { width: 100%; padding: 9px 12px; }

  /* Note cards */
  .note-card { padding: 12px 14px; gap: 6px; border-radius: 10px; }
  .note-card-top { gap: 8px; }
  .note-title { font-size: 0.92rem; }
  .note-meta { font-size: 0.72rem; gap: 3px 8px; }
  .note-desc { font-size: 0.8rem; }
  .note-actions { gap: 6px; }
  .note-actions .btn-primary,
  .note-actions .btn-secondary,
  .gdocs-btn,
  .quizlet-btn {
    padding: 7px 11px;
    font-size: 0.78rem;
  }
  .note-actions .btn-fullscreen {
    width: 30px;
    height: 30px;
    padding: 5px;
  }

  /* Folder browser — always 1 col; tighter folder cards */
  .folder-children { grid-template-columns: 1fr; gap: 8px; }
  .folder-card { padding: 12px 12px 12px 10px; gap: 10px; }
  .folder-card-name { font-size: 0.9rem; }
  .folder-card-meta { font-size: 0.72rem; }
  .folder-breadcrumb { font-size: 0.78rem; gap: 4px; }
  .folder-subhead { margin: 14px 0 8px; font-size: 0.7rem; }

  /* Timer panels */
  .sub-tabs { gap: 4px; margin-bottom: 14px; }
  .sub-tab { padding: 7px 10px; font-size: 0.82rem; }
  .timer-phase-label { font-size: 0.78rem; }
  .timer-display { font-size: 2.8rem; margin: 4px 0 12px; }
  .timer-cycles { font-size: 0.78rem; margin-bottom: 14px; }
  .timer-controls { gap: 8px; margin-bottom: 12px; }
  .timer-controls .btn-primary,
  .timer-controls .btn-secondary {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
  .cd-input-row input { width: 60px; }

  /* Maths finder */
  .maths-finder { padding: 16px 14px 14px; }
  .maths-finder .section-tabs { gap: 6px; }
  .maths-finder .tab { padding: 7px 12px; font-size: 0.78rem; }
  .maths-finder .btn-check { padding: 12px 16px; font-size: 0.92rem; }

  /* English Speaking finder */
  .speaking-finder { padding: 16px 14px 14px; }
  .speaking-finder .section-tabs { gap: 6px; }
  .speaking-finder .tab { padding: 7px 12px; font-size: 0.78rem; }
  .sp-item { gap: 8px; padding: 9px 10px; }
  .sp-bar { width: 46px; }
  .sp-pct { font-size: 1.3rem; min-width: 46px; }
  .sp-name { width: 100%; order: 5; }

  /* Admin */
  .admin-wrap { padding: 14px 12px 32px; }
  .admin-card { padding: 12px 14px; border-radius: 12px; }
  .admin-card-title { font-size: 0.95rem; }
  .admin-card-meta { font-size: 0.74rem; }
  .admin-card-clicks { font-size: 0.72rem; }
  .admin-card-clicks .cstat { font-size: 0.7rem; padding: 1px 6px; }
  .stats-dashboard { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-tile { padding: 10px 12px; }
  .stat-tile-num { font-size: 1.35rem; }
  .stat-tile-label { font-size: 0.66rem; }
  .folder-row { padding: 9px 10px 9px 6px; gap: 6px; }
  .folder-row-name { font-size: 0.85rem; max-width: 100%; }
  .folder-row-actions { width: 100%; padding-left: 24px; }
  .folder-row-actions button { padding: 5px 9px; font-size: 0.72rem; }
}

/* ---------- Subjects & Types (admin taxonomy) ---------- */
.taxonomy-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.taxonomy-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.taxonomy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.taxonomy-h {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
}
.taxonomy-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.taxonomy-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.taxonomy-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.taxonomy-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}
.btn-danger-outline {
  color: #b91c1c;
  border-color: #fca5a5;
}
.btn-danger-outline:hover {
  border-color: #b91c1c;
  background: #fef2f2;
}
@media (max-width: 640px) {
  .taxonomy-row { grid-template-columns: 1fr; gap: 14px; }
  .taxonomy-row-item { flex-wrap: wrap; }
  .taxonomy-actions { width: 100%; justify-content: flex-end; }
}

/* ---------- Exam Coverage (admin) ---------- */
.coverage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.coverage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  min-width: 0;
}
.coverage-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}
.coverage-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.coverage-subject {
  font-weight: 700;
  font-size: 0.95rem;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coverage-classes {
  font-size: 0.78rem;
  color: #6b7280;
}
.coverage-row .btn-sm { flex-shrink: 0; }
@media (min-width: 760px) {
  .coverage-list { grid-template-columns: 1fr 1fr; }
}

/* ---------- Coverage inline editor (admin) ---------- */
.coverage-edit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cov-edit-card .subj-card-summary {
  flex-wrap: wrap;
  row-gap: 6px;
}
.cov-edit-card .subj-name,
.cov-edit-card .subj-classes,
.cov-edit-card .subj-icon,
.cov-edit-card .cov-li-text {
  outline: none;
}
.cov-edit-card [contenteditable="true"]:focus {
  background: #fff7ed;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #fdba74;
}
.cov-edit-card .cov-edit-icon {
  cursor: text;
  min-width: 1.6em;
  display: inline-flex;
  justify-content: center;
}
.cov-card-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
  margin-right: 8px;
  flex-shrink: 0;
}
.cov-card-actions button:disabled {
  opacity: 0.5;
  cursor: default;
}
.cov-edit-card .subj-list li {
  position: relative;
  padding-right: 28px;
}
.cov-li-x {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
}
.cov-li-x:hover {
  background: #fee2e2;
  color: #b91c1c;
}
.cov-add-line {
  margin-top: 8px;
  background: transparent;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: #6b7280;
  cursor: pointer;
}
.cov-add-line:hover {
  border-color: #6d28d9;
  color: #6d28d9;
}
.cov-x-hint {
  display: inline-block;
  width: 1.2em;
  text-align: center;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 4px;
  font-weight: 700;
}

/* ---------- Report a problem (hub) ---------- */
.report-card {
  max-width: 760px;
  margin: 22px auto 8px;
  padding: 0 14px;
}
.report-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px dashed #fcd34d;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: #78350f;
  transition: background 0.15s, border-color 0.15s;
}
.report-toggle:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}
.report-toggle-icon { font-size: 1.05rem; flex-shrink: 0; }
.report-toggle-text { font-weight: 700; font-size: 0.92rem; flex: 1; }
.report-toggle-hint { font-size: 0.74rem; color: #92400e; opacity: 0.85; }
.report-toggle[aria-expanded="true"] {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}
.report-collapse {
  border: 1px dashed #fcd34d;
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 14px;
  background: #fffdf7;
}
.report-privacy {
  font-size: 0.78rem;
  color: #6b7280;
  margin: 0 0 12px;
  line-height: 1.45;
}
#report-message {
  width: 100%;
  resize: vertical;
}
.report-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.report-status {
  font-size: 0.85rem;
  color: #6b7280;
  min-height: 1.2em;
}
.report-status.ok  { color: #047857; }
.report-status.err { color: #b91c1c; }
@media (max-width: 520px) {
  .report-toggle-hint { display: none; }
}

/* ---------- Reports (admin) ---------- */
.reports-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reports-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #4b5563;
  cursor: pointer;
  user-select: none;
}
.report-row {
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #f59e0b;
  border-radius: 10px;
}
.report-row.is-resolved {
  opacity: 0.6;
  border-left-color: #10b981;
}
.report-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.report-cat {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.rep-access   { background: #fee2e2; color: #991b1b; }
.rep-download { background: #ffedd5; color: #9a3412; }
.rep-view     { background: #e0e7ff; color: #3730a3; }
.rep-load     { background: #fef3c7; color: #92400e; }
.rep-other    { background: #e5e7eb; color: #374151; }
.report-when {
  font-size: 0.75rem;
  color: #6b7280;
}
.report-row-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 6px;
}
.report-msg {
  margin-top: 8px;
  font-size: 0.93rem;
  color: #111827;
  line-height: 1.45;
  word-break: break-word;
}
.report-empty { color: #9ca3af; }
.report-meta {
  margin-top: 8px;
  font-size: 0.74rem;
  color: #6b7280;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: baseline;
}
.report-meta-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: #9ca3af;
}
.report-meta code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.74rem;
  color: #374151;
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
  word-break: break-all;
}

/* ---------- Coverage editor: doc-like polish ---------- */
.cov-edit-card { position: relative; }
.cov-edit-card .cov-card-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  z-index: 2;
}
.cov-edit-card:hover .cov-card-delete,
.cov-edit-card:focus-within .cov-card-delete {
  opacity: 0.7;
}
.cov-edit-card .cov-card-delete:hover {
  opacity: 1;
  background: #fee2e2;
  color: #b91c1c;
}
.cov-edit-card .cov-add-line {
  opacity: 0;
  transition: opacity 0.15s;
}
.cov-edit-card:hover .cov-add-line,
.cov-edit-card:focus-within .cov-add-line,
.subj-section-empty .cov-add-line {
  opacity: 1;
}
/* No need to leave room for the deleted per-bullet × control. */
.cov-edit-card .subj-list li { padding-right: 0; }
/* Hide the (now unused) per-bullet remove button. */
.cov-edit-card .cov-li-x { display: none; }

/* Floating save-status pill */
.cov-save-indicator {
  position: fixed;
  right: 18px;
  bottom: 18px;
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.04);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 60;
}
.cov-save-indicator:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}
.cov-save-indicator.is-saving { color: #6b7280; }
.cov-save-indicator.is-saved  { color: #047857; }
.cov-save-indicator.is-error  { color: #b91c1c; }

/* Request card — same chrome as the upload toggle, purple/violet
   accent to distinguish it from admin actions. Shown to non-admins
   instead of the upload card. */
.request-card { padding: 0; overflow: hidden; }
.request-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: #6d28d9;
  font-size: 0.95rem;
  font-weight: 700;
  transition: background 0.15s;
}
.request-toggle:hover { background: #faf5ff; }
.request-toggle-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #8b5cf6;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}
.request-toggle-text { flex: 1; }
.request-toggle-hint {
  font-size: 0.75rem;
  font-weight: 500;
  color: #9ca3af;
  white-space: nowrap;
}
.request-modal-card { max-width: 520px; }

/* Admin requests list */
.requests-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.req-card {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.req-card.is-done { opacity: 0.6; border-style: dashed; }
.req-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.req-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
}
.req-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.req-status-pending { background: #fef3c7; color: #92400e; }
.req-status-done    { background: #dcfce7; color: #15803d; }
.req-meta {
  font-size: 0.78rem;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.req-desc {
  font-size: 0.85rem;
  color: #374151;
  margin-top: 2px;
  line-height: 1.5;
}
.req-link {
  font-size: 0.82rem;
  color: #1a56db;
  word-break: break-all;
}
.req-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.req-actions button,
.req-actions a {
  padding: 6px 12px;
  font-size: 0.78rem;
}
@media (max-width: 480px) {
  .request-toggle { padding: 12px 14px; }
  .request-toggle-hint { display: none; }
}

.req-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  margin-left: 8px;
  padding: 0 7px;
  background: #dc2626;
  color: #fff;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  vertical-align: 2px;
}
.req-count-badge:empty { display: none; }

/* Archived admin card — dimmed, dashed border, faint badge. */
.admin-card-archived {
  opacity: 0.55;
  border-style: dashed;
  background: #f9fafb;
}
.admin-card-archived .admin-card-title::after {
  content: 'ARCHIVED';
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  vertical-align: 2px;
}

/* Quizlet warning modal — re-uses .gdocs-modal / .gdocs-warn-card
   chrome from the Google Docs warning, with a blue Q logo
   surrounded by floating mini emoji icons that pop in with a
   small stagger when the modal opens. */
.quizlet-warn-icon {
  position: relative;
  background: linear-gradient(135deg, #dbeafe 0%, #ffffff 100%) !important;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.22) !important;
}
.qz-mini {
  position: absolute;
  font-size: 18px;
  opacity: 0;
  transform: translateY(8px) scale(0.5);
  animation: qzMiniIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
             qzMiniBob 2.4s ease-in-out 0.7s infinite;
}
.qz-mini-1 { top: -8px;   left: -6px;  animation-delay: 0.20s, 0.7s; }
.qz-mini-2 { top: -4px;   right: -8px; animation-delay: 0.30s, 0.9s; }
.qz-mini-3 { bottom: -8px; left: -4px; animation-delay: 0.40s, 1.1s; }
.qz-mini-4 { bottom: -2px; right: -8px; animation-delay: 0.50s, 1.3s; }
@keyframes qzMiniIn {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes qzMiniBob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50%      { transform: translateY(-3px) rotate(6deg); }
}

/* ---------- Note tags ----------
   Tiny pill chips shown below the description on every public and
   admin note card. */
.note-tags, .admin-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.note-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  letter-spacing: 0.01em;
}

/* ---------- Tag editor (in admin edit modal) ---------- */
.tag-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  padding: 6px 8px;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  align-items: center;
}
.tag-chips-empty {
  font-size: 0.82rem;
  color: #9ca3af;
  font-style: italic;
  padding: 0 4px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 10px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1f2937;
}
.tag-chip-remove {
  width: 18px;
  height: 18px;
  border: none;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 50%;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.tag-chip-remove:hover { background: #fee2e2; color: #b91c1c; }

.tag-input-row input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.85rem;
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-family: inherit;
}
.tag-input-row input:focus {
  border-color: #1a56db;
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-suggestion {
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tag-suggestion:hover { background: #dbeafe; border-color: #93c5fd; }

/* ---------- Live viewers banner (admin dashboard) ---------- */
.live-viewers-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 100%);
  border: 1px solid #a7f3d0;
  border-left: 4px solid #10b981;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.10);
  position: relative;
  overflow: hidden;
}
.live-viewers-card.live-viewers-empty {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-color: #e2e8f0;
  border-left-color: #94a3b8;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}
.live-viewers-pulse {
  position: relative;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.live-viewers-dot {
  position: absolute;
  inset: 0;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.live-viewers-ring {
  position: absolute;
  inset: -4px;
  border: 2px solid #10b981;
  border-radius: 50%;
  opacity: 0;
  animation: liveViewersRing 1.8s ease-out infinite;
}
.live-viewers-empty .live-viewers-dot {
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.16);
}
.live-viewers-empty .live-viewers-ring { animation: none; opacity: 0; }
@keyframes liveViewersRing {
  0%   { transform: scale(0.7); opacity: 0.55; }
  100% { transform: scale(1.9); opacity: 0; }
}
.live-viewers-text {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.live-viewers-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: #047857;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.live-viewers-empty .live-viewers-num { color: #64748b; }
.live-viewers-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #115e59;
}
.live-viewers-empty .live-viewers-label { color: #64748b; }
.live-viewers-meta {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  background: #10b981;
  padding: 4px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.live-viewers-empty .live-viewers-meta { background: #94a3b8; }
@media (max-width: 520px) {
  .live-viewers-card { padding: 12px 14px; gap: 10px; }
  .live-viewers-num  { font-size: 1.25rem; }
  .live-viewers-label { font-size: 0.82rem; }
}

/* ---------- In-depth engagement rows (shared by the Insights tab) ---------- */
.indepth-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.indepth-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.indepth-emoji {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
}
.indepth-text { flex: 1; min-width: 0; }
.indepth-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.indepth-live {
  font-size: 0.7rem;
  font-weight: 800;
  color: #047857;
  background: #d1fae5;
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}
.indepth-meta {
  font-size: 0.76rem;
  color: #64748b;
  margin-top: 2px;
}
.indepth-stats {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.indepth-stat {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.indepth-view    { background: #dbeafe; color: #1d4ed8; }
.indepth-dl      { background: #d1fae5; color: #047857; }
.indepth-gdocs   { background: #fef3c7; color: #b45309; }
.indepth-quizlet { background: #ede9fe; color: #6d28d9; }
@media (max-width: 520px) {
  .indepth-row { flex-wrap: wrap; }
  .indepth-stats { width: 100%; justify-content: flex-start; }
}

/* ---------- Admin tabs (Dashboard ⇄ Insights) ---------- */
.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 5px;
}
.admin-tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.admin-tab:hover { color: #0f172a; }
.admin-tab.is-active {
  background: #fff;
  color: #0d9488;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.10);
}

/* Insights panel — hidden until its tab is active. The people-online
   banner stays visible on both tabs; every other dashboard section is
   hidden while Insights is showing. */
.insights-panel { display: none; }
#admin-app.show-insights > section:not(.live-viewers-card):not(.insights-panel) { display: none; }
#admin-app.show-insights .insights-panel { display: block; }
.insights-intro { margin-bottom: 14px; }
.insights-block { margin-bottom: 16px; }
.insights-section-group { margin-bottom: 14px; }
.insights-section-group:last-child { margin-bottom: 0; }
.insights-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
  margin: 4px 0 8px;
}
.indepth-row-section { padding-left: 12px; }

/* ---------- Collapsible admin section ---------- */
.collapsible-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.collapsible-toggle:hover { color: #1a56db; }
.collapsible-chevron {
  display: inline-block;
  font-size: 0.85em;
  color: #6b7280;
  transition: transform 0.2s ease;
  transform-origin: 50% 55%;
}
.collapsible-card.is-collapsed .collapsible-chevron { transform: rotate(-90deg); }
.collapsible-card.is-collapsed .collapsible-body { display: none; }
.collapsible-card.is-collapsed .collapsible-head { margin-bottom: 0; }
.collapsible-card.is-collapsed { padding-bottom: 18px; }

/* ---------- Finished-exams collapsible (timetable modal) ---------- */
.finished-exams-group {
  border-radius: 14px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  margin-bottom: 14px;
  overflow: hidden;
}
.finished-exams-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-weight: 700;
  color: #475569;
  transition: background 0.15s;
}
.finished-exams-summary::-webkit-details-marker { display: none; }
.finished-exams-summary:hover { background: #e2e8f0; }
.finished-exams-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.06);
}
.finished-exams-label {
  flex: 1;
  font-size: 0.92rem;
  color: #334155;
}
.finished-exams-count {
  display: inline-block;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.finished-exams-chevron {
  font-size: 0.85rem;
  color: #94a3b8;
  transition: transform 0.2s ease;
}
.finished-exams-group[open] .finished-exams-chevron { transform: rotate(180deg); }
.finished-exams-body {
  padding: 6px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}
.finished-exams-body .day-card { opacity: 0.85; }
@media (max-width: 520px) {
  .finished-exams-summary { padding: 10px 12px; }
  .finished-exams-label { font-size: 0.85rem; }
}

/* ---------- Engagement analytics card (admin) ---------- */
.engagement-card {
  padding: 18px 20px;
  margin-bottom: 14px;
}
.engagement-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.engagement-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.engagement-total-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: #1a56db;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.engagement-total-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
}

.engagement-peaks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.engagement-peak {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 12px 14px;
}
.engagement-peak-visitors {
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
  border-color: #a7f3d0;
}
.engagement-peak-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1e40af;
  margin-bottom: 4px;
}
.engagement-peak-visitors .engagement-peak-label { color: #047857; }
.engagement-peak-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.engagement-peak-meta {
  font-size: 0.78rem;
  color: #475569;
  margin-top: 2px;
}

.engagement-section { margin-bottom: 16px; }
.engagement-section:last-child { margin-bottom: 0; }
.engagement-section-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 8px;
}

.engagement-hours {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
  background: #f8fafc;
  border-radius: 10px;
  padding: 8px 10px 4px;
  border: 1px solid #e2e8f0;
}
.engagement-hour-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  height: 100%;
  gap: 4px;
  cursor: default;
}
.engagement-hour-bar {
  width: 100%;
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: filter 0.15s;
}
.engagement-hour-col:hover .engagement-hour-bar { filter: brightness(1.15); }
.engagement-hour-col.is-peak .engagement-hour-bar {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
}
.engagement-hour-tick {
  font-size: 0.62rem;
  color: #94a3b8;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-height: 0.7rem;
}

.engagement-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.engagement-action {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-top-width: 3px;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.engagement-action-view     { border-top-color: #3b82f6; }
.engagement-action-download { border-top-color: #10b981; }
.engagement-action-gdocs    { border-top-color: #f59e0b; }
.engagement-action-quizlet  { border-top-color: #8b5cf6; }
.engagement-action-num {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.engagement-action-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}

.engagement-top-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.engagement-top-head .engagement-section-label { margin-bottom: 0; }
.engagement-top-tabs {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.engagement-top-tab {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.engagement-top-tab:hover { color: #1a56db; }
.engagement-top-tab.is-active {
  background: #fff;
  color: #1a56db;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.engagement-top {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.engagement-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.engagement-top-rank {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1a56db;
  color: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.engagement-top-row:nth-child(1) .engagement-top-rank { background: linear-gradient(135deg, #f59e0b, #d97706); }
.engagement-top-row:nth-child(2) .engagement-top-rank { background: linear-gradient(135deg, #64748b, #475569); }
.engagement-top-row:nth-child(3) .engagement-top-rank { background: linear-gradient(135deg, #b45309, #92400e); }
.engagement-top-text {
  flex: 1;
  min-width: 0;
}
.engagement-top-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.engagement-top-meta {
  font-size: 0.76rem;
  color: #64748b;
}
.engagement-top-count {
  font-size: 1rem;
  font-weight: 800;
  color: #1a56db;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .engagement-actions { grid-template-columns: repeat(2, 1fr); }
  .engagement-peaks   { grid-template-columns: 1fr; }
  .engagement-hours   { height: 64px; }
  .engagement-hour-tick { font-size: 0.55rem; }
}
