/* ============================================================
   Nexus Ramo — Design System
   Paleta: #7EC8FF · #00B8FF · #A6B0BA · #0E1624 · #FF8A33 · #F5F7FA
   Tipografia: Inter / Poppins
   ============================================================ */

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

:root {
  --azul-principal:   #7EC8FF;
  --azul-destaque:    #00B8FF;
  --cinza-prata:      #A6B0BA;
  --azul-escuro:      #0E1624;
  --laranja-acao:     #FF8A33;
  --fundo-claro:      #F5F7FA;

  /* superfícies */
  --bg-app:           #0B1828;
  --bg-sidebar:       #0A1120;
  --bg-card:          #161f2e;
  --bg-input:         #1a2436;
  --bg-hover:         #1e2d42;
  --bg-active:        #1a3050;

  /* texto */
  --text-primary:     #f0f4f8;
  --text-secondary:   #8a9bb0;
  --text-muted:       #4d5e72;

  /* bordas */
  --border-subtle:    rgba(126,200,255,.08);
  --border-light:     rgba(126,200,255,.14);
  --border-mid:       rgba(126,200,255,.22);

  /* efeitos */
  --glow-blue:        0 0 18px rgba(0,184,255,.12);
  --shadow-card:      0 4px 24px rgba(0,0,0,.35);
  --shadow-input:     0 2px 16px rgba(0,0,0,.3);

  /* raios */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  16px;
  --r-xl:  22px;

  /* sidebar */
  --sidebar-w: 240px;

  /* transição */
  --t: .18s ease;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-app);
  overflow: hidden;
}

button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea, select { font: inherit; color: inherit; background: none; border: none; outline: none; }
a { color: inherit; text-decoration: none; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-mid); }

/* ── App Shell ────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: 160px;
  max-width: 480px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--t), min-width var(--t), transform var(--t);
  position: relative;
  z-index: 10;
}
.sidebar.resizing {
  transition: none;
  user-select: none;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

/* Sidebar resize handle */
.sidebar-resize-handle {
  width: 5px;
  height: 100vh;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  background: transparent;
  transition: background 0.15s;
  margin-left: -1px; /* sobrepõe o border-right da sidebar */
}
.sidebar-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  border-radius: 99px;
  background: var(--border-subtle);
  opacity: 0;
  transition: opacity 0.15s;
}
.sidebar-resize-handle:hover::after,
.sidebar-resize-handle.dragging::after {
  opacity: 1;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: rgba(126,200,255,0.06);
}
.sidebar.collapsed + .sidebar-resize-handle {
  display: none;
}

/* Logo */
.sidebar-top { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px 8px; }

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px 10px;
  margin-bottom: 6px;
}

.logo-svg { width: 44px; flex-shrink: 0; }
.logo-svg svg { width: 100%; height: auto; display: block; }

.logo-text {
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .05em;
  white-space: nowrap;
}
.logo-nexus { color: var(--text-primary); }
.logo-ramo  { color: var(--azul-destaque); }

/* Nav */
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--t), color var(--t);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item--primary { color: var(--azul-destaque); }
.nav-item--primary:hover { background: rgba(0,184,255,.08); }

/* ── Section toggles (Ferramentas / Ramificações) ─────────── */
.section-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  transition: color var(--t), background var(--t);
  text-align: left;
}
.section-toggle > svg:first-child { width: 13px; height: 13px; flex-shrink: 0; }
.section-toggle:hover { color: var(--text-primary); background: rgba(255,255,255,.02); }
.section-toggle.open { color: var(--text-primary); }

.chevron-icon {
  width: 11px; height: 11px;
  margin-left: auto;
  flex-shrink: 0;
  opacity: .5;
  transition: transform .22s ease, opacity var(--t);
}
.section-toggle.open .chevron-icon,
.section-toggle:hover .chevron-icon { opacity: .8; }
.section-toggle.open .chevron-icon { transform: rotate(90deg); }

/* ── Collapsible panels ───────────────────────────────────── */
.collapsible-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height .3s cubic-bezier(.4,0,.2,1);
}
/* Ferramentas: teto fixo (conteúdo pequeno) */
#tools-panel.open { max-height: 400px; }
/* Ramificações: cresce livremente — rolagem fica no .branches-section */
#branches-panel.open { max-height: none; overflow: visible; }

.collapsible-inner { padding-bottom: 6px; }

/* ── Ferramentas ──────────────────────────────────────────── */
.tools-section { margin-top: 2px; }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px 8px 2px;
}

.tool-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  transition: background var(--t), border-color var(--t), transform .15s ease, color var(--t);
  position: relative;
  color: var(--cinza-prata);
  min-height: 44px;
}
.tool-chip svg { width: 14px; height: 14px; flex-shrink: 0; }
.tool-chip:hover {
  background: var(--bg-hover);
  border-color: var(--tool-color, var(--border-light));
  color: var(--tool-color, var(--azul-principal));
  transform: scale(1.07);
}

/* ── Ramificações ─────────────────────────────────────────── */
.branches-section {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  min-height: 0;
}

.branches-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 8px 0;
}

/* Branch item row */
.branch-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t), color var(--t);
  border: 1px solid transparent;
  user-select: none;
}
.branch-color-icon { width: 13px; height: 13px; flex-shrink: 0; }
.branch-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.branch-item.active {
  background: var(--bg-active);
  color: var(--azul-principal);
  border-color: var(--border-light);
}

.branch-lesson-count {
  margin-left: auto;
  font-size: 9.5px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 1px 5px;
  border-radius: 99px;
  flex-shrink: 0;
}

/* Per-branch chevron */
.branch-chevron {
  width: 10px; height: 10px;
  flex-shrink: 0;
  opacity: .35;
  transition: transform .2s ease, opacity var(--t);
  margin-left: 2px;
}
.branch-item:hover .branch-chevron { opacity: .6; }
.branch-chevron.open { transform: rotate(90deg); opacity: .7; }

/* Branch children (collapsible tree) */
.branch-children {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .24s ease;
}
.branch-children.open { grid-template-rows: 1fr; }

.branch-children-inner {
  min-height: 0;
  overflow: hidden;
}

/* Tree sub-items container */
.branch-subtree {
  position: relative;
  margin: 2px 0 4px 16px;
  padding-left: 12px;
}

/* Vertical connector line */
.branch-subtree::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 6px;
  width: 1px;
  background: var(--border-subtle);
  border-radius: 1px;
}

/* Sub-item row */
.branch-sub-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: color var(--t), background var(--t);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Horizontal connector to sub-item */
.branch-sub-item::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: var(--border-subtle);
}

.branch-sub-item:hover { color: var(--text-secondary); background: rgba(255,255,255,.025); }

.branch-sub-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  opacity: .6;
}

.branch-sub-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-sub-progress {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: .7;
}

/* Empty state inside tree */
.branch-empty-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 6px 4px 10px;
  opacity: .6;
  position: relative;
}
.branch-empty-hint::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: var(--border-subtle);
}

/* ── Topic rows (nível 1 do tree) ─────────────────────────── */
.topic-row {
  cursor: pointer;
}
.topic-row:hover { color: var(--text-secondary); background: rgba(255,255,255,.025); }
.topic-row.topic-active { color: var(--azul-principal); }
.topic-row.topic-active .branch-sub-dot { background: var(--azul-principal); }

.topic-page-badge {
  margin-left: auto;
  font-size: 9px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 1px 4px;
  border-radius: 99px;
  flex-shrink: 0;
  min-width: 14px;
  text-align: center;
}

/* ── Drag handle das ramificações ───────────────────────── */
.branch-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0;
  cursor: grab;
  transition: opacity .15s;
  margin-right: -2px;
}
.branch-item:hover .branch-drag-handle { opacity: 0.5; }
.branch-drag-handle:hover { opacity: 1 !important; color: var(--text-secondary); }
[data-branch-wrap].branch-dragging {
  opacity: 0.4;
}
[data-branch-wrap].branch-drag-over > .branch-item {
  background: rgba(126,200,255,0.08);
  border-radius: var(--r-sm);
  outline: 1px dashed rgba(126,200,255,0.3);
}

/* ── Sub-tópicos ─────────────────────────────────────────── */
.subtopic-list {
  border-left: 1px solid var(--border-subtle);
  margin-left: 14px;
  padding-left: 2px;
}
.is-subtopic {
  font-size: 11.5px;
}
.subtopic-arrow {
  color: var(--text-muted);
  opacity: 0.5;
  flex-shrink: 0;
  margin-right: -2px;
}
.add-subtopic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
  padding: 0;
  margin-left: auto;
  transition: opacity .15s, background .15s, color .15s;
}
.add-subtopic-btn svg { width: 10px; height: 10px; }
.add-subtopic-btn:hover { background: rgba(126,200,255,0.12); color: var(--azul-principal); opacity: 1 !important; }
.topic-row:hover .add-subtopic-btn { opacity: 0.6; }

/* ── Botões de exclusão seletiva ─────────────────────────── */
.del-branch-btn,
.del-topic-btn,
.del-entry-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
  padding: 0;
  margin-left: auto;
  transition: opacity .15s, background .15s, color .15s;
}
.del-branch-btn svg,
.del-topic-btn svg,
.del-entry-btn svg {
  width: 10px;
  height: 10px;
}
.del-branch-btn:hover,
.del-topic-btn:hover,
.del-entry-btn:hover {
  background: rgba(255,80,80,0.15);
  color: #ff5555;
}
/* Mostrar ao hover no item pai */
.branch-item:hover .del-branch-btn,
.topic-row:hover .del-topic-btn,
.entry-item:hover .del-entry-btn {
  opacity: 1;
}
/* topic-page-badge some quando botões aparecem */
.topic-row:hover .topic-page-badge { display: none; }
/* del-topic-btn não empurra pro lado quando add-subtopic já tem margin-left:auto */
.topic-row .del-topic-btn { margin-left: 2px; }

/* ── Entry items (nível 2 — páginas) ─────────────────────── */
.topic-entries {
  position: relative;
  padding-left: 14px;
  margin-left: 8px;
  margin-bottom: 2px;
}
.topic-entries::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 6px;
  width: 1px;
  background: var(--border-subtle);
  opacity: .5;
  border-radius: 1px;
}

.entry-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 5px 3px 10px;
  font-size: 10.5px;
  color: var(--text-muted);
  border-radius: 3px;
  cursor: pointer;
  transition: color var(--t), background var(--t);
}
.entry-item::before {
  content: '';
  position: absolute;
  left: -14px; top: 50%;
  width: 12px; height: 1px;
  background: var(--border-subtle);
  opacity: .5;
}
.entry-item:hover { color: var(--text-secondary); background: rgba(255,255,255,.02); }
.entry-item.current { color: var(--azul-destaque); }
.entry-item.current .entry-dot { background: var(--azul-destaque); box-shadow: 0 0 4px var(--azul-destaque); }

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

/* Banner de continuidade ao reabrir tópico */
.topic-resume-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-bottom: 12px;
  background: rgba(0,184,255,.05);
  border: 1px solid rgba(0,184,255,.1);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--text-secondary);
}
.topic-resume-banner svg { width: 13px; height: 13px; color: var(--azul-destaque); flex-shrink: 0; }

.create-branch-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 8px 4px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  transition: all var(--t);
}
.create-branch-btn svg { width: 12px; height: 12px; }
.create-branch-btn:hover {
  border-color: var(--azul-destaque);
  color: var(--azul-destaque);
  background: rgba(0,184,255,.04);
}

/* Sidebar bottom */
.sidebar-bottom {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Linha do user chip + botão de recolher ─────────────── */
.user-chip-row {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px;
}

/* ── Botão de recolher (quadradinho com traço) ───────────── */
.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  color: var(--text-muted); flex-shrink: 0;
  transition: background var(--t), color var(--t);
}
.sidebar-collapse-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Modo icon-only ─────────────────────────────────────── */
.sidebar--icononly { width: 56px !important; min-width: 56px !important; }
.sidebar--icononly .logo-text,
.sidebar--icononly .nav-item span,
.sidebar--icononly .section-toggle > span:not(.chevron-icon),
.sidebar--icononly .chevron-icon,
.sidebar--icononly .collapsible-panel,
.sidebar--icononly .create-branch-btn,
.sidebar--icononly .user-info { display: none !important; }
.sidebar--icononly .logo-wrap { justify-content: center; padding: 0; }
.sidebar--icononly .nav-item,
.sidebar--icononly .section-toggle { justify-content: center; padding: 8px; }
.sidebar--icononly .user-chip-row { justify-content: center; flex-direction: column; gap: 2px; padding: 4px 2px; }
.sidebar--icononly .user-chip { justify-content: center; padding: 4px; width: auto; }

