/* ============================================================
   Espaço de Estudos — identidade visual
   Paleta: papel quente, tinta grafite, indigo profundo (acento),
   ambar (datas/aulas), verde-musgo (tags). Tipografia: Fraunces
   (display, serifada com carater) + Inter (corpo/UI).
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600&display=swap');

:root {
  --paper: #faf8f3;
  --paper-2: #f1ede3;
  --ink: #1f1d1a;
  --ink-soft: #5c574e;
  --line: #e2dccd;
  --indigo: #3a3a8c;
  --indigo-soft: #ecebf7;
  --amber: #b06d12;
  --amber-soft: #f7eddc;
  --moss: #4a6b46;
  --danger: #9c3a2e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31,29,26,.06), 0 8px 24px rgba(31,29,26,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ---------- Botoes ---------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: .15s;
}
.btn:hover { border-color: var(--ink-soft); }
.btn-primary {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
}
.btn-primary:hover { background: #2f2f78; }
.btn-ghost { border: none; background: transparent; color: var(--ink-soft); padding: 6px 8px; }
.btn-ghost:hover { color: var(--ink); background: var(--paper-2); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: #f7e7e4; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---------- Inputs ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--ink-soft); margin-bottom: 5px; }
.input, textarea.input, select.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.input:focus, textarea.input:focus, select.input:focus {
  outline: none; border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 500px at 80% -10%, var(--indigo-soft), transparent),
    var(--paper);
}
.login-card {
  width: 100%; max-width: 380px; background: #fff;
  border: 1px solid var(--line); border-radius: 16px; padding: 32px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 26px;
  letter-spacing: -.01em; margin-bottom: 4px;
}
.login-card .sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand {
  font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600;
  letter-spacing: -.01em; padding: 4px 8px 18px; display: flex; align-items: center; gap: 8px;
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--indigo); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); padding: 14px 8px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  text-align: left; border: none; background: transparent;
  padding: 8px 8px; border-radius: 8px; color: var(--ink-soft);
  font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: #fff; color: var(--ink); }
.nav-item.active { background: #fff; color: var(--indigo); box-shadow: var(--shadow); }
.nav-item .ico { width: 16px; text-align: center; opacity: .8; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; justify-content: space-between; }

.main { padding: 0; overflow-y: auto; height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: rgba(250,248,243,.85);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding: 14px 32px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h2 { font-family: 'Fraunces', serif; font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.breadcrumb { font-size: 13px; color: var(--ink-soft); }
.breadcrumb a { color: var(--indigo); cursor: pointer; text-decoration: none; }
.content { padding: 28px 32px 80px; max-width: 980px; }

/* ---------- Cards / listas ---------- */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: .15s;
}
.card.clickable:hover { border-color: var(--indigo); transform: translateY(-1px); }
.card h3 { font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px; margin-bottom: 4px; }
.card .meta { font-size: 13px; color: var(--ink-soft); }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.empty { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty .big { font-family: 'Fraunces', serif; font-size: 20px; color: var(--ink); margin-bottom: 6px; }

/* ---------- Tags / pills ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--indigo-soft); color: var(--indigo);
}
.tag .x { cursor: pointer; opacity: .6; }
.tag .x:hover { opacity: 1; }
.pill-level {
  display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  background: var(--amber-soft); color: var(--amber);
}
.date-chip {
  display: inline-flex; flex-direction: column; line-height: 1.2;
  background: var(--amber-soft); color: var(--amber);
  padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 500;
}
.date-chip small { color: var(--ink-soft); font-weight: 400; font-size: 11px; }

/* ---------- Editor de notas (rich text) ---------- */
.editor-toolbar { display: flex; gap: 2px; flex-wrap: wrap; padding: 6px;
  border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0; background: var(--paper-2); }
.editor-toolbar button { border: none; background: transparent; padding: 5px 9px; border-radius: 6px;
  font-size: 13px; color: var(--ink-soft); min-width: 30px; }
.editor-toolbar button:hover { background: #fff; color: var(--ink); }
.editor {
  border: 1px solid var(--line); border-radius: 0 0 8px 8px; padding: 14px 16px;
  min-height: 180px; background: #fff; outline: none; font-size: 15px; line-height: 1.65;
}
.editor:focus { border-color: var(--indigo); }
.editor h1, .editor h2 { font-family: 'Fraunces', serif; }
.editor pre { background: var(--paper-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto;
  font-family: ui-monospace, 'Cascadia Code', monospace; font-size: 13px; }
.editor code { background: var(--paper-2); padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: .9em; }
.editor blockquote { border-left: 3px solid var(--indigo); padding-left: 12px; color: var(--ink-soft); }
.editor ul, .editor ol { padding-left: 22px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(31,29,26,.4); display: grid; place-items: center;
  z-index: 50; padding: 20px; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-family: 'Fraunces', serif; font-size: 19px; font-weight: 600; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* repeater (telefones/emails/datas) */
.repeat-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.repeat-row.dates { grid-template-columns: 160px 1fr auto; }
.logo-prev { width: 56px; height: 56px; border-radius: 10px; object-fit: contain; background: var(--paper-2); border: 1px solid var(--line); }

/* ============================================================
   CHAT DE IA (canto inferior direito)
   ============================================================ */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--indigo); color: #fff; font-size: 22px;
  box-shadow: 0 8px 24px rgba(58,58,140,.4);
}
.chat-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 41;
  width: 360px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 44px);
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; overflow: hidden;
}
.chat-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.chat-head .title { font-family: 'Fraunces', serif; font-weight: 600; }
.chat-head .status { font-size: 11px; color: var(--ink-soft); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 9px 12px; border-radius: 12px; font-size: 14px; max-width: 85%; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--indigo); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--paper-2); color: var(--ink); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: var(--amber-soft); color: var(--amber); font-size: 12px; text-align: center; }
.chat-input { padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.chat-input textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; max-height: 90px; }

