/* ============================================
   Geo-AI Studio - Design System
   Dark Mode + Glassmorphism + Premium Feel
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Variables ── */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-accent: linear-gradient(135deg, #06b6d4, #3b82f6);
  --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Subject Tabs ── */
.subject-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.subject-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 28px;
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-normal);
  min-width: 140px;
  color: var(--text-secondary);
}

.subject-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.subject-btn.active[data-subject="math"] {
  border-color: var(--accent-blue);
  background: rgba(59,130,246,0.1);
  box-shadow: 0 0 20px rgba(59,130,246,0.15);
  color: var(--text-primary);
}

.subject-btn.active[data-subject="physics"] {
  border-color: var(--accent-orange);
  background: rgba(245,158,11,0.1);
  box-shadow: 0 0 20px rgba(245,158,11,0.15);
  color: var(--text-primary);
}

.subject-btn.active[data-subject="chemistry"] {
  border-color: var(--accent-green);
  background: rgba(16,185,129,0.1);
  box-shadow: 0 0 20px rgba(16,185,129,0.15);
  color: var(--text-primary);
}

.subject-btn.active[data-subject="lab"] {
  border-color: var(--accent-purple);
  background: rgba(139,92,246,0.1);
  box-shadow: 0 0 20px rgba(139,92,246,0.15);
  color: var(--text-primary);
}

.subject-icon { font-size: 1.8rem; transition: transform 0.3s ease; display: inline-block; }
.subject-name { font-weight: 700; font-size: 0.95rem; }
.subject-desc { font-size: 0.72rem; color: var(--text-muted); }
.subject-btn.active .subject-desc { color: var(--text-secondary); }

/* 🔺 Toán học: Xoay 3D */
.subject-btn[data-subject="math"]:hover .subject-icon {
  animation: iconSpin3D 0.8s ease infinite;
}
@keyframes iconSpin3D {
  0% { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.2); }
  100% { transform: rotateY(360deg) scale(1); }
}

/* ⚡ Vật lý: Nhấp nháy sét */
.subject-btn[data-subject="physics"]:hover .subject-icon {
  animation: iconFlash 0.5s ease infinite;
}
@keyframes iconFlash {
  0%, 100% { transform: scale(1); opacity: 1; }
  25% { transform: scale(1.4) translateY(-3px); opacity: 0.6; }
  50% { transform: scale(0.9); opacity: 1; }
  75% { transform: scale(1.3) translateY(-2px); opacity: 0.7; }
}

/* 🧪 Hóa học: Lắc ống nghiệm */
.subject-btn[data-subject="chemistry"]:hover .subject-icon {
  animation: iconShake 0.4s ease infinite;
}
@keyframes iconShake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(15deg); }
  40% { transform: rotate(-15deg); }
  60% { transform: rotate(10deg); }
  80% { transform: rotate(-10deg); }
}

/* 🔬 Phòng TN: Phóng to kính hiển vi */
.subject-btn[data-subject="lab"]:hover .subject-icon {
  animation: iconZoom 0.6s ease infinite;
}
@keyframes iconZoom {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.35) rotate(-5deg); }
}

.subject-section { animation: fadeInUp 0.4s ease; }

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

/* ── Physics Timeline ── */
.physics-timeline {
  background: var(--bg-glass);
  border-top: 1px solid var(--border-glass);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.physics-timeline input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
  outline: none;
}

.physics-timeline input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-orange);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(245,158,11,0.4);
}

@media (max-width: 768px) {
  .subject-tabs { flex-direction: column; gap: 8px; }
  .subject-btn { flex-direction: row; gap: 10px; min-width: auto; padding: 10px 16px; }
  .subject-icon { font-size: 1.4rem; }
}

/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── Background animation ── */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Header ── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  background: rgba(139, 92, 246, 0.2);
  color: var(--accent-purple);
  border-radius: 20px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition-fast);
  cursor: pointer;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.nav-links a.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

/* ── Main Layout ── */
.main-content {
  margin-top: 64px;
  position: relative;
  z-index: 1;
}