/* ── User menu wrap ─────────────────────────────────────── */
.user-menu-wrap { position: relative; }

.user-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 8px; right: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: none;
  flex-direction: column;
  z-index: 50;
}
.user-menu.open { display: flex; }

.user-menu-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px;
  font-size: 13px; color: var(--text-secondary);
  transition: background var(--t), color var(--t);
  text-align: left; width: 100%;
}
.user-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.user-menu-item--danger:hover { color: #e05555; }
.user-menu-sep { height: 1px; background: var(--border-subtle); margin: 2px 0; }

/* ── User chip (agora é botão) ──────────────────────────── */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: var(--r-sm);
  cursor: pointer; transition: background var(--t);
  width: 100%;
}
.user-chip:hover { background: var(--bg-hover); }
.user-chip-chevron { margin-left: auto; color: var(--text-muted); flex-shrink: 0; }
.user-menu-wrap.menu-open .user-chip-chevron { transform: rotate(180deg); }

.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--azul-principal), var(--azul-destaque));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.user-name  { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 10px; color: var(--text-muted); }

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
}

/* Header */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-app);
  flex-shrink: 0;
  min-height: 52px;
}

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

.toggle-sidebar-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  transition: background var(--t), color var(--t);
}
.toggle-sidebar-btn svg { width: 18px; height: 18px; }
.toggle-sidebar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.active-branch-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.branch-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--azul-destaque);
  box-shadow: 0 0 6px var(--azul-destaque);
}

.header-right { display: flex; align-items: center; gap: 6px; }

.header-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all var(--t);
}
.header-btn svg { width: 15px; height: 15px; }
.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

/* Content area */
.content-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Welcome Screen ───────────────────────────────────────── */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}

.welcome-logo-mark svg { width: 80px; height: auto; filter: drop-shadow(0 0 20px rgba(0,184,255,.18)); }

.welcome-title {
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-primary);
}

.welcome-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 400;
}

.welcome-hints {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

.hint-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 99px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t);
}
.hint-chip svg { width: 14px; height: 14px; }
.hint-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--azul-principal);
}

/* ── Chat Messages ────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  padding: 40px 48px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* Separador de página — fino e elegante */
.page-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 32px 0 28px;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: 0.55;
}
.page-divider::before, .page-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Divisor entre entradas — linha fina com número lateral discreto */
.entry-page-divider {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 44px 0 36px;
  position: relative;
}
.entry-page-divider::before,
.entry-page-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border-subtle));
}
.entry-page-divider::after {
  background: linear-gradient(90deg, var(--border-subtle), transparent);
}
.epd-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  background: var(--bg-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.epd-page {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.epd-sep { font-size: 10px; color: var(--text-muted); opacity: 0.5; }
.epd-topic {
  font-size: 10px;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.epd-date { font-size: 10px; color: var(--text-muted); opacity: 0.7; }

/* ── Widget de troca de ramificação ─────────────────────────── */
.subject-switch-widget {
  align-self: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px auto;
  width: fit-content;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ssw-header {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.ssw-branches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.ssw-branch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ssw-branch:hover { background: var(--bg-tertiary); border-color: var(--border-strong); }
.ssw-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ssw-create {
  font-size: 11px;
  color: var(--azul-principal);
  background: none;
  border: none;
  cursor: pointer;
  text-align: center;
  padding: 2px 0;
  opacity: 0.8;
  transition: opacity .15s;
}
.ssw-create:hover { opacity: 1; }

/* Mensagem do aluno */
.msg-user {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 28px;
  margin-top: 8px;
}
.msg-user .bubble {
  background: rgba(126,200,255,0.07);
  border: 1px solid rgba(126,200,255,0.13);
  border-radius: 18px 18px 4px 18px;
  padding: 10px 18px;
  max-width: 68%;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Mensagem da IA — documento vivo, sem caixa */
.msg-ai {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 36px;
}
.msg-ai-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(126,200,255,0.08);
  border: 1px solid rgba(126,200,255,0.18);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 3px;
}
.msg-ai-avatar svg { width: 13px; height: 13px; color: var(--azul-principal); opacity: .7; }
.msg-ai .bubble {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 15px;
  line-height: 1.78;
  color: var(--text-primary);
}

.msg-ai .bubble h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 22px 0 8px;
  letter-spacing: -0.01em;
  line-height: 1.4;
}
.msg-ai .bubble h3:first-child { margin-top: 0; }
.msg-ai .bubble h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 16px 0 5px;
}
.msg-ai .bubble p { margin-bottom: 12px; line-height: 1.78; }
.msg-ai .bubble p:last-child { margin-bottom: 0; }
.msg-ai .bubble ul, .msg-ai .bubble ol { padding-left: 20px; margin-bottom: 12px; }
.msg-ai .bubble li { margin-bottom: 6px; line-height: 1.72; }
.msg-ai .bubble blockquote {
  border-left: 2px solid rgba(126,200,255,0.3);
  padding: 6px 14px;
  margin: 14px 0;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 14px;
}

/* Separador sutil entre blocos de conteúdo */
.msg-ai .bubble hr, .content-sep {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 20px 0;
  opacity: 0.5;
}
.formula-inline {
  display: inline-block;
  background: rgba(126,200,255,.07);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  color: var(--azul-principal);
  font-style: normal;
}
.msg-ai .bubble code {
  background: rgba(126,200,255,0.07);
  border: 1px solid rgba(126,200,255,0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  color: var(--azul-principal);
}
.msg-ai .bubble .formula-block {
  background: rgba(126,200,255,0.04);
  border-left: 2px solid rgba(126,200,255,0.3);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 12px 18px;
  margin: 14px 0;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  color: var(--azul-principal);
  text-align: center;
  letter-spacing: .02em;
}

/* ── Botão trigger de ilustração ────────────────────────────── */
.vis-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,184,255,.06);
  border: 1px solid rgba(0,184,255,.22);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--azul-principal);
  font-size: 12.5px;
  font-family: var(--font-ui);
  cursor: pointer;
  margin: 8px 0;
  transition: background .18s, border-color .18s;
  line-height: 1.4;
}
.vis-trigger:hover { background: rgba(0,184,255,.12); border-color: rgba(0,184,255,.4); }
.vis-trigger.vis-active { background: rgba(0,184,255,.15); border-color: var(--azul-principal); }
.vis-trigger svg { width: 14px; height: 14px; flex-shrink: 0; opacity: .7; }
.vis-trigger .vis-icon { font-size: 15px; }

/* ── Painel de ilustração inline ────────────────────────────── */
.illu-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .3s cubic-bezier(.4,0,.2,1), opacity .25s ease;
  margin: 0 16px 0 54px;
}
.illu-panel.open {
  max-height: 520px;
  opacity: 1;
}
.illu-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.illu-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.illu-icon {
  font-size: 18px;
  opacity: .8;
  line-height: 1;
}
.illu-title {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--texto-primario);
  font-family: var(--font-ui);
}
.illu-desc {
  display: block;
  font-size: 10.5px;
  color: var(--cinza-prata);
  font-family: var(--font-ui);
  margin-top: 1px;
}
.illu-close {
  background: none;
  border: none;
  color: var(--cinza-prata);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color .15s;
}
.illu-close:hover { color: var(--texto-primario); }
.illu-close svg { width: 15px; height: 15px; }
.illu-canvas {
  padding: 12px 14px 10px;
  background: #0F1318;
  border-radius: 0 0 10px 10px;
}
.illu-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  margin-bottom: 8px;
}

/* Rodapé de identificação de assunto em cada resposta da IA */
.msg-footer-id {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.55;
  margin-top: 10px;
  margin-bottom: 2px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 500;
}