/* ============================================================
   NAVEGAÇÃO EM ÁRVORE (sidebar)
   ============================================================ */
.nav-caret-static { width: 14px; display: inline-block; text-align: center; font-size: 10px; opacity: .7; }
.nav-tree { display: flex; flex-direction: column; gap: 2px; padding-left: 4px; }
.nav-course-wrap { display: flex; flex-direction: column; }
.nav-course { display: flex; align-items: center; gap: 2px; padding: 6px 6px; }
.nav-caret {
  border: none; background: transparent; color: var(--ink-soft);
  width: 18px; height: 22px; border-radius: 5px; font-size: 10px; flex-shrink: 0;
}
.nav-caret:hover { background: #fff; color: var(--ink); }
.nav-course-label {
  flex: 1; text-align: left; border: none; background: transparent;
  color: var(--ink); font-size: 13.5px; font-weight: 600; padding: 2px 4px;
  border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-course-label:hover { color: var(--indigo); }
.nav-course.active { background: #fff; box-shadow: var(--shadow); }
.nav-children { display: flex; flex-direction: column; gap: 1px; padding-left: 18px; margin: 2px 0 6px; border-left: 1px solid var(--line); margin-left: 12px; }
.nav-sub { padding: 5px 8px; font-size: 13px; font-weight: 400; }
.nav-sub .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sub .ico { opacity: .5; font-size: 11px; }
.nav-sub .sem { color: var(--amber); font-weight: 500; font-size: 11px; }
.nav-add { color: var(--indigo); font-size: 12.5px; font-weight: 500; padding: 5px 8px; }
.nav-add:hover { background: #fff; }
.nav-empty { font-size: 12px; color: var(--ink-soft); padding: 4px 8px; font-style: italic; }
.nav-root .ico { width: 16px; text-align: center; }

/* ============================================================
   PÁGINA DA DISCIPLINA (ocupa toda a área à direita)
   ============================================================ */
.content-wide { max-width: 1100px; }
.section-title { font-family: 'Fraunces', serif; font-weight: 600; margin-bottom: 12px; font-size: 18px; }
.subject-page { padding-bottom: 40px; }
.subject-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; margin-bottom: 2px; }
.subject-meta .dotsep { color: var(--line); }
.subject-section { margin-top: 28px; }
.sem-chip {
  display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px;
  font-weight: 600; background: var(--amber-soft); color: var(--amber); vertical-align: middle;
}
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid-form { grid-template-columns: 1fr; } }

/* Visualização das anotações (modo leitura) */
.notes-view { font-size: 15.5px; line-height: 1.7; }
.notes-view h1, .notes-view h2 { font-family: 'Fraunces', serif; margin: 18px 0 8px; }
.notes-view h1 { font-size: 26px; }
.notes-view h2 { font-size: 21px; }
.notes-view p { margin: 8px 0; }
.notes-view ul, .notes-view ol { padding-left: 24px; margin: 8px 0; }
.notes-view blockquote { border-left: 3px solid var(--indigo); padding-left: 14px; color: var(--ink-soft); margin: 10px 0; }
.notes-view pre { background: var(--paper-2); padding: 12px 14px; border-radius: 8px; overflow-x: auto;
  font-family: ui-monospace, 'Cascadia Code', monospace; font-size: 13.5px; }
.notes-view code { background: var(--paper-2); padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: .9em; }

/* ============================================================
   RECURSOS MATEMÁTICOS (fórmulas LaTeX + gráficos)
   ============================================================ */
.tb-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.editor-toolbar button[data-math] { color: var(--indigo); font-weight: 600; }

/* Nó de fórmula dentro do editor / visualização */
.mathnode { display: inline-block; padding: 0 2px; cursor: pointer; border-radius: 4px; }
.mathnode:hover { background: var(--indigo-soft); }
.mathnode.block { display: block; text-align: center; margin: 12px 0; padding: 8px; }
.notes-view .mathnode { cursor: default; }
.notes-view .mathnode:hover { background: transparent; }

/* Gráfico de função */
.fn-graph {
  display: block; margin: 14px 0; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; background: #fff; cursor: pointer; max-width: 620px;
}
.fn-graph:hover { border-color: var(--indigo); }
.notes-view .fn-graph { cursor: default; }
.notes-view .fn-graph:hover { border-color: var(--line); }
.fn-graph canvas { display: block; border-radius: 6px; }

/* Pré-visualização nos modais de matemática */
.formula-preview {
  margin-top: 6px; min-height: 48px; padding: 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--paper-2); display: flex; align-items: center;
  justify-content: center; overflow-x: auto;
}

/* ============================================================
   FILTROS (listas de Cursos e Disciplinas)
   ============================================================ */
.filter-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  padding: 14px 16px; margin-bottom: 18px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.filter { display: flex; flex-direction: column; gap: 4px; }
.filter > span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.filter select.input { min-width: 150px; padding: 7px 9px; }
.filter-tags { flex: 1; min-width: 200px; }
.fchips { gap: 6px; }
.fchip { cursor: pointer; background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line); }
.fchip:hover { border-color: var(--ink-soft); }
.fchip.on { border-color: transparent; }
.filter-row [data-fclear] { margin-left: auto; align-self: center; }

