:root {
  --blue: #00B9F1;
  --blue-dark: #017DC5;
  --blue-bg: #E5F9FF;
  --yellow: #FED001;
  --yellow-text: #3A3A3A;
  --ink: #3A3A3A;
  --ink-soft: #777777;
  --white: #FFFFFF;
  --red: #F75A5B;
  --green: #50B849;
  --border: #E4EBF0;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Roboto', system-ui, sans-serif;
  color: var(--ink);
  background: var(--blue-bg);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }
::placeholder { color: #9FB0BE; }

.app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  display: flex;
  flex-direction: column;
  width: 300px;
  flex-shrink: 0;
  background: var(--white);
  padding: 28px 20px;
  box-shadow: 2px 0 18px rgba(20, 50, 80, 0.06);
  overflow: hidden;
  transition: width 0.2s ease, padding 0.2s ease;
}

.app.sidebar-collapsed .sidebar { width: 0; padding-left: 0; padding-right: 0; }

.hamburger-btn { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  padding-left: 4px;
}
.logo-img { width: 100%; height: auto; object-fit: contain; }

.member-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 6px 4px;
  min-height: 62px;
}
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0F3D5C;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.member-name { font-size: 14.5px; font-weight: 600; }

.nav-primary, .nav-emphasis {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nav-emphasis { margin-top: 6px; }

.nav-link, .pill-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0.825rem 1rem;
  border-radius: 0.625rem;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  color: #737B8B;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover:not(.active):not(.nav-link-home) { background: #F3F8FB; }
.nav-link.active { background: var(--blue); color: var(--white); }
.nav-link.nav-link-home { background: var(--blue); color: var(--white); }

.pill-link { background: var(--yellow); color: var(--yellow-text); }
.pill-link.disabled { opacity: 0.55; pointer-events: none; cursor: not-allowed; }

/* MAIN */
.main { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 26px 36px;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--blue-dark); margin: 0; }
.spacer { flex: 1; }

.content { flex: 1; padding: 6px 36px 36px; overflow: auto; }

.view[hidden] { display: none; }

/* BANNER */
.banner {
  position: relative;
  background: var(--blue-dark);
  border-radius: 1.6rem;
  padding: 36px 40px;
  min-height: 150px;
}
.banner-text { max-width: 640px; }
.banner h2 { font-size: 26px; font-weight: 800; color: white; margin: 0 0 10px; }
.banner p { font-size: 15px; color: #DCEEFC; font-weight: 500; line-height: 1.5; margin: 0; }

.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 30px 2px 14px; }
.section-heading h3 { font-size: 18px; font-weight: 800; margin: 0; }

.card {
  background: var(--white);
  border-radius: 0.75rem;
  box-shadow: 0 4px 14px rgba(20, 50, 80, 0.06);
}

.empty-card {
  background: var(--white);
  border-radius: 0.75rem;
  box-shadow: 0 4px 14px rgba(20, 50, 80, 0.06);
  padding: 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.empty-card p { margin: 0; color: var(--ink-soft); font-weight: 500; }

.competencias-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 3rem;
}
.competencia-card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 18px 16px;
  box-shadow: 0 4px 14px rgba(20, 50, 80, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.competencia-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.competencia-label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.competencia-score { font-size: 20px; font-weight: 800; }
.competencia-score small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.competencia-bar { height: 7px; border-radius: 999px; background: #EEF2F5; overflow: hidden; }
.competencia-bar-fill { height: 100%; border-radius: 999px; }

.info-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--white);
  border-radius: 0.75rem;
  padding: 22px 26px;
  box-shadow: 0 4px 14px rgba(20, 50, 80, 0.06);
}
.info-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #FFF3D6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.info-body { flex: 1; }
.info-title { font-size: 15.5px; font-weight: 800; margin-bottom: 3px; }
.info-subtitle { font-size: 13.5px; color: var(--ink-soft); font-weight: 600; }