/* Chip de matéria detectada — sutil, quase um label */
.subject-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
  opacity: 0.75;
}
.subject-chip.mat-portugues,  .blib-chip.mat-portugues  { color: var(--azul-principal); }
.subject-chip.mat-matematica, .blib-chip.mat-matematica { color: var(--laranja-acao); }
.subject-chip.mat-ciencias,   .blib-chip.mat-ciencias   { color: #50dc78; }
.subject-chip.mat-biologia,   .blib-chip.mat-biologia   { color: #38c87a; }
.subject-chip.mat-fisica,     .blib-chip.mat-fisica     { color: #00cfcf; }
.subject-chip.mat-quimica,    .blib-chip.mat-quimica    { color: #a78bfa; }
.subject-chip.mat-historia,   .blib-chip.mat-historia   { color: #b478ff; }
.subject-chip.mat-geografia,  .blib-chip.mat-geografia  { color: #6ebf8b; }
.subject-chip.mat-financeiro, .blib-chip.mat-financeiro { color: #20c997; }
.subject-chip.mat-ingles,     .blib-chip.mat-ingles     { color: #60a5fa; }
.subject-chip.mat-filosofia,  .blib-chip.mat-filosofia  { color: #f472b6; }
.subject-chip.mat-sociologia, .blib-chip.mat-sociologia { color: #fb923c; }
.subject-chip.mat-artes,      .blib-chip.mat-artes      { color: #e879f9; }
.subject-chip.mat-redacao,    .blib-chip.mat-redacao    { color: #93c5fd; }
.subject-chip.mat-geral,      .blib-chip.mat-geral      { color: var(--cinza-prata); }
.subject-chip.mat-portugues   { background: rgba(126,200,255,.1); border: 1px solid rgba(126,200,255,.2); }
.subject-chip.mat-matematica  { background: rgba(255,138,51,.1);  border: 1px solid rgba(255,138,51,.2); }
.subject-chip.mat-ciencias    { background: rgba(80,220,120,.1);  border: 1px solid rgba(80,220,120,.2); }
.subject-chip.mat-biologia    { background: rgba(56,200,122,.1);  border: 1px solid rgba(56,200,122,.2); }
.subject-chip.mat-fisica      { background: rgba(0,207,207,.1);   border: 1px solid rgba(0,207,207,.2); }
.subject-chip.mat-quimica     { background: rgba(167,139,250,.1); border: 1px solid rgba(167,139,250,.2); }
.subject-chip.mat-historia    { background: rgba(180,120,255,.1); border: 1px solid rgba(180,120,255,.2); }
.subject-chip.mat-geografia   { background: rgba(110,191,139,.1); border: 1px solid rgba(110,191,139,.2); }
.subject-chip.mat-financeiro  { background: rgba(32,201,151,.1);  border: 1px solid rgba(32,201,151,.2); }
.subject-chip.mat-ingles      { background: rgba(96,165,250,.1);  border: 1px solid rgba(96,165,250,.2); }
.subject-chip.mat-filosofia   { background: rgba(244,114,182,.1); border: 1px solid rgba(244,114,182,.2); }
.subject-chip.mat-sociologia  { background: rgba(251,146,60,.1);  border: 1px solid rgba(251,146,60,.2); }
.subject-chip.mat-artes       { background: rgba(232,121,249,.1); border: 1px solid rgba(232,121,249,.2); }
.subject-chip.mat-redacao     { background: rgba(147,197,253,.1); border: 1px solid rgba(147,197,253,.2); }
.subject-chip.mat-geral       { background: rgba(166,176,186,.1); border: 1px solid rgba(166,176,186,.2); }

/* ── Biblioteca de Ramificações ────────────────────────────── */
.blib-overlay { position: fixed; inset: 0; z-index: 1199; background: rgba(0,0,0,.45); }
.branch-library-panel {
  display: none; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  z-index: 1200; width: 500px; max-width: calc(100vw - 32px);
  background: #13171E; border: 1px solid #1E2A36;
  border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,.7); overflow: hidden;
}
.branch-library-panel.open { display: block; }
.blib-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid #1E2A36; }
.blib-title { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: #7EC8FF; }
.blib-close { width: 26px; height: 26px; border-radius: 6px; background: #1A2230; border: none; color: #5A7A9A; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1; transition: background .15s, color .15s; }
.blib-close:hover { background: #1E2A3A; color: #C8D1DA; }
.blib-body { padding: 18px 20px 20px; }
.blib-section-label { font-size: 10px; font-weight: 700; letter-spacing: .08em; color: #3A4A5A; margin-bottom: 12px; }
.blib-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-bottom: 14px; }
.blib-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 11px 6px 9px; border-radius: 10px; cursor: pointer; border: 2px solid transparent; background: #0F1318; position: relative; transition: transform .15s, opacity .15s, border-color .15s; text-align: center; opacity: .5; }
.blib-chip:hover { transform: translateY(-2px); opacity: .85; }
.blib-chip.active { opacity: 1; border-color: currentColor; background: rgba(255,255,255,.03); }
.blib-chip.active:hover { transform: none; }
.blib-abbr { font-size: 16px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.blib-name { font-size: 9px; font-weight: 600; color: #7A8A9A; line-height: 1.2; }
.blib-check { display: none; position: absolute; top: 4px; right: 4px; width: 13px; height: 13px; border-radius: 50%; background: currentColor; align-items: center; justify-content: center; font-size: 8px; font-weight: 800; color: #0F1318; }
.blib-chip.active .blib-check { display: flex; }
.blib-legend { display: flex; gap: 14px; margin-bottom: 16px; font-size: 10px; color: #3A4A5A; }
.blib-legend-item { display: flex; align-items: center; gap: 5px; }
.blib-legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.blib-divider { height: 1px; background: #1E2A36; margin: 0 0 14px; }
.blib-custom-row { display: flex; gap: 8px; align-items: center; }
.blib-custom-input { flex: 1; background: #0F1318; border: 1px solid #1E2A36; border-radius: 8px; padding: 8px 12px; color: #C8D1DA; font-size: 12px; font-family: inherit; outline: none; transition: border-color .15s; }
.blib-custom-input:focus { border-color: #2E4A6A; }
.blib-custom-input::placeholder { color: #2A3A4A; }
.blib-custom-btn { background: #1E3050; border: 1px solid #2E4A6A; border-radius: 8px; color: #7EC8FF; font-size: 12px; font-weight: 600; padding: 8px 14px; cursor: pointer; white-space: nowrap; transition: background .15s; }
.blib-custom-btn:hover { background: #253A60; }

/* Ações da mensagem IA — flutuam abaixo, sem borda */
.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 12px;
  opacity: 0;
  transition: opacity .2s;
}
.msg-ai:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 11px;
  color: var(--text-muted);
  transition: all var(--t);
  border: 1px solid transparent;
}
.msg-action-btn svg { width: 12px; height: 12px; }
.msg-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
}
.typing-dots {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}
.typing-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
  animation: bounce .9s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Bloco de ilustração sketch interativo ──────────────────── */
.illu-block {
  background: rgba(126,200,255,0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 14px 16px 12px;
  margin: 10px 0 22px;
  max-width: 400px;
  animation: fadeIn .2s ease;
}
.illu-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.illu-label {
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.illu-label strong { color: var(--text-secondary); font-weight: 600; text-transform: none; letter-spacing: 0; }
.illu-close-btn {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  transition: background var(--t), color var(--t);
}
.illu-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.illu-close-btn svg { width: 11px; height: 11px; }
.illu-svg-wrap { width: 100%; border-radius: var(--r-sm); overflow: hidden; }
.illu-svg-wrap svg { display: block; width: 100%; height: auto; }
.illu-ftr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.illu-dots { display: flex; gap: 5px; align-items: center; }
.illu-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--border-light);
  transition: background .2s;
}
.illu-dot.active { background: var(--azul-principal); }
.illu-refine-btn {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-subtle);
  transition: all var(--t);
}
.illu-refine-btn:hover { border-color: var(--azul-principal); color: var(--azul-principal); background: rgba(126,200,255,0.05); }
.illu-max { font-size: 10px; color: var(--text-muted); opacity: 0.5; }

/* ── Navegação bidirecional de sketches ──────────────────────── */
.illu-nav-btn {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-subtle);
  transition: all var(--t);
  cursor: pointer;
  background: none;
}
.illu-nav-btn:hover { border-color: var(--azul-principal); color: var(--azul-principal); background: rgba(126,200,255,0.05); }
.illu-nav-off { opacity: 0.25; pointer-events: none; border-color: transparent !important; background: none !important; }

/* ── Ilustração gerada por IA (Pollinations) ─────────────────── */
.illu-ai-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  color: #9c6fea;
  background: rgba(156,111,234,0.1);
  border: 1px solid rgba(156,111,234,0.25);
  border-radius: 99px;
  padding: 1px 7px;
}
.illu-ai-img-wrap {
  width: 100%;
  min-height: 120px;
  border-radius: var(--r-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.02);
}
.illu-ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
}
.illu-ai-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border-subtle);
  border-top-color: #9c6fea;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.illu-ai-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-sm);
}
.illu-ai-img.hidden { display: none; }
.illu-ai-credit {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ── Placeholders de ilustração (durante o stream) ───────────── */
.vis-pending {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(0,184,255,0.06);
  border: 1px solid rgba(0,184,255,0.2);
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0;
  animation: pulse-vis 1.4s ease-in-out infinite;
}
.sketch-pending { display: block; height: 4px; }
@keyframes pulse-vis {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── Ilustração interativa inline (auto-renderizada) ─────────── */
.illu-inline {
  margin: 10px 0;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  overflow: hidden;
}
.illu-inline-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.illu-inline-icon { font-size: 15px; }
.illu-inline-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}
.illu-interact-badge {
  font-size: 9.5px;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(80,220,120,0.08);
  border: 1px solid rgba(80,220,120,0.2);
  color: #50dc78;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.illu-inline-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: flex; padding: 2px;
  border-radius: 4px; transition: all var(--t);
}
.illu-inline-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.illu-inline-close svg { width: 11px; height: 11px; }
.illu-inline-canvas { padding: 12px 14px 8px; }
.illu-inline-hint {
  padding: 4px 14px 8px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.65;
}

/* ── Balão de Significado ─────────────────────────────────────── */
.meaning-balloon {
  position: fixed;
  z-index: 650;
  display: none;
  flex-direction: column;
  min-width: 220px;
  max-width: 300px;
  background: rgba(14,22,36,0.97);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 14px 13px;
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);
  animation: balloonIn .15s cubic-bezier(.2,.8,.4,1);
  pointer-events: all;
}
.meaning-balloon::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px; height: 5px;
  background: rgba(14,22,36,0.97);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.meaning-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}
.meaning-word {
  font-size: 10.5px;
  color: var(--azul-principal);
  font-weight: 600;
  letter-spacing: .04em;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meaning-close-btn {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  border-radius: 3px;
  transition: color var(--t);
  flex-shrink: 0;
}
.meaning-close-btn:hover { color: var(--text-primary); }
.meaning-close-btn svg { width: 10px; height: 10px; }
.meaning-content {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-secondary);
}
.meaning-loading {
  display: flex;
  gap: 4px;
  padding: 3px 0;
}
.meaning-loading span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--azul-principal);
  opacity: 0.5;
  animation: bounce .9s infinite;
}
.meaning-loading span:nth-child(2) { animation-delay: .15s; }
.meaning-loading span:nth-child(3) { animation-delay: .3s; }

/* ============================================================
   INPUT BAR
   ============================================================ */
.input-bar-wrap {
  flex-shrink: 0;
  padding: 8px 24px 12px;
  background: var(--bg-app);
}

.input-bar {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-input);
  padding: 10px 14px 8px;
  transition: border-color var(--t), box-shadow var(--t);
  max-width: 660px;
  margin: 0 auto;
}

.input-bar:focus-within {
  border-color: var(--azul-destaque);
  box-shadow: var(--glow-blue), var(--shadow-input);
}

.input-meta { min-height: 4px; margin-bottom: 4px; }

.detected-subject {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input {
  flex: 1;
  resize: none;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
  background: transparent;
  max-height: 160px;
  overflow-y: auto;
}
.chat-input::placeholder { color: var(--text-muted); }

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding-bottom: 2px;
}

.attach-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: all var(--t);
}
.attach-btn svg { width: 16px; height: 16px; }
.attach-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

.audio-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t);
}
.audio-btn svg { width: 16px; height: 16px; }
.audio-btn:hover { background: var(--bg-hover); color: var(--azul-destaque); }
.audio-btn.recording { color: #ff4d4d; animation: pulse-mic .8s ease-in-out infinite; }
.audio-btn.hidden { display: none; }
.audio-btn.recording {
  color: #ff4d4d;
  background: rgba(255,77,77,.1);
  animation: pulse-mic .8s ease-in-out infinite;
}
@keyframes pulse-mic { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .6; transform: scale(.92); } }

/* ── Preview de imagem anexada ─────────────────────────── */
.attach-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-hover);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  animation: fadeIn .15s ease;
}
.attach-preview-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}
.attach-preview-name {
  flex: 1;
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-preview-remove {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--t);
}
.attach-preview-remove svg { width: 12px; height: 12px; }
.attach-preview-remove:hover { background: rgba(255,77,77,.15); color: #ff6b6b; }

/* ── Barra de escuta (áudio ao vivo) ──────────────────── */
.audio-listening-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,77,77,.07);
  border: 1px solid rgba(255,77,77,.15);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  animation: fadeIn .15s ease;
}
.audio-pulse {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #ff4d4d;
  flex-shrink: 0;
  animation: pulse-dot .9s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: .5; }
}
.audio-listening-text {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}
.audio-stop-btn {
  font-size: 11px;
  font-weight: 600;
  color: #ff4d4d;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255,77,77,.3);
  background: rgba(255,77,77,.08);
  cursor: pointer;
  transition: all var(--t);
}
.audio-stop-btn:hover { background: rgba(255,77,77,.18); }

/* Imagem do usuário no chat */
.user-msg-image {
  max-width: 200px;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  display: block;
  margin-bottom: 6px;
}

.send-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--azul-destaque), #0090cc);
  color: #fff;
  transition: all var(--t);
  box-shadow: 0 2px 10px rgba(0,184,255,.25);
}
.send-btn svg { width: 14px; height: 14px; }
.send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(0,184,255,.4); }
.send-btn:disabled { opacity: .4; pointer-events: none; }

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
}
.input-hint { font-size: 10px; color: var(--text-muted); }
.char-count  { font-size: 10px; color: var(--text-muted); }
/* ── Banner de manutenção ──────────────────────────────────── */
.maintenance-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #b45309;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.maintenance-banner svg { flex-shrink: 0; opacity: .9; }
.maintenance-banner span { flex: 1; }
.maintenance-banner button {
  background: none; border: none; cursor: pointer;
  color: #fff; opacity: .7; padding: 2px;
  display: flex; align-items: center;
  flex-shrink: 0;
}
.maintenance-banner button:hover { opacity: 1; }

.ai-disclaimer {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin: 6px auto 0;
  max-width: 660px;
  opacity: .6;
  line-height: 1.4;
  padding-bottom: 10px;
}

/* ============================================================
   MODAIS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,14,24,.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .15s ease;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-box--wide  { width: 720px; }
.modal-box--sm    { width: 360px; }
.modal-box--print {
  width: min(96vw, 1080px);
  height: min(90vh, 780px);
}

/* ── Print body: selector + preview ─────────────────────────── */
.print-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  border-top: 1px solid var(--border);
}
.print-selector {
  width: 230px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
  background: var(--bg-main);
}
.print-selector-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px 10px;
  margin-bottom: 2px;
}
.psel-branch { margin-bottom: 6px; }
.psel-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  user-select: none;
}
.psel-label:hover { background: var(--bg-active); }
.psel-branch-label .psel-name { font-weight: 600; font-size: 12px; color: var(--text-primary); }
.psel-topic { padding-left: 14px; margin-top: 2px; }
.psel-topic-label .psel-name { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.psel-entries { padding-left: 14px; margin-top: 2px; }
.psel-entry-label .psel-name { font-size: 11px; color: var(--text-muted); }
.psel-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.psel-cb { accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.psel-selectall {
  font-size: 10px;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 8px 8px;
  display: block;
}
.psel-selectall:hover { text-decoration: underline; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 15px; font-weight: 600; }

.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: all var(--t);
}
.modal-close svg { width: 16px; height: 16px; }
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-section h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
  gap: 12px;
}

.settings-input {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  width: 200px;
  flex-shrink: 0;
  transition: border-color var(--t);
}
.settings-input:focus { border-color: var(--azul-destaque); }
.settings-input option { background: var(--bg-card); }

/* ── Settings hint ─── */
.settings-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: -6px 0 10px;
  line-height: 1.4;
}

/* ── Tools toggle grid ─── */
.tools-toggle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.tool-toggle-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-card);
  transition: all var(--t);
  user-select: none;
}
.tool-toggle-item svg { width: 13px; height: 13px; flex-shrink: 0; }
.tool-toggle-item.active {
  border-color: var(--azul-destaque);
  color: var(--azul-destaque);
  background: rgba(126,200,255,.06);
}
.tool-toggle-check {
  margin-left: auto;
  font-size: 10px;
  color: var(--azul-destaque);
  font-weight: 700;
}
.tool-toggle-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Tool chip label ─── */
.tool-chip-label {
  font-size: 8px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  margin-top: 2px;
  line-height: 1;
}