/* ============================================================
   PÁGINA-DOCUMENTO DA DISCIPLINA (estilo Notion)
   ============================================================ */
.save-status { font-size: 12px; color: var(--ink-soft); min-width: 78px; text-align: right; }
.doc { padding-bottom: 80px; }
.doc-title {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 34px; letter-spacing: -.01em;
  line-height: 1.2; outline: none; padding: 4px 0; margin-bottom: 4px; color: var(--ink);
}
.doc-title:empty:before { content: attr(data-ph); color: var(--line); }
.doc-details { margin-bottom: 18px; }
.doc-details-btn {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px;
  border: none; background: transparent; padding: 4px 6px; border-radius: 8px;
  cursor: pointer; text-align: left; max-width: 100%;
}
.doc-details-btn:hover { background: var(--paper-2); }
.doc-detail { font-size: 13px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 4px; }
.doc-detail.add { color: var(--indigo); font-weight: 500; }
.doc-detail.edit { color: var(--ink-soft); opacity: 0; transition: .15s; font-size: 12px; }
.doc-details-btn:hover .doc-detail.edit { opacity: .7; }
.doc-detail-tags { display: inline-flex; flex-wrap: wrap; gap: 5px; }

/* Documento em largura total (só a barra lateral fica de fora). */
.doc-content { padding-left: 24px; padding-right: 24px; max-width: none; }
.doc-content.has-outline { padding-right: 224px; }
.doc-title, .doc-details { margin-left: 64px; }