.btn-primary {
  background: var(--blue);
  color: white;
  font-weight: 600;
  font-size: 13.5px;
  padding: 11px 20px;
  border-radius: 2.5rem;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-lg { font-size: 15px; padding: 14px 30px; }

.btn-secondary {
  background: var(--blue-bg);
  color: var(--blue-dark);
  font-weight: 600;
  font-size: 13.5px;
  padding: 11px 20px;
  border-radius: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.btn-secondary:hover { background: #D6F2FC; }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ENVIAR */
.enviar-layout { display: flex; gap: 24px; align-items: flex-start; }
.enviar-form { flex: 1; padding: 34px; }
.enviar-aside { width: 280px; flex-shrink: 0; padding: 26px; }

.field-label { display: block; font-size: 13px; font-weight: 800; color: var(--ink-soft); margin-bottom: 8px; }

.field-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.field-label-row .field-label { margin-bottom: 0; }
.ocr-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 2.5rem;
  border: 1.5px solid var(--blue);
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.ocr-upload-btn:hover { background: var(--blue-bg); }
.ocr-upload-btn.is-loading { opacity: 0.6; pointer-events: none; }
.field-hint { font-size: 12px; color: var(--ink-soft); font-weight: 500; margin-top: 6px; text-align: right; }

#temaInput {
  width: 100%;
  padding: 14px 20px;
  border-radius: 6.25rem;
  border: 1.5px solid var(--border);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 22px;
}
#redacaoInput {
  width: 100%;
  min-height: 260px;
  padding: 16px 18px;
  border-radius: 0.75rem;
  border: 1.5px solid var(--border);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  resize: vertical;
  line-height: 1.6;
}
#temaInput:focus, #redacaoInput:focus, #chatInput:focus { outline: none; border-color: var(--blue); }

.form-error {
  margin-top: 14px;
  padding: 12px 16px;
  background: #FDECEC;
  color: #B23A3A;
  border-radius: 0.75rem;
  font-size: 13.5px;
  font-weight: 600;
}

.enviar-actions { display: flex; justify-content: flex-end; margin-top: 22px; }

.aside-text { font-size: 13.5px; color: var(--ink-soft); font-weight: 500; line-height: 1.6; margin: 10px 0 16px; }
.aside-list { list-style: none; margin: 0; padding: 0; }
.aside-list li {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 8px 0;
  border-top: 1px solid #F0F3F5;
}

/* COMPETÊNCIAS ENEM */
.evolucao-card { padding: 24px 30px; margin-top: 16px; }
.evolucao-legenda { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 18px; }
.legenda-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.legenda-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.evolucao-chart svg { display: block; }

/* MINHAS REDAÇÕES */
.minhas-list { display: flex; flex-direction: column; gap: 14px; }
.minhas-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 26px;
  text-align: left;
  width: 100%;
}
.minhas-item-tema { flex: 1; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.minhas-item-meta { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.minhas-item-data { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.minhas-item-nota { font-size: 18px; font-weight: 800; color: var(--blue-dark); flex-shrink: 0; }
.minhas-item-nota small { font-size: 11px; font-weight: 700; color: var(--ink-soft); }

/* RESULTADO */
.resultado-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 26px 30px;
  margin-bottom: 20px;
}
.resultado-tema { flex: 1; }
.resultado-tema-texto { font-size: 16px; font-weight: 700; }
.resultado-nota { text-align: right; }
.nota-total { font-size: 34px; font-weight: 800; color: var(--blue-dark); line-height: 1; }
.nota-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.nivel-badge {
  padding: 8px 16px;
  border-radius: 2.5rem;
  background: var(--blue-bg);
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 13px;
  text-transform: capitalize;
}

.resultado-feedback { padding: 24px 30px; margin-bottom: 22px; }

.competencias-detalhe { display: flex; flex-direction: column; gap: 14px; }
.competencia-detalhe-card { padding: 22px 26px; }
.competencia-detalhe-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.competencia-detalhe-titulo { font-size: 15.5px; font-weight: 800; }
.competencia-detalhe-nota { font-size: 15px; font-weight: 800; color: var(--blue-dark); }
.competencia-detalhe-comentario { font-size: 13.5px; color: var(--ink-soft); font-weight: 500; line-height: 1.6; margin-bottom: 14px; }
.competencia-detalhe-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.competencia-detalhe-col-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px; }
.pontos-fortes .competencia-detalhe-col-title { color: var(--green); }
.pontos-melhoria .competencia-detalhe-col-title { color: #E08A00; }
.competencia-detalhe-cols ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-soft); font-weight: 500; line-height: 1.6; }

/* TUTOR */
.view[data-view="tutor"] { height: 100%; display: flex; flex-direction: column; }
.tutor-layout { display: flex; gap: 20px; flex: 1; min-height: 0; margin-bottom: 2rem; }
.tutor-layout .chat-card { margin-bottom: 0; }
.chat-card { display: flex; flex-direction: column; flex: 1; margin-bottom: 2rem; padding: 20px; min-height: 500px; }