.settings-access-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
}

.access-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  text-align: center;
  color: var(--text-secondary);
  transition: all var(--t);
}
.access-card svg { width: 20px; height: 20px; }
.access-card.access-active {
  border-color: var(--border-mid);
  color: var(--text-primary);
}
.access-card.access-soon { opacity: .55; }

.access-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 99px;
  background: var(--bg-hover);
  color: var(--text-muted);
}
.access-badge--active {
  background: rgba(0,184,255,.1);
  color: var(--azul-destaque);
}

.theme-toggle {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.theme-btn {
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-muted);
  transition: all var(--t);
}
.theme-btn--active { background: var(--bg-active); color: var(--text-primary); }

/* ── cfg-shell — Modal de Configurações duas colunas ───── */
.cfg-shell {
  display: flex;
  width: 900px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 48px);
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* Coluna esquerda — navegação */
.cfg-nav {
  display: flex;
  flex-direction: column;
  width: 196px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: 16px 10px 12px;
  gap: 2px;
  position: relative;
  overflow-y: auto;
}

.cfg-nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}
.cfg-nav-logo svg { width: 16px; height: 16px; color: var(--azul-destaque); flex-shrink: 0; }

.cfg-nav-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 4px;
}

.cfg-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t);
  text-align: left;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
}
.cfg-nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .7; }
.cfg-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.cfg-nav-item:hover svg { opacity: 1; }
.cfg-nav-item.active {
  background: var(--bg-active);
  color: var(--azul-destaque);
  font-weight: 600;
}
.cfg-nav-item.active svg { opacity: 1; }

.cfg-nav-spacer { flex: 1; }
.cfg-nav-logout { color: #c75e5e !important; margin-top: 2px; }
.cfg-nav-logout:hover { background: rgba(199,94,94,.1) !important; color: #e05555 !important; }
.cfg-nav-logout svg { opacity: .8 !important; }

.cfg-close {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t);
  align-self: flex-end;
}
.cfg-close svg { width: 16px; height: 16px; }
.cfg-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Coluna direita — conteúdo */
.cfg-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 24px;
  min-width: 0;
}

.cfg-tab { display: none; }
.cfg-tab.active { display: block; }

.cfg-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  letter-spacing: -.01em;
}

.cfg-section {
  margin-bottom: 22px;
}

.cfg-section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
  gap: 12px;
}
.cfg-row label { flex: 1; color: var(--text-secondary); font-size: 13px; }

.cfg-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
}

/* ── Plano & Conta ─────────────────────────────────────── */
.plan-current {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}
.plan-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  flex-shrink: 0;
}
.plan-free { background: rgba(126,200,255,.12); color: var(--azul-destaque); border: 1px solid rgba(126,200,255,.2); }
.plan-info { display: flex; flex-direction: column; gap: 2px; }
.plan-info strong { font-size: 13px; color: var(--text-primary); }
.plan-info span { font-size: 11.5px; color: var(--text-muted); }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.plan-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--t);
}
.plan-card:hover { border-color: var(--border-mid); }
.plan-card--active { border-color: var(--azul-destaque); background: rgba(0,184,255,.05); }

.plan-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}
.plan-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.plan-price { font-size: 16px; font-weight: 700; color: var(--azul-destaque); }
.plan-price small { font-size: 10px; color: var(--text-muted); font-weight: 400; }

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
  flex: 1;
}
.plan-features li { line-height: 1.4; }
.plan-features .dim { color: var(--text-muted); }

.plan-btn {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-hover);
  color: var(--text-muted);
  width: 100%;
  text-align: center;
  cursor: not-allowed;
}
.plan-current-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--azul-destaque);
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Badge beta */
.plan-beta {
  background: rgba(255,138,51,.12);
  color: var(--laranja-acao);
  border: 1px solid rgba(255,138,51,.22);
}

/* Grade 3 colunas */
.plan-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

/* Destaque do plano mais popular */
.plan-card--highlight {
  border-color: var(--azul-destaque);
  background: rgba(0,184,255,.06);
  position: relative;
}

/* Tag em cima de cada card */
.plan-card-tag {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.plan-card-tag--blue { color: var(--azul-destaque); }

/* Botão "Em breve" com destaque no Pro */
.plan-btn--soon {
  background: rgba(0,184,255,.12);
  color: var(--azul-destaque);
  cursor: not-allowed;
}

/* Card escola — futuro */
.plan-escola-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px dashed var(--border-mid);
  border-radius: var(--r-md);
}
.plan-escola-icon svg {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.plan-escola-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.plan-escola-info strong {
  font-size: 13px;
  color: var(--text-primary);
}
.plan-escola-info span {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.plan-escola-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--bg-hover);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── IA & Modelo ───────────────────────────────────────── */
.ia-model-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
}
.ia-model-logo svg { width: 40px; height: 40px; }
.ia-model-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.ia-model-maker { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.ia-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.ia-info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px;
}
.ia-info-label {
  color: var(--text-muted);
  min-width: 80px;
  flex-shrink: 0;
}
.ia-info-val { color: var(--text-primary); font-weight: 500; }

.ia-feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ia-feature-list li {
  font-size: 12.5px;
  color: var(--text-secondary);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}
.ia-feature-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--azul-destaque);
  font-size: 11px;
}

/* ── Termos / Privacidade — corpo legal ─────────────────── */
.cfg-legal-body {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.75;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cfg-legal-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: -4px;
}
.cfg-legal-body h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .03em;
  margin-bottom: -8px;
}
.cfg-legal-body p { line-height: 1.7; }
.cfg-legal-body strong { color: var(--text-primary); }

/* ── Sobre ─────────────────────────────────────────────── */
.sobre-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
}
.sobre-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.01em;
  font-family: 'Poppins', sans-serif;
}
.sobre-tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Print Preview ──────────────────────────────────────── */
.print-preview-area {
  overflow-y: auto;
  padding: 32px 40px;
  background: #fff;
  color: #1a1a2e;
  flex: 1;
  min-height: 400px;
}

.print-empty {
  text-align: center;
  padding: 48px 20px;
  color: #A6B0BA;
  font-size: 13px;
  line-height: 1.7;
}