/* Caixa branca do editor: engloba a barra de botões e a numeração. */
.doc-editor-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.doc-editor-card .editor-toolbar {
  border: none; border-bottom: 1px solid var(--line); border-radius: 0;
  background: #fbfaf7;
}

/* Editor com numeração de linhas (gutter dentro da caixa) */
.editor-wrap { position: relative; }
.editor-gutter {
  position: absolute; top: 0; left: 0; width: 24px; height: 100%;
  border-right: 1px solid var(--line);
}
.editor-gutter .ln {
  position: absolute; right: 6px; color: #c4bdac; font-size: 12px;
  font-family: ui-monospace, monospace; user-select: none; line-height: 1.7;
}
.editor.doc-body {
  margin-left: 0; padding: 10px 16px 14px 64px; min-height: 420px;
  border: none; border-radius: 0; font-size: 16px; line-height: 1.7;
}
.input.mono, textarea.input.mono { font-family: ui-monospace, 'Cascadia Code', monospace; }
.editor.doc-body:focus { border: none; }
.doc-body h1, .doc-body h2 { font-family: 'Fraunces', serif; }
.doc-body h1 { font-size: 26px; margin: 16px 0 6px; }
.doc-body h2 { font-size: 21px; margin: 14px 0 6px; }
.doc-body p { margin: 6px 0; }
.doc-body blockquote { border-left: 3px solid var(--indigo); padding-left: 14px; color: var(--ink-soft); margin: 8px 0; }

/* Imagens nas anotações */
.doc-img { max-width: 100%; height: auto; border-radius: 8px; margin: 10px 0; display: block; }

/* Tabelas editáveis */
.doc-table { border-collapse: collapse; margin: 12px 0; width: auto; min-width: 60%; }
.doc-table td, .doc-table th { border: 1px solid var(--line); padding: 7px 10px; min-width: 48px; vertical-align: top; }
.doc-table th { background: var(--paper-2); font-weight: 600; text-align: left; }
.doc-table td:focus, .doc-table th:focus { outline: 2px solid var(--indigo-soft); outline-offset: -2px; }

