body {
  background: #f7fbff;
}

.question-text {
  white-space: normal;
}

.question-figure {
  margin: 1em 0;
}

.question-figure img {
  height: auto;
}

.question-meta {
  white-space: nowrap;
}

.profile-avatar {
  object-fit: cover;
  border: 4px solid #dee2e6;
  padding: 4px;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.15rem 0.05rem; /* vertical horizontal */
}

@media (min-width: 768px) {
  .avatar-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.avatar-option {
  border-radius: 12px;
  border: 2px solid transparent;
  padding: 1px;
  cursor: pointer;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.avatar-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.avatar-option img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid #e5e7eb;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.avatar-option:hover img {
  transform: scale(1.05);
}

.avatar-option input:checked + img {
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

.nav-avatar {
  border-radius: 50%;
  border: 2px solid #dee2e6;
  object-fit: cover;
}

.nav-avatar-btn {
  box-shadow: none !important;
}

.brand-logo {
  display: inline-block;
}

.choices-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.choices-grid .form-check {
  min-width: 180px;
}

.home-hero {
  background: linear-gradient(135deg, #fdf6ff, #eef6ff);
}

.student-collage {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.student-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-radius: 1.25rem;
  color: #fff;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.15);
}

.student-card img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.student-label {
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.student-note {
  font-size: 0.9rem;
  line-height: 1.3;
}

.student-card.accent-blue {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.student-card.accent-purple {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
}

.student-card.accent-green {
  background: linear-gradient(135deg, #059669, #10b981);
}

.feature-list li {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0;
}

.feature-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0d6efd;
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.stat-card {
  border-radius: 1.25rem;
  background: white;
  padding: 1.5rem;
  border: 1px solid #e3e8ef;
}

.home-panel {
  background: #fefefe;
  border-radius: 1.5rem;
  padding: 2rem;
  border: 1px solid #e3e8ef;
}

.review-feed {
  max-height: 220px;
  overflow-y: auto;
}

.question-set-card {
  background: #fff;
}

.topics-hero {
  background: linear-gradient(135deg, #f5f5ff, #f0fbff);
}

.topic-card {
  background: #fff;
  border-radius: 1.25rem;
  padding: 2rem;
  border: 1px solid #e3e8ef;
}

.topic-card-header h2 {
  font-weight: 600;
}

.topic-count-badge {
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
}

.topic-children {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.topic-child {
  background: #f8fafc;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.topic-child:hover {
  border-color: #0d6efd;
  background: #fff;
}

.topic-question-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
}

.topic-question-card .list-group-item {
  cursor: pointer;
}

.topic-question-card .list-group-item input[type="radio"] {
  cursor: pointer;
}

.topic-workspace {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.review-question-main {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1.25rem;
}

.topic-chat-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
  min-height: calc(100vh - 200px);
  max-height: calc(100vh - 200px);
  width: 100%;
  display: flex;
  flex-direction: column;
}

.topic-chat-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.topic-chat-empty {
  font-size: 0.9rem;
  color: #6b7280;
  margin-top: 1rem;
}

.topic-chat-input {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.topic-chat-message {
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.45;
}

.topic-chat-message.user {
  background: #e0f2ff;
  align-self: flex-end;
}

.topic-chat-message.assistant {
  background: #f8f9fb;
  align-self: flex-start;
}

@media (min-width: 992px) {
  .topic-workspace {
    flex-direction: row;
    align-items: flex-start;
  }
.topic-workspace-active .topic-question-card {
    flex: 0 0 60%;
    max-width: 60%;
  }
  .topic-workspace-active .topic-chat-panel {
    flex: 0 0 40%;
    max-width: 40%;
    position: sticky;
    top: 1rem;
  }
  .topic-workspace:not(.topic-workspace-active) .topic-question-card {
    flex: 1 1 100%;
    max-width: 100%;
  }
  .topic-workspace:not(.topic-workspace-active) .topic-chat-panel {
    display: none;
  }
}

@media (max-width: 575px) {
  .student-card {
    flex-direction: column;
    text-align: center;
  }
  .student-card img {
    margin-bottom: 0.5rem;
  }
  .feature-list li {
    flex-direction: column;
  }
}

/* Calculator Styles */
.calculator-btn {
  transition: all 0.15s ease;
  padding: 0.25rem 0.5rem;
}

.calculator-btn:hover {
  transform: scale(1.05);
}

.calculator-btn:active {
  transform: scale(0.95);
}

.calculator-display input {
  text-align: right;
  font-family: 'Courier New', monospace;
  font-size: 1.5rem;
  font-weight: 600;
}

/* Floating Calculator Window */
.floating-calculator {
  position: fixed;
  top: 80px;
  right: 20px;
  width: 280px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  z-index: 1050;
  display: none;
}

.floating-calculator.show {
  display: block;
}

.floating-calculator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #dee2e6;
  cursor: move;
  background: #f8f9fa;
  border-radius: 0.5rem 0.5rem 0 0;
}

.floating-calculator-header h6 {
  margin: 0;
  font-weight: 600;
}

.floating-calculator-body {
  padding: 1rem;
}

@media (max-width: 768px) {
  .floating-calculator {
    top: auto;
    bottom: 20px;
    right: 10px;
    left: 10px;
    width: auto;
    max-width: none;
  }
}

/* Topic Page Navigation */
.topic-navigation {
  margin-top: 1.5rem;
}

.topic-nav-btn,
.calculator-btn {
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-color: #dee2e6;
  color: #6c757d;
  background-color: #f8f9fa;
}

.topic-nav-btn:hover,
.calculator-btn:hover {
  background-color: #e9ecef;
  border-color: #ced4da;
  color: #495057;
}

.topic-page-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.topic-page-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 0.875rem;
  color: #6c757d;
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.topic-page-number:hover {
  background-color: #f8f9fa;
  color: #495057;
}

.topic-page-number.current {
  background-color: #e9ecef;
  color: #212529;
  font-weight: 500;
}

.topic-page-ellipsis {
  color: #adb5bd;
  padding: 0 4px;
}