/* Document header */
.print-doc-header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid #0E1624;
}
.print-doc-logo {
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #0E1624;
  letter-spacing: -.01em;
}
.print-doc-meta {
  font-size: 11px;
  color: #6e7a85;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* Branch section */
.print-section {
  margin-bottom: 32px;
}
.print-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e0e4e8;
}
.print-section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.print-section-name {
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #0E1624;
  flex: 1;
}
.print-section-count {
  font-size: 10px;
  color: #A6B0BA;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Topic block */
.print-topic {
  margin-bottom: 24px;
  padding-left: 16px;
  border-left: 2px solid #e8eaed;
}
.print-topic-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.print-topic-title {
  font-size: 13px;
  font-weight: 600;
  color: #2a3240;
  flex: 1;
}
.print-topic-date {
  font-size: 10px;
  color: #A6B0BA;
  white-space: nowrap;
}

/* Page entries */
.print-page-entry {
  margin-bottom: 14px;
}
.print-page-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #c0c8d0;
  margin-bottom: 6px;
}
.print-page-content,
.print-page-text {
  font-size: 13px;
  line-height: 1.7;
  color: #1a1a2e;
}
.print-page-content p, .print-page-text p  { margin: 0 0 8px; }
.print-page-content ul, .print-page-text ul,
.print-page-content ol, .print-page-text ol { margin: 0 0 8px; padding-left: 18px; }
.print-page-content li, .print-page-text li { margin-bottom: 3px; }
.print-page-content strong, .print-page-text strong { font-weight: 600; }
.print-page-content .katex-display, .print-page-text .katex-display { margin: 10px 0; }
.print-page-content .vis-trigger, .print-page-text .vis-trigger,
.print-page-content .vis-pending,  .print-page-text .vis-pending,
.print-page-content .sketch-pending, .print-page-text .sketch-pending,
.print-page-content .illu-inline,  .print-page-text .illu-inline,
.print-page-content .msg-actions,  .print-page-text .msg-actions,
.print-page-content .illu-panel,   .print-page-text .illu-panel { display: none !important; }
/* Sketches estáticos SÃO impressos (illu-block fica visível) */
@media print {
  .illu-inline { display: none !important; }
  .illu-block { break-inside: avoid; border: 1px solid #ddd; }
  .illu-nav-btn, .illu-close-btn, .print-entry-toolbar { display: none !important; }
}

/* Toolbar de remoção dentro do preview de impressão */
.print-entry-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.print-entry-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.print-page-entry:hover .print-entry-actions { opacity: 1; }
.print-el-remove {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #A6B0BA;
  background: none;
  border: 1px solid #dde0e4;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.print-el-remove:hover { color: #e05555; border-color: #e05555; background: rgba(224,85,85,.06); }
.print-el-remove--page:hover { color: #c0392b; border-color: #c0392b; }

.print-page-sep {
  border: none;
  border-top: 1px dashed #e8eaed;
  margin: 12px 0;
}

/* Botões ação */
.btn-confirm {
  background: linear-gradient(135deg, var(--azul-destaque), #0090cc);
  color: #fff;
  padding: 8px 20px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t);
}
.btn-confirm:hover { opacity: .9; transform: translateY(-1px); }
.btn-cancel {
  background: var(--bg-hover);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  border: 1px solid var(--border-subtle);
  transition: all var(--t);
}
.btn-cancel:hover { background: var(--bg-card); color: var(--text-primary); }

/* ── Busca global ─────────────────────────────────────────── */
.search-overlay {
  align-items: flex-start;
  padding-top: 80px;
}
.search-shell {
  width: 640px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  overflow: hidden;
  animation: slideDown .15s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.search-icon {
  width: 18px; height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.search-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
}
.search-input-field::placeholder { color: var(--text-muted); }
.search-esc-hint {
  font-size: 10px;
  font-family: inherit;
  color: var(--text-muted);
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.search-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px 0;
}

.search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.search-empty svg { width: 36px; height: 36px; opacity: .4; }

.search-no-results {
  padding: 32px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Grupo de resultados */
.search-group {
  padding: 0 8px 4px;
}
.search-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.search-group-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Item de resultado */
.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t);
}
.search-result-item:hover,
.search-result-item.focused {
  background: var(--bg-hover);
}
.search-result-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.search-result-excerpt {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.search-result-excerpt mark {
  background: rgba(0,184,255,.2);
  color: var(--azul-destaque);
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}
.search-result-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Busca inteligente por IA ─────────────────────────────── */
.search-ai-section {
  margin-top: 10px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}
.search-ai-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; color: var(--azul-destaque);
  padding: 0 4px 6px;
  opacity: .8;
}
.search-ai-item {
  display: flex; align-items: center; gap: 10px;
}
.search-result-label {
  font-size: 13px; color: var(--text-primary); font-weight: 500;
}
.search-result-branch {
  font-size: 11px; color: var(--text-muted); margin-top: 1px;
}

/* ── Tooltip ──────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  padding: 5px 9px;
  font-size: 11px;
  color: var(--text-secondary);
  pointer-events: none;
  box-shadow: var(--shadow-card);
  white-space: nowrap;
  animation: fadeIn .1s ease;
}

/* ── Balão de Seleção Contextual ─────────────────────────── */
.sel-balloon {
  position: fixed;
  z-index: 600;
  display: none;
  flex-direction: column;
  gap: 2px;
  background: rgba(13, 17, 26, 0.96);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  padding: 5px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  animation: balloonIn .15s cubic-bezier(.2,.8,.4,1);
  pointer-events: all;
}
.sel-balloon::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 5px;
  background: rgba(13, 17, 26, 0.96);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
@keyframes balloonIn {
  from { opacity: 0; transform: translateY(4px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.sel-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.82);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s;
  text-align: left;
}
.sel-opt:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sel-opt svg { width: 14px; height: 14px; flex-shrink: 0; opacity: .7; }
.sel-opt:hover svg { opacity: 1; }
.sel-opt[data-action="meaning"]:hover svg { color: #7EC8FF; }
.sel-opt[data-action="queue"]:hover svg   { color: #50dc78; }
.sel-opt[data-action="note"]:hover svg    { color: #F5C842; }
.sel-opt[data-action="branch"]:hover svg  { color: #b478ff; }

/* ── Drawers (Ferramentas laterais) ─────────────────────── */
.tool-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  z-index: 300;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.2,.8,.3,1);
  box-shadow: none;
}
.tool-drawer.open {
  transform: translateX(0);
  box-shadow: -8px 0 40px rgba(0,0,0,0.35);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.drawer-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.drawer-title-wrap svg { width: 16px; height: 16px; color: var(--text-secondary); flex-shrink: 0; }
.drawer-badge {
  background: #7EC8FF;
  color: #0A0E17;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}
.drawer-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.drawer-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.drawer-close svg { width: 14px; height: 14px; }

.drawer-desc {
  padding: 10px 16px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}
/* ── Picker de grupo de ilustrações ──────────────────────── */
.il-group-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.il-pick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 10px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t);
  min-width: 70px;
  flex: 1;
}
.il-pick-btn:hover { border-color: var(--azul-principal); color: var(--text-primary); background: rgba(126,200,255,.06); }
.il-pick-btn.active { border-color: var(--azul-principal); background: rgba(126,200,255,.1); color: var(--azul-principal); }
.il-pick-icon { font-size: 18px; line-height: 1; }
.il-pick-label { font-size: 10px; font-weight: 500; text-align: center; white-space: nowrap; }
.il-drawer-desc { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.il-drawer-canvas { width: 100%; }

.drawer-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ── Queue Items ─────────────────────────────────────────── */
.queue-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: border-color .15s;
}
.queue-item:hover { border-color: var(--border-mid); }
.queue-item-text {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 5px;
  line-height: 1.4;
}
.queue-item-meta {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.queue-item-actions {
  display: flex;
  gap: 6px;
}
.queue-study {
  flex: 1;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid rgba(126,200,255,0.3);
  background: rgba(126,200,255,0.07);
  color: #7EC8FF;
  font-size: 11px;
  cursor: pointer;
  transition: background .15s;
}
.queue-study:hover { background: rgba(126,200,255,0.15); }
.queue-remove {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.queue-remove:hover { background: rgba(255,80,80,0.1); color: #ff5050; border-color: rgba(255,80,80,0.2); }

/* ── Notepad ─────────────────────────────────────────────── */
.notepad-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notepad-ta {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 16px;
  border: none;
  outline: none;
  resize: none;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.7;
  box-sizing: border-box;
}
.notepad-ta::placeholder { color: var(--text-muted); }
.notepad-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.notepad-saved {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.notepad-saved.saving { color: #7EC8FF; }
.notepad-clear {
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  transition: background .15s, color .15s;
}
.notepad-clear:hover { background: rgba(255,80,80,0.1); color: #ff5050; }

/* ── Focus Widget ────────────────────────────────────────── */
.focus-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 400;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  backdrop-filter: blur(12px);
  overflow: hidden;
  animation: focusIn .2s cubic-bezier(.2,.8,.4,1);
}
@keyframes focusIn {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.focus-inner { padding: 16px 18px 12px; }
.focus-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.focus-mode-btns {
  display: flex;
  gap: 6px;
}
.focus-mode-btn {
  flex: 1;
  padding: 7px 4px;
  border-radius: 7px;
  border: 1px solid var(--border-mid);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.focus-mode-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.focus-mode-btn.active { background: rgba(126,200,255,0.12); border-color: rgba(126,200,255,0.4); color: #7EC8FF; }
.focus-display {
  font-family: 'Poppins', monospace;
  font-size: 38px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
  text-align: center;
  margin-bottom: 12px;
  transition: color .3s;
}
.focus-display.done { color: #50dc78; }
.focus-ctrl {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.focus-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-mid);
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.focus-btn svg { width: 14px; height: 14px; }
.focus-btn:hover { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-mid); }
.focus-widget-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .5;
  transition: opacity .15s;
}
.focus-widget-close:hover { opacity: 1; }
.focus-widget-close svg { width: 10px; height: 10px; }

/* ── Toast Notifications ─────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.nexus-toast {
  background: rgba(13, 17, 26, 0.94);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.88);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.nexus-toast.visible { opacity: 1; transform: translateY(0); }

/* ── Aviso de sistema (detecção automática de ramificação) ── */
.system-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 20px;
  padding: 4px 12px;
  margin: 8px auto;
  width: fit-content;
  max-width: 80%;
}
.system-notice strong { color: var(--text-secondary); }

/* ── Tool chip badge ─────────────────────────────────────── */
.tool-chip { position: relative; }
.tool-chip-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  background: #7EC8FF;
  color: #0A0E17;
  font-size: 8px;
  font-weight: 700;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

/* ── Calculadora ─────────────────────────────────────────── */
.calc-display {
  background: var(--bg-main);
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 2px;
}
.calc-expr {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 16px;
  word-break: break-all;
  text-align: right;
}
.calc-result {
  font-family: 'Poppins', monospace;
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
  text-align: right;
  letter-spacing: -.02em;
}
.calc-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px;
  flex: 1;
  align-content: start;
}
.calc-btn {
  padding: 0;
  height: 46px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .1s, transform .08s;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}
.calc-btn:active { transform: scale(.94); }
.calc-btn:hover { background: var(--bg-hover); }
.calc-sci {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-sidebar);
  height: 38px;
}
.calc-sci:hover { color: #7EC8FF; }
.calc-op { color: #7EC8FF; }
.calc-op:hover { background: rgba(126,200,255,0.1); }
.calc-eq {
  background: #7EC8FF;
  color: #0A0E17;
  border-color: #7EC8FF;
  font-size: 18px;
  font-weight: 600;
}
.calc-eq:hover { background: #9dd4ff; }
.calc-zero { grid-column: span 1; }

/* ── Conversor ───────────────────────────────────────────── */
.conv-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.conv-cat {
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border-mid);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: 'Inter', sans-serif;
}
.conv-cat:hover { background: var(--bg-hover); color: var(--text-primary); }
.conv-cat.active { background: rgba(126,200,255,0.12); border-color: rgba(126,200,255,0.4); color: #7EC8FF; }
.conv-body {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.conv-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.conv-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-mid);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  font-family: 'Poppins', sans-serif;
  outline: none;
  transition: border-color .15s;
}
.conv-input:focus { border-color: rgba(126,200,255,0.5); }
.conv-result { color: #7EC8FF; }
.conv-select {
  width: 90px;
  padding: 10px 8px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-mid);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  outline: none;
  cursor: pointer;
}
.conv-arrow {
  display: flex;
  justify-content: center;
  padding: 8px 0;
  color: var(--text-muted);
}
.conv-arrow svg { width: 20px; height: 20px; }

/* ── Fórmulas ────────────────────────────────────────────── */
.formula-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.formula-search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-mid);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
.formula-search-input:focus { border-color: rgba(126,200,255,0.4); }
.formula-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.formula-tab {
  flex: 1;
  padding: 9px 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  font-family: 'Inter', sans-serif;
}
.formula-tab:hover { color: var(--text-secondary); }
.formula-tab.active { color: #7EC8FF; border-bottom-color: #7EC8FF; }
.formula-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}
.formula-card {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.formula-card:hover { border-color: var(--border-mid); background: var(--bg-hover); }
.formula-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}
.formula-math {
  font-family: 'Poppins', monospace;
  font-size: 14px;
  color: #7EC8FF;
  background: rgba(126,200,255,0.07);
  padding: 4px 8px;
  border-radius: 5px;
  margin-bottom: 5px;
  word-break: break-all;
}
.formula-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Tabela Periódica — Painel Horizontal ────────────────── */
.periodic-panel {
  position: fixed;
  z-index: 250;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.55);
  display: none;
  flex-direction: column;
  height: 85vh;
  width: calc(88vw - var(--sidebar-w));
  min-width: 600px;
  overflow: hidden;
}
.periodic-panel.open { display: flex; }

/* Header */
.pt-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  cursor: move;
  user-select: none;
}
.pt-header input, .pt-header button { cursor: default; }
.pt-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.pt-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}
.pt-search {
  width: 200px;
  padding: 5px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-mid);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color .15s;
}
.pt-search:focus { border-color: rgba(126,200,255,0.4); }
.pt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}
.pt-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
}
.pt-legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pt-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.pt-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.pt-close svg { width: 13px; height: 13px; }

/* Detail strip */
.pt-detail-strip {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  animation: fadeIn .15s ease;
}
.pt-detail-sym {
  font-family: 'Poppins', sans-serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  min-width: 40px;
  text-align: center;
}
.pt-detail-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.pt-detail-cat  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.pt-detail-props {
  display: flex;
  gap: 20px;
  margin-left: 8px;
}
.pt-prop { display: flex; flex-direction: column; gap: 1px; }
.pt-prop-label { font-size: 8px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.pt-prop-val   { font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* Body — sem scroll, tudo encaixado */
.pt-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 8px 12px 8px;
  gap: 4px;
}

/* Main 18-column grid — flex:1 para preencher o espaço disponível */
.pt-main-grid {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* F-block (lanthanides + actinides) */
.pt-fblock {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
  border-top: 1px dashed var(--border-subtle);
  flex-shrink: 0;
}
.pt-frow {
  display: grid;
  grid-template-columns: 52px repeat(15, 1fr);
  gap: 3px;
  align-items: center;
}
.pt-frow-label {
  font-size: 8px;
  color: var(--text-muted);
  text-align: right;
  padding-right: 6px;
  line-height: 1.2;
}

/* Element chip */
.pt-chip {
  border-radius: 3px;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, border-color .1s, background .1s, z-index 0s;
  gap: 1px;
  padding: 1px;
  min-height: 0;
  overflow: hidden;
}
.pt-chip:hover {
  transform: scale(1.8);
  z-index: 20;
  background: var(--bg-hover) !important;
  border-color: currentColor !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
.pt-chip.selected { border-color: #fff !important; background: rgba(255,255,255,0.1) !important; }
.pt-chip.dimmed { opacity: 0.18; }
.pt-chip-placeholder {
  border-radius: 3px;
  border: 1px dashed var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6px;
  color: var(--text-muted);
  min-height: 0;
}
.pt-z    { font-size: 7px; line-height: 1; }
.pt-sym  { font-size: 12px; font-weight: 700; line-height: 1; }
.pt-name { font-size: 6px; line-height: 1; text-align: center; color: rgba(255,255,255,0.4); }

/* ── Mapa Geográfico — Painel Overlay ───────────────────── */
.map-panel {
  position: fixed;
  left: var(--sidebar-w);
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 280;
  background: #0d1117;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.2,.8,.3,1);
}
.map-panel.open { transform: translateX(0); }
.sidebar.collapsed ~ * .map-panel { left: 60px; }

/* Top bar */
.map-ui-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: linear-gradient(to bottom, rgba(13,17,23,0.95) 60%, transparent);
  pointer-events: none;
}
.map-ui-top > * { pointer-events: auto; }
.map-panel-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  letter-spacing: .04em;
  white-space: nowrap;
}
.map-scene-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-align: center;
  animation: fadeIn .3s ease;
}
.map-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.map-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
.map-close svg { width: 13px; height: 13px; }

/* Map container (Leaflet renders here) */
.map-container {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #0d1117;
}

/* Leaflet dark-theme overrides */
.leaflet-container {
  background: #0d1117 !important;
  font-family: 'Inter', sans-serif;
}
.leaflet-control-zoom {
  border: 1px solid rgba(255,255,255,0.12) !important;
  background: rgba(13,17,23,0.85) !important;
  backdrop-filter: blur(8px);
}
.leaflet-control-zoom a {
  background: transparent !important;
  color: rgba(255,255,255,0.6) !important;
  border-color: rgba(255,255,255,0.1) !important;
  line-height: 26px !important;
}
.leaflet-control-zoom a:hover { color: #fff !important; background: rgba(255,255,255,0.08) !important; }
.leaflet-control-attribution {
  background: rgba(13,17,23,0.7) !important;
  color: rgba(255,255,255,0.3) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: rgba(255,255,255,0.4) !important; }
.leaflet-popup-content-wrapper {
  background: rgba(18,24,32,0.97) !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
  color: #fff !important;
  font-size: 12px !important;
  font-family: 'Inter', sans-serif !important;
  font-weight: 500 !important;
}
.leaflet-popup-tip { background: rgba(18,24,32,0.97) !important; }
.leaflet-popup-close-button { color: rgba(255,255,255,0.4) !important; }
.leaflet-popup-close-button:hover { color: #fff !important; }

/* Animated line layers */
@keyframes map-dash-flow {
  to { stroke-dashoffset: -24; }
}
.leaflet-interactive.map-animated-line {
  animation: map-dash-flow 1.4s linear infinite;
}

/* Legend overlay */
.map-legend-wrap {
  position: absolute;
  bottom: 90px;
  left: 14px;
  z-index: 10;
  pointer-events: none;
}
.map-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(13,17,23,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px;
}
.map-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
}
.map-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.map-legend-line {
  width: 18px;
  height: 2px;
  flex-shrink: 0;
  border-radius: 2px;
}

/* Bottom bar */
.map-ui-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 0 14px 14px;
  background: linear-gradient(to top, rgba(13,17,23,0.97) 60%, transparent);
}
.map-chips-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  justify-content: center;
}
.map-chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.65);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.map-chip:hover { background: rgba(255,255,255,0.13); color: #fff; border-color: rgba(255,255,255,0.3); }
.map-chip.active { background: rgba(126,200,255,0.15); color: #7EC8FF; border-color: rgba(126,200,255,0.4); }
.map-query-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 30px;
  padding: 8px 12px;
  transition: border-color .15s;
}
.map-query-wrap:focus-within { border-color: rgba(126,200,255,0.4); }
.map-query-icon { width: 14px; height: 14px; color: rgba(255,255,255,0.35); flex-shrink: 0; }
.map-query-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
}
.map-query-input::placeholder { color: rgba(255,255,255,0.3); }
.map-query-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(126,200,255,0.2);
  color: #7EC8FF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.map-query-btn:hover { background: rgba(126,200,255,0.35); }
.map-query-btn svg { width: 13px; height: 13px; }

/* ── Tabuada ─────────────────────────────────────────────── */
.tabuada-wrap { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.tabuada-selector { display: flex; flex-direction: column; gap: 8px; }
.tabuada-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.tabuada-nums { display: flex; flex-wrap: wrap; gap: 5px; }
.tabuada-num {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border-mid);
  background: var(--bg-card); color: var(--text-secondary);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--t);
}
.tabuada-num:hover { border-color: var(--azul-destaque); color: var(--azul-destaque); }
.tabuada-num.active { background: var(--azul-destaque); color: #fff; border-color: var(--azul-destaque); }
.tabuada-grid { display: flex; flex-direction: column; gap: 4px; }
.tabuada-row {
  display: grid; grid-template-columns: 28px 18px 28px 18px 40px;
  align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 6px;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  font-size: 14px;
}
.tabuada-a, .tabuada-b { font-weight: 700; color: var(--text-primary); }
.tabuada-op, .tabuada-eq { color: var(--text-muted); text-align: center; }
.tabuada-r { font-weight: 800; color: var(--azul-destaque); font-size: 15px; }

/* ── Conjugador ─────────────────────────────────────────── */
.conj-wrap { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.conj-input-row { display: flex; gap: 6px; }
.conj-input {
  flex: 1; padding: 7px 10px; border-radius: var(--r-md);
  border: 1px solid var(--border-mid); background: var(--bg-card);
  color: var(--text-primary); font-size: 13px; outline: none; font-family: 'Inter', sans-serif;
}
.conj-input:focus { border-color: var(--azul-destaque); }
.conj-btn {
  padding: 7px 14px; border-radius: var(--r-md); border: none;
  background: var(--azul-destaque); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: opacity var(--t);
}
.conj-btn:hover { opacity: .85; }
.conj-result { display: flex; flex-direction: column; gap: 10px; }
.conj-tempo { background: var(--bg-card); border-radius: 8px; overflow: hidden; border: 1px solid var(--border-subtle); }
.conj-tempo-nome { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--azul-destaque); padding: 6px 10px; border-bottom: 1px solid var(--border-subtle); }
.conj-formas { display: grid; grid-template-columns: 1fr 1fr; }
.conj-forma { display: flex; gap: 6px; align-items: baseline; padding: 5px 10px; border-bottom: 1px solid var(--border-subtle); }
.conj-forma:nth-last-child(-n+2) { border-bottom: none; }
.conj-pron { font-size: 10px; color: var(--text-muted); min-width: 55px; }
.conj-verb { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.conj-tip { font-size: 12px; color: var(--text-muted); text-align: center; padding: 20px; }

/* ── Linha do tempo ─────────────────────────────────────── */
.timeline-wrap { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.timeline-add-row { display: flex; gap: 6px; }
.tl-year {
  width: 70px; padding: 7px 8px; border-radius: var(--r-md);
  border: 1px solid var(--border-mid); background: var(--bg-card);
  color: var(--text-primary); font-size: 13px; outline: none; font-family: 'Inter', sans-serif;
}
.tl-event {
  flex: 1; padding: 7px 10px; border-radius: var(--r-md);
  border: 1px solid var(--border-mid); background: var(--bg-card);
  color: var(--text-primary); font-size: 13px; outline: none; font-family: 'Inter', sans-serif;
}
.tl-year:focus, .tl-event:focus { border-color: var(--azul-destaque); }
.tl-add-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--azul-destaque); color: #fff; font-size: 18px; font-weight: 300;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: opacity var(--t);
}
.tl-add-btn:hover { opacity: .85; }
.timeline-list { display: flex; flex-direction: column; gap: 0; position: relative; }
.timeline-list::before { content: ''; position: absolute; left: 42px; top: 0; bottom: 0; width: 1px; background: var(--border-mid); }
.tl-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; position: relative;
}
.tl-year-badge {
  min-width: 70px; text-align: right; font-size: 12px; font-weight: 700;
  color: var(--azul-destaque); flex-shrink: 0;
}
.tl-event-text { flex: 1; font-size: 13px; color: var(--text-primary); padding-left: 12px; }
.tl-del { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 0 4px; transition: color var(--t); }
.tl-del:hover { color: #ff4d4d; }
.tl-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 20px; }

/* ── ABNT / APA ─────────────────────────────────────────── */
.abnt-wrap { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.abnt-type-row { display: flex; gap: 5px; }
.abnt-type-btn {
  padding: 5px 14px; border-radius: 99px; border: 1px solid var(--border-mid);
  background: transparent; color: var(--text-secondary); font-size: 12px; cursor: pointer; transition: all var(--t);
}
.abnt-type-btn.active { background: var(--azul-destaque); border-color: var(--azul-destaque); color: #fff; }
.abnt-fields { display: flex; flex-direction: column; gap: 6px; }
.abnt-field-row { display: flex; flex-direction: column; gap: 3px; }
.abnt-field-label { font-size: 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.abnt-field-input {
  padding: 6px 10px; border-radius: var(--r-md); border: 1px solid var(--border-mid);
  background: var(--bg-card); color: var(--text-primary); font-size: 12px; outline: none; font-family: 'Inter', sans-serif;
}
.abnt-field-input:focus { border-color: var(--azul-destaque); }
.abnt-generate-btn {
  padding: 8px; border-radius: var(--r-md); border: none;
  background: var(--azul-destaque); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity var(--t);
}
.abnt-generate-btn:hover { opacity: .85; }
.abnt-result-wrap { display: flex; flex-direction: column; gap: 8px; }
.abnt-norm-row { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 8px 10px; }
.abnt-norm-label { font-size: 9px; font-weight: 700; letter-spacing: .08em; color: var(--azul-destaque); text-transform: uppercase; display: block; margin-bottom: 4px; }
.abnt-result { font-size: 11px; color: var(--text-primary); white-space: pre-wrap; margin: 0; font-family: 'Inter', sans-serif; line-height: 1.5; }
.abnt-copy {
  margin-top: 6px; padding: 4px 10px; border-radius: var(--r-sm); border: 1px solid var(--border-mid);
  background: transparent; color: var(--text-muted); font-size: 10px; cursor: pointer; transition: all var(--t);
}
.abnt-copy:hover { border-color: var(--azul-destaque); color: var(--azul-destaque); }

/* ============================================================
   TEMA CLARO
   Sidebar: azul petróleo (#0A2240)
   Fundo: prata claro (#EEF2F7 / branco)
   Texto: ardósia escura, não preto puro (#1B2B3C)
   ============================================================ */

body.theme-light {
  /* Superfícies — área principal */
  --bg-app:      #EEF2F7;
  --bg-card:     #FFFFFF;
  --bg-input:    #FFFFFF;
  --bg-hover:    #E4ECF6;
  --bg-active:   #D5E3F2;
  --bg-sidebar:  #0A1120;   /* azul escuro — sidebar permanece escura */

  /* Texto */
  --text-primary:   #1B2B3C;
  --text-secondary: #4A6180;
  --text-muted:     #8298B2;

  /* Bordas */
  --border-subtle: rgba(26,43,60,.07);
  --border-light:  rgba(26,43,60,.12);
  --border-mid:    rgba(26,43,60,.20);

  /* Sombras mais suaves no claro */
  --shadow-card:  0 4px 20px rgba(26,43,60,.10);
  --shadow-input: 0 2px 12px rgba(26,43,60,.08);
  --glow-blue:    0 0 16px rgba(0,184,255,.10);
}

/* ── Sidebar permanece com identidade azul petróleo ─────────── */
body.theme-light .sidebar {
  border-right-color: rgba(255,255,255,.06);
}
body.theme-light .logo-nexus { color: #E8F0FA; }
body.theme-light .nav-item   { color: rgba(232,240,250,.72); }
body.theme-light .nav-item:hover {
  background: rgba(126,200,255,.10);
  color: #E8F0FA;
}
body.theme-light .nav-item--primary { color: var(--azul-destaque); }
body.theme-light .section-toggle    { color: rgba(232,240,250,.55); }
body.theme-light .section-toggle:hover { color: rgba(232,240,250,.85); }
body.theme-light .sidebar-bottom-btn { color: rgba(232,240,250,.6); }
body.theme-light .sidebar-bottom-btn:hover {
  background: rgba(126,200,255,.10);
  color: #E8F0FA;
}
body.theme-light .branch-item       { color: rgba(232,240,250,.8); }
body.theme-light .branch-item:hover { background: rgba(126,200,255,.08); }
body.theme-light .branch-item.active { background: rgba(126,200,255,.14); }
body.theme-light .topic-row         { color: rgba(232,240,250,.72); }
body.theme-light .topic-row:hover   { background: rgba(126,200,255,.08); }
body.theme-light .topic-row.active-topic { color: var(--azul-destaque); }
body.theme-light .collapsible-panel { background: transparent; }
body.theme-light .tool-chip {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.12);
  color: rgba(232,240,250,.75);
}
body.theme-light .tool-chip:hover {
  background: rgba(126,200,255,.18);
  border-color: rgba(126,200,255,.35);
  color: #E8F0FA;
  transform: scale(1.07);
}
body.theme-light .sidebar-resize-handle:hover,
body.theme-light .sidebar-resize-handle.dragging { background: rgba(255,255,255,.05); }

/* ── Área principal — main header ───────────────────────────── */
body.theme-light .main-header {
  background: var(--bg-app);
  border-bottom: 1px solid rgba(26,43,60,.07);
  box-shadow: none;
}
body.theme-light .toggle-sidebar-btn { color: var(--text-secondary); }
body.theme-light .toggle-sidebar-btn:hover { background: var(--bg-hover); }
body.theme-light .btn-acao {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
body.theme-light .btn-acao:hover { background: var(--bg-hover); }

/* ── Chat — área de mensagens ───────────────────────────────── */
body.theme-light .chat-messages { background: var(--bg-app); }

body.theme-light .msg-user .bubble {
  background: rgba(10,34,64,.06);
  border-color: rgba(10,34,64,.10);
  color: var(--text-primary);
}

body.theme-light .msg-ai .bubble { color: var(--text-primary); }
body.theme-light .msg-ai .bubble h3 { color: var(--text-primary); }
body.theme-light .msg-ai .bubble h4 { color: var(--text-secondary); }
body.theme-light .msg-ai .bubble code {
  background: rgba(10,34,64,.06);
  color: #0A6EBD;
  border-color: rgba(10,34,64,.10);
}
body.theme-light .msg-ai .bubble pre {
  background: rgba(10,34,64,.04);
  border: 1px solid rgba(10,34,64,.10);
}
body.theme-light .msg-ai .bubble blockquote {
  border-left-color: var(--azul-destaque);
  background: rgba(0,184,255,.05);
}
body.theme-light .msg-ai-avatar {
  background: rgba(10,34,64,.06);
  border-color: rgba(10,34,64,.12);
}

/* ── Input bar ──────────────────────────────────────────────── */
body.theme-light .input-bar-wrap { background: var(--bg-app); border-top: 1px solid rgba(26,43,60,.07); }
body.theme-light .input-bar {
  background: var(--bg-input);
  border-color: var(--border-light);
  box-shadow: 0 2px 12px rgba(26,43,60,.07);
}
body.theme-light .chat-input { color: var(--text-primary); }
body.theme-light .chat-input::placeholder { color: var(--text-muted); }
body.theme-light .attach-btn { color: var(--text-muted); }
body.theme-light .attach-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

/* ============================================================
   PAINEL DE PESQUISA NA INTERNET
   ============================================================ */
.web-search-panel {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 290;
  background: var(--bg-app);
  display: none;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
}

.web-search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.web-search-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.web-search-badge {
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(0,184,255,.1);
  color: #00B8FF;
  border-radius: 20px;
  border: 1px solid rgba(0,184,255,.2);
}

.web-search-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.web-search-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.web-search-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.web-search-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}
.web-search-empty p { font-size: 14px; max-width: 320px; line-height: 1.5; }

.web-search-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.web-search-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 14px;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
}
.web-search-input:focus { outline: none; border-color: rgba(0,184,255,.4); }
.web-search-input::placeholder { color: var(--text-muted); }

.web-search-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: #00B8FF;
  color: #000;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--t);
}
.web-search-send:hover { opacity: .85; }

/* Mensagens do chat de pesquisa */
.wsearch-msg {
  max-width: 780px;
  line-height: 1.65;
  font-size: 14px;
  border-radius: var(--r-md);
  padding: 12px 16px;
  word-break: break-word;
}
.wsearch-msg--user {
  align-self: flex-end;
  background: rgba(0,184,255,.12);
  border: 1px solid rgba(0,184,255,.2);
  color: var(--text-primary);
  max-width: 60%;
}
.wsearch-msg--ai {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 100%;
}
.wsearch-msg--ai a {
  color: #00B8FF;
  text-decoration: underline;
  word-break: break-all;
}
.wsearch-thinking {
  color: var(--text-muted);
  font-style: italic;
  animation: wsearch-blink 1.2s ease-in-out infinite;
}
@keyframes wsearch-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* Wrapper 16:9 para iframes do YouTube */
.wsearch-yt-wrap {
  margin: 12px 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #000;
}
.wsearch-yt-wrap iframe {
  display: block;
  width: 100%;
  height: 200px;
  border: none;
}

/* ============================================================
   PAINEL DE ARQUIVO
   ============================================================ */
.arquivo-panel {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 290;
  background: var(--bg-app);
  display: none;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
}

.arquivo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.arquivo-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.arquivo-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.arquivo-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.arquivo-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.arquivo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 60px 40px;
}
.arquivo-empty p { font-size: 14px; max-width: 300px; line-height: 1.5; }

.arquivo-group { display: flex; flex-direction: column; gap: 12px; }
.arquivo-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #c97c20;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.arquivo-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 12px 14px;
  transition: border-color var(--t);
}
.arquivo-item:hover { border-color: var(--border-light); }

.arquivo-item-thumb {
  width: 80px;
  height: 46px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
}
.arquivo-item-thumb svg { width: 100%; height: 100%; }

.arquivo-item-info {
  flex: 1;
  min-width: 0;
}
.arquivo-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  border-radius: 4px;
  padding: 1px 4px;
  margin: -1px -4px;
}
.arquivo-item-name:focus {
  background: var(--bg-input);
  white-space: normal;
  overflow: visible;
}
.arquivo-item-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.arquivo-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.arquivo-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity var(--t);
}
.arquivo-btn--download {
  background: rgba(201,124,32,.15);
  color: #c97c20;
  border: 1px solid rgba(201,124,32,.25);
}
.arquivo-btn--download:hover { opacity: .8; }
.arquivo-btn--delete {
  background: rgba(255,80,80,.1);
  color: #ff6b6b;
  border: 1px solid rgba(255,80,80,.2);
  padding: 5px 8px;
}
.arquivo-btn--delete:hover { opacity: .8; }

