:root {
  /* Cor primária (configurável na app) */
  --primario: #2563eb;
  --primario-claro: #3b82f6;
  --primario-suave: #dbeafe;
  --primario-fundo: #eff6ff;
  --primario-escuro: #1e40af;
  /* Superfícies (mudam no modo escuro) */
  --fundo: #f3f4f6;
  --borda: #e5e7eb;
  --texto: #1f2937;
  --texto-suave: #6b7280;
  --cartao-bg: #ffffff;
  --input-bg: #ffffff;
  --superficie-botao: #f3f4f6;
  --superficie-botao-hover: #e5e7eb;
  --zebra: #f9fafb;
  --success: #16a34a;
  --success-suave: #dcfce7;
  --error: #dc2626;
  --error-suave: #fee2e2;
  --favorito: #f59e0b;
  --sombra: 0 1px 3px rgba(0, 0, 0, 0.1);
  --sombra-media: 0 4px 12px rgba(0, 0, 0, 0.12);
  --raio: 14px;
  --fonte-tamanho: 15px;
  --fonte-titulo: 15px;
}

/* ===== Tema escuro ===== */
body.tema-escuro {
  --fundo: #0b1220;
  --borda: #263247;
  --texto: #e2e8f0;
  --texto-suave: #94a3b8;
  --cartao-bg: #16203a;
  --input-bg: #1b2742;
  --superficie-botao: #1e2b47;
  --superficie-botao-hover: #283754;
  --primario-suave: rgba(59, 130, 246, 0.28);
  --primario-fundo: rgba(59, 130, 246, 0.12);
  --success-suave: rgba(22, 163, 74, 0.25);
  --error-suave: rgba(220, 38, 38, 0.25);
  --zebra: #1b2742;
  --sombra: 0 1px 3px rgba(0, 0, 0, 0.4);
  --sombra-media: 0 4px 12px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
body.tema-escuro .sidebar { background: var(--cartao-bg); }
body.tema-escuro .nav-item:hover { background: var(--superficie-botao); }
body.tema-escuro .search-box input { background: var(--input-bg); color: var(--texto); }
body.tema-escuro .search-box input::placeholder { color: var(--texto-suave); }
body.tema-escuro .clear-search { background: var(--superficie-botao); color: var(--texto); }
body.tema-escuro .search-subst input,
body.tema-escuro .ed-subst input { background: var(--input-bg); color: var(--texto); }
body.tema-escuro .btn-secondary { background: var(--superficie-botao); color: var(--texto); }
body.tema-escuro .btn-secondary:hover { background: var(--superficie-botao-hover); }
body.tema-escuro .field-input { background: var(--input-bg); color: var(--texto); }
body.tema-escuro .add-tarefa input { background: var(--input-bg); color: var(--texto); }
body.tema-escuro .tarefa-item .ctrl:hover { background: var(--superficie-botao); }
body.tema-escuro .editor-actions .icon-btn { background: var(--superficie-botao); color: var(--texto); }
body.tema-escuro .sidebar-head .icon-btn { background: var(--superficie-botao); color: var(--texto); }
body.tema-escuro .ctx-menu button:hover { background: var(--superficie-botao-hover); }
body.tema-escuro .toast { background: #334155; }
body.tema-escuro mark { background: #854d0e; color: #fef08a; }

/* Cores de pastas — definidas por variável inline na pasta */
.pasta-cor { --pasta-cor: var(--primario); }

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Cabeçalho ===== */
.app-header {
  background: linear-gradient(135deg, var(--primario-escuro), var(--primario), var(--primario-claro));
  color: #fff;
  padding: env(safe-area-inset-top, 0px) 16px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 4px 14px rgba(30, 64, 175, 0.35);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* app-title removed — breadcrumb is now the title */

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.3); }
.icon-btn.favorito-ativo { background: rgba(255, 255, 255, 0.35); }

.breadcrumb {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: center;
  min-width: 0;
  margin: 0 4px;
}
.breadcrumb .crumb { background: none; border: none; color: #fff; cursor: pointer; padding: 0 2px; font-size: 16px; font-weight: 700; }
.breadcrumb .crumb:hover { text-decoration: underline; }
.breadcrumb .sep { opacity: 0.6; margin: 0 2px; font-weight: 400; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon { position: absolute; left: 12px; color: #9ca3af; font-size: 15px; }
.search-box input {
  width: 100%;
  padding: 11px 40px 11px 36px;
  border: none;
  border-radius: 999px;
  font-size: 15px;
  outline: none;
  background: var(--input-bg);
  color: var(--texto);
}
.search-box input::placeholder { color: var(--texto-suave); }
.clear-search {
  position: absolute;
  right: 8px;
  border: none;
  background: var(--superficie-botao);
  color: var(--texto);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.search-subst {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; padding: 8px 12px;
  border: 1px solid var(--borda);
  border-radius: 12px;
  background: var(--cartao-bg, #fff);
}
.search-subst[hidden] { display: none; }
.search-subst input {
  flex: 1; min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--borda);
  border-radius: 999px;
  font-size: 14px;
  outline: none;
  background: var(--input-bg);
  color: var(--texto);
}
.search-subst input::placeholder { color: var(--texto-suave); }
.btn-subst {
  flex: none;
  padding: 9px 14px;
  border: none;
  border-radius: 999px;
  background: var(--primario);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-subst:active { opacity: 0.85; }

/* ===== Barra lateral ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 280px;
  max-width: 85vw;
  background: var(--cartao-bg);
  z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sidebar.aberto { transform: translateX(0); }
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--borda);
  position: sticky;
  top: 0;
  background: var(--cartao-bg);
  z-index: 2;
}
.sidebar-head h2 { margin: 0; font-size: 18px; }
.sidebar-head .icon-btn { background: var(--superficie-botao); color: var(--texto); }
.sidebar-nav { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav-bottom { border-top: 1px solid var(--borda); padding-top: 8px; margin-top: 4px; }
.sidebar-arvore { display: none; padding: 0 8px 8px; border-top: 1px solid var(--borda); }
.sidebar-arvore-sec { margin-top: 8px; }
.sidebar-arvore-sec-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--texto-suave); padding: 4px 10px; font-weight: 600; }
.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--texto);
  width: 100%;
  text-align: left;
  transition: background 0.12s;
}
.tree-item:hover { background: var(--primario-fundo); }
.tree-item.ativo { background: var(--primario-suave); color: var(--primario-escuro); font-weight: 600; }
.tree-item-icon { flex-shrink: 0; width: 16px; text-align: center; font-size: 14px; }
.tree-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item-count { font-size: 11px; color: var(--texto-suave); flex-shrink: 0; }
.tree-item-add { font-size: 12px; color: var(--primario); font-weight: 600; }
.tree-sub { padding-left: 16px; }
.nav-item {
  text-align: left;
  padding: 12px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  color: var(--texto);
  transition: background 0.15s;
}
.nav-item:hover { background: var(--primario-fundo); }
.nav-item.ativo { background: var(--primario-suave); color: var(--primario-escuro); font-weight: 600; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--borda); position: sticky; bottom: 0; background: var(--cartao-bg); z-index: 2; }
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 30;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s;
}
.sidebar-overlay.aberto { opacity: 1; visibility: visible; }

.sync-status { font-size: 13px; color: var(--texto-suave); margin-bottom: 8px; text-align: center; }
.sync-status.ok { color: var(--success); }
.sync-status.erro { color: var(--error); }
.sync-status.sync { color: var(--primario); }
.app-version { font-size: 11px; color: var(--texto-suave); text-align: center; margin-top: 6px; opacity: 0.6; }
.app-version-top { font-size: 10px; font-weight: 600; color: var(--texto-suave); background: var(--superficie-botao); border: 1px solid var(--borda); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

/* ===== Conteúdo ===== */
.main {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

.view { animation: fadein 0.2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-title { font-size: 22px; font-weight: 700; margin: 0 0 12px; color: var(--texto); }

/* Destaque de pesquisa no editor */

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.view-head h2 { margin: 0; font-size: 18px; }

/* ===== Botões ===== */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primario); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--superficie-botao); color: var(--texto); }
.btn-secondary:hover { background: var(--superficie-botao-hover); }
.btn-danger { background: var(--error-suave); color: var(--error); }
.btn-danger:hover { filter: brightness(0.97); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ===== Cartões (notas) ===== */
.card-list { display: flex; flex-direction: column; gap: 10px; }

.nota-card {
  background: var(--cartao-bg);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 14px;
  box-shadow: var(--sombra);
  cursor: pointer;
  transition: box-shadow 0.15s;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.nota-card .nota-head { display: flex; align-items: center; gap: 8px; }
.nota-card .nota-titulo { font-size: var(--fonte-titulo, 15px); font-weight: 600; margin: 0; flex: 1; }
.nota-card .star {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #d1d5db;
  line-height: 1;
}
.nota-card .star.ativo { color: var(--favorito); }
.nota-card .nota-preview {
  color: var(--texto-suave);
  font-size: 13px;
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.nota-snippet {
  font-size: 13px;
  color: var(--texto-suave);
  margin: 6px 0 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
.nota-snippet mark { background: #fef08a; color: inherit; padding: 1px 2px; border-radius: 3px; text-decoration: none !important; -webkit-text-decoration: none !important; }
.nota-card .nota-meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--texto-suave);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.nota-card .badge {
  background: var(--primario-suave);
  color: var(--primario-escuro);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.nota-card .badge-tarefa { background: var(--success-suave); color: var(--success); }

/* ===== Swipe wrap (indicadores de arrasto) ===== */
.swipe-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--raio);
  border: 1px solid var(--borda);
  box-shadow: var(--sombra);
}
.swipe-bg {
  position: absolute;
  top: 0; bottom: 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}
.swipe-bg-arquivo { left: 0; background: var(--success); }
.swipe-bg-lixeira { right: 0; background: var(--error); }
.swipe-wrap > .nota-card,
.swipe-wrap > .nota-item {
  position: relative;
  z-index: 1;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.swipe-wrap:hover { box-shadow: var(--sombra-media); }
.swipe-wrap:active { transform: scale(0.99); }
.swipe-wrap:has(> .nota-card.favorita),
.swipe-wrap:has(> .nota-item.favorita) { border-left: 4px solid var(--favorito); }

/* ===== Nota item (linha horizontal dentro de pasta) ===== */
.nota-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.nota-item {
  background: var(--cartao-bg);
  border-radius: var(--raio);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.nota-item.favorita { border-left: 4px solid var(--favorito); }
.nota-item-titulo { flex: 1; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nota-item-tags { display: flex; gap: 4px; flex-wrap: wrap; flex-shrink: 0; }
.nota-item-data { font-size: 12px; color: var(--texto-suave); flex-shrink: 0; }
.nota-item .star { background: none; border: none; font-size: 18px; cursor: pointer; color: #d1d5db; line-height: 1; flex-shrink: 0; }
.nota-item .star.ativo { color: var(--favorito); }

/* Notas dentro de uma pasta: mais altas para facilitar o swipe */
#view-pastas #subpastas-list .nota-item {
  padding: 16px 18px;
  gap: 12px;
}
#view-pastas #subpastas-list .nota-item .nota-item-titulo { font-size: 16px; }
#view-pastas #subpastas-list .nota-list { gap: 10px; }
#view-pastas #subpastas-list .nota-item .star { font-size: 22px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }

/* ===== Ordenação (dentro de pasta) ===== */
.ordenacao-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  background: var(--cartao-bg);
  border: 1px solid var(--borda);
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: var(--sombra);
  position: sticky;
  top: 8px;
  z-index: 10;
}
.ordenacao-bar .opcao { padding: 5px 10px; font-size: 13px; }

mark { background: #fef08a; color: inherit; padding: 1px 2px; border-radius: 3px; text-decoration: none !important; -webkit-text-decoration: none !important; }

/* ===== Pastas ===== */
.folder-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.folder-item {
  background: var(--cartao-bg);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 10px 12px;
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.folder-item:hover { box-shadow: var(--sombra-media); }
.folder-item.folder-diario { border-left: 3px solid var(--primario); }
.folder-item.folder-sem-pasta { border-left: 3px dashed var(--texto-suave); }
.folder-item .folder-icon { font-size: 22px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.folder-item .folder-icon svg { display: block; }
.folder-item .folder-info { flex: 1; min-width: 0; }
.folder-item .folder-name { font-size: 15px; font-weight: 600; margin: 0; word-break: break-word; }
.folder-item .folder-count { font-size: 12px; color: var(--texto-suave); margin: 0; }

/* ===== Menu contextual ===== */
.ctx-backdrop {
  position: fixed; inset: 0; z-index: 999;
  background: transparent;
}
.ctx-menu {
  position: fixed; z-index: 1000;
  background: var(--cartao-bg); border: 1px solid var(--borda); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 8px 0; min-width: 200px;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 14px 18px; font-size: 17px; cursor: pointer; color: var(--texto);
}
.ctx-menu button:hover { background: var(--superficie-botao-hover); }
.ctx-menu button:last-child { color: #dc2626; }
.ctx-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
}
.ctx-box {
  background: var(--cartao-bg); border: 1px solid var(--borda); border-radius: 16px;
  padding: 20px; width: min(360px, 90vw); max-height: 70vh;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.ctx-box h3 { margin: 0; font-size: 18px; text-align: center; color: var(--texto); }
.ctx-box .pasta-escolha-lista { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 40vh; }
.ctx-box .pasta-escolha-lista button { font-size: 17px; padding: 12px 14px; }
.ctx-btn-row { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== Pill bars (categorias / listas) ===== */
.pill-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.pill {
  border: 1px solid var(--borda);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--cartao-bg);
  color: var(--texto);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.pill:hover { border-color: var(--primario); color: var(--primario); }
.pill.ativo {
  background: var(--pill-cor, var(--primario));
  color: #fff;
  border-color: var(--pill-cor, var(--primario));
}
.pill-add {
  background: transparent;
  border: 2px dashed var(--borda);
  color: var(--texto-suave);
  font-size: 16px;
  font-weight: 700;
  padding: 6px 12px;
}
.pill-add:hover { border-color: var(--primario); color: var(--primario); }

/* ===== Tarefas ===== */
.add-tarefa { display: flex; gap: 8px; margin-bottom: 14px; }
.add-tarefa input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--borda);
  border-radius: 999px;
  font-size: 15px;
  outline: none;
}
.add-tarefa input:focus { border-color: var(--primario); }

.tarefas-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

/* Toggle tarefas realizadas */
.tarefas-feitas-toggle { margin-bottom: 10px; text-align: center; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.feitas-toggle-btn {
  background: var(--superficie-botao);
  border: 1px solid var(--borda);
  color: var(--texto);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 10px;
}
.feitas-toggle-btn:hover { background: var(--primario-fundo); color: var(--primario); }
.feitas-apagar { color: #e74c3c !important; }
.feitas-apagar:hover { background: #fde8e8 !important; color: #c0392b !important; }
.tarefa-item {
  background: var(--cartao-bg);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 12px 14px;
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tarefa-item .tarefa-check {
  width: 22px;
  height: 22px;
  border: 2px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 14px;
  background: var(--input-bg);
  transition: all 0.15s;
}
.tarefa-item .tarefa-check.feita {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.tarefa-item .tarefa-texto { flex: 1; font-size: 15px; word-break: break-word; }
.tarefa-item .tarefa-texto.feita { text-decoration: line-through; color: var(--texto-suave); }
.tarefa-item .tarefa-controls { display: flex; gap: 2px; flex-shrink: 0; }
.tarefa-item .ctrl {
  background: none;
  border: none;
  color: var(--texto-suave);
  font-size: 18px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 6px;
}
.tarefa-item .ctrl:hover { background: var(--superficie-botao); color: var(--primario); }
.tarefa-item .ctrl.del:hover { color: var(--error); }
.tarefa-item .ctrl:disabled { opacity: 0.3; cursor: default; }
.tarefa-item .star { font-size: 18px; }

/* Indentação de tarefas */
.tarefa-item[data-nivel="1"] { margin-left: 28px; }
.tarefa-item[data-nivel="2"] { margin-left: 56px; }
.tarefa-item[data-nivel="3"] { margin-left: 84px; }

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: var(--texto-suave);
  font-size: 16px;
  line-height: 1;
  padding: 2px;
  touch-action: none;
  user-select: none;
  flex-shrink: 0;
  border-radius: 4px;
  letter-spacing: -2px;
  margin-left: auto;
  order: 10;
}
.drag-handle:hover { background: var(--superficie-botao); color: var(--primario); }
body.dragging { user-select: none; overflow: hidden; }
.tarefa-item.arrastando {
  opacity: 0.6;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  z-index: 100;
  position: relative;
  transition: none;
}
.tarefa-item.drag-highlight {
  border-top: 2px solid var(--primario);
}

/* Botões indentar/desindentar */
.tarefa-item .ctrl.indent,
.tarefa-item .ctrl.outdent { font-size: 15px; font-weight: 600; }

/* ===== Lixeira e Arquivo ===== */
.lixeira-card, .arquivo-card { padding: 12px 14px; }
.lixeira-card-head, .arquivo-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.lixeira-tipo, .arquivo-tipo { font-size: 12px; font-weight: 600; color: var(--texto-suave); text-transform: uppercase; letter-spacing: 0.5px; }
.lixeira-data, .arquivo-data { font-size: 12px; color: var(--texto-suave); }
.lixeira-texto, .arquivo-texto { font-size: 15px; margin: 0 0 8px; color: var(--texto); word-break: break-word; }
.lixeira-acoes, .arquivo-acoes { display: flex; gap: 8px; }
.btn-apagar-def { background: none; border: 1px solid var(--error); color: var(--error); font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.btn-apagar-def:hover { background: var(--error); color: #fff; }
.btn-arquivar { font-size: 16px; }

/* ===== Slider de tamanho de letra ===== */
.fonte-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 12px;
}
.fonte-row input[type="range"] {
  flex: 1;
  accent-color: var(--primario);
}
.fonte-mini { font-size: 12px; color: var(--texto-suave); }
.fonte-grande { font-size: 20px; font-weight: 600; color: var(--texto-suave); }
.fonte-val { font-size: 13px; color: var(--texto-suave); min-width: 40px; text-align: right; }

/* ===== Editor ===== */
.editor-overlay[hidden] { display: none; }
.editor-placeholder {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--texto-suave);
  padding: 40px;
  width: 100%;
  height: 100%;
  text-align: center;
  position: relative;
  overflow: hidden;
  background: var(--cartao-bg);
}
.editor-placeholder::before {
  content: "";
  position: absolute; inset: -20px;
  background: url("https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg/1280px-Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg") center/cover no-repeat;
  opacity: 0.28;
  filter: saturate(0.8);
  mix-blend-mode: multiply;
  background-color: var(--primario-suave);
  animation:quadro-drift 30s ease-in-out infinite alternate;
}
.editor-placeholder::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, var(--cartao-bg) 75%);
}
@keyframes quadro-drift {
  0% { transform: scale(1.05) translate(0, 0); }
  100% { transform: scale(1.12) translate(-1%, -0.5%); }
}
.ph-icon { font-size: 56px; opacity: 0.45; filter: grayscale(0.3); position: relative; z-index: 1; }
.ph-title { font-size: 17px; font-weight: 600; color: var(--primario-escuro); opacity: 0.75; position: relative; z-index: 1; }
.ph-dicas {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 8px; position: relative; z-index: 1;
}
.ph-dica {
  font-size: 13px; color: var(--texto-suave); opacity: 0.85;
  display: flex; align-items: center; gap: 8px; justify-content: center;
}
.editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  padding: 0;
}
.editor {
  position: relative;
  background: var(--cartao-bg);
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  animation: slideup 0.25s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
}
.editor-handle { display: none; }
.editor-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.editor-handle::after {
  content: "";
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: var(--borda);
}
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--borda);
  flex-shrink: 0;
}
.editor-actions { display: flex; gap: 4px; }
.editor-actions .icon-btn { background: var(--superficie-botao); color: var(--texto); font-size: 18px; width: 36px; height: 36px; }
.editor-actions .icon-btn.favorito-ativo { background: #fef3c7; color: var(--favorito); }
.ed-conteudo {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 16px;
  font-size: var(--fonte-tamanho, 16px);
  line-height: 1.5;
  min-height: 0;
  overflow-y: auto;
  font-family: inherit;
}
.ed-conteudo:empty::before {
  content: attr(data-placeholder);
  color: var(--texto-suave, #999);
  pointer-events: none;
}
.ed-conteudo ul, .ed-conteudo ol { margin: 8px 0; padding-left: 28px; }
.ed-conteudo ul { list-style-type: disc; }
.ed-conteudo ul ul { list-style-type: circle; }
.ed-conteudo ol { list-style-type: decimal; }
.ed-conteudo ul li, .ed-conteudo ol li { margin: 2px 0; }
.ed-conteudo .nota-tarefa {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px 8px 10px; cursor: pointer;
  border-radius: 10px; transition: background 0.15s;
}
.ed-conteudo .nota-tarefa:active { background: var(--primario-suave); }
.ed-conteudo .nota-tarefa .tarefa-texto { flex: 1; word-break: break-word; min-width: 0; outline: none; }
.ed-conteudo .nota-tarefa .tarefa-check {
  width: 28px; height: 28px; border: 2px solid var(--borda);
  border-radius: 6px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--cartao-bg); transition: all 0.15s;
}
.ed-conteudo .nota-tarefa .tarefa-check.fechada {
  background: var(--primario); border-color: var(--primario);
  color: #fff;
}
.ed-conteudo .nota-tarefa.tarefa-feita .tarefa-texto {
  text-decoration: line-through; opacity: 0.5;
}
.ed-conteudo .nota-tarefa.nivel-1 { margin-left: 28px; }
.ed-conteudo .nota-tarefa.nivel-2 { margin-left: 56px; }
.ed-conteudo .nota-tarefa.nivel-3 { margin-left: 84px; }
.ed-conteudo .nota-tarefa.nivel-4 { margin-left: 112px; }
.ed-conteudo .nota-tarefa.nivel-5 { margin-left: 140px; }
body.drag-linha-ativo {
  user-select: none !important; -webkit-user-select: none !important;
  -webkit-touch-callout: none; cursor: grabbing;
  touch-action: none; overscroll-behavior: none;
}
body.drag-linha-ativo * { user-select: none !important; -webkit-user-select: none !important; }
body.drag-linha-ativo #ed-conteudo { touch-action: none; -webkit-user-select: none !important; }
/* ===== Substituir no editor ===== */
.ed-subst {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--borda);
  background: var(--cartao-bg, #fff);
  flex-wrap: wrap;
}
.ed-subst[hidden] { display: none; }
.ed-subst input {
  flex: 1; min-width: 90px;
  padding: 7px 10px;
  border: 1px solid var(--borda);
  border-radius: 999px;
  font-size: 13px;
  outline: none;
  background: var(--input-bg);
  color: var(--texto);
}
.ed-subst input::placeholder { color: var(--texto-suave); }
.ed-subst .btn-subst { padding: 7px 12px; font-size: 12px; }
.ed-subst-fechar {
  flex: none; width: 26px; height: 26px;
  border: none; border-radius: 50%;
  background: var(--superficie-botao);
  color: var(--texto);
  font-size: 11px; line-height: 1; cursor: pointer;
}
/* ===== Modo Outline (WorkFlowy) ===== */
.ed-outline-crumb {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--borda);
  background: var(--cartao-bg, #fff);
}
.ed-outline-crumb[hidden] { display: none; }
.ed-outline-crumb .icon-btn { flex: none; }
.o-crumb-itens {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; min-width: 0;
}
.o-crumb-itens button {
  flex: none; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--borda);
  background: #fff; color: var(--texto);
  font-size: 12px; cursor: pointer;
}
.o-crumb-itens button.ativo { background: var(--primario-suave); border-color: var(--primario); }
.ed-conteudo .o-zoom {
  flex: none; align-self: center; margin-left: 6px; padding: 0 6px;
  color: var(--texto-suave); cursor: pointer; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none; font-size: 14px;
}
.ed-conteudo .o-zoom:active { color: var(--primario); }
.ed-conteudo .nota-tarefa.o-oculta { display: none; }
.ed-toolbar button.ed-ativo {
  background: var(--primario-suave);
  color: var(--primario-escuro);
  border-color: var(--primario);
}
.ed-conteudo.outline-ativo .nota-tarefa .tarefa-check {
  font-size: 13px;
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.ed-conteudo.outline-ativo .nota-tarefa .tarefa-check:active { background: var(--primario-suave); }
.ed-conteudo.outline-ativo .nota-tarefa .tarefa-check.fechada { font-size: 13px; line-height: 1; }
/* Durante o long-press (em espera para agarrar), impede a seleção de texto
   nativa do browser, que cancelava o drag de itens de lista (<li>). */
.ed-conteudo.linha-drag-hold,
.ed-conteudo.linha-drag-hold * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.ghost-linha {
  position: fixed; z-index: 99999; pointer-events: none;
  opacity: 0.65; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  background: #fff;
  border: 1px dashed rgba(0, 0, 0, 0.18);
}
.ed-conteudo .linha-drag-orig { opacity: 0.35; }
/* Barra de inserção: marca o VÃO exato onde a linha vai ficar. Encostada ao
   topo do alvo = fica ANTES; encostada à base = fica DEPOIS. */
.drag-linha-alvo-bar {
  position: fixed; z-index: 100000; pointer-events: none;
  height: 4px; border-radius: 3px;
  background: var(--primario);
  box-shadow: 0 0 0 2px #fff;
}
.drag-linha-alvo-bar.alvo-antes::before,
.drag-linha-alvo-bar.alvo-depois::after {
  content: ""; position: absolute; top: -5px;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
}
.drag-linha-alvo-bar.alvo-antes::before { left: 10px; border-top: 8px solid var(--primario); }
.drag-linha-alvo-bar.alvo-depois::after { right: 10px; border-bottom: 8px solid var(--primario); }
.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-top: 1px solid var(--borda);
  border-bottom: none;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.ed-toolbar button {
  border: none; background: none; cursor: pointer;
  padding: 12px 16px; border-radius: 10px;
  font-size: 18px; font-weight: 600; color: var(--texto);
  white-space: nowrap; flex-shrink: 0;
  transition: background 0.12s;
}
.ed-toolbar button:hover { background: var(--superficie-botao-hover); }
.ed-toolbar button:active { background: var(--borda); }
.ed-sep {
  width: 1px; height: 20px; background: var(--borda);
  flex-shrink: 0; margin: 0 4px;
}
.ed-hl { font-size: 16px; }
/* Botões do modo Outline (↳ criar filho · ↲ recuar) — só visíveis com o
   Outline ativo, para não poluir a barra em notas normais. */
.ed-hl-outline { display: none; }
.ed-sep-outline { display: none !important; }
.ed-conteudo.outline-ativo + .ed-toolbar .ed-hl-outline { display: inline-flex; }
.ed-conteudo.outline-ativo + .ed-toolbar .ed-sep-outline { display: inline-block !important; }
/* Botão flutuante "voltar à lista": toque curto guarda, toque longo elimina */
.ed-fab {
  position: absolute;
  right: 14px;
  bottom: 74px;
  z-index: 5;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--primario);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.15s ease;
}
.ed-fab:active { transform: scale(1.06); }
.ed-fab.eliminar-ativo { background: #dc2626; }
.ed-hl-verde { color: #16a34a; }
.ed-hl-amarelo { color: #eab308; }
.editor-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--borda);
  flex-shrink: 0;
}

/* ===== Modo leitura / Navegação ===== */
.ed-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--borda);
  flex-shrink: 0;
}
.ed-nav .icon-btn {
  background: var(--superficie-botao);
  color: var(--texto);
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ed-nav .icon-btn:disabled { opacity: 0.3; cursor: default; }
.ed-nav .icon-btn:not(:disabled):hover { background: var(--primario); color: #fff; }
.ed-nav-info { font-size: 13px; color: var(--texto-suave); min-width: 40px; text-align: center; }
.ed-conteudo.modo-leitura { cursor: default; user-select: text; }

/* ===== Vazio / vazio estados ===== */
.empty-state {
  text-align: center;
  color: var(--texto-suave);
  padding: 40px 16px;
  font-size: 15px;
}
.empty-state p { margin: 6px 0; }
.empty-state p:first-child { font-size: 40px; margin-bottom: 10px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--sombra-media);
  z-index: 60;
  max-width: 90vw;
  text-align: center;
  animation: fadein 0.2s ease;
}
.toast.erro { background: var(--error); }

/* ===== Botão topo ===== */
.topo-btn {
  position: fixed;
  right: 18px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--primario);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--sombra-media);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s;
  z-index: 25;
}
.topo-btn.visivel { opacity: 1; visibility: visible; transform: none; }

/* ===== Apresentação (janela flutuante) ===== */
.apresentacao-overlay[hidden] { display: none; }
.apresentacao-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.apresentacao-janela {
  background: var(--cartao-bg);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  width: 70vw;
  max-width: 900px;
  min-width: 320px;
  height: 70vh;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  resize: both;
}
.apresentacao-drag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--borda);
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}
.apresentacao-drag:active { cursor: grabbing; }
.apresentacao-titulo {
  font-size: 14px;
  font-weight: 600;
  color: var(--texto);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.apresentacao-controlos {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.apresentacao-controlos .icon-btn {
  width: 32px;
  height: 32px;
  font-size: 18px;
  border-radius: 8px;
  border: none;
  background: var(--superficie-botao);
  color: var(--texto);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.apresentacao-controlos .icon-btn:hover { background: var(--superficie-botao-hover); }
.apresentacao-zoom-val {
  font-size: 12px;
  color: var(--texto-suave);
  min-width: 40px;
  text-align: center;
}
.apresentacao-conteudo {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  font-size: 18px;
  line-height: 1.7;
  color: var(--texto);
}
.apresentacao-conteudo p { margin: 0 0 12px; }
.apresentacao-conteudo ul, .apresentacao-conteudo ol { margin: 8px 0; padding-left: 28px; }
.apresentacao-conteudo b, .apresentacao-conteudo strong { font-weight: 700; }

/* ===== Definições ===== */
.card {
  background: var(--cartao-bg);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 16px;
  box-shadow: var(--sombra);
  margin-bottom: 14px;
}
.card h3 { margin: 0 0 12px; font-size: 16px; }
.field-label { display: block; font-size: 13px; color: var(--texto-suave); margin: 10px 0 4px; }
.field-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--borda);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
}
.field-input:focus { border-color: var(--primario); }
.hint { font-size: 13px; color: var(--texto-suave); margin: 10px 0 0; line-height: 1.5; }
.backup-info {
  font-size: 12px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--primario-suave);
  color: var(--primario-escuro);
  line-height: 1.4;
  min-height: 20px;
}
body.tema-escuro .backup-info { background: var(--superficie-botao); color: var(--texto-suave); }
.card-perigo { border: 1px solid var(--error); }
.card-perigo h3 { color: var(--error); }
.card-perigo code { background: var(--error-suave); padding: 1px 5px; border-radius: 6px; font-size: 12px; }

/* ===== Paleta de cores ===== */
.paleta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}
.swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.ativo { border-color: var(--texto); box-shadow: 0 0 0 3px var(--fundo); }

/* ===== Toggle ===== */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
}
.toggle {
  position: relative;
  width: 52px;
  height: 28px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--superficie-botao-hover);
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.toggle.ligado { background: var(--primario); }
.toggle.ligado::after { transform: translateX(24px); }

/* ===== Opções em pílulas ===== */
.opcoes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0;
}
.opcao {
  border: 1px solid var(--borda);
  background: var(--superficie-botao);
  color: var(--texto);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.opcao:hover { background: var(--superficie-botao-hover); }
.opcao.ativo {
  background: var(--primario);
  border-color: var(--primario);
  color: #fff;
  font-weight: 600;
}

/* ===== Menu suspenso de agrupamento (junto ao botão "Nova nota") ===== */
.agrupamento-drop { position: relative; margin-right: auto; }
.btn-agrupamento { padding: 8px 12px; font-size: 13px; font-weight: 600; }
.seta-drop { font-size: 10px; opacity: 0.7; margin-left: 4px; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 160px;
  background: var(--cartao-bg);
  border: 1px solid var(--borda);
  border-radius: 12px;
  box-shadow: var(--sombra);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.dropdown-menu[hidden] { display: none; }
.dropdown-item {
  text-align: left;
  border: none;
  background: none;
  color: var(--texto);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--superficie-botao); }
.dropdown-item.ativo { background: var(--primario-suave); color: var(--primario-escuro); font-weight: 600; }

/* ===== Cabeçalhos de grupo (por pasta) ===== */
.grupo-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--pasta-cor, var(--texto));
  margin: 14px 4px 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.grupo-header .grupo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pasta-cor, var(--primario));
  flex-shrink: 0;
}
.grupo-header .grupo-count {
  background: var(--superficie-botao);
  color: var(--texto-suave);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: auto;
}

/* ===== Cor de pasta ===== */
.folder-item {
  border-left: 4px solid var(--pasta-cor, var(--borda));
}
.folder-item .folder-icon { color: var(--pasta-cor, var(--primario)); }
.pasta-cor-picker { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.pasta-cor-picker .swatch { width: 32px; height: 32px; }

/* ===== Painel seletor de cor de pasta ===== */
.cor-pasta-panel { padding-bottom: 8px; }
.cor-pasta-panel .pasta-cor-picker {
  justify-content: center;
  padding: 16px 20px;
  gap: 12px;
}
.cor-pasta-panel .pasta-cor-picker .swatch { width: 44px; height: 44px; }
.cor-pasta-titulo { margin: 0; font-size: 17px; flex: 1; text-align: center; }
.cor-pasta-panel .editor-foot { justify-content: center; }

/* ===== Seletor de pasta para nova subpasta ===== */
.subpasta-nome, .subpasta-escolha { padding: 12px 20px; font-size: 17px; }
.subpasta-escolha { border-top: 1px solid var(--borda); }
.pasta-escolha-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 40vh;
  overflow-y: auto;
}
.pasta-escolha-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--superficie-botao);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 17px;
  cursor: pointer;
  color: var(--texto);
  transition: all 0.15s;
}
.pasta-escolha-item:hover { background: var(--superficie-botao-hover); border-color: var(--primario); }
.pasta-escolha-item .pasta-escolha-icone { color: var(--pasta-cor, var(--primario)); display: inline-flex; }
.pasta-escolha-item .pasta-escolha-icone svg { display: block; }

/* ===== Sub-tarefas ===== */
.tarefa-item .sub-tarefas {
  width: 100%;
  margin-top: 6px;
  padding-left: 6px;
  border-left: 2px solid var(--borda);
}
.tarefa-item .sub-tarefa-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 14px;
}
.tarefa-item .sub-tarefa-check {
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 12px;
  background: var(--input-bg);
}
.tarefa-item .sub-tarefa-check.feita { background: var(--success); border-color: var(--success); color: #fff; }
.tarefa-item .sub-tarefa-texto { flex: 1; word-break: break-word; font-size: 14px; }
.tarefa-item .sub-tarefa-texto.feita { text-decoration: line-through; color: var(--texto-suave); }
.tarefa-item .sub-tarefa-del { background: none; border: none; color: var(--texto-suave); cursor: pointer; font-size: 15px; }
.tarefa-item .sub-tarefa-del:hover { color: var(--error); }
.add-sub-tarefa { display: flex; gap: 6px; margin-top: 4px; }
.add-sub-tarefa input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--texto);
  outline: none;
}
.add-sub-tarefa input:focus { border-color: var(--primario); }
.tarefa-item .btn-add-sub { padding: 6px 10px; font-size: 13px; }
.tarefa-item .toggle-sub-btn {
  background: none;
  border: none;
  color: var(--texto-suave);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
}
.tarefa-item .toggle-sub-btn:hover { background: var(--superficie-botao); color: var(--primario); }