/* ── Hero Section ── */
.hero {
  padding: 3rem 2rem 2rem;
  text-align: center;
  position: relative;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero h1 span {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ── Tabs ── */
.tabs-container {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 0 2rem;
  margin-bottom: 2rem;
}

.tab-btn {
  padding: 10px 24px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.tab-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

.tab-btn .tab-icon {
  font-size: 1.1rem;
}

/* ── Content Panels ── */
.tab-panel {
  display: none;
  padding: 0 2rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease;
}

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

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

/* ── Cards ── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: var(--transition-normal);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1rem;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.card-icon.blue { background: rgba(59, 130, 246, 0.15); }
.card-icon.purple { background: rgba(139, 92, 246, 0.15); }
.card-icon.cyan { background: rgba(6, 182, 212, 0.15); }
.card-icon.green { background: rgba(16, 185, 129, 0.15); }
.card-icon.orange { background: rgba(245, 158, 11, 0.15); }
.card-icon.pink { background: rgba(236, 72, 153, 0.15); }

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ── Examples Grid ── */
.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.examples-grid::-webkit-scrollbar {
  width: 6px;
}
.examples-grid::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}
.examples-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.examples-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.example-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.example-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: var(--transition-fast);
}

.example-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.example-card:hover::before {
  opacity: 1;
}

.example-card.selected {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: var(--shadow-glow);
}

.example-card.selected::before {
  opacity: 1;
}

.example-card .example-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.example-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.example-card p {
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.5;
}

.example-tag {
  display: inline-block;
  padding: 2px 10px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 0.75rem;
}

/* ── Workspace Layout ── */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

/* ── 3D Viewer ── */
.viewer-container {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  min-height: 500px;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-glass);
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 480px) {
  .viewer-header {
    padding: 0.6rem 0.75rem;
  }
  .viewer-title {
    font-size: 0.78rem;
  }
  .viewer-badge { display: none; }
  .viewer-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 0.8rem;
  }
  .viewer-actions {
    gap: 3px;
  }
}

.viewer-title {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-badge {
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}

.viewer-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.viewer-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.viewer-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

#canvas-container {
  width: 100%;
  height: 450px;
  position: relative;
}

#canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 450px;
  color: var(--text-muted);
}

.viewer-empty .empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.viewer-empty p {
  font-size: 0.9rem;
}

/* ── Controls Panel ── */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.control-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Steps (Build steps) ── */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: var(--transition-fast);
  cursor: pointer;
}

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

.step-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
}

.step-item.completed {
  color: var(--accent-green);
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.step-item.active .step-dot {
  background: var(--accent-blue);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.step-item.completed .step-dot {
  background: var(--accent-green);
}

/* ── Slider (Cross Section) ── */
.slider-container {
  padding: 0.5rem 0;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-blue);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
  cursor: grab;
}

input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.2);
}

/* ── Buttons ── */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-group {
  display: flex;
  gap: 8px;
  margin-top: 1rem;
}

/* ── Textarea ── */
.textarea-wrapper {
  position: relative;
}

textarea {
  width: 100%;
  min-height: 120px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--text-primary);
  font-family: 'Inter', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
  transition: var(--transition-fast);
}

textarea:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

textarea::placeholder {
  color: var(--text-muted);
}

/* ── Code block ── */
.code-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--accent-cyan);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

/* ── QR Modal ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.modal p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

#qr-code {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

#qr-code canvas,
#qr-code img {
  border-radius: var(--radius-md);
}

/* ── Tab: Paste AI Code ── */
.paste-section {
  max-width: 800px;
  margin: 0 auto;
}

.prompt-display {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 12px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-blue);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.copy-btn:hover {
  background: rgba(59, 130, 246, 0.3);
}

/* ── Info Grid ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ── Tooltip ── */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
}

.tooltip:hover::after {
  opacity: 1;
}

/* ── Status indicator ── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.active {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 0 1rem;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 0.95rem;
  }

  .tabs-container {
    flex-wrap: wrap;
    padding: 0 1rem;
  }

  .tab-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
  }

  .tab-panel {
    padding: 0 1rem 2rem;
  }

  .examples-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }

  .btn-group {
    flex-direction: column;
  }
}

/* ── Mobile Menu ── */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  z-index: 201; /* Ensure button stays on top of menu or other elements */
}

.hamburger-line {
  width: 22px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.3s ease;
}

.mobile-menu-btn:hover .hamburger-line {
  background-color: var(--accent-blue);
}

/* Active hamburger icon (X) */
.mobile-menu-btn.is-open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-btn.is-open .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.is-open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-subjects-dropdown {
  display: none;
  position: absolute;
  top: 70px;
  left: 1rem;
  right: 1rem;
  background: rgba(10, 14, 23, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  z-index: 200;
  flex-direction: column;
  gap: 8px;
  transform-origin: top center;
}

.mobile-subjects-dropdown.show {
  display: flex;
  animation: slideDownMenu 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideDownMenu {
  0% { opacity: 0; transform: scaleY(0.8) translateY(-10px); }
  100% { opacity: 1; transform: scaleY(1) translateY(0); }
}

.mobile-subject-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.95rem;
}

.mobile-subject-item.active,
.mobile-subject-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.mobile-subject-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }
  .subject-tabs {
    display: none !important;
  }
}

/* ── Animations ── */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.2); }
  50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.4); }
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

/* ── Geometry Info ── */
.geo-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 0.75rem;
}

.geo-info-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 8px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
}