/* Botão Guardar nas ilustrações */
.illu-guardar-btn {
  background: rgba(201,124,32,.15);
  color: #c97c20;
  border: 1px solid rgba(201,124,32,.25);
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  cursor: pointer;
  transition: opacity var(--t);
  margin-left: auto;
}
.illu-guardar-btn:hover { opacity: .8; }

/* Modal de escolha de matéria para guardar */
.arquivo-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.arquivo-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  padding: 24px;
  min-width: 260px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-card);
}
.arquivo-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}
.arquivo-modal-subjects {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.arquivo-modal-subject {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 16px;
  cursor: pointer;
  text-align: left;
  transition: background var(--t), border-color var(--t);
}
.arquivo-modal-subject:hover { background: var(--bg-hover); border-color: var(--border-mid); }
.arquivo-modal-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  padding: 6px;
  transition: color var(--t);
}
.arquivo-modal-cancel:hover { color: var(--text-secondary); }
body.theme-light .audio-btn { color: var(--text-muted); }
body.theme-light .audio-btn:hover { background: var(--bg-hover); color: var(--azul-destaque); }
body.theme-light .char-count { color: var(--text-muted); }
body.theme-light .input-hint  { color: var(--text-muted); }

/* ── Welcome screen ─────────────────────────────────────────── */
body.theme-light .welcome-screen { background: var(--bg-app); }
body.theme-light .welcome-title  { color: var(--text-primary); }
body.theme-light .welcome-sub    { color: var(--text-secondary); }
body.theme-light .welcome-chip   {
  background: rgba(10,34,64,.05);
  border-color: rgba(10,34,64,.10);
  color: var(--text-secondary);
}
body.theme-light .welcome-chip:hover { background: var(--bg-active); }