/* ===== Barra inferior (mobile) ===== */
.bottom-bar {
  display: none;
}
@media (max-width: 699px) {
  .bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 30;
    background: var(--cartao-bg, #fff);
    border-top: 1px solid var(--borda);
    padding: 4px 0 env(safe-area-inset-bottom, 6px);
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  }
  .bottom-bar-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: none; cursor: pointer;
    color: var(--texto-suave); font-size: 10px; padding: 4px 8px;
    border-radius: 10px; transition: color .15s; -webkit-tap-highlight-color: transparent;
    min-width: 0; flex: 1;
  }
  .bottom-bar-item .bb-icon { font-size: 20px; line-height: 1; }
  .bottom-bar-item .bb-label { font-weight: 500; line-height: 1; }
  .bottom-bar-item.ativo, .bottom-bar-item:hover { color: var(--primario); }
  .bottom-bar-item.bb-new .bb-icon {
    background: var(--primario); color: #fff; width: 36px; height: 36px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; line-height: 1;
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
  }
  .bottom-bar-item.bb-new { color: var(--primario); }
  .bottom-bar-item.bb-new .bb-label { font-weight: 600; }

  /* Main com padding em baixo para a barra */
  .main { padding-bottom: 72px !important; }

  /* Header mobile: pesquisar como ícone, tudo compacto */
  .breadcrumb { display: none; }
  .header-top { justify-content: flex-end; }
  .header-actions { display: flex; gap: 6px; align-items: center; }
  .header-actions .icon-btn { width: 40px; height: 40px; font-size: 18px; }
  #btn-menu { display: none; }

  /* Search toggle */
  .search-box {
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height .25s ease, opacity .2s ease, margin .2s ease, padding .2s ease;
    margin: 0; padding: 0;
  }
  .search-box.aberto {
    max-height: 50px; opacity: 1; margin-top: 8px; padding: 0;
  }
}

