:root {
  --bg: #f4f3ee;
  --surface: #ffffff;
  --ink: #1f1f1f;
  --muted: #6b6b6b;
  --accent: #e8a33d;
  --border: #e3e1d8;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-hover: 0 6px 16px rgba(0,0,0,0.12);
  --note-filter: none;
}

:root[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #242424;
  --ink: #ececec;
  --muted: #a0a0a0;
  --accent: #e8a33d;
  --border: #383838;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-hover: 0 6px 16px rgba(0,0,0,0.5);
  /* Atenúa los colores pastel de las notas para que no deslumbren en modo oscuro */
  --note-filter: brightness(0.82) saturate(0.9);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  transition: background-color .15s, color .15s;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 22px; }
.brand h1 { font-size: 18px; font-weight: 600; margin: 0; }

.search-wrap { flex: 1; max-width: 480px; }
#search {
  width: 100%;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 14px;
  outline: none;
  transition: box-shadow .15s;
}
#search:focus { box-shadow: 0 0 0 2px var(--accent); background: var(--surface); }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 32px;
}

.composer input, .composer textarea {
  width: 100%;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  background: transparent;
}

#new-title { font-weight: 600; margin-bottom: 6px; font-size: 16px; }
#new-content { min-height: 24px; line-height: 1.4; }

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.colors { display: flex; gap: 8px; }
.color-dot {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform .1s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-color: var(--ink); }

#add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
#add-btn:hover { opacity: .9; }

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 24px 0 10px;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  transition: outline-color .15s;
}
.grid.drag-active {
  min-height: 64px;
  outline: 2px dashed var(--border);
  outline-offset: 6px;
  border-radius: var(--radius);
}

.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: box-shadow .15s, transform .1s, filter .15s;
  min-height: 100px;
  filter: var(--note-filter);
}
.note:hover { box-shadow: var(--shadow-hover); }
.note[draggable="true"] { cursor: grab; }
.note.dragging { opacity: .4; cursor: grabbing; }

.note-header {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.drag-handle {
  flex-shrink: 0;
  cursor: grab;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  margin: -2px 0 0 -4px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity .15s, background .15s;
  user-select: none;
}
.note:hover .drag-handle,
.note:focus-within .drag-handle { opacity: 1; }
.drag-handle:hover { background: rgba(0,0,0,0.06); }
.drag-handle:active { cursor: grabbing; }

.note-title {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  outline: none;
  word-break: break-word;
  cursor: text;
}
.note-content {
  font-size: 14px;
  color: var(--ink);
  white-space: pre-wrap;
  outline: none;
  word-break: break-word;
  flex: 1;
  cursor: text;
}
.note-title:empty::before { content: attr(data-placeholder); color: var(--muted); }
.note-content:empty::before { content: attr(data-placeholder); color: var(--muted); }

.note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  transition: opacity .15s;
}
.note:hover .note-actions,
.note:focus-within .note-actions { opacity: 1; }

.note-actions .colors { gap: 6px; }
.note-actions .color-dot { width: 18px; height: 18px; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--muted);
}
.icon-btn:hover { background: rgba(0,0,0,0.06); color: var(--ink); }
.icon-btn.pinned { color: var(--accent); }

.theme-toggle {
  font-size: 18px;
  flex-shrink: 0;
}
[data-theme="dark"] .icon-btn:hover { background: rgba(255,255,255,0.08); }

.empty {
  text-align: center;
  color: var(--muted);
  margin-top: 60px;
  font-size: 15px;
}