/* ── Modais ─────────────────────────────────────────────────── */
body.theme-light .modal-box {
  background: #FFFFFF;
  border-color: var(--border-mid);
}
body.theme-light .modal-header { border-bottom-color: var(--border-light); }
body.theme-light .modal-close:hover { background: var(--bg-hover); }

/* ── cfg-shell (Configurações) ──────────────────────────────── */
body.theme-light .cfg-shell { background: #FFFFFF; border-color: var(--border-mid); }
body.theme-light .cfg-nav {
  background: #0A2240;
  border-right-color: rgba(255,255,255,.06);
}
body.theme-light .cfg-nav-logo { color: #E8F0FA; }
body.theme-light .cfg-nav-logo svg { color: var(--azul-destaque); }
body.theme-light .cfg-nav-item { color: rgba(232,240,250,.72); }
body.theme-light .cfg-nav-item:hover { background: rgba(126,200,255,.10); color: #E8F0FA; }
body.theme-light .cfg-nav-item.active { background: rgba(126,200,255,.16); color: var(--azul-destaque); }
body.theme-light .cfg-close { color: rgba(232,240,250,.55); }
body.theme-light .cfg-close:hover { background: rgba(126,200,255,.10); color: #E8F0FA; }
body.theme-light .cfg-title  { color: var(--text-primary); }
body.theme-light .cfg-row label { color: var(--text-secondary); }
body.theme-light .cfg-hint   { color: var(--text-muted); }
body.theme-light .settings-input {
  background: var(--bg-input);
  border-color: var(--border-light);
  color: var(--text-primary);
}
body.theme-light .plan-card  { background: var(--bg-input); border-color: var(--border-light); }
body.theme-light .plan-current { background: var(--bg-input); border-color: var(--border-light); }
body.theme-light .plan-escola-card { background: var(--bg-input); border-color: var(--border-mid); }
body.theme-light .ia-model-card { background: var(--bg-input); border-color: var(--border-light); }

/* ── Busca ──────────────────────────────────────────────────── */
body.theme-light .search-shell { background: #FFFFFF; border-color: var(--border-mid); }
body.theme-light .search-input-field { color: var(--text-primary); }
body.theme-light .search-result-item:hover,
body.theme-light .search-result-item.focused { background: var(--bg-hover); }

/* ── Aparência — botões de tema ─────────────────────────────── */
body.theme-light .theme-btn { color: var(--text-muted); }
body.theme-light .theme-btn--active { background: var(--bg-active); color: var(--text-primary); }

/* ── Painel flutuante de ferramentas ────────────────────── */
.tools-float-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8,14,24,.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 60px 24px 0 0;
  animation: fadeIn .15s ease;
}
.tools-float-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  width: 400px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideDown .18s ease;
}
.tools-float-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.tools-float-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
.tools-float-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: all var(--t);
}
.tools-float-close svg { width: 15px; height: 15px; }
.tools-float-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.tools-float-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px;
  overflow-y: auto;
}

.tool-float-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--t);
  text-align: center;
}
.tool-float-item:hover {
  border-color: var(--tool-color, var(--azul-destaque));
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.tool-float-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--tool-color-bg, rgba(126,200,255,.1));
  flex-shrink: 0;
}
.tool-float-icon svg { width: 18px; height: 18px; color: var(--tool-color, var(--azul-destaque)); }
.tool-float-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
.tool-float-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Tema claro */
body.theme-light .tools-float-panel {
  background: #FFFFFF;
  border-color: var(--border-mid);
}
body.theme-light .tool-float-item {
  background: var(--bg-input);
  border-color: var(--border-light);
}
body.theme-light .tool-float-item:hover {
  background: var(--bg-hover);
}

/* ── Print media ──────────────────────────────────────────────── */
@media print {
  /* Forçar variáveis para fundo branco — evita manchas pretas */
  :root, body.theme-light {
    --bg-app:     #ffffff !important;
    --bg-card:    #ffffff !important;
    --bg-sidebar: #ffffff !important;
    --bg-input:   #ffffff !important;
    --text-primary:   #1a1a2e !important;
    --text-secondary: #3a4a5e !important;
    --border-subtle:  rgba(0,0,0,.1) !important;
    --border-light:   rgba(0,0,0,.15) !important;
  }

  /* Esconder TODO elemento de interface que não é conteúdo */
  .sidebar,
  .sidebar-resize-handle,
  .main-header,
  .input-bar-wrap,
  .modal-overlay,
  .entry-page-divider,
  .map-panel,
  .periodic-panel,
  .tool-drawer,
  .focus-widget,
  .toast-wrap,
  .tools-float-overlay,
  .search-overlay,
  .meaning-balloon,
  .sel-balloon,
  .tooltip { display: none !important; }

  /* Corrigir layout do shell para impressão */
  html, body { overflow: visible !important; height: auto !important; background: #fff !important; }
  .app-shell  { display: block !important; overflow: visible !important; height: auto !important; background: #fff !important; }
  .main-area  { height: auto !important; overflow: visible !important; background: #fff !important; }
  .content-area { overflow: visible !important; }
  .chat-messages { max-width: 100%; padding: 16px 24px; background: #fff !important; }

  /* Bolhas */
  .msg-user .bubble { background: #f0f4f8 !important; border: 1px solid #d0d8e0 !important; color: #1a1a2e !important; }
  .msg-ai  .bubble  { background: #fff !important; border: 1px solid #e0e4e8 !important; color: #1a1a2e !important; }
}

/* ── Responsive ───────────────────────────────────────────── */
/* ── Botão hamburger mobile ──────────────────────────────── */
.mobile-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r-sm);
  color: var(--text-secondary);
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Overlay mobile ──────────────────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 19;
  backdrop-filter: blur(2px);
}
.mobile-overlay.active { display: block; }

@media (max-width: 600px) {
  :root { --sidebar-w: 260px; }

  /* Sidebar vira gaveta lateral */
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%);
    z-index: 20;
    transition: transform .25s ease;
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
    box-shadow: 4px 0 32px rgba(0,0,0,.5);
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* Sidebar icon-only desabilitado no mobile */
  .sidebar--icononly {
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
  }
  .sidebar--icononly .logo-text,
  .sidebar--icononly .nav-item span,
  .sidebar--icononly .user-info { display: flex !important; }

  /* Main area ocupa 100% */
  .main-area { margin-left: 0 !important; width: 100% !important; }
  .sidebar-resize-handle { display: none; }

  /* Collapse btn escondido no mobile */
  .sidebar-collapse-btn { display: none !important; }

  /* Hamburger aparece */
  .mobile-menu-btn { display: flex; }

  .input-bar-wrap { padding: 10px 12px 14px; }
  .chat-messages { padding-left: 14px; padding-right: 14px; }
  .settings-access-grid { grid-template-columns: 1fr; }
  .modal-box { border-radius: var(--r-lg); width: 96vw !important; }
  .modal-box--print { flex-direction: column; height: 96vh !important; }
  .print-selector { width: 100% !important; max-height: 200px; border-right: none; border-bottom: 1px solid var(--border-subtle); }
}

/* ── Print actions bar ─────────────────────────────────────── */
.print-actions-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--bg-card);
}
.print-action-btn {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
}
.print-action-btn svg { flex-shrink: 0; margin-bottom: 2px; }
.print-action-btn--primary {
  background: var(--azul-principal);
  color: #fff;
  border-color: transparent;
}
.print-action-btn--primary:hover { opacity: .88; }
.print-action-btn:not(.print-action-btn--primary):hover { background: var(--bg-active); }
.print-action-hint {
  font-size: 10px;
  opacity: .55;
  font-weight: 400;
}

/* ── Arquivo dropzone ─────────────────────────────────────── */
.arquivo-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  margin: 12px 16px;
  border: 2px dashed var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: 12px;
  transition: all var(--t);
  cursor: default;
}
.arquivo-dropzone.drag-over {
  border-color: var(--azul-principal);
  background: rgba(126,200,255,.06);
  color: var(--azul-principal);
}

