:root {
  --bg-app: #202124;
  --bg-surface: #202124;
  --bg-elevated: #28292c;
  --bg-hover: rgba(232, 234, 237, 0.08);
  --border-color: #5f6368;
  --border-strong: #80868b;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #80868b;

  /* Cores solicitadas pelo usuário */
  --check-green: #16a34a;
  --check-green-glow: rgba(22, 163, 74, 0.35);
  --check-blue: #2563eb;
  --check-blue-light: #3b82f6;
  --check-blue-glow: rgba(37, 99, 235, 0.38);
  --accent-amber: #FEBA00;

  /* Paleta estilo Google Keep (Escuro) */
  --note-default: #202124;
  --note-coral: #5c2b29;
  --note-peach: #614a19;
  --note-sand: #635d19;
  --note-mint: #345920;
  --note-teal: #16504b;
  --note-fog: #2d555e;
  --note-storm: #1e3a5f;
  --note-dusk: #42275e;
  --note-blossom: #5b2245;
  --note-clay: #442f19;
  --note-chalk: #2b2f36;

  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.28);
  --shadow-modal: 0 18px 50px rgba(0, 0, 0, 0.65);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

[data-theme="light"] {
  --bg-app: #f4f6f8;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.05);
  --border-color: #e0e4e8;
  --border-strong: #c2c9d1;
  --text-primary: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #8c959f;

  --note-default: #ffffff;
  --note-coral: #faafa8;
  --note-peach: #f39f76;
  --note-sand: #fff8b8;
  --note-mint: #e2f6d3;
  --note-teal: #b4ddd3;
  --note-fog: #d4e4ed;
  --note-storm: #aeccdc;
  --note-dusk: #d3bfdb;
  --note-blossom: #f6e2dd;
  --note-clay: #e9e3d4;
  --note-chalk: #efeff1;

  --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.08);
  --shadow-modal: 0 20px 50px rgba(15, 23, 42, 0.22);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.hidden {
  display: none !important;
}

/* ============================================================================
   CABEÇALHO (TOPBAR)
   ============================================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #FEBA00;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(254, 186, 0, 0.32);
}

.brand-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-title span {
  color: var(--accent-amber);
  margin-left: 2px;
}

.topbar-search {
  flex: 1;
  max-width: 680px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0 14px;
  height: 44px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.search-icon {
  color: var(--text-muted);
  margin-right: 10px;
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-new-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-new-note:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: var(--accent-amber);
}

.btn-new-note kbd {
  font-size: 0.7rem;
  padding: 1px 5px;
}

.btn-instructions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-instructions:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-instructions span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  font-weight: 700;
  font-size: 0.75rem;
}

.instructions-modal-card {
  max-width: 580px;
}

.instructions-title {
  font-size: 1.12rem;
  font-weight: 700;
}

.instructions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 4px 0;
}

.instruction-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.instruction-keys {
  min-width: 125px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.instruction-text strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 3px;
  color: var(--text-primary);
}

.instruction-text p {
  font-size: 0.81rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.12);
  color: #4ade80;
  border: 1px solid rgba(22, 163, 74, 0.3);
}

[data-theme="light"] .status-pill {
  color: #15803d;
  background: rgba(22, 163, 74, 0.1);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn.active {
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.14);
}

.icon-btn-sm {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 6px;
}

/* ============================================================================
   LAYOUT & SIDEBAR
   ============================================================================ */
.app-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

