/* ================================================================
   Teacher Reveal Module — Premium Nordic Glass UI
   ================================================================
   Floating control panel for real-time exam answer reveal.
   Glass morphism + warm Nordic depth + satisfying reveal states.
   ================================================================ */

/* ── Login button (top-right, pill shape) ── */
.tr-login-btn {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 9999;
  padding: 8px 18px;
  border: 1px solid rgba(120, 113, 108, 0.2);
  border-radius: 9999px;
  background: rgba(255, 253, 250, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font: 500 12px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  color: #44403C;
  cursor: pointer;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, opacity 0.3s ease;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.08);
}
.tr-login-btn:hover,
.tr-login-btn:focus {
  opacity: 1;
  transform: translateY(-1px);
  background: rgba(255, 253, 250, 0.95);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.12);
  outline: none;
}
.tr-login-btn:active {
  transform: translateY(0) scale(0.97);
}
[data-theme="dark"] .tr-login-btn,
html.dark .tr-login-btn {
  background: rgba(41, 37, 36, 0.85);
  color: #E7E5E4;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .tr-login-btn:hover,
html.dark .tr-login-btn:hover {
  background: rgba(41, 37, 36, 0.95);
}

/* ── Login button inside nav bar (Dual Scope pages) ── */
.tr-login-btn--nav {
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  padding: 6px 14px;
  font-size: 11px;
  opacity: 0.4;
}
.tr-login-btn--nav:hover,
.tr-login-btn--nav:focus {
  opacity: 1;
  transform: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ── Locked state (student answer buttons disabled) ── */
.tr-locked {
  pointer-events: none !important;
  opacity: 0.3 !important;
  filter: grayscale(0.6) !important;
  cursor: not-allowed !important;
  position: relative;
}

/* ── Hidden answers (display: none until teacher reveals) ── */
.tr-answer-hidden {
  display: none !important;
}


/* ================================================================
   CONTROL PANEL — Glass Morphism Container
   ================================================================ */
.tr-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  width: 420px;
  min-width: 300px;
  max-width: 600px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;

  /* Glass morphism — single backdrop-filter, safe */
  background: rgba(255, 253, 250, 0.78);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);

  border-radius: 16px;
  border: 1px solid rgba(168, 162, 158, 0.25);
  box-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.03),
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 8px 24px rgba(0, 0, 0, 0.1),
    0 24px 48px rgba(0, 0, 0, 0.06);

  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 13px;
  color: #1C1917;

  /* Panel entrance */
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}
[data-theme="dark"] .tr-panel,
html.dark .tr-panel {
  background: rgba(28, 25, 23, 0.82);
  color: #F5F5F4;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.04),
    0 2px 4px rgba(0, 0, 0, 0.15),
    0 8px 24px rgba(0, 0, 0, 0.35),
    0 24px 48px rgba(0, 0, 0, 0.2);
}


/* ── Panel Header — Strong presence with accent line ── */
.tr-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  position: relative;
  flex-shrink: 0;
}
/* Accent gradient underline for header */
.tr-panel-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 1.5px;
  background: linear-gradient(90deg,
    #0D9488 0%,
    rgba(13, 148, 136, 0.3) 60%,
    transparent 100%);
  border-radius: 1px;
}
[data-theme="dark"] .tr-panel-header::after,
html.dark .tr-panel-header::after {
  background: linear-gradient(90deg,
    #14B8A6 0%,
    rgba(20, 184, 166, 0.3) 60%,
    transparent 100%);
}

/* Header title text */
.tr-panel-header > span:first-child {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0D9488;
}
[data-theme="dark"] .tr-panel-header > span:first-child,
html.dark .tr-panel-header > span:first-child {
  color: #14B8A6;
}

/* Close button */
.tr-panel-close {
  width: 26px;
  height: 26px;
  border: none;
  background: rgba(120, 113, 108, 0.08);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #78716C;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.tr-panel-close:hover {
  background: rgba(120, 113, 108, 0.15);
  color: #44403C;
  transform: scale(1.05);
}
.tr-panel-close:active {
  transform: scale(0.92);
}
[data-theme="dark"] .tr-panel-close,
html.dark .tr-panel-close {
  background: rgba(255, 255, 255, 0.06);
  color: #A8A29E;
}
[data-theme="dark"] .tr-panel-close:hover,
html.dark .tr-panel-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #E7E5E4;
}