/* Bloco de código com seletor de linguagem */
.code-block { margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.code-head { display: flex; align-items: center; justify-content: flex-end; padding: 5px 8px; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.code-lang { font-family: 'Inter', sans-serif; font-size: 12px; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: #fff; cursor: pointer; }
.code-block pre { margin: 0; }
.code-block code { display: block; padding: 12px 14px; font-family: ui-monospace, 'Cascadia Code', monospace; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; outline: none; background: transparent; }

/* ============================================================
   EDITOR DE BLOCOS (Notion-like): blocos, alça, menus, sumário
   ============================================================ */
/* Tipos de bloco */
.doc-body .has-bg { padding: 4px 8px; border-radius: 6px; }
.todo-item { display: flex; align-items: flex-start; gap: 8px; margin: 3px 0; }
.todo-check { margin-top: 5px; flex-shrink: 0; }
.todo-text { flex: 1; }
.todo-check:checked + .todo-text { text-decoration: line-through; color: var(--ink-soft); }
.toggle { margin: 4px 0; }
.toggle-caret { border: none; background: none; cursor: pointer; color: var(--ink-soft); width: 20px; padding: 0; font-size: 12px; display: inline-block; vertical-align: top; transition: transform .15s; }
.toggle[data-open="0"] .toggle-caret { transform: rotate(-90deg); }
.toggle-title { display: inline-block; vertical-align: top; min-width: 40px; }
.toggle-body { margin: 4px 0 4px 24px; }
.toggle[data-open="0"] .toggle-body { display: none; }
.callout { display: flex; gap: 10px; background: var(--paper-2); border-radius: 8px; padding: 12px 14px; margin: 8px 0; }
.callout-ico { font-size: 18px; line-height: 1.5; flex-shrink: 0; }
.callout-body { flex: 1; }
hr.divider { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* Alça de bloco (aparece ao passar o mouse), entre a numeração e o texto */
.blk-handle { position: absolute; left: 26px; display: flex; gap: 1px; height: 26px; align-items: center; z-index: 6; }
.blk-btn { width: 22px; height: 24px; border: none; background: transparent; color: var(--ink-soft); border-radius: 5px; font-size: 14px; cursor: pointer; display: grid; place-items: center; }
.blk-btn:hover { background: var(--paper-2); color: var(--ink); }
.blk-grip { cursor: grab; font-size: 12px; }

/* Menus flutuantes (alça e comando "/") */
.editor-menu {
  position: fixed; z-index: 60; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 6px;
  width: 236px; max-height: 62vh; overflow-y: auto;
}
.menu-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); padding: 7px 8px 3px; font-weight: 600; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.menu-item:hover { background: var(--paper-2); }
.menu-ico { width: 22px; text-align: center; font-size: 13px; color: var(--ink-soft); }
.menu-label { flex: 1; }
.menu-divider { height: 1px; background: var(--line); margin: 5px 4px; }
.color-row { display: flex; gap: 6px; padding: 4px 8px 8px; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; font-weight: 700; cursor: pointer; display: grid; place-items: center; background: #fff; color: var(--ink); }
.swatch.bg { font-size: 0; }
.swatch:hover { border-color: var(--ink-soft); }

/* Sumário de seções (direita) */
.doc-outline { position: fixed; top: 116px; right: 24px; width: 184px; max-height: 64vh; overflow-y: auto; }
.outline-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 600; margin-bottom: 8px; }
.outline-item { color: var(--ink-soft); padding: 3px 6px; border-radius: 5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.outline-item:hover { background: var(--paper-2); color: var(--ink); }
.outline-item.lvl2 { padding-left: 16px; font-size: 12.5px; }
.outline-item.lvl3 { padding-left: 28px; font-size: 12px; }
.outline-empty { font-size: 12px; color: var(--ink-soft); font-style: italic; line-height: 1.5; }
@media (max-width: 1180px) { .doc-outline { display: none; } }

/* ============================================================
   PALETA DE SÍMBOLOS (modal de fórmula)
   ============================================================ */
.sym-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.sym-tab {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
}
.sym-tab:hover { border-color: var(--ink-soft); }
.sym-tab.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.sym-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px;
  max-height: 200px; overflow-y: auto; padding: 10px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2);
}
.sym-btn {
  min-height: 42px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  display: grid; place-items: center; padding: 4px; font-size: 15px; color: var(--ink);
  overflow: hidden;
}
.sym-btn:hover { border-color: var(--indigo); background: var(--indigo-soft); }
.sym-btn .katex { font-size: 1em; }

/* ============================================================
   PERFIL, AVATAR E CAMPO DE SENHA
   ============================================================ */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 38px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; font-size: 15px; opacity: .45;
  padding: 4px; border-radius: 6px; line-height: 1;
}
.pw-eye:hover { opacity: .85; }
.pw-eye.on { opacity: 1; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; background: var(--indigo);
  color: #fff; font-weight: 600; font-size: 14px; overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: 12px; }
.avatar-lg { width: 84px; height: 84px; font-size: 32px; }

.sidebar-user {
  display: flex; align-items: center; gap: 8px; border: none; background: transparent;
  padding: 5px 6px; border-radius: 8px; cursor: pointer; color: var(--ink);
  flex: 1; min-width: 0; text-align: left;
}
.sidebar-user:hover { background: #fff; }
.sidebar-user.active { background: #fff; box-shadow: var(--shadow); }
.sidebar-user .su-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile-card { max-width: 560px; }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }

/* ---------- responsivo ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { width: 100%; }
  .content { padding: 20px 16px 80px; }
  .doc-content, .doc-content.has-outline { padding-left: 12px; padding-right: 12px; }
  .doc-title, .doc-details { margin-left: 48px; }
  .topbar { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