.sidebar {
  width: 265px;
  padding: 16px 12px;
  border-right: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
  transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar.collapsed {
  display: none;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-radius: 0 24px 24px 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(245, 158, 11, 0.16);
  color: var(--accent-amber);
  font-weight: 600;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 12px;
}

.shortcuts-card {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.79rem;
  color: var(--text-secondary);
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.35;
}

kbd, code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.blue-ok-demo {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--check-blue);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ============================================================================
   CONTEÚDO PRINCIPAL & COMPOSER (CRIADOR DE NOTAS)
   ============================================================================ */
.main-content {
  flex: 1;
  padding: 28px 32px 64px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.composer-wrapper {
  max-width: 680px;
  margin: 0 auto 36px;
  transition: max-width 0.2s ease;
}

.composer-wrapper:has(#composerExpanded:not(.hidden)) {
  width: 80vw;
  max-width: 80vw;
}

.composer-Expanded-min {
  min-height: 55vh;
}

.composer-card,
.note-card,
.modal-card {
  background-color: var(--note-default);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

/* Cores de notas estilo Google Keep */
[data-color="default"] { background-color: var(--note-default); }
[data-color="coral"]   { background-color: var(--note-coral); }
[data-color="peach"]   { background-color: var(--note-peach); }
[data-color="sand"]    { background-color: var(--note-sand); }
[data-color="mint"]    { background-color: var(--note-mint); }
[data-color="teal"]    { background-color: var(--note-teal); }
[data-color="fog"]     { background-color: var(--note-fog); }
[data-color="storm"]   { background-color: var(--note-storm); }
[data-color="dusk"]    { background-color: var(--note-dusk); }
[data-color="blossom"] { background-color: var(--note-blossom); }
[data-color="clay"]    { background-color: var(--note-clay); }
[data-color="chalk"]   { background-color: var(--note-chalk); }

.composer-collapsed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  cursor: text;
  gap: 12px;
  flex-wrap: wrap;
}

.composer-placeholder {
  color: var(--text-secondary);
  font-size: 0.96rem;
  font-weight: 500;
}

.composer-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.btn-chip:hover {
  border-color: var(--accent-amber);
}

.btn-chip-master {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(37, 99, 235, 0.12);
}

.composer-expanded {
  padding: 16px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
}

/* Barra do Título quando possui quadrados [] abaixo */
.composer-header.master-title-bar {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 8px;
  padding: 8px 10px;
}

.composer-header.title-completed {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(59, 130, 246, 0.6);
}

/* Folha de Bloco de Notas limpa (igual ao Print 1 do Google Keep) */
.notepad-sheet {
  min-height: 140px;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  cursor: text;
  transition: border-color 0.2s, background 0.2s;
}

/* Quando tem título + itens com quadrado [], agrupa discretamente dentro de um quadro */
.notepad-sheet.has-title-box {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.1);
}

.notepad-sheet.box-completed {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(37, 99, 235, 0.06);
}

.composer-title-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1.15rem;
  font-weight: 600;
  outline: none;
}

.composer-title-input::placeholder {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================================================
   ITENS DA NOTA: FOLHA CONTÍNUA DE BLOCO DE NOTAS + [] + NOTA MESTRA
   ============================================================================ */
.note-items-editor {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.note-item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 3px 2px;
  border-radius: 6px;
  transition: background 0.12s, margin-left 0.18s ease;
  position: relative;
}

.note-item-row .custom-checkbox,
.note-item-row .master-collapse-btn {
  margin-top: 2px;
}

.note-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.note-inline-image-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.2);
  align-self: flex-start;
}

.note-inline-image {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 7px;
}

.remove-inline-img-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.note-inline-image-wrap:hover .remove-inline-img-btn {
  opacity: 1;
}

.note-item-row:focus-within {
  background: transparent;
}

/* Recuo multi-nível: SOMENTE as sub-notas abaixo recuam para a direita conforme seu nível! */
.note-item-row.is-child {
  padding-left: 10px;
  border-left: 2px solid rgba(59, 130, 246, 0.38);
}

/* Nota Marco: mantém seu alinhamento original à esquerda (sem pular para a direita!) */
.note-item-row.is-master {
  padding: 5px 2px;
  margin-top: 2px;
}

.note-item-row.is-master.all-children-done {
  background: transparent;
}

/* Botão de abrir e fechar (expand/collapse) a Nota Mestra */
.master-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 24px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: rgba(37, 99, 235, 0.18);
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