/* ── Panel Body — Scrollable content area ── */
.tr-panel-body {
  padding: 12px 14px 14px;
  overflow-y: auto;
  flex: 1;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 113, 108, 0.2) transparent;
}
.tr-panel-body::-webkit-scrollbar {
  width: 4px;
}
.tr-panel-body::-webkit-scrollbar-track {
  background: transparent;
}
.tr-panel-body::-webkit-scrollbar-thumb {
  background: rgba(120, 113, 108, 0.2);
  border-radius: 4px;
}
.tr-panel-body::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 113, 108, 0.35);
}


/* ── Panel Section Dividers ── */
.tr-panel-section {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(168, 162, 158, 0.12);
}
[data-theme="dark"] .tr-panel-section,
html.dark .tr-panel-section {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
.tr-panel-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.tr-panel-logout {
  border-top: 1px solid rgba(168, 162, 158, 0.15);
  margin-top: 8px;
  padding-top: 8px;
}
[data-theme="dark"] .tr-panel-logout,
html.dark .tr-panel-logout {
  border-top-color: rgba(255, 255, 255, 0.08);
}

/* ── Labels & Info ── */
.tr-panel-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #A8A29E;
  margin-bottom: 8px;
}

.tr-panel-info {
  font-size: 12px;
  color: #78716C;
  margin-bottom: 8px;
  line-height: 1.5;
}
[data-theme="dark"] .tr-panel-info,
html.dark .tr-panel-info {
  color: #A8A29E;
}


/* ================================================================
   SECTION GROUPS — Badge-style section titles
   ================================================================ */
.tr-section-group {
  margin-bottom: 10px;
}

/* Section header row — title + ALL inline */
.tr-section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

/* Section title — badge/tab treatment */
.tr-section-title {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #57534E;
  padding: 3px 10px 3px 8px;
  background: rgba(120, 113, 108, 0.08);
  border-radius: 6px;
  line-height: 1.5;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="dark"] .tr-section-title,
html.dark .tr-section-title {
  color: #D6D3D1;
  background: rgba(255, 255, 255, 0.06);
}


/* ── Resize handle (left edge) ── */
.tr-resize-handle {
  position: absolute;
  left: -3px;
  top: 40px;
  bottom: 40px;
  width: 6px;
  cursor: ew-resize;
  border-radius: 3px;
  background: transparent;
  transition: background-color 0.15s ease;
  z-index: 1;
}
.tr-resize-handle:hover {
  background: rgba(13, 148, 136, 0.35);
}
[data-theme="dark"] .tr-resize-handle:hover,
html.dark .tr-resize-handle:hover {
  background: rgba(20, 184, 166, 0.35);
}

/* ── Question Container (collapsible section content) ── */
.tr-q-container {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}
.tr-q-container.collapsed {
  max-height: 0;
  opacity: 0;
}