/* ── Arquivo selection bar ───────────────────────────────── */
.arquivo-sel-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(126,200,255,.08);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.arquivo-sel-bar button {
  padding: 4px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
}

/* ── Arquivo item checkbox ───────────────────────────────── */
.arquivo-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ── Arquivo item types ─────────────────────────────────── */
.arquivo-item-icon {
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
}

/* ── Nome modal overlay ──────────────────────────────────── */
.nome-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nome-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  padding: 24px;
  width: 340px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.nome-modal h3 { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.nome-modal input, .nome-modal select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
}
.nome-modal input:focus, .nome-modal select:focus {
  outline: none;
  border-color: var(--azul-destaque);
}
.nome-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.nome-modal-actions button {
  padding: 7px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border-light);
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nome-modal-actions button.primary {
  background: var(--azul-principal);
  color: #fff;
  border-color: transparent;
}

/* ── Painel do Pai / Responsável ──────────────────────────── */
.parent-dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.parent-dash-header h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.parent-dash-header p { font-size: 14px; color: var(--text-secondary); }
.parent-child-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.parent-child-top { display: flex; align-items: center; gap: 14px; }
.parent-child-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--azul-principal);
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.parent-child-name { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.parent-child-plan { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.parent-child-stats { display: flex; gap: 20px; }
.parent-stat { display: flex; flex-direction: column; gap: 2px; }
.parent-stat-value { font-size: 22px; font-weight: 700; color: var(--azul-destaque); }
.parent-stat-label { font-size: 11px; color: var(--text-muted); }
.parent-child-branches { display: flex; flex-wrap: wrap; gap: 8px; }
.parent-branch-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 99px;
  background: var(--bg-hover); border: 1px solid var(--border-subtle);
  font-size: 12px; color: var(--text-secondary);
}
.parent-branch-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.parent-last-active { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }

/* ── Painel do responsável — ramificações expansíveis ───────── */
.pdash-branches { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border-subtle); padding-top: 14px; }
.pdash-empty { font-size: 13px; color: var(--text-muted); padding: 6px 0; }

.pdash-branch { border-radius: var(--r-md); border: 1px solid var(--border-subtle); overflow: hidden; }
.pdash-branch-hdr {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 10px 14px; background: var(--bg-hover);
  border: none; cursor: pointer; text-align: left;
  transition: background .15s;
}
.pdash-branch-hdr:hover { background: var(--bg-active); }
.pdash-branch-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.pdash-branch-name { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; }
.pdash-branch-count { font-size: 11px; color: var(--text-muted); }
.pchev { color: var(--text-muted); transition: transform .2s; flex-shrink: 0; }

.pdash-branch-body {
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease, padding .3s;
  padding: 0 14px;
}
.pdash-branch.pdash-open .pdash-branch-body { max-height: 1200px; padding: 10px 14px 14px; }
.pdash-branch.pdash-open .pchev { transform: rotate(180deg); }

.pdash-no-topics { font-size: 12px; color: var(--text-muted); padding: 4px 0; }

.pdash-topic { margin-bottom: 10px; }
.pdash-topic:last-child { margin-bottom: 0; }
.pdash-topic-hdr {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 5px;
}
.pdash-topic-hdr svg { color: var(--text-muted); flex-shrink: 0; }
.pdash-topic-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); flex: 1; }
.pdash-topic-meta { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

.pdash-summaries { padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.pdash-summary {
  font-size: 12px; color: var(--text-muted); line-height: 1.5;
  border-left: 2px solid var(--border-subtle);
  padding-left: 8px;
}

/* ── Aba Utilização ──────────────────────────────────────── */
.uso-plano-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 16px 20px;
}
.uso-plano-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--azul-principal);
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}
.uso-plano-badge.badge-pro   { background: #7EC8FF; color: #0d1117; }
.uso-plano-badge.badge-familia { background: #20c997; color: #0d1117; }
.uso-plano-badge.badge-estudante { background: var(--text-muted); color: #fff; }
.uso-plano-info { display: flex; flex-direction: column; gap: 3px; }
.uso-plano-info strong { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.uso-plano-info span { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

.uso-bar-wrap { display: flex; flex-direction: column; gap: 8px; }
.uso-bar-top { display: flex; justify-content: space-between; align-items: center; }
.uso-bar-top span { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.uso-reset-hint { font-size: 11px !important; color: var(--text-muted) !important; font-weight: 400 !important; }
.uso-bar-track {
  height: 8px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.uso-bar-fill {
  height: 100%;
  background: var(--azul-principal);
  border-radius: 99px;
  transition: width .4s ease;
}
.uso-bar-fill.warn  { background: #FF8A33; }
.uso-bar-fill.limit { background: #ff5f5f; }

.uso-modulos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.uso-modulo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}
.uso-modulo-item.available { color: var(--text-primary); }
.uso-modulo-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--border-subtle);
}
.uso-modulo-item.available .uso-modulo-dot { background: #50dc78; }
.uso-modulo-label { flex: 1; font-size: 12px; }
.uso-modulo-plan {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 99px;
  white-space: nowrap;
}

body.theme-light .uso-plano-card { background: var(--bg-input); border-color: var(--border-light); }
body.theme-light .uso-modulo-item { background: var(--bg-input); border-color: var(--border-light); }

/* ── TTS — Leitura em voz alta ──────────────────────────────── */
.bubble-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.bubble-top-row .subject-chip { margin-bottom: 0 !important; }

.tts-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tts-play-btn,
.tts-gender-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 99px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-family: inherit;
  font-size: 12px;
  white-space: nowrap;
}
.tts-play-btn  { padding: 4px 10px 4px 8px; }
.tts-gender-btn { padding: 4px 8px; }

.tts-play-btn:hover,
.tts-gender-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-mid);
}
.tts-play-btn.playing {
  background: rgba(126,200,255,0.12);
  border-color: rgba(126,200,255,0.4);
  color: var(--azul-principal);
  opacity: 1 !important;
  animation: tts-pulse 1.4s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(5,143,232,.25); }
  50%       { box-shadow: 0 0 0 5px rgba(5,143,232,0); }
}

/* Botão de velocidade de escrita na barra inferior */
.input-footer { justify-content: space-between; }
.input-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

body.theme-light .tts-play-btn,
body.theme-light .tts-gender-btn { background: var(--bg-input); border-color: var(--border-light); }

/* ── Seleção de voz nas configurações ───────────────────────── */
.voice-select-grid {
  display: flex;
  gap: 12px;
}
.voice-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color .15s, background .15s, color .15s;
}
.voice-card:hover {
  border-color: var(--border-mid);
  color: var(--text-primary);
}
.voice-card--active {
  border-color: var(--azul-principal);
  background: rgba(126,200,255,0.08);
  color: var(--text-primary);
}
.voice-card-symbol {
  font-size: 28px;
  line-height: 1;
}
.voice-card-name {
  font-size: 13px;
  font-weight: 600;
}
.voice-card-sub {
  font-size: 11px;
  opacity: 0.6;
}

/* ── Painel do Responsável — melhorias ─────────────────────── */
.parent-dash-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.parent-use-platform-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--azul-principal);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s;
}
.parent-use-platform-btn:hover { background: #0a7fd4; }
.parent-privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(80,220,120,0.08);
  border: 1px solid rgba(80,220,120,0.2);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.parent-privacy-note svg { flex-shrink: 0; margin-top: 1px; color: #50dc78; }
.parent-last-active {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── Suporte ─────────────────────────────────────────────────── */
.suporte-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  resize: vertical;
  min-height: 100px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.6;
}
.suporte-textarea:focus {
  border-color: var(--azul-principal);
  box-shadow: 0 0 0 3px rgba(5,143,232,.1);
}
.suporte-textarea::placeholder { color: var(--text-muted); }

.suporte-upload-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-hover);
  border: 1.5px dashed var(--border-mid);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.suporte-upload-area:hover {
  border-color: var(--azul-principal);
  background: rgba(5,143,232,.05);
}
.suporte-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--azul-principal);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}
.suporte-send-btn:hover { background: #0a7fd4; }
.suporte-send-btn:disabled { background: var(--bg-hover); color: var(--text-muted); cursor: not-allowed; }

.suporte-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.5;
}
.suporte-status--ok  { background: rgba(80,220,120,.1); border: 1px solid rgba(80,220,120,.25); color: #50dc78; }
.suporte-status--err { background: rgba(255,95,95,.1);  border: 1px solid rgba(255,95,95,.25);  color: #ff6b6b; }

body.theme-light .suporte-textarea  { background: var(--bg-input); border-color: var(--border-light); }
body.theme-light .suporte-upload-area { background: var(--bg-hover); border-color: var(--border-mid); }

/* ── Prompt de arquivamento (modo livre) ─────────────────────── */
.branch-prompt-card {
  margin: 8px 0 4px 0;
  background: #161f2e;
  border: 1px solid rgba(126,200,255,0.14);
  border-radius: 14px;
  padding: 16px 18px;
  animation: bprompt-in .25s ease;
}

@keyframes bprompt-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bprompt-card--done,
.bprompt-card--dismissed {
  opacity: 0;
  transform: translateY(-4px) scale(.98);
  transition: opacity .3s, transform .3s;
}

.bprompt-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: #8b98a8;
  margin-bottom: 12px;
}

.bprompt-branches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.bprompt-branch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: #c8d2de;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  font-family: inherit;
}

.bprompt-branch:hover {
  background: rgba(126,200,255,0.08);
  border-color: rgba(126,200,255,0.25);
  color: #e6edf3;
}

.bprompt-branch--suggested {
  border-color: rgba(126,200,255,0.3);
  background: rgba(126,200,255,0.07);
}

.bprompt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bprompt-hint {
  font-size: 10px;
  background: rgba(126,200,255,0.15);
  color: #7EC8FF;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 2px;
}

.bprompt-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bprompt-create {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px dashed rgba(126,200,255,0.25);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: #7EC8FF;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}

.bprompt-create:hover {
  background: rgba(126,200,255,0.08);
  border-color: rgba(126,200,255,0.45);
}

.bprompt-dismiss {
  background: none;
  border: none;
  font-size: 12px;
  color: #4a5a6a;
  cursor: pointer;
  font-family: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  transition: color .15s;
}

.bprompt-dismiss:hover { color: #7d8ea0; }

.bprompt-create-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
}

.bprompt-new-input {
  flex: 1;
  min-width: 160px;
  background: #0d1520;
  border: 1px solid rgba(126,200,255,0.2);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: #e6edf3;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

.bprompt-new-input:focus { border-color: rgba(5,143,232,0.6); }
.bprompt-new-input::placeholder { color: #3d4d5f; }

.bprompt-confirm {
  background: #058FE8;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}

.bprompt-confirm:hover { background: #0a7fd4; }

/* Tema claro */
body.theme-light .branch-prompt-card {
  background: #f0f4f8;
  border-color: rgba(5,143,232,0.15);
}
body.theme-light .bprompt-branch {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
  color: #334155;
}
body.theme-light .bprompt-branch:hover {
  background: rgba(5,143,232,0.07);
}

/* ── Modo Livre toggle (18+) ────────────────────────────────── */
.free-mode-toggle {
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
}

.free-mode-toggle--active {
  background: rgba(180,120,255,0.12) !important;
  border-color: rgba(180,120,255,0.35) !important;
  color: #b478ff !important;
}

.free-mode-toggle--active svg {
  stroke: #b478ff;
}