[data-theme="light"] .master-collapse-btn {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.12);
}

.master-collapse-btn:hover {
  background: var(--check-blue);
  color: #ffffff;
}

.master-collapse-icon {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.7rem;
}

.master-collapse-btn.collapsed .master-collapse-icon {
  transform: rotate(-90deg);
}

/* Quadrado desenhado pelo [] */
.custom-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--text-secondary);
  background: rgba(0, 0, 0, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

[data-theme="light"] .custom-checkbox {
  background: rgba(255, 255, 255, 0.8);
}

.custom-checkbox:hover {
  border-color: var(--check-green);
  transform: scale(1.08);
}

/* Check Verde ao clicar no meio do quadrado */
.custom-checkbox.checked-green {
  background-color: var(--check-green);
  border-color: var(--check-green);
  box-shadow: 0 0 10px var(--check-green-glow);
  color: #ffffff;
}

/* Check de OK Azul automático na Nota Mestra quando todas as sub-notas estão marcadas */
.custom-checkbox.checked-blue-master {
  background-color: var(--check-blue);
  border-color: var(--check-blue-light);
  box-shadow: 0 0 12px var(--check-blue-glow);
  color: #ffffff;
}

.custom-checkbox svg {
  width: 14px;
  height: 14px;
  stroke-width: 3;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.16s ease;
}

.custom-checkbox.checked-green svg,
.custom-checkbox.checked-blue-master svg {
  opacity: 1;
  transform: scale(1);
}

/* Selo de OK Azul da Nota Mestra */
.master-blue-ok-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--check-blue);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 8px var(--check-blue-glow);
  flex-shrink: 0;
  animation: popIn 0.22s ease-out;
}

.master-progress-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

@keyframes popIn {
  0% { transform: scale(0.75); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Textarea multi-linha do bloco (quebra para baixo como bloco de notas real) */
.note-item-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.55;
  outline: none;
  min-width: 0;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  display: block;
}

/* Nota Mestra: um pouco maior e em negrito, conforme solicitado */
.note-item-row.is-master .note-item-input,
.card-item-row.is-master .card-item-text {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Linha cinza suave no meio quando concluído, visível em todas as linhas e fácil de ler */
.note-item-row.is-checked .note-item-input,
.card-item-row.is-checked .card-item-text {
  text-decoration: line-through;
  text-decoration-color: rgba(185, 196, 212, 0.65);
  text-decoration-thickness: 1.5px;
  color: rgba(232, 234, 237, 0.72);
}

[data-theme="light"] .note-item-row.is-checked .note-item-input,
[data-theme="light"] .card-item-row.is-checked .card-item-text {
  text-decoration-color: rgba(71, 85, 105, 0.6);
  color: rgba(31, 35, 40, 0.68);
}

.item-row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.note-item-row:hover .item-row-actions,
.note-item-row:focus-within .item-row-actions {
  opacity: 1;
}

.row-action-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 0.78rem;
}

.row-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.add-line-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.84rem;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.add-line-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================================================
   TAGS, PALETA DE CORES & RODAPÉ DO EDITOR
   ============================================================================ */
.composer-tags-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.tags-left-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.edited-timestamp {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.keep-toolbar-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-keep-close {
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-keep-close:hover {
  background: var(--bg-hover);
}

.tags-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
}

[data-theme="light"] .tag-pill {
  background: rgba(0, 0, 0, 0.08);
}

.tag-pill button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0.7;
}

.tag-inline-input {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  outline: none;
  min-width: 120px;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Barra Inferior Idêntica ao Google Keep */
.keep-bottom-bar {
  position: relative;
  padding-top: 6px;
}

.keep-toolbar-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.keep-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #9aa0a6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.keep-icon-btn:hover,
.keep-icon-btn.active {
  background: rgba(232, 234, 237, 0.12);
  color: #e8eaed;
}

.keep-icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

[data-theme="light"] .keep-icon-btn {
  color: #5f6368;
}

[data-theme="light"] .keep-icon-btn:hover,
[data-theme="light"] .keep-icon-btn.active {
  background: rgba(0, 0, 0, 0.08);
  color: #202124;
}

/* Gaveta de Opções de Formatação (Botão A) */
.keep-format-drawer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.format-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.format-pill:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--border-strong);
}