/* ===== Desktop ===== */
@media (min-width: 700px) {
  /* Layout 3 painéis via grid */
  .app {
    display: grid;
    grid-template-columns: 200px minmax(240px, 0.45fr) 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    max-width: 1400px;
    overflow: hidden;
  }
  /* Sidebar compacta à esquerda */
  .sidebar { transform: none; position: relative; top: 0; height: 100%; width: auto; flex-shrink: 0; border-radius: 0; border-right: 1px solid var(--borda); overflow: hidden; overflow-y: auto; grid-column: 1; grid-row: 1 / -1; display: flex; flex-direction: column; }
  .sidebar-arvore { display: block; }
  .nav-item-pastas { display: none; }
  .sidebar-overlay { display: none; }
  #btn-menu { display: none; }
  #btn-close-sidebar { display: none; }
  .bottom-bar { display: none !important; }
  .header-actions { display: none; }
  .breadcrumb { display: block; }
  .main { padding-bottom: 0 !important; }
  .view-title { display: none; }
  .app-header { border-radius: 0; padding: 8px 16px 10px; grid-column: 2; grid-row: 1; }
  .app-title { font-size: 16px; margin: 0; }
  .main { min-width: 0; overflow-y: auto; padding: 16px 16px 24px; grid-column: 2; grid-row: 2; }
  /* No desktop, pastas ficam na sidebar — esconder grelha do painel do meio */
  #pastas-list { display: none; }
  /* Editor como painel à direita (sempre visível) */
  #editor-overlay[hidden] { display: flex !important; }
  #editor-overlay {
    position: relative;
    inset: auto;
    background: none;
    z-index: auto;
    min-width: 0;
    max-width: none;
    border-left: 1px solid var(--borda);
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
    grid-column: 3;
    grid-row: 1 / -1;
  }
  #editor-overlay .editor { width: 100%; height: 100%; border-radius: 0; animation: none; }
  #editor-overlay .editor-handle { display: none; }
  /* Placeholder vs editor */
  .editor-placeholder { display: none; }
  #editor-overlay[hidden] .editor-placeholder { display: flex; }
  #editor-overlay[hidden] .editor { display: none; }
  #editor-overlay:not([hidden]) .editor-placeholder { display: none; }
  #editor-overlay:not([hidden]) .editor { display: flex; }
  /* Pastas em grelha */
  .folder-list { grid-template-columns: repeat(3, 1fr); }
}