.geo-info-item .info-label {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.geo-info-item .info-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Step control buttons ── */
.step-controls {
  display: flex;
  gap: 8px;
  margin-top: 1rem;
}

.step-btn {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.step-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

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

/* ── Section headings ── */
.section-heading {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading .heading-icon {
  font-size: 1.3rem;
}

/* ── Checkbox toggle ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  transition: var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-blue);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* notification toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  z-index: 2000;
  opacity: 0;
  transform: translateY(20px);
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { border-color: rgba(16, 185, 129, 0.3); }
.toast.error { border-color: rgba(239, 68, 68, 0.3); }

/* ── Spinner ── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Measurement Status Bar ── */
.measure-status {
  padding: 8px 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-glass);
  background: rgba(0, 0, 0, 0.3);
  text-align: center;
  transition: var(--transition-fast);
}

.measure-status.active {
  background: linear-gradient(90deg, rgba(255, 204, 0, 0.08), rgba(255, 107, 107, 0.08));
  color: var(--accent-orange);
  border-bottom-color: rgba(255, 204, 0, 0.2);
}

/* Viewer button active state */
.viewer-btn.active {
  background: rgba(59, 130, 246, 0.25);
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

/* ============================================
   STUDENT MODE - Fullscreen 3D Viewer
   Activated when URL has ?mobile=1
   ============================================ */

/* Hide teacher-only UI */
body.student-mode .header,
body.student-mode .hero,
body.student-mode .tabs-container,
body.student-mode .examples-grid,
body.student-mode .section-heading,
body.student-mode .controls-panel,
body.student-mode #panel-ai-paste,
body.student-mode #panel-guide {
  display: none !important;
}

body.student-mode .main-content {
  margin-top: 0;
  padding: 0;
}

/* Ẩn nút chat, mini bar bài học, playlist và footer trong student mode */
body.student-mode #chat-bubble,
body.student-mode #chat-widget,
body.student-mode #mobile-steps-box,
body.student-mode #mobile-playlist-bar,
body.student-mode #mobile-playlist-sheet,
body.student-mode footer {
  display: none !important;
}

body.student-mode #panel-explore {
  display: block !important;
  padding: 0;
  max-width: 100%;
}

body.student-mode .workspace {
  display: block;
  margin-top: 0;
  gap: 0;
}

/* Fullscreen viewer */
body.student-mode .viewer-container {
  border: none;
  border-radius: 0;
  min-height: 100vh;
  height: 100vh;
}

body.student-mode .viewer-header {
  display: none;
}

body.student-mode #canvas-container,
body.student-mode #physics-canvas-container,
body.student-mode #chem-canvas-container,
body.student-mode #lab-canvas-container {
  height: calc(100vh - 54px - 42px - 56px) !important; /* top + bottom header + step bar */
  margin-top: calc(54px + 42px) !important; /* 2-row student header */
}

/* ── Cross Section Slider Overlay (Student Mode) ── */
.student-cs-slider {
  position: fixed !important;
  bottom: 80px !important;
  left: 20px !important;
  right: 20px !important;
  background: rgba(17, 24, 39, 0.8) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px 16px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  z-index: 210 !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.student-cs-slider input[type="range"] {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
  -webkit-appearance: none;
}

.student-cs-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* ── Student Header Bar ── */
.student-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
}

/* Hàng 1: Logo giống header trang chủ */
.student-bar-top {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Hàng 2: Tên bài + Reset */
.student-bar-bottom {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  gap: 8px;
}

.student-bar-bottom .student-btn {
  flex-shrink: 0;
}

/* Icon về trang chủ (ở cuối dòng 1) */
.student-home-icon {
  font-size: 1.25rem;
  text-decoration: none;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.student-home-icon:hover { opacity: 1; }

.student-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-logo {
  font-size: 1.3rem;
}

.student-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-bar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* Logo link in student bar */
.student-logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.student-logo-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.student-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.student-logo-name {
  font-size: 0.85rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.student-logo-badge {
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--accent-blue);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.8;
}

/* Home button style */
.student-btn-home {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.student-btn {
  padding: 6px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.student-btn:hover,
.student-btn:active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.3);
}

/* ── Student Steps Panel (compact fixed bottom bar) ── */
.student-steps-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-glass);
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 8px 0.75rem;
}

.student-steps-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.student-nav-btn {
  padding: 8px 18px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.student-nav-btn:active {
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.35);
}

.student-step-label {
  flex: 1;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  padding: 0 4px;
}

/* ── Touch Hint ── */
.touch-hint {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  padding: 10px 24px;
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass);
  border-radius: 30px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.5s ease;
  animation: hintBounce 2s ease-in-out infinite;
}

@keyframes hintBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* ── Lab Section Layout ── */
.viewer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  width: 100%;
}

.geo-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  width: 100%;
}

.geo-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  width: 100%;
  overflow: hidden;
}

.geo-panel .panel-header {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.geo-panel .panel-content {
  overflow-x: auto;
}


/* Mobile-specific for student mode */
@media (max-width: 768px) {
  .student-title {
    max-width: 150px;
    font-size: 0.9rem;
  }

  .student-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .touch-hint {
    font-size: 0.8rem;
    padding: 8px 18px;
  }
}