.format-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

/* Popovers Flutuantes (Cores, Lembrete, Colaborador, Menu 3 Pontos ⋮) */
.keep-popover-anchor {
  position: relative;
  display: inline-flex;
}

.keep-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 280;
  background: #28292c;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  animation: popIn 0.14s ease-out;
}

[data-theme="light"] .keep-popover {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.palette-popover {
  padding: 12px 16px;
  width: max-content;
  max-width: 92vw;
  border-radius: 16px;
  background: #2d2e30;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
}

.color-palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px;
}

.palette-row-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
  margin: 10px -16px;
}

.theme-palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px;
}

.color-swatch,
.theme-swatch {
  position: relative;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #e8eaed;
  padding: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.color-swatch {
  width: 34px;
  height: 34px;
}

.theme-swatch {
  width: 42px;
  height: 42px;
  overflow: visible;
}

.theme-swatch-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-swatch-inner svg {
  width: 100%;
  height: 100%;
  display: block;
}

.color-swatch:hover,
.theme-swatch:hover {
  border-color: #ffffff;
}

.color-swatch.active,
.theme-swatch.active {
  border: 2px solid #a142f4;
  box-shadow: none;
}

.swatch-check-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #a142f4;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.swatch-check-badge svg {
  width: 11px;
  height: 11px;
  stroke-width: 3;
}

/* Temas de fundo ilustrados aplicados nos cartões e no modal */
[data-bg-theme="groceries"] {
  background-image: radial-gradient(circle at 92% 90%, rgba(234, 88, 12, 0.25) 0%, transparent 45%),
                    radial-gradient(circle at 80% 95%, rgba(37, 99, 235, 0.22) 0%, transparent 50%);
}
[data-bg-theme="food"] {
  background-image: radial-gradient(circle at 90% 85%, rgba(45, 212, 191, 0.18) 0%, transparent 50%);
}
[data-bg-theme="music"] {
  background-image: radial-gradient(circle at 88% 92%, rgba(244, 63, 94, 0.2) 0%, transparent 48%);
}
[data-bg-theme="recipes"] {
  background-image: radial-gradient(circle at 90% 88%, rgba(22, 163, 74, 0.24) 0%, transparent 48%);
}
[data-bg-theme="notes"] {
  background-image: radial-gradient(circle at 90% 88%, rgba(139, 92, 246, 0.25) 0%, transparent 50%);
}
[data-bg-theme="places"] {
  background-image: radial-gradient(circle at 90% 88%, rgba(192, 132, 252, 0.2) 0%, transparent 50%);
}
[data-bg-theme="travel"] {
  background-image: radial-gradient(circle at 90% 88%, rgba(56, 189, 248, 0.24) 0%, transparent 50%);
}
[data-bg-theme="video"] {
  background-image: radial-gradient(circle at 90% 88%, rgba(148, 163, 184, 0.22) 0%, transparent 50%);
}
[data-bg-theme="celebration"] {
  background-image: radial-gradient(circle at 90% 88%, rgba(34, 197, 94, 0.2) 0%, transparent 50%);
}

.reminder-popover {
  padding: 10px 0;
  width: 260px;
}

.collab-popover {
  padding: 10px 0;
  width: 340px;
}

.collab-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 12px;
}

.collab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
}

.collab-email {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.collab-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.collab-mini-btn {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.72rem;
  cursor: pointer;
}

.collab-mini-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text-primary);
}

/* Menu de 3 Pontos (⋮) idêntico ao Print 2 enviado pelo usuário */
.more-popover {
  padding: 6px 0;
  width: 235px;
}

.popover-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 4px 16px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}