/* Telas muito pequenas: 2 colunas garantidas */
@media (min-width: 480px) and (max-width: 699px) {
  .folder-list { grid-template-columns: repeat(2, 1fr); }
}

/* Botão flutuante "Voltar à lista" — só mobile, controlado por JS */
/* =========================================================
   Tags
   ========================================================= */
.tags-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.tags-bar-empty { font-size: 13px; color: var(--texto-suave); font-style: italic; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primario-fundo, #eff6ff); color: var(--primario, #3b82f6);
  border: 1px solid var(--primario-suave, #bfdbfe); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tag-pill:hover, .tag-pill.ativo {
  background: var(--primario, #3b82f6); color: #fff; border-color: var(--primario);
}
.tag-limpar {
  background: #fee2e2; color: #991b1b; border-color: #fca5a5; font-weight: 600;
}
.tag-limpar:hover { background: #dc2626; color: #fff; border-color: #dc2626; }
.nota-tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 2px; }
.nota-tag {
  display: inline-block; background: var(--primario-fundo, #eff6ff); color: var(--primario, #3b82f6);
  border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.nota-tag:hover { background: var(--primario); color: #fff; }

/* ── Editor tags (painel) ─────────────────────────────────── */
.ed-tags-editor {
  padding: 10px 14px; border-top: 1px solid var(--borda);
  display: flex; flex-direction: column; gap: 8px;
  background: var(--cartao-bg, #fff); position: relative;
}
.ed-tags-editor[hidden] { display: none; }

.ed-tags-top { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.ed-tags-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.ed-tags-empty { color: var(--texto-suave); font-size: 13px; font-style: italic; }

/* Chip — tag ativa no editor */
.ed-tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, var(--primario-fundo, #eff6ff), #dbeafe);
  color: var(--primario-escuro, #1e40af); border: 1px solid var(--primario-suave, #93c5fd);
  border-radius: 8px; padding: 4px 8px 4px 10px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; user-select: none;
}
.ed-tag-chip:hover { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.ed-tag-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.08); font-size: 14px; line-height: 1;
  transition: background 0.15s;
}
.ed-tag-chip:hover .ed-tag-chip-x { background: rgba(239,68,68,.25); color: #dc2626; }
.ed-tag-mais {
  background: var(--superficie-botao, #f1f5f9); color: var(--texto-suave);
  border-color: var(--borda); cursor: pointer; font-size: 12px; padding: 4px 10px;
}
.ed-tag-mais:hover { background: var(--primario-fundo); color: var(--primario); }

/* Input com ícone */
.ed-tags-input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--cartao-bg, #fff); border: 1.5px solid var(--borda);
  border-radius: 10px; padding: 0 10px; transition: border-color 0.2s;
}
.ed-tags-input-wrap:focus-within { border-color: var(--primario); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.ed-tags-icon { flex-shrink: 0; color: var(--texto-suave); }
.ed-tags-input-wrap:focus-within .ed-tags-icon { color: var(--primario); }
.ed-tag-input {
  flex: 1; border: none; outline: none; background: transparent;
  padding: 8px 0; font-size: 14px; color: var(--texto);
}
.ed-tag-input::placeholder { color: var(--texto-suave); }

/* Dropdown de sugestões */
.ed-tags-dropdown {
  position: absolute; left: 14px; right: 14px;
  background: var(--cartao-bg, #fff); border: 1px solid var(--borda);
  border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
  max-height: 180px; overflow-y: auto; z-index: 10; padding: 4px;
}
.ed-tags-dropdown[hidden] { display: none; }
.ed-tags-drop-item {
  padding: 8px 12px; border-radius: 8px; font-size: 13px;
  color: var(--texto); cursor: pointer; transition: background 0.1s;
}
.ed-tags-drop-item:hover { background: var(--primario-fundo); color: var(--primario); }
