:root {
  --subject-card-background: rgba(17, 24, 39, 0.82);
  --subject-card-hover: rgba(0, 155, 58, 0.22);
  --subject-icon-color: #ffdf00;
  --chat-bubble-user: rgba(0, 155, 58, 0.28);
  --chat-bubble-ai: rgba(12, 28, 20, 0.78);
}

.aulas-page {
  display: flex;
  flex-direction: column;
  gap: var(--app-spacing-xl);
  flex: 1;
}

.topbar + .aulas-page {
  margin-top: var(--app-spacing-xl);
}

.subject-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--app-spacing-lg);
}

.subject-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--app-spacing-sm);
  padding: clamp(16px, 3vw, 24px);
  border-radius: var(--app-radius-lg);
  border: 1px solid var(--app-border);
  background: radial-gradient(circle at top, rgba(0, 155, 58, 0.32), rgba(8, 27, 18, 0.9));
  color: var(--app-heading);
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  min-height: 150px;
}

.subject-button .icon {
  width: clamp(38px, 9vw, 46px);
  height: clamp(38px, 9vw, 46px);
  color: #ffd700;
}

.subject-button:hover,
.subject-button:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 24px 45px rgba(8, 15, 32, 0.45);
  border-color: rgba(0, 155, 58, 0.55);
  outline: none;
}

.chat-container {
  display: flex;
  flex-direction: column;
  gap: var(--app-spacing-md);
  background: rgba(15, 23, 42, 0.75);
  border-radius: var(--app-radius-lg);
  border: 1px solid var(--app-border);
  padding: clamp(16px, 3vw, 24px);
  box-shadow: 0 28px 50px rgba(8, 15, 32, 0.45);
}

.back-button {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 155, 58, 0.35);
  background: rgba(3, 12, 6, 0.72);
  color: var(--app-heading);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  min-height: 36px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.back-button .icon {
  width: 18px;
  height: 18px;
}

.back-button:hover,
.back-button:focus-visible {
  transform: translateX(-4px);
  box-shadow: 0 16px 28px rgba(8, 15, 32, 0.4);
  border-color: rgba(0, 155, 58, 0.5);
  outline: none;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: var(--app-spacing-sm);
  max-height: min(520px, 50vh);
  overflow-y: auto;
  padding-right: var(--app-spacing-sm);
}

.message {
  padding: 12px 16px;
  border-radius: var(--app-radius-md);
  line-height: 1.5;
  font-size: 0.95rem;
  color: var(--app-heading);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.user-message {
  align-self: flex-end;
  background: var(--chat-bubble-user);
  border: 1px solid rgba(0, 155, 58, 0.35);
}

.bot-message {
  align-self: flex-start;
  background: var(--chat-bubble-ai);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--app-muted);
}

.topic-list,
.subtopic-list {
  list-style: none;
  display: grid;
  gap: var(--app-spacing-xs);
  margin: 0;
  padding: 0;
}

.topic-item,
.subtopic-item {
  display: inline-flex;
  align-items: center;
  gap: var(--app-spacing-xs);
  padding: 10px 14px;
  border-radius: var(--app-radius-md);
  background: rgba(148, 163, 184, 0.12);
  color: var(--app-heading);
  font-size: 0.9rem;
  transition: transform 0.2s ease, background 0.2s ease;
}

.topic-item i,
.subtopic-item i {
  font-size: 1rem;
}

.topic-item:hover,
.subtopic-item:hover {
  transform: translateX(4px);
  background: rgba(0, 155, 58, 0.22);
}

.chat-input {
  display: flex;
  align-items: center;
  gap: var(--app-spacing-sm);
  background: rgba(10, 12, 24, 0.9);
  border-radius: var(--app-radius-md);
  border: 1px solid var(--app-border);
  padding: 10px 14px;
  position: sticky;
  bottom: calc(var(--app-spacing-lg));
  box-shadow: 0 14px 30px rgba(8, 15, 32, 0.4);
}

.chat-input input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--app-radius-md);
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.8);
  color: var(--app-heading);
  font-size: 0.95rem;
}

.chat-input input:focus {
  outline: none;
  border-color: rgba(0, 155, 58, 0.6);
  box-shadow: 0 0 0 3px rgba(0, 155, 58, 0.25);
}

.chat-input button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--app-primary) 0%, var(--app-primary-strong) 100%);
  color: var(--app-heading);
  font-size: 0.6rem;
  line-height: 1;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-input button .icon {
  pointer-events: none;
  width: 12px;
  height: 12px;
}

.chat-input button:hover,
.chat-input button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(0, 155, 58, 0.45);
  outline: none;
}

@media (max-width: 768px) {
  .subject-buttons {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .chat-messages {
    max-height: 60vh;
  }
}

@media (max-width: 480px) {
  .aulas-page {
    gap: var(--app-spacing-lg);
  }

  .chat-input {
    bottom: calc(var(--app-spacing-md));
    flex-wrap: wrap;
  }

  .chat-input button {
    width: 16px;
    height: 16px;
  }
}