.popover-menu-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.87rem;
  font-weight: 400;
  text-align: left;
  padding: 9px 18px;
  cursor: pointer;
  display: block;
  transition: background 0.12s;
}

.popover-menu-item:hover {
  background: rgba(232, 234, 237, 0.1);
}

[data-theme="light"] .popover-menu-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

.popover-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.16);
  margin: 6px 12px;
}

[data-theme="light"] .popover-divider {
  background: rgba(0, 0, 0, 0.12);
}

.popover-custom-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
}

.popover-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 0.78rem;
  outline: none;
}

.btn-keep-sm {
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: none;
  background: var(--check-blue);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

/* Modal de Desenho */
.modal-card.drawing-modal-card {
  width: 94vw;
  max-width: 820px;
  height: auto;
  max-height: 92vh;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  box-shadow: var(--shadow-modal);
}

.drawing-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawing-canvas-wrap {
  background: #16181c;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

#drawingCanvas {
  width: 100%;
  max-width: 760px;
  height: 420px;
  cursor: crosshair;
  touch-action: none;
}

.color-palette {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: filter 0.15s;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.86rem;
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger-ghost {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  font-weight: 500;
  font-size: 0.84rem;
  cursor: pointer;
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.22);
}

/* ============================================================================
   GRADE DE CARTÕES DE NOTAS (ESTILO GOOGLE KEEP)
   ============================================================================ */
.notes-section {
  margin-bottom: 32px;
}

.section-heading {
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-left: 4px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}

.notes-grid.list-view {
  grid-template-columns: 1fr;
  max-width: 680px;
  margin: 0 auto;
}

.note-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  cursor: default;
}

.note-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.note-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-card-header.card-master-title-bar {
  background: rgba(37, 99, 235, 0.11);
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 9px;
  padding: 8px 10px;
}

.note-card-header.card-master-title-bar.title-completed {
  background: rgba(37, 99, 235, 0.22);
  border-color: rgba(59, 130, 246, 0.65);
}

.note-card-title {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
  flex: 1;
}

.note-card-items.inside-title-box {
  border: 1.5px solid rgba(59, 130, 246, 0.3);
  background: rgba(0, 0, 0, 0.14);
  border-radius: 9px;
  padding: 9px;
}

[data-theme="light"] .note-card-items.inside-title-box {
  background: rgba(37, 99, 235, 0.04);
}

.note-card-items.inside-title-box.box-completed {
  border-color: rgba(59, 130, 246, 0.65);
  background: rgba(37, 99, 235, 0.09);
}

.note-card-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-item-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 5px 6px;
  border-radius: 7px;
  transition: background 0.15s;
}

.card-item-row .custom-checkbox,
.card-item-row .master-collapse-btn {
  margin-top: 2px;
}

.card-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.card-item-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.card-item-row.is-child {
  margin-left: calc(var(--level, 1) * 22px);
  padding-left: 10px;
  border-left: 2px solid rgba(59, 130, 246, 0.35);
}

.card-item-row.is-master {
  padding: 5px 2px;
  margin-top: 2px;
}

.card-item-row.is-master.all-children-done {
  background: transparent;
}

.card-item-text {
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  cursor: pointer;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================================
   MODAL DE EDIÇÃO & AUTENTICAÇÃO
   ============================================================================ */
.modal-backdrop,
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.modal-card {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border: none;
  padding: 24px 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: none;
}

.modal-card.instructions-modal-card {
  width: 92vw;
  max-width: 580px;
  height: auto;
  max-height: 88vh;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-modal);
}

.confirm-backdrop {
  z-index: 260;
}

.modal-card.confirm-modal-card {
  width: 92vw;
  max-width: 420px;
  height: auto;
  max-height: none;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  box-shadow: var(--shadow-modal);
  gap: 14px;
}

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

.confirm-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.confirm-header h3 {
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--text-primary);
}