/* ── Section collapse toggle ── */
.tr-section-toggle {
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  font-size: 9px;
  cursor: pointer;
  color: #A8A29E;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, color 0.15s ease;
  padding: 0;
}
.tr-section-toggle:hover { color: #57534E; }
.tr-section-toggle.collapsed { transform: rotate(-90deg); }
[data-theme="dark"] .tr-section-toggle { color: #78716C; }
[data-theme="dark"] .tr-section-toggle:hover,
html.dark .tr-section-toggle:hover { color: #D6D3D1; }

/* ── Question Row — inline layout ── */
.tr-q-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(168, 162, 158, 0.08);
}
.tr-q-row:last-of-type {
  border-bottom: none;
}
[data-theme="dark"] .tr-q-row,
html.dark .tr-q-row {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

/* ── Q button in row context — compact inline ── */
.tr-q-row .tr-btn-q {
  aspect-ratio: auto;
  width: 38px;
  height: 26px;
  padding: 0;
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  flex-shrink: 0;
}

/* ── Question preview text ── */
.tr-q-preview {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: #78716C;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}
[data-theme="dark"] .tr-q-preview,
html.dark .tr-q-preview {
  color: #A8A29E;
}

/* ── Answer distribution toggle chevron ── */
.tr-answer-toggle {
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  font-size: 8px;
  cursor: pointer;
  color: #A8A29E;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, color 0.15s ease;
  padding: 0;
}
.tr-answer-toggle:hover { color: #57534E; }
.tr-answer-toggle.open { transform: rotate(180deg); color: #0D9488; }
[data-theme="dark"] .tr-answer-toggle { color: #78716C; }
[data-theme="dark"] .tr-answer-toggle:hover,
html.dark .tr-answer-toggle:hover { color: #D6D3D1; }
[data-theme="dark"] .tr-answer-toggle.open,
html.dark .tr-answer-toggle.open { color: #14B8A6; }

/* ── Collapsible student response area ── */
.tr-q-answers {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease;
  padding: 0 4px;
}
.tr-q-answers.open {
  max-height: 200px;
  padding: 4px 4px 8px;
}

/* ── Legacy Q grid (kept for non-dualscope patterns) ── */
.tr-q-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}


/* ================================================================
   BUTTONS — Base, Question, Section, Primary, Danger
   ================================================================ */

/* Base button reset */
.tr-btn {
  padding: 6px 12px;
  border: 1px solid rgba(168, 162, 158, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  font: 500 12px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  color: #44403C;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.tr-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(168, 162, 158, 0.35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}
.tr-btn:active {
  transform: scale(0.95);
  box-shadow: none;
}
[data-theme="dark"] .tr-btn,
html.dark .tr-btn {
  background: rgba(255, 255, 255, 0.06);
  color: #E7E5E4;
  border-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .tr-btn:hover,
html.dark .tr-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}


/* ── Question Buttons (Q1, Q2, Q3...) ── */
.tr-btn-q {
  aspect-ratio: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  letter-spacing: -0.01em;
  width: 100%;
}

/* Revealed state — satisfying teal with glow */
.tr-btn-q.revealed {
  background: linear-gradient(135deg, #0D9488, #0F766E);
  color: #fff;
  border-color: transparent;
  box-shadow:
    0 1px 3px rgba(13, 148, 136, 0.25),
    0 0 12px rgba(13, 148, 136, 0.15);
  transform: translateY(0);
}
.tr-btn-q.revealed:hover {
  background: linear-gradient(135deg, #14B8A6, #0D9488);
  box-shadow:
    0 2px 6px rgba(13, 148, 136, 0.3),
    0 0 16px rgba(13, 148, 136, 0.2);
  transform: translateY(-1px);
}
[data-theme="dark"] .tr-btn-q.revealed,
html.dark .tr-btn-q.revealed {
  background: linear-gradient(135deg, #14B8A6, #0D9488);
  box-shadow:
    0 1px 3px rgba(20, 184, 166, 0.3),
    0 0 16px rgba(20, 184, 166, 0.15);
}
[data-theme="dark"] .tr-btn-q.revealed:hover,
html.dark .tr-btn-q.revealed:hover {
  background: linear-gradient(135deg, #2DD4BF, #14B8A6);
  box-shadow:
    0 2px 6px rgba(20, 184, 166, 0.35),
    0 0 20px rgba(20, 184, 166, 0.2);
}

/* Reset Responses button */
.tr-btn-reset {
  width: 100%;
  margin-top: 6px;
  padding: 7px 0;
  background: none;
  border: 1px dashed rgba(168, 162, 158, 0.3);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #78716C;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tr-btn-reset:hover {
  border-color: #F59E0B;
  color: #D97706;
  background: rgba(245, 158, 11, 0.06);
}
[data-theme="dark"] .tr-btn-reset,
html.dark .tr-btn-reset {
  border-color: rgba(255, 255, 255, 0.1);
  color: #A8A29E;
}
[data-theme="dark"] .tr-btn-reset:hover,
html.dark .tr-btn-reset:hover {
  border-color: #F59E0B;
  color: #FBBF24;
  background: rgba(245, 158, 11, 0.08);
}

/* Logout button (bottom of panel) */
.tr-btn-logout {
  width: 100%;
  padding: 6px 0;
  background: none;
  border: 1px solid rgba(168, 162, 158, 0.2);
  border-radius: 8px;
  font-size: 11px;
  color: #78716C;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tr-btn-logout:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #DC2626;
  border-color: rgba(239, 68, 68, 0.3);
}
[data-theme="dark"] .tr-btn-logout,
html.dark .tr-btn-logout {
  border-color: rgba(255, 255, 255, 0.08);
  color: #A8A29E;
}
[data-theme="dark"] .tr-btn-logout:hover,
html.dark .tr-btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.3);
}


/* ── Section "All" Button ── */
.tr-btn-section {
  font-size: 10px;
  font-weight: 700;
  padding: 5px 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 8px;
}

/* Section "All" revealed state */
.tr-btn-section.revealed {
  background: linear-gradient(135deg, #0D9488, #0F766E);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(13, 148, 136, 0.2);
}
.tr-btn-section.revealed:hover {
  background: linear-gradient(135deg, #14B8A6, #0D9488);
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.3);
}
[data-theme="dark"] .tr-btn-section.revealed,
html.dark .tr-btn-section.revealed {
  background: linear-gradient(135deg, #14B8A6, #0D9488);
}


/* ── Primary (Start Session) — Teal gradient CTA ── */
.tr-btn-primary {
  background: linear-gradient(135deg, #0D9488, #0F766E);
  color: #fff;
  border: none;
  width: 100%;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(13, 148, 136, 0.2),
    0 4px 12px rgba(13, 148, 136, 0.15);
}
.tr-btn-primary:hover {
  background: linear-gradient(135deg, #14B8A6, #0D9488);
  box-shadow:
    0 2px 4px rgba(13, 148, 136, 0.25),
    0 8px 20px rgba(13, 148, 136, 0.2);
  transform: translateY(-1px);
}
.tr-btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(13, 148, 136, 0.2);
}
[data-theme="dark"] .tr-btn-primary,
html.dark .tr-btn-primary {
  background: linear-gradient(135deg, #14B8A6, #0D9488);
  box-shadow:
    0 1px 2px rgba(20, 184, 166, 0.25),
    0 4px 12px rgba(20, 184, 166, 0.15);
}
[data-theme="dark"] .tr-btn-primary:hover,
html.dark .tr-btn-primary:hover {
  background: linear-gradient(135deg, #2DD4BF, #14B8A6);
}


/* ── Danger (End Session / Reveal All) — Warm rust-red ── */
.tr-btn-danger {
  background: linear-gradient(135deg, #B45309, #A3440C);
  color: #fff;
  border: none;
  width: 100%;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(180, 83, 9, 0.2),
    0 4px 12px rgba(180, 83, 9, 0.12);
}
.tr-btn-danger:hover {
  background: linear-gradient(135deg, #D97706, #B45309);
  box-shadow:
    0 2px 4px rgba(180, 83, 9, 0.25),
    0 8px 20px rgba(180, 83, 9, 0.18);
  transform: translateY(-1px);
}
.tr-btn-danger:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(180, 83, 9, 0.2);
}
[data-theme="dark"] .tr-btn-danger,
html.dark .tr-btn-danger {
  background: linear-gradient(135deg, #D97706, #B45309);
  box-shadow:
    0 1px 2px rgba(217, 119, 6, 0.25),
    0 4px 12px rgba(217, 119, 6, 0.15);
}
[data-theme="dark"] .tr-btn-danger:hover,
html.dark .tr-btn-danger:hover {
  background: linear-gradient(135deg, #F59E0B, #D97706);
}


/* ================================================================
   REVEAL ANIMATION — Smooth entrance for answers
   ================================================================ */
@keyframes trReveal {
  from {
    opacity: 0;
    transform: translateY(-6px);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}
.tr-revealing {
  animation: trReveal 0.35s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}


/* ================================================================
   TOAST — Bottom-center notification
   ================================================================ */
.tr-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 10001;
  padding: 10px 22px;
  background: rgba(28, 25, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #F5F5F4;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  font: 500 13px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 8px 32px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}
.tr-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
[data-theme="dark"] .tr-toast,
html.dark .tr-toast {
  background: rgba(41, 37, 36, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
}


/* ================================================================
   SESSION BADGE — Student-facing "class mode" indicator
   ================================================================ */
.tr-session-badge {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 9999;
  padding: 7px 14px;
  background: linear-gradient(135deg, #0D9488, #0F766E);
  color: #fff;
  border-radius: 9999px;
  font: 700 11px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  letter-spacing: 0.03em;
  box-shadow:
    0 1px 3px rgba(13, 148, 136, 0.3),
    0 4px 16px rgba(13, 148, 136, 0.2);
  animation: trBadgePulse 2.5s ease-in-out infinite;
}
@keyframes trBadgePulse {
  0%, 100% {
    box-shadow:
      0 1px 3px rgba(13, 148, 136, 0.3),
      0 4px 16px rgba(13, 148, 136, 0.2);
  }
  50% {
    box-shadow:
      0 1px 3px rgba(13, 148, 136, 0.4),
      0 4px 24px rgba(13, 148, 136, 0.35);
  }
}
[data-theme="dark"] .tr-session-badge,
html.dark .tr-session-badge {
  background: linear-gradient(135deg, #14B8A6, #0D9488);
  box-shadow:
    0 1px 3px rgba(20, 184, 166, 0.35),
    0 4px 16px rgba(20, 184, 166, 0.2);
}


/* ================================================================
   RESPONSIVE — Mobile (< 600px)
   ================================================================ */
@media (max-width: 600px) {
  .tr-panel {
    width: calc(100% - 24px) !important;
    min-width: unset;
    max-width: unset;
    right: 12px;
    bottom: 12px;
    max-height: 55vh;
    border-radius: 14px;
  }

  .tr-resize-handle {
    display: none;
  }

  .tr-panel-header {
    padding: 12px 14px 10px;
  }

  .tr-panel-body {
    padding: 10px 12px 12px;
  }

  .tr-btn-q {
    font-size: 10px;
    border-radius: 8px;
  }

  .tr-q-grid {
    gap: 3px;
  }

  .tr-q-row .tr-btn-q {
    width: 34px;
    height: 24px;
    font-size: 9px;
  }

  .tr-q-preview {
    font-size: 10px;
  }

  .tr-btn-primary,
  .tr-btn-danger {
    padding: 10px 14px;
    font-size: 12px;
  }

  .tr-toast {
    bottom: 72px;
    font-size: 12px;
    padding: 9px 18px;
    max-width: calc(100% - 48px);
    white-space: normal;
    text-align: center;
  }
}


/* ================================================================
   COLLAPSE BUTTON — In panel header, beside close button
   ================================================================ */
.tr-panel-collapse-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: rgba(120, 113, 108, 0.08);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #78716C;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  margin-right: 4px;
}
.tr-panel-collapse-btn:hover {
  background: rgba(120, 113, 108, 0.15);
  color: #44403C;
  transform: scale(1.05);
}
.tr-panel-collapse-btn:active {
  transform: scale(0.92);
}
[data-theme="dark"] .tr-panel-collapse-btn,
html.dark .tr-panel-collapse-btn {
  background: rgba(255, 255, 255, 0.06);
  color: #A8A29E;
}
[data-theme="dark"] .tr-panel-collapse-btn:hover,
html.dark .tr-panel-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #E7E5E4;
}


/* ================================================================
   COLLAPSED TAB — Small floating button when panel is collapsed
   ================================================================ */
.tr-collapsed-tab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(168, 162, 158, 0.25);
  border-radius: 12px;
  background: rgba(255, 253, 250, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #0D9488;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tr-collapsed-tab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.1),
    0 12px 32px rgba(0, 0, 0, 0.14);
}
.tr-collapsed-tab:active {
  transform: scale(0.95);
}
[data-theme="dark"] .tr-collapsed-tab,
html.dark .tr-collapsed-tab {
  background: rgba(28, 25, 23, 0.88);
  color: #14B8A6;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.25),
    0 8px 24px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .tr-collapsed-tab:hover,
html.dark .tr-collapsed-tab:hover {
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.3),
    0 12px 32px rgba(0, 0, 0, 0.4);
}

@media (max-width: 600px) {
  .tr-collapsed-tab {
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }
}


/* ================================================================
   REDUCED MOTION — Respect user preference
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  .tr-panel,
  .tr-btn,
  .tr-btn-q,
  .tr-btn-section,
  .tr-btn-primary,
  .tr-btn-danger,
  .tr-panel-close,
  .tr-panel-collapse-btn,
  .tr-collapsed-tab,
  .tr-login-btn,
  .tr-toast,
  .tr-q-container,
  .tr-section-toggle,
  .tr-answer-toggle,
  .tr-q-answers,
  .tr-resize-handle,
  .tr-btn-reset,
  .tr-btn-logout {
    transition-duration: 0.01ms !important;
  }

  .tr-revealing {
    animation-duration: 0.01ms !important;
  }

  .tr-session-badge {
    animation: none;
  }
}


/* ══════════════════════════════════════════════════════════
   Teacher Analytics
   ══════════════════════════════════════════════════════════ */

.tr-analytics-section .tr-section-title {
  font: 700 12px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  color: var(--text-muted, #A8A29E);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.tr-item-analysis {
  margin-bottom: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.tr-analysis-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font: 500 12px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  border-bottom: 1px solid rgba(168, 162, 158, 0.08);
}
.tr-analysis-row:last-child {
  border-bottom: none;
}

.tr-analysis-label {
  font-weight: 700;
  color: var(--text, #1C1917);
  width: 50px;
  flex-shrink: 0;
}

.tr-analysis-difficulty {
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 11px;
}
.tr-analysis-difficulty.easy {
  background: rgba(22, 163, 74, 0.1);
  color: #16A34A;
}
.tr-analysis-difficulty.medium {
  background: rgba(234, 179, 8, 0.1);
  color: #CA8A04;
}
.tr-analysis-difficulty.hard {
  background: rgba(220, 38, 38, 0.08);
  color: #DC2626;
}

.tr-analysis-distractor {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted, #A8A29E);
  background: rgba(120, 113, 108, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

.tr-btn-export {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(13, 148, 136, 0.3);
  border-radius: 8px;
  background: rgba(13, 148, 136, 0.06);
  color: #0D9488;
  font: 600 12px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.tr-btn-export:hover {
  background: rgba(13, 148, 136, 0.12);
  transform: translateY(-1px);
}

.tr-btn-secondary {
  width: 100%;
  padding: 6px 12px;
  border: 1px solid rgba(120, 113, 108, 0.15);
  border-radius: 8px;
  background: rgba(120, 113, 108, 0.04);
  color: var(--text-muted, #78716C);
  font: 500 11px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tr-btn-secondary:hover {
  background: rgba(120, 113, 108, 0.08);
}

/* Dark mode for analytics */
[data-theme="dark"] .tr-analysis-label,
html.dark .tr-analysis-label {
  color: var(--text, #F5F3F0);
}
[data-theme="dark"] .tr-analysis-difficulty.easy,
html.dark .tr-analysis-difficulty.easy {
  background: rgba(34, 197, 94, 0.12);
  color: #22C55E;
}
[data-theme="dark"] .tr-analysis-difficulty.medium,
html.dark .tr-analysis-difficulty.medium {
  background: rgba(250, 204, 21, 0.1);
  color: #FACC15;
}
[data-theme="dark"] .tr-analysis-difficulty.hard,
html.dark .tr-analysis-difficulty.hard {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}
[data-theme="dark"] .tr-btn-export,
html.dark .tr-btn-export {
  border-color: rgba(20, 184, 166, 0.3);
  background: rgba(20, 184, 166, 0.08);
  color: #14B8A6;
}
[data-theme="dark"] .tr-btn-export:hover,
html.dark .tr-btn-export:hover {
  background: rgba(20, 184, 166, 0.15);
}

/* ── Presence counter ── */
.tr-presence {
  padding: 6px 12px;
  margin-top: 4px;
  font: 500 13px -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  color: #64748B;
  text-align: center;
  border-radius: 6px;
  background: rgba(100, 116, 139, 0.06);
}
[data-theme="dark"] .tr-presence,
html.dark .tr-presence {
  color: #94A3B8;
  background: rgba(148, 163, 184, 0.08);
}