.conversas-aside { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.conversas-nova { width: 100%; }
.conversas-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.conversa-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 0.625rem;
  border: 1.5px solid transparent;
  background: #F5F9FB;
}
.conversa-item:hover { background: var(--blue-bg); }
.conversa-item.active { border-color: var(--blue); background: var(--blue-bg); }
.conversa-item-corpo { flex: 1; min-width: 0; }
.conversa-item-titulo {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversa-item-data { font-size: 11px; color: #8FA0AC; margin-top: 3px; }
.conversa-item-excluir {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9FB0BE;
}
.conversa-item-excluir:hover { background: #FDE7E4; color: #D8503A; }
.conversas-empty { font-size: 12.5px; color: var(--ink-soft); padding: 10px 4px; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 8px; }

.chat-row { display: flex; align-items: flex-end; gap: 10px; }
.chat-row.user { justify-content: flex-end; }
.chat-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; background: var(--blue-bg); }

.chat-msg { max-width: 78%; padding: 12px 16px; border-radius: 0.75rem; font-size: 14px; line-height: 1.6; font-weight: 500; }
.chat-msg.user { align-self: flex-end; background: var(--blue); color: white; white-space: pre-wrap; }
.chat-msg.assistant { align-self: flex-start; background: #F3F8FB; color: var(--ink); }

.chat-msg-col { display: flex; flex-direction: column; gap: 4px; max-width: 78%; }
.chat-msg-col .chat-msg { max-width: 100%; }
.chat-feedback { display: flex; gap: 6px; padding-left: 4px; }

.chat-video-embed { background: #F3F8FB; border-radius: 0.75rem; padding: 10px; }
.chat-video-frame { position: relative; width: 100%; padding-top: 56.25%; border-radius: 0.5rem; overflow: hidden; background: #000; }
.chat-video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.chat-video-caption { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-top: 8px; }
.feedback-btn { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #8FA0AC; background: #F1F6F8; }
.feedback-btn:hover { background: #E4EEF2; }
.feedback-btn.active[data-feedback="positivo"] { background: #DFF6E4; color: #2E9E4C; }
.feedback-btn.active[data-feedback="negativo"] { background: #FDE7E4; color: #D8503A; }

.chat-typing { display: flex; align-items: center; gap: 5px; padding: 16px 18px; }
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #9FB0BE;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* TUTOR — WIDGET FLUTUANTE */
.fab-tutor {
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 8px 20px rgba(0, 185, 241, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: transform 0.15s;
}
.fab-tutor:hover { transform: scale(1.06); }
.fab-tutor.is-open { background: var(--blue-dark); }

.tutor-floating {
  position: fixed;
  right: 32px;
  bottom: 104px;
  width: 380px;
  height: 520px;
  background: var(--white);
  border-radius: 1rem;
  box-shadow: 0 16px 40px rgba(20, 50, 80, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}

.tutor-floating-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--blue-dark);
  color: white;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}
.tutor-floating-close { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.tutor-floating-close:hover { background: rgba(255, 255, 255, 0.15); }

.tutor-floating-empty { flex: 1; margin: 18px; border-radius: 0.75rem; }

.tutor-floating-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 14px; }
.tutor-floating-chat .chat-messages { padding: 4px; }
.tutor-floating-chat .chat-input-row { display: flex; gap: 8px; margin-top: 12px; }
.chat-input-floating {
  flex: 1;
  padding: 10px 16px;
  border-radius: 6.25rem;
  border: 1.5px solid var(--border);
  font-size: 13.5px;
}
.chat-input-floating:focus { outline: none; border-color: var(--blue); }

@media (max-width: 500px) {
  .tutor-floating { right: 16px; left: 16px; width: auto; bottom: 96px; }
  .fab-tutor { right: 20px; bottom: 20px; }
}

.chat-msg.assistant > *:first-child { margin-top: 0; }
.chat-msg.assistant > *:last-child { margin-bottom: 0; }
.chat-msg.assistant h1, .chat-msg.assistant h2, .chat-msg.assistant h3 {
  font-size: 15px; font-weight: 800; margin: 14px 0 6px;
}
.chat-msg.assistant p { margin: 0 0 10px; }
.chat-msg.assistant ul, .chat-msg.assistant ol { margin: 0 0 10px; padding-left: 22px; }
.chat-msg.assistant li { margin-bottom: 4px; }
.chat-msg.assistant strong { font-weight: 800; }
.chat-msg.assistant code {
  background: #E7EEF2; padding: 2px 6px; border-radius: 4px; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.chat-msg.assistant pre {
  background: #1F2A33; color: #E7EEF2; padding: 12px 14px; border-radius: 0.625rem;
  overflow-x: auto; margin: 0 0 10px;
}
.chat-msg.assistant pre code { background: none; padding: 0; color: inherit; }
.chat-msg.assistant blockquote {
  margin: 0 0 10px; padding: 4px 14px; border-left: 3px solid var(--blue); color: var(--ink-soft);
}
.chat-msg.assistant hr { border: none; border-top: 1px solid #E4EBF0; margin: 14px 0; }
.chat-msg.assistant a { color: var(--blue-dark); }
.chat-msg.assistant table { border-collapse: collapse; margin: 0 0 10px; width: 100%; font-size: 13px; }
.chat-msg.assistant th, .chat-msg.assistant td { border: 1px solid #E4EBF0; padding: 6px 10px; text-align: left; }
.chat-msg.assistant th { background: #E7EEF2; font-weight: 700; }
.chat-input-row { display: flex; gap: 10px; margin-top: 14px; }
#chatInput {
  flex: 1;
  padding: 12px 18px;
  border-radius: 6.25rem;
  border: 1.5px solid var(--border);
  font-size: 14px;
}

@media (max-width: 1100px) {
  .competencias-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .enviar-layout { flex-direction: column; }
  .enviar-aside { width: 100%; }
  .competencia-detalhe-cols { grid-template-columns: 1fr; }
}

.auth-block {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-bg);
}
.auth-block-card {
  background: #fff;
  border-radius: 0.75rem;
  padding: 40px 44px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}
.auth-block-card svg { margin-bottom: 16px; }
.auth-block-card h1 { font-size: 20px; margin: 0 0 10px; color: var(--ink); }
.auth-block-card p { font-size: 14px; color: #6B7C87; margin: 0; line-height: 1.5; }