.confirm-message {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.confirm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.btn-danger-solid {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #dc2626;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: filter 0.15s;
}

.btn-danger-solid:hover {
  filter: brightness(1.1);
}

.modal-items-scroll {
  flex: 1;
  max-height: none;
  overflow-y: auto;
  padding-right: 8px;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #FEBA00;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg {
  width: 24px;
  height: 24px;
}

.auth-logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.auth-logo p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-form input {
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 0.92rem;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent-amber);
}

.auth-error {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 0.82rem;
}

.btn-full {
  width: 100%;
  height: 42px;
  margin-top: 6px;
}

.auth-footer {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.security-badge-inline {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-secondary);
  max-width: 460px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 2.6rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-card);
  animation: popIn 0.2s ease-out;
}

.sidebar-backdrop {
  display: none;
}

/* ============================================================================
   RESPONSIVO — TABLET / CELULAR
   ============================================================================ */
@media (max-width: 768px) {
  /* --- Topbar em 2 linhas: [menu + marca + ações] / [busca 100%] --- */
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px 6px;
  }
  .topbar-left {
    min-width: 0;
    gap: 6px;
    flex: 1 1 auto;
  }
  .brand-icon {
    width: 32px;
    height: 32px;
  }
  .topbar-right {
    gap: 4px;
    flex-shrink: 0;
  }
  .topbar-search {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }
  .search-box {
    height: 40px;
  }
  /* 16px evita o zoom automático do iOS ao focar */
  .search-box input,
  .composer-title-input,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea {
    font-size: 16px;
  }

  /* Botões só com ícone */
  .btn-new-note,
  .btn-instructions {
    font-size: 0;
    gap: 0;
    padding: 0;
    width: 36px;
    height: 36px;
    justify-content: center;
  }
  .btn-new-note span {
    font-size: 1.2rem;
    line-height: 1;
  }
  .btn-instructions span {
    font-size: 0.8rem;
  }
  .status-pill {
    padding: 6px 8px;
  }
  .status-pill span:last-child {
    display: none;
  }

  /* --- Sidebar vira gaveta sobreposta com fundo escuro --- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 82vw);
    z-index: 120;
    overflow-y: auto;
    box-shadow: var(--shadow-modal);
    padding-top: 20px;
  }
  .sidebar:not(.collapsed) + .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(0, 0, 0, 0.55);
  }

  /* --- Conteúdo --- */
  .main-content {
    padding: 16px 12px 56px;
    min-width: 0;
  }
  .composer-wrapper,
  .composer-wrapper:has(#composerExpanded:not(.hidden)) {
    width: 100%;
    max-width: 100%;
    margin-bottom: 24px;
  }
  .composer-expanded {
    padding: 14px 14px 10px;
  }
  .composer-footer {
    gap: 8px;
  }
  .composer-actions {
    margin-left: auto;
  }
  /* Grade: 2 colunas lado a lado (estilo Keep). Botão grade/lista volta para 1 coluna */
  .notes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .notes-grid.list-view {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .note-card {
    padding: 14px;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  /* Cartões compactos quando estão em 2 colunas */
  .notes-grid:not(.list-view) .note-card {
    padding: 9px;
    gap: 8px;
    border-radius: 12px;
  }
  .notes-grid:not(.list-view) .note-card {
    overflow-wrap: break-word;
  }
  /* Cabeçalho: [▼ 4/6] [□] ........ [📌] na 1ª linha, título inteiro na 2ª */
  .notes-grid:not(.list-view) .note-card-header {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }
  .notes-grid:not(.list-view) .note-card-header > .icon-btn {
    margin-left: auto;
    width: 30px;
    height: 30px;
  }
  .notes-grid:not(.list-view) .note-card-title {
    order: 10;
    flex: 1 1 100%;
    min-width: 0;
    font-size: 0.88rem;
    line-height: 1.3;
  }
  /* Nota Marco interna: texto ocupa a linha; selo 4/5 e ✓ OK descem se não couber */
  .notes-grid:not(.list-view) .card-item-row.is-master {
    flex-wrap: wrap;
  }
  .notes-grid:not(.list-view) .card-item-row .card-item-content {
    flex: 1 1 0;
    min-width: 0;
  }
  .notes-grid:not(.list-view) .card-item-row.is-master .card-item-content {
    flex-basis: calc(100% - 30px);
  }
  .notes-grid:not(.list-view) .card-item-row.is-master .master-collapse-btn,
  .notes-grid:not(.list-view) .card-item-row.is-master .master-blue-ok-badge {
    margin-left: 24px;
  }
  .notes-grid:not(.list-view) .card-item-row.is-master .master-blue-ok-badge + .master-collapse-btn {
    margin-left: 0;
  }
  .notes-grid:not(.list-view) .card-item-text {
    font-size: 0.78rem;
  }
  .notes-grid:not(.list-view) .card-item-row {
    gap: 6px;
    padding: 3px 2px;
  }
  .notes-grid:not(.list-view) .card-item-row.is-child {
    margin-left: calc(var(--level, 1) * 8px);
    padding-left: 5px;
  }
  /* Prévia: todos os cartões com a mesma altura; toque abre a nota inteira */
  .notes-grid:not(.list-view) .note-card {
    height: 250px;
    overflow: hidden;
    cursor: pointer;
  }
  .notes-grid:not(.list-view) .note-card > * {
    flex-shrink: 0;
  }
  .notes-grid:not(.list-view) .note-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .notes-grid:not(.list-view) .note-card > .note-card-items {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 65%, transparent 100%);
  }
  .notes-grid:not(.list-view) .card-item-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .notes-grid:not(.list-view) .tags-pills {
    flex-wrap: nowrap;
    overflow: hidden;
  }
  /* Rodapé enxuto: sem data, só as ações */
  .notes-grid:not(.list-view) .note-card-footer > span:first-child {
    display: none;
  }
  .notes-grid:not(.list-view) .note-card-footer {
    justify-content: flex-end;
  }
  .notes-grid:not(.list-view) .note-card-header > .master-blue-ok-badge {
    display: none;
  }
  .tag-group-heading {
    margin-top: 22px;
  }
  .notes-grid:not(.list-view) .note-card-header.card-master-title-bar,
  .notes-grid:not(.list-view) .note-card-items.inside-title-box {
    padding: 6px;
  }
  .notes-grid:not(.list-view) .custom-checkbox {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }
  .notes-grid:not(.list-view) .note-card-footer {
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.68rem;
  }
  img,
  canvas {
    max-width: 100%;
  }

  /* --- Modais --- */
  .modal-card {
    padding: 16px 14px 12px;
    height: 100dvh;
    max-height: 100dvh;
  }
  .modal-card.instructions-modal-card,
  .modal-card.confirm-modal-card,
  .modal-card.drawing-modal-card {
    width: calc(100vw - 24px);
    height: auto;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
  /* Cabeçalho do modal/criador: título encolhe, botões nunca saem da tela */
  .composer-header {
    gap: 6px;
  }
  .composer-header .composer-title-input {
    min-width: 0;
    width: 0;
  }
  .composer-header > button {
    flex-shrink: 0;
  }
  .composer-header .btn-keep-close {
    font-size: 0;
    padding: 8px 10px;
  }
  .composer-header .btn-keep-close::after {
    content: '✕';
    font-size: 1.1rem;
  }
  .instruction-item {
    flex-direction: column;
    gap: 8px;
  }
  .instruction-keys {
    min-width: 0;
  }
  #drawingCanvas {
    height: 300px;
  }
  .drawing-tools {
    flex-wrap: wrap;
  }
  .auth-overlay {
    padding: 12px;
  }
  .auth-card {
    padding: 22px 18px;
  }

  /* --- Popovers não podem passar da tela --- */
  .keep-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    max-height: 60dvh;
    overflow-y: auto;
  }

  /* --- Toast centralizado --- */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 16px;
  }
}

@media (max-width: 380px) {
  .brand-title {
    display: none;
  }
}
