/* ═══════════════════════════════════════════
   InkPad — Sistema de Temas 2.0
   Paletas investigadas de Catppuccin, Rosé Pine,
   Tokyo Night y Everforest — cómodas para la vista
   ═══════════════════════════════════════════ */

/* ── Transición global de temas (excluir canvas para rendimiento) ── */

*, *::before, *::after { transition: background-color 200ms ease, border-color 200ms ease, color 150ms ease, box-shadow 200ms ease; }
canvas, canvas * { transition: none !important; }

/* ── Variables base: Sistema de Diseño Premium ──
   Inspirado en Geist (Vercel), Linear, Apple HIG y Bear
   Spacing: 4px base · Radius: 6/8/12/9999 · Timing: 0.15s swift */

:root {
  --topbar-h: 48px;
  --sidebar-w: 280px;
  --editor-max-w: 65ch;

  /* Spacing scale (4px base — Geist) */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border radius (Linear/Geist) */
  --radius-sm:    4px;
  --radius-md:    6px;     /* Geist default, Linear components */
  --radius-lg:    8px;     /* Apple CTA, cards */
  --radius-xl:    12px;    /* Dialogs, larger surfaces */
  --radius-2xl:   16px;    /* Special surfaces */
  --radius-pill:  9999px;  /* Pill buttons (Linear, Vercel) */

  /* Typography */
  --font-sans:  system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono:  ui-monospace, 'SF Mono', 'Cascadia Code', 'Consolas', monospace;

  --text-xs:     11px;   /* Caption 2 (Apple HIG) */
  --text-sm:     12px;   /* Caption 1 (Apple HIG) */
  --text-base:   13px;   /* Footnote (Apple HIG) */
  --text-md:     14px;   /* Default body */
  --text-lg:     15px;   /* Body (Linear) */
  --text-xl:     17px;   /* Headline (Apple HIG body) */
  --text-2xl:    20px;   /* Title 3 (Apple HIG) */
  --text-3xl:    24px;   /* Cards, sections */
  --text-4xl:    32px;   /* Page titles */

  --weight-normal:   400;
  --weight-medium:  500;
  --weight-semibold: 590;  /* Linear's precise weight */
  --weight-bold:    600;
  --weight-xbold:   700;

  --leading-tight:   1.0;
  --leading-snug:    1.2;
  --leading-normal:  1.4;
  --leading-relaxed: 1.6;

  /* Shadows — composite multi-layer (Geist) */
  --shadow-sm:    0px 1px 2px rgba(0,0,0,0.08);
  --shadow-md:    0px 2px 2px rgba(0,0,0,0.06), 0px 4px 8px -4px rgba(0,0,0,0.10);
  --shadow-lg:    0px 2px 2px rgba(0,0,0,0.04), 0px 8px 16px -4px rgba(0,0,0,0.08);
  --shadow-xl:    0 0 0 1px rgba(0,0,0,0.06), 0px 8px 16px -4px rgba(0,0,0,0.06), 0px 24px 32px -8px rgba(0,0,0,0.10);

  /* Motion */
  --ease-swift:   cubic-bezier(.175, .885, .32, 1.1);   /* Vercel bounce */
  --ease-smooth:  cubic-bezier(0.4, 0, 0.2, 1);          /* Standard */
  --ease-linear:  cubic-bezier(0.25, 0.46, 0.45, 0.94);  /* Linear app */
  --duration-fast:  0.1s;
  --duration-base:  0.15s;
  --duration-slow:  0.2s;
  --duration-modal: 0.3s;
}

/* ── Font rendering base ── */
html, body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  font-weight: var(--weight-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ═══════════════════════════════════════════
   TEMA 1: CATPPUCCIN LATTE (claro · juvenil)
   Grises refinados, tonos pastel, moderno y fresco
   ═══════════════════════════════════════════ */

[data-theme="catppuccin-latte"] {
  color-scheme: light;
  --bg:       #eff1f5;
  --surface:  #e6e9ef;
  --surface2: #dce0e8;
  --surface3: #ccd0da;
  --text:     #4c4f69;
  --text2:    #5c5f77;
  --muted:    #9ca0b0;
  --line:     rgba(76,79,105,0.10);
  --line2:    rgba(76,79,105,0.18);
  --brand:    #1e66f5;
  --brand-rgb: 30, 102, 245;
  --brand2:   #ea76cb;
  --danger:   #d20f39;
  --accent:   #8839ef;
  --shadow: 0 4px 16px rgba(76,79,105,0.08);
  --sidebar-bg: rgba(230,233,239,0.88);
  --topbar-bg: rgba(230,233,239,0.85);
  --fab-gradient: linear-gradient(135deg, #1e66f5, #3b82f6);
}

/* ═══════════════════════════════════════════
   TEMA 2: ROSÉ PINE DAWN (claro · cálido)
   Rosas suaves, tonos tierra, acogedor
   ═══════════════════════════════════════════ */

[data-theme="rose-pine-dawn"] {
  color-scheme: light;
  --bg:       #faf4ed;
  --surface:  #fffaf3;
  --surface2: #f2e9e1;
  --surface3: #e5dbd3;
  --text:     #464261;
  --text2:    #797593;
  --muted:    #9893a5;
  --line:     rgba(70,66,97,0.08);
  --line2:    rgba(70,66,97,0.15);
  --brand:    #286983;
  --brand-rgb: 40, 105, 131;
  --brand2:   #56949f;
  --danger:   #b4637a;
  --accent:   #907aa9;
  --shadow: 0 4px 16px rgba(70,66,97,0.08);
  --sidebar-bg: rgba(250,244,237,0.88);
  --topbar-bg: rgba(250,244,237,0.85);
  --fab-gradient: linear-gradient(135deg, #286983, #31748f);
}

/* ═══════════════════════════════════════════
   TEMA 3: TOKYO NIGHT DAY (claro · fresco)
   Azul grisáceo, limpio, moderno
   ═══════════════════════════════════════════ */

[data-theme="tokyo-day"] {
  color-scheme: light;
  --bg:       #e1e2e7;
  --surface:  #cbccd5;
  --surface2: #d5d6db;
  --surface3: #e8e9ec;
  --text:     #343b58;
  --text2:    #565a6e;
  --muted:    #96999b;
  --line:     rgba(52,59,88,0.09);
  --line2:    rgba(52,59,88,0.16);
  --brand:    #2f3fba;
  --brand-rgb: 47, 63, 186;
  --brand2:   #0f4b6e;
  --danger:   #8c4351;
  --accent:   #5a4a78;
  --shadow: 0 4px 16px rgba(52,59,88,0.08);
  --sidebar-bg: rgba(203,204,213,0.85);
  --topbar-bg: rgba(203,204,213,0.82);
  --fab-gradient: linear-gradient(135deg, #2f3fba, #1e2a8a);
}

/* ═══════════════════════════════════════════
   TEMA 4: EVERFOREST LIGHT (claro · natural)
   Verdes suaves, terroso, fácil para los ojos
   ═══════════════════════════════════════════ */

[data-theme="everforest-light"] {
  color-scheme: light;
  --bg:       #fdf6e3;
  --surface:  #efeBD4;
  --surface2: #f4f0d9;
  --surface3: #e6e2cc;
  --text:     #5c6a72;
  --text2:    #939f91;
  --muted:    #a6b0a0;
  --line:     rgba(92,106,114,0.09);
  --line2:    rgba(92,106,114,0.16);
  --brand:    #3a94c5;
  --brand-rgb: 58, 148, 197;
  --brand2:   #35a77c;
  --danger:   #f85552;
  --accent:   #df69ba;
  --shadow: 0 4px 16px rgba(92,106,114,0.08);
  --sidebar-bg: rgba(239,235,212,0.88);
  --topbar-bg: rgba(239,235,212,0.85);
  --fab-gradient: linear-gradient(135deg, #3a94c5, #2d7aa0);
}

/* ═══════════════════════════════════════════
   TEMA 5: CATPPUCCIN MOCHA (oscuro · acogedor)
   Púrpura oscuro, frambuesa, el más popular
   ═══════════════════════════════════════════ */

[data-theme="catppuccin-mocha"] {
  color-scheme: dark;
  --bg:       #1e1e2e;
  --surface:  #181825;
  --surface2: #11111b;
  --surface3: #313244;
  --text:     #cdd6f4;
  --text2:    #bac2de;
  --muted:    #6c7086;
  --line:     rgba(205,214,244,0.06);
  --line2:    rgba(205,214,244,0.12);
  --brand:    #89b4fa;
  --brand-rgb: 137, 180, 250;
  --brand2:   #f5c2e7;
  --danger:   #f38ba8;
  --accent:   #cba6f7;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --sidebar-bg: rgba(24,24,37,0.55);
  --topbar-bg: rgba(24,24,37,0.82);
  --fab-gradient: linear-gradient(135deg, #89b4fa, #b4befe);
}

/* ═══════════════════════════════════════════
   TEMA 6: ROSÉ PINE (oscuro · cálido)
   Pino violáceo, romántico, acogedor
   ═══════════════════════════════════════════ */

[data-theme="rose-pine"] {
  color-scheme: dark;
  --bg:       #191724;
  --surface:  #1f1d2e;
  --surface2: #26233a;
  --surface3: #312f44;
  --text:     #e0def4;
  --text2:    #908caa;
  --muted:    #6e6a86;
  --line:     rgba(224,222,244,0.05);
  --line2:    rgba(224,222,244,0.10);
  --brand:    #31748f;
  --brand-rgb: 49, 116, 143;
  --brand2:   #9ccfd8;
  --danger:   #eb6f92;
  --accent:   #c4a7e7;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --sidebar-bg: rgba(31,29,46,0.55);
  --topbar-bg: rgba(31,29,46,0.82);
  --fab-gradient: linear-gradient(135deg, #31748f, #9ccfd8);
}

/* ═══════════════════════════════════════════
   TEMA 7: TOKYO NIGHT (oscuro · vibrante)
   Azul noche neón, moderno y enérgico
   ═══════════════════════════════════════════ */

[data-theme="tokyo-night"] {
  color-scheme: dark;
  --bg:       #1f2335;
  --surface:  #24283b;
  --surface2: #1b1e2d;
  --surface3: #292e42;
  --text:     #c0caf5;
  --text2:    #a9b1d6;
  --muted:    #565f89;
  --line:     rgba(192,202,245,0.05);
  --line2:    rgba(192,202,245,0.10);
  --brand:    #7aa2f7;
  --brand-rgb: 122, 162, 247;
  --brand2:   #7dcfff;
  --danger:   #f7768e;
  --accent:   #bb9af7;
  --shadow: 0 4px 20px rgba(0,0,0,0.45);
  --sidebar-bg: rgba(36,40,59,0.55);
  --topbar-bg: rgba(36,40,59,0.82);
  --fab-gradient: linear-gradient(135deg, #7aa2f7, #bb9af7);
}

/* ═══════════════════════════════════════════
   TEMA 8: EVERFOREST DARK (oscuro · natural)
   Verde bosque, terroso, el más cómodo para leer
   ═══════════════════════════════════════════ */

[data-theme="everforest-dark"] {
  color-scheme: dark;
  --bg:       #2d353b;
  --surface:  #232a2e;
  --surface2: #343f44;
  --surface3: #3d484d;
  --text:     #d3c6aa;
  --text2:    #859289;
  --muted:    #7a8478;
  --line:     rgba(211,198,170,0.06);
  --line2:    rgba(211,198,170,0.12);
  --brand:    #7fbbb3;
  --brand-rgb: 127, 187, 179;
  --brand2:   #83c092;
  --danger:   #e67e80;
  --accent:   #d699b6;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --sidebar-bg: rgba(35,42,46,0.55);
  --topbar-bg: rgba(35,42,46,0.82);
  --fab-gradient: linear-gradient(135deg, #7fbbb3, #83c092);
}

/* ═══════════════════════════════════════════
   TEMA 9: UPNOTE (claro · cálido · minimalista)
   Inspirado en UpNote: limpio, beige, tipografía cómoda
   ═══════════════════════════════════════════ */

[data-theme="upnote"] {
  color-scheme: light;
  --bg:       #F0ECE6;
  --surface:  #FFFFFF;
  --surface2: #F5F2ED;
  --surface3: #EBE7E0;
  --text:     #2C2C2C;
  --text2:    #6B6B6B;
  --muted:    #8E8E8E;
  --line:     rgba(0,0,0,0.08);
  --line2:    rgba(0,0,0,0.14);
  --brand:    #2B6DE5;
  --brand-rgb: 43, 109, 229;
  --brand2:   #3A8A4A;
  --danger:   #DC3545;
  --accent:   #7C4DBB;
  --shadow: 0 2px 10px rgba(0,0,0,0.06), 0 4px 24px rgba(0,0,0,0.04);
  --sidebar-bg: rgba(255,255,255,0.85);
  --topbar-bg: rgba(255,255,255,0.88);
  --fab-gradient: linear-gradient(135deg, #2B6DE5, #1A5CDE);
}

/* ── Reset ── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body { overflow: hidden; }

/* ── Topbar ── */

.topbar {
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
  -webkit-user-select: none;
  user-select: none;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  grid-column: 1;
}

#sidebarToggle {
  display: none;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.brand__dot {
  width: 10px; height: 10px;
  border-radius: 999px;
  background: conic-gradient(from 90deg, var(--brand), var(--brand2), var(--brand));
  box-shadow: 0 0 0 2px rgba(var(--brand-rgb),0.2);
  flex-shrink: 0;
}

.brand__title { font-weight: 700; font-size: 15px; letter-spacing: 0.1px; }
.brand__sub { font-size: 11px; color: var(--text2); }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  grid-column: 3;
  justify-content: flex-end;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.dateLabel {
  min-width: 130px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.divider {
  width: 1px; height: 22px;
  background: var(--line);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ── Navegación modo ── */

.mode-nav {
  display: flex;
  gap: 2px;
  grid-column: 2;
  justify-self: center;
}

.mode-nav__btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text2);
  padding: 5px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-swift),
              color var(--duration-fast) var(--ease-swift),
              border-color var(--duration-fast) var(--ease-swift);
  white-space: nowrap;
}
.mode-nav__btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.mode-nav__btn--active {
  background: rgba(var(--brand-rgb),0.1);
  color: var(--brand);
  border-color: rgba(var(--brand-rgb),0.25);
}

/* ── Botones genéricos ── */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-swift),
              border-color var(--duration-fast) var(--ease-swift),
              color var(--duration-fast) var(--ease-swift),
              transform var(--duration-fast) var(--ease-swift);
  user-select: none;
}
.btn:hover { background: var(--surface3); border-color: var(--line2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--brand), 0 0 0 4px rgba(var(--brand-rgb),0.15); }
.btn--primary {
  background: rgba(var(--brand-rgb),0.12);
  border-color: rgba(var(--brand-rgb),0.25);
  color: var(--brand);
}
.btn--primary:hover {
  background: rgba(var(--brand-rgb),0.18);
  border-color: rgba(var(--brand-rgb),0.35);
}
.btn--seg[aria-pressed="true"] {
  background: rgba(var(--brand-rgb),0.12);
  border-color: rgba(var(--brand-rgb),0.3);
}
.btn--sm { padding: 4px 8px; font-size: 11px; }

.toolset { display: inline-flex; align-items: center; gap: 4px; }
.toolset--hidden { display: none !important; }

/* ── Layout principal ── */

.layout {
  height: calc(100% - var(--topbar-h));
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  position: relative;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  overflow: hidden;
  min-width: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

/* Stats */
.sidebar__stats {
  padding: 8px 12px;
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text2);
  border-bottom: 1px solid var(--line);
}
.sidebar__stats span { font-weight: 600; color: var(--text); }

/* Buscador */
.sidebar__search { padding: 8px 12px 0; }

/* Calendar */
.sidebar__cal { padding: 12px 12px 8px; }

.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 700; font-size: 13px; }
.cal-nav {
  appearance: none; border: none; background: transparent;
  color: var(--text2); cursor: pointer; padding: 4px 8px; border-radius: 6px;
  font-size: 14px;
}
.cal-nav:hover { background: rgba(255,255,255,0.05); color: var(--text); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
  font-size: 12px;
}

.cal-day-label { color: var(--muted); font-size: 10px; font-weight: 700; padding: 4px 0; text-transform: uppercase; }

.cal-day {
  padding: 5px 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text2);
  transition: background 80ms ease;
}
.cal-day:hover { background: rgba(255,255,255,0.05); }
.cal-day--other { opacity: 0.3; }
.cal-day--today { background: rgba(var(--brand-rgb),0.15); color: var(--brand); }
.cal-day--selected { background: var(--brand); color: #fff !important; font-weight: 700; }
.cal-day--has-entry { color: var(--text); font-weight: 700; }
.cal-day--selected.cal-day--has-entry { color: #fff !important; }

/* ── Notas list (reemplaza entry list en modo notes) ── */
.sidebar__notes-list {
  overflow-y: auto;
  min-height: 0;
  padding: 0 12px 8px;
}

/* ── Entry list (diary mode) ── */
.sidebar__entries { overflow-y: auto; min-height: 0; padding: 0 12px 8px; }
.sidebar__section-title { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 0 4px; }

.entry-list { display: flex; flex-direction: column; gap: 0; }

.entry-month-header {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 12px 8px 4px;
}

.entry-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 80ms ease;
}
.entry-item:hover { background: rgba(255,255,255,0.04); }
.entry-item--selected { background: rgba(var(--brand-rgb),0.12); border-color: rgba(var(--brand-rgb),0.3); }

.entry-item__date {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 36px;
  flex-shrink: 0;
  line-height: 1.2;
}
.entry-item__dow { font-size: 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.entry-item__day { font-size: 16px; font-weight: 800; color: var(--text); }

.entry-item__content { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.entry-item__title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-item__meta-bar { font-size: 10px; color: var(--muted); display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* Folder badge en entry list */
.folder-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}
.folder-badge--color { color: #fff; }

/* ── Carpeta / Filtro en sidebar ── */
.sidebar__folders {
  padding: 0 12px 4px;
  border-bottom: 1px solid var(--line);
}
.sidebar__folders-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 6px 0 4px;
}
.folder-list { display: flex; flex-direction: column; gap: 1px; }
.folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text2);
  transition: background 80ms ease;
}
.folder-item:hover { background: rgba(255,255,255,0.04); }
.folder-item--active { color: var(--text); background: rgba(var(--brand-rgb),0.08); }
.folder-item__color {
  width: 10px; height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.folder-item__name { flex: 1; font-weight: 600; }
.folder-item__count { font-size: 10px; color: var(--muted); font-weight: 700; }

/* ── Mood bar ── */
.sidebar__meta { padding: 8px 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.meta-row { display: flex; align-items: center; gap: 8px; }
.meta-label { font-size: 11px; color: var(--muted); font-weight: 600; min-width: 60px; }
.mood-bar { display: flex; gap: 3px; }
.mood-btn {
  appearance: none; border: 1px solid var(--line);
  background: transparent; border-radius: 6px; 
  cursor: pointer; padding: 2px 4px; font-size: 16px;
  transition: background 80ms ease, transform 80ms ease;
}
.mood-btn:hover { background: rgba(255,255,255,0.05); transform: scale(1.15); }
.mood-btn--active { background: rgba(var(--brand-rgb),0.15); border-color: var(--brand); }

/* ── Weather & Location ── */
.meta-row--compact { gap: 4px; }
.weather-select {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.weather-select:focus { border-color: var(--brand); outline: none; }
.location-input {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 11px;
  width: 100px;
  outline: none;
}
.location-input:focus { border-color: var(--brand); }

/* ── Tags ── */
.tags-wrap { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(var(--brand-rgb),0.12); border: 1px solid rgba(var(--brand-rgb),0.2);
  border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600;
}
.tag__del { appearance: none; border: none; background: transparent; color: var(--text2); cursor: pointer; padding: 0; font-size: 12px; line-height: 1; }
.tag__del:hover { color: var(--danger); }

.input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font-weight: 600; font-size: 13px; outline: none; }
.input:focus { border-color: var(--brand); }
.input--sm { padding: 4px 8px; font-size: 12px; }
.input::placeholder { color: var(--muted); }

.sidebar__footer { padding: 8px 12px; border-top: 1px solid var(--line); background: rgba(15,23,42,0.2); }
.hint { font-size: 11px; color: var(--text2); line-height: 1.4; }
kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 10px; background: rgba(0,0,0,0.3); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }
.status { margin-top: 6px; font-size: 11px; color: var(--text2); min-height: 14px; }

/* ── Stage / Main ── */

.stage { display: grid; overflow: hidden; min-width: 0; }

/* ── Editor wrapper ── */

.editor-wrap { 
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* Notes mode: 4 hijos, asignar filas explícitamente */
#notesPanelMain.editor-wrap {
  grid-template-rows: auto auto 1fr auto;
}
#notesPanelMain .notes-editor-top { grid-row: 1; }
#notesPanelMain .editor-toolbar { grid-row: 2; }
#notesPanelMain .page-container { grid-row: 3; }
#notesPanelMain #noteInkBar { grid-row: 4; }

.editor-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
  flex-wrap: wrap;
  -webkit-user-select: none;
  user-select: none;
  max-width: var(--editor-max-w);
  margin: 0 auto;
  width: 100%;
}

.editor-btn {
  appearance: none; border: 1px solid transparent;
  background: transparent; color: var(--text2);
  padding: 4px 8px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; font-weight: var(--weight-semibold);
  transition: background var(--duration-fast) var(--ease-swift),
              color var(--duration-fast) var(--ease-swift);
}
.editor-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.editor-divider { width: 1px; height: 18px; background: var(--line); margin: 0 4px; flex-shrink: 0; }

/* ── Page container ── */

.page-container {
  position: relative;
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.ink-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  touch-action: none;
  display: block;
  /* La tinta se oscurece sobre el texto en lugar de ocultarlo */
  mix-blend-mode: multiply;
  /* Aislar mix-blend-mode para que no afecte al layout */
  isolation: isolate;
}
[data-theme="catppuccin-mocha"] .ink-canvas,
[data-theme="rose-pine"] .ink-canvas,
[data-theme="tokyo-night"] .ink-canvas,
[data-theme="everforest-dark"] .ink-canvas {
  /* En modo oscuro, screen funciona mejor para trazos claros */
  mix-blend-mode: screen;
}

.stage { position: relative; display: grid; overflow: hidden; min-width: 0; }

.editor-body {
  position: relative;
  z-index: 4;
  padding: 20px 24px;
  min-height: 400px;
  outline: none;
  line-height: var(--lh-base, 1.75);
  font-size: var(--step-0, clamp(0.9375rem, 0.875rem + 0.25vw, 1.0625rem));
  font-weight: var(--font-weight-base, 400);
  color: var(--text);
  max-width: var(--editor-max-w, 65ch);
  width: 100%;
  margin: 0 auto;
  background: transparent;

  /* ═══ Reading optimization ═══ */
  font-kerning: normal;
  font-variant-ligatures: common-ligatures contextual;
  font-variant-numeric: proportional-nums;
  text-rendering: var(--text-rendering, optimizeLegibility);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  hyphens: auto;
  overflow-wrap: break-word;
  orphans: 2;
  widows: 2;
}

/* Notes mode: more compact */
#notesPanelMain .editor-body {
  padding: 8px 24px 20px;
  min-height: 250px;
  max-width: var(--editor-max-w, 65ch);
  margin: 0 auto;
}

.editor-body:empty::before {
  content: "Escribe aquí tu entrada…";
  color: var(--muted);
  font-style: italic;
}

.editor-body h2 {
  font-size: var(--step-3, clamp(1.75rem, 1.375rem + 1.25vw, 2rem));
  font-weight: 700;
  line-height: var(--lh-heading, 1.2);
  margin: 1.25em 0 0.35em;
  letter-spacing: -0.02em;
  color: var(--text-heading, var(--text));
}
.editor-body h3 {
  font-size: var(--step-2, clamp(1.375rem, 1.125rem + 0.75vw, 1.625rem));
  font-weight: 650;
  line-height: var(--lh-heading, 1.2);
  margin: 1em 0 0.3em;
  letter-spacing: -0.015em;
  color: var(--text-heading, var(--text));
}
.editor-body p {
  margin: 0 0 0.75em;
}
.editor-body ul, .editor-body ol { margin: 4px 0 12px; padding-left: 24px; }
.editor-body li { margin: 2px 0; }

/* ── Ink bar ── */

.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 15;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--fab-gradient);
  color: #fff;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(var(--brand-rgb),0.4);
  display: grid;
  place-items: center;
  transition: transform 100ms ease, box-shadow 100ms ease;
  user-select: none;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(var(--brand-rgb),0.5); }
.fab:active { transform: scale(0.95); }

.ink-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--line2);
  background: rgba(17,24,39,0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: opacity 200ms ease, transform 200ms ease;
  white-space: nowrap;
}
.ink-bar--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
}
.ink-bar__label { font-size: 13px; font-weight: 600; color: var(--text2); }
.ink-bar__btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(15,23,42,0.8);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ink-bar__btn:hover { background: rgba(30,41,59,0.8); }
.ink-bar__btn--primary {
  background: rgba(var(--brand-rgb),0.15);
  border-color: rgba(var(--brand-rgb),0.3);
}
.ink-bar__btn--primary:hover { background: rgba(var(--brand-rgb),0.22); }

/* ── Notes module ── */

/* Note selector panel (modo notas) */
.note-selector {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  min-height: 0;
  padding: 0 0 8px;
}
.note-selector__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.note-selector__new-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text2);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.note-selector__new-btn:hover { color: var(--brand); border-color: var(--brand); }

.note-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 0;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 80ms ease;
}
.note-item:hover { background: rgba(255,255,255,0.03); }
.note-item--selected { background: rgba(var(--brand-rgb),0.1); border-left-color: var(--brand); }

.note-item__icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}
.note-item__content { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.note-item__title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item__preview { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item__meta { font-size: 10px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.note-item__folder-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

/* ── Panel de Ajustes ── */

.settings-panel {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 32px;
  overflow-y: auto;
  height: 100%;
}

.settings-panel h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 4px;
}

.settings-panel p {
  font-size: 13px;
  color: var(--text2);
  margin: 0 0 24px;
}

.settings-section {
  margin-bottom: 28px;
}

.settings-section__title {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
}

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

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid var(--line);
  cursor: pointer;
  transition: border-color 80ms ease, background 80ms ease;
  background: transparent;
  appearance: none;
  color: var(--text);
  font-size: 12px;
}
.theme-card:hover { border-color: var(--line2); }
.theme-card--active { border-color: var(--brand); background: rgba(var(--brand-rgb),0.08); }

.theme-card__preview {
  width: 100%;
  height: 48px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.theme-card__name { font-weight: 600; }

/* Settings rows */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.settings-row__label { font-size: 13px; font-weight: 600; }
.settings-row__desc { font-size: 11px; color: var(--muted); }
.settings-row__action { display: flex; align-items: center; gap: 8px; }

/* ── Folder manager ── */

.folder-manager {
  display: grid;
  gap: 6px;
}

.folder-manager__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
}

.folder-manager__color {
  width: 14px; height: 14px;
  border-radius: 999px;
  flex-shrink: 0;
}

.folder-manager__name {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
}

.folder-manager__count {
  font-size: 11px;
  color: var(--muted);
}

.folder-manager__del {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 80ms ease;
}
.folder-manager__item:hover .folder-manager__del { opacity: 1; }

.folder-add-row {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  gap: 8px;
}
.empty-state__icon { font-size: 40px; opacity: 0.4; }
.empty-state__text { font-size: 14px; }
.empty-state__sub { font-size: 12px; color: var(--muted); opacity: 0.7; }

/* ── File inputs ── */
.fileInput { position: fixed; left: -10000px; top: 0; width: 1px; height: 1px; opacity: 0; }

/* ── Dialog ── */
.dialog { border: 1px solid var(--line2); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(400px, calc(100vw - 24px)); }
.dialog__form { display: grid; gap: 10px; padding: 16px; }
.dialog__msg { margin: 0; font-size: 14px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Responsive ── */

/* ═══════════════════════════════════════════
   RESPONSIVE — Sistema completo
   ═══════════════════════════════════════════ */

/* Desktop wide (>1200) — layout completo */
@media (min-width: 1201px) {
  /* font-size hereda de clamp() en :root → .editor-body */
}

/* Desktop compact (901–1200) */
@media (max-width: 1200px) {
  :root { --sidebar-w: 260px; }
  .editor-body { padding: 16px 20px; }
}

/* Tablet landscape (769–900) */
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; --editor-max-w: 100%; }
  .brand__sub { display: none; }
  .mode-nav__btn { font-size: 11px; padding: 4px 8px; }
  .editor-body { padding: 16px 20px; }
  #notesPanelMain .editor-body { padding: 6px 20px 16px; }
  .topbar__actions { gap: 2px; }
  .dateLabel { min-width: 100px; font-size: 12px; }
  .settings-panel { padding: 20px; }
}

/* Tablet portrait & large phone (481–768) */
@media (max-width: 768px) {
  :root { --sidebar-w: 280px; --topbar-h: 48px; --editor-max-w: 100%; }

  /* Sidebar overlay */
  #sidebarToggle { display: flex; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: var(--sidebar-w);
    height: calc(100% - var(--topbar-h));
    z-index: 20;
    transform: translateX(-100%);
    opacity: 0;
    border-right: 1px solid var(--line);
    background: rgba(11,14,26,0.97);
    transition: transform 220ms ease, opacity 220ms ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); opacity: 1; }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 19;
  }

  .layout { grid-template-columns: 1fr; }
  .topbar { padding: 0 6px; }
  .topbar__actions { gap: 2px; }
  #prevDateBtn, #nextDateBtn { min-width: 34px; min-height: 34px; }

  /* Editor */
  .editor-body { padding: 14px 16px; min-height: 250px; }
  #notesPanelMain .editor-body { padding: 6px 16px 14px; }

  /* Ink bar */
  .ink-bar { bottom: 10px; padding: 6px 10px; font-size: 12px; }
  .ink-bar__label { display: none; }

  /* Mode nav */
  .mode-nav__btn { font-size: 11px; padding: 4px 7px; }

  /* Theme grid */
  .theme-grid { grid-template-columns: repeat(2, 1fr); }

  /* Settings */
  .settings-panel { padding: 14px; }

  /* Journal toolbar */
  #exportPngBtn { display: none; }

  /* Calendar */
  .cal-day { padding: 4px 0; font-size: 11px; }

  /* Note list grid */
  .note-list--grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* Small phone (≤480) */
@media (max-width: 480px) {
  :root { --topbar-h: 44px; }
  .topbar { padding: 0 4px; gap: 2px; }
  .brand__title { font-size: 13px; }
  .brand__dot { width: 8px; height: 8px; }

  /* Date nav: hide arrow buttons, keep today */
  #prevDateBtn, #nextDateBtn { display: none; }
  .dateLabel { min-width: 70px; font-size: 11px; padding: 4px 6px; }

  /* Mode nav compact */
  .mode-nav { gap: 1px; margin-right: 4px; }
  .mode-nav__btn { font-size: 10px; padding: 3px 5px; }

  /* Editor */
  .editor-body { padding: 10px 12px; min-height: 200px; }
  #notesPanelMain .editor-body { padding: 4px 12px 10px; }
  #noteTitleInput { font-size: 16px !important; }
  #noteTitleInput::placeholder { font-size: 16px; }

  /* Notes toolbar compact */
  .editor-toolbar { padding: 3px 10px; gap: 1px; }
  .editor-btn { padding: 3px 5px; font-size: 11px; }

  /* Notes editor top */
  .notes-editor-top { padding: 6px 12px 3px; }
  .notes-editor-actions .btn--seg { font-size: 11px; padding: 2px 4px; }

  /* Sidebar */
  .sidebar { width: 100% !important; }

  /* Notes list */
  .note-list--grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }

  /* Theme grid */
  .theme-grid { grid-template-columns: repeat(2, 1fr); }

  /* FAB smaller */
  .fab { width: 44px; height: 44px; font-size: 22px; bottom: 16px; right: 16px; }

  /* Ink bar compact */
  .ink-bar { bottom: 8px; padding: 4px 8px; }
  .ink-bar__btn { font-size: 11px; padding: 3px 7px; }

  /* Editor toolbar - hide less essential buttons */
  .editor-btn[data-cmd="foreColor"] { display: none; }
  .editor-divider + .editor-btn[data-cmd="foreColor"] { display: none; }

  /* Settings */
  .settings-panel { padding: 12px; }

  /* Calendar smaller */
  .cal-day { padding: 3px 0; font-size: 10px; }

  /* Meta section compact */
  .meta-label { min-width: 40px; font-size: 10px; }
  .sidebar__meta { padding: 6px 8px; gap: 4px; }

  /* Entry list */
  .entry-item { padding: 6px 6px; }
  .entry-item__day { font-size: 14px; }
  .entry-item__title { font-size: 12px; }

  /* Note cards */
  .note-card { padding: 8px 10px; min-height: 56px; }
  .note-item { padding: 5px 6px; gap: 4px; }

  /* Theme cards */
  .theme-card { padding: 8px; }
  .theme-card__preview { height: 36px; font-size: 14px; }

  /* Dialogs */
  .dialog--wide { width: 95vw; }

  /* Quick switcher */
  .qs-header { padding: 8px 10px; }
  .qs-item { padding: 6px 8px; font-size: 12px; }

  /* Stats */
  .sidebar__stats { padding: 6px 8px; gap: 8px; font-size: 10px; }
  .sidebar__search { padding: 6px 8px 0; }

  /* Folder items */
  .folder-item { padding: 3px 5px; font-size: 11px; }

  /* Paper selector hide labels */
  .paper-selector { gap: 2px; margin-left: 4px; }
  .paper-btn { padding: 2px 5px; font-size: 10px; }
}

/* Touch optimization: bigger hit targets on touch devices */
@media (hover: none) and (pointer: coarse) {
  .btn, .editor-btn, .mode-nav__btn, .note-item, .entry-item,
  .cal-day, .folder-item, .mood-btn, .paper-btn {
    min-height: 44px;
  }
  .btn--sm { min-height: 36px; }
  .note-item, .entry-item { padding-top: 8px; padding-bottom: 8px; }
  .mode-nav__btn { min-height: 40px; }
  .notes-editor-actions .btn--seg { min-height: 36px; }
}

/* Ensure sidebar has a minimum width on mobile when open */
@media (max-width: 480px) {
  body.sidebar-open .sidebar {
    width: 85vw !important;
  }
}

/* ═══════════════════════════════════════════
   MEJORAS NOTAS — nuevos estilos
   ═══════════════════════════════════════════ */

/* Notes editor top bar */
.notes-editor-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 16px 4px;
  max-width: var(--editor-max-w);
  margin: 0 auto;
  width: 100%;
}
#noteTitleInput {
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1.3;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  width: 100%;
  outline: none;
}
#noteTitleInput:focus {
  outline: none;
}
#noteTitleInput::placeholder {
  color: var(--muted);
  font-weight: 500;
  font-size: 18px;
  opacity: 0.5;
}
.notes-editor-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.notes-editor-actions .btn--seg {
  font-size: 13px;
  padding: 3px 6px;
}

/* Notes selector header actions */
.note-selector__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 12px;
}
.note-selector__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.sort-select {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 10px;
  color: var(--text2);
  cursor: pointer;
}

/* Notes stats bar */
.note-selector__stats {
  padding: 0 10px 6px;
  font-size: 10px;
  color: var(--muted);
  display: flex;
  gap: 4px;
}

/* Note list (list view) */
.note-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 6px 8px;
}
.note-list--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
  padding: 0 6px 8px;
}

/* Note item (list view) */
.note-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}
.note-item:hover { background: var(--surface3); }
.note-item--selected {
  background: var(--surface3);
  outline: 1px solid var(--brand);
}

/* Note item color accent */
.note-item--color {
  border-left: 3px solid var(--note-color);
}

/* Note card (grid view) */
.note-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.12s;
  position: relative;
  min-height: 70px;
  display: flex;
  flex-direction: column;
}
.note-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.note-card--color {
  border-top: 3px solid var(--note-color);
}
.note-card__pinned {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 11px;
  opacity: 0.6;
}
.note-card__title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 16px;
}
.note-card__preview {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.3;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-card__meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.note-card__folder-badge, .note-item__folder-badge {
  display: inline-block;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 9px;
  color: #fff;
  font-weight: 500;
  line-height: 14px;
}

/* Pinned indicator in list view */
.note-item__pinned {
  position: absolute;
  top: 3px;
  right: 6px;
  font-size: 10px;
  opacity: 0.5;
}

/* Note item content */
.note-item__icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.note-item__content { flex: 1; min-width: 0; }
.note-item__title {
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item__preview {
  font-size: 10.5px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0;
}
.note-item__meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px;
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

/* Trash specific */
.trash-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.trash-item:hover { background: var(--surface3); }
.trash-item__title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trash-item__date {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}
.trash-item__actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.trash-item__actions button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 4px;
  color: var(--text2);
}
.trash-item__actions button:hover { background: var(--surface3); }

/* Archive view */
.archive-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.archive-item:hover { background: var(--surface3); }
.archive-item__icon { font-size: 14px; flex-shrink: 0; }
.archive-item__title {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.archive-item__date { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.archive-item__restore {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 4px;
  color: var(--text2);
  flex-shrink: 0;
}
.archive-item__restore:hover { background: var(--surface3); }

/* Focus mode */
.focus-mode .editor-body > *:not(.focus-active) {
  opacity: 0.25;
  transition: opacity 0.3s;
}
.focus-mode .editor-body > *:hover {
  opacity: 1;
}
.focus-mode .editor-body > *.focus-active {
  opacity: 1;
}

/* Markdown preview */
.md-preview-active .editor-body {
  white-space: pre-wrap;
  font-family: 'Georgia', 'Times New Roman', serif;
  line-height: 1.8;
  font-size: 16px;
}
.md-preview-active .editor-body[contenteditable] {
  user-select: text;
  -webkit-user-select: text;
}
.md-preview-active .editor-toolbar .editor-btn:not(#mdPreviewBtn) {
  opacity: 0.3;
  pointer-events: none;
}

/* Wiki-links autocomplete */
.link-autocomplete {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  min-width: 200px;
}
.link-ac-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.link-ac-item:hover, .link-ac-item--active {
  background: var(--surface3);
}
.link-ac-item__icon { font-size: 12px; flex-shrink: 0; }
.link-ac-item__title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-ac-empty {
  padding: 10px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Template system */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.template-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s;
}
.template-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}
.template-card__icon { font-size: 24px; margin-bottom: 4px; }
.template-card__name { font-size: 11px; color: var(--text2); }

/* Quick Switcher */
.dialog--wide {
  width: min(520px, 90vw);
  padding: 0;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.qs-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.qs-results {
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
}
.qs-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}
.qs-item:hover, .qs-item--active {
  background: var(--surface3);
}
.qs-item__icon {
  font-size: 14px;
  flex-shrink: 0;
}
.qs-item__title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qs-item__date {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}
.qs-empty {
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* Color picker for notes */
.note-color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

/* Toggle lists */
.editor-body details.toggle-block {
  margin: 4px 0;
  cursor: pointer;
}
.editor-body details.toggle-block summary {
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.editor-body details.toggle-block summary::-webkit-details-marker {
  display: none;
}
.editor-body details.toggle-block summary::before {
  content: "▶";
  font-size: 10px;
  display: inline-block;
  transition: transform 0.2s;
  width: 14px;
  text-align: center;
  color: var(--text2);
}
.editor-body details.toggle-block[open] summary::before {
  transform: rotate(90deg);
}
.editor-body details.toggle-block > div {
  padding-left: 18px;
  border-left: 1px solid var(--line);
  margin-left: 5px;
}

/* Callout blocks */
.editor-body .callout-block {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  margin: 8px 0;
  border-radius: 8px;
  background: var(--surface2);
  border-left: 4px solid var(--brand);
  align-items: flex-start;
}
.editor-body .callout-block--info {
  border-left-color: #60a5fa;
  background: rgba(96, 165, 250, 0.08);
}
.editor-body .callout-block--warning {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}
.editor-body .callout-block--success {
  border-left-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}
.editor-body .callout-block--danger {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}
.editor-body .callout-emoji {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}
.editor-body .callout-content {
  flex: 1;
  min-width: 0;
}

/* Checklist styling */
.editor-body ul[style*="list-style-type: none"] li,
.editor-body ul[data-checkbox] li {
  list-style: none;
  margin-left: -20px;
}
.editor-body input[type="checkbox"] {
  margin-right: 6px;
  transform: scale(1.1);
  accent-color: var(--brand);
  cursor: pointer;
}
.editor-body input[type="checkbox"]:checked + span {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Code block styling */
.editor-body pre {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  overflow-x: auto;
  margin: 8px 0;
}
.editor-body code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
  padding: 1px 4px;
  background: var(--surface2);
  border-radius: 3px;
}

/* Blockquote */
.editor-body blockquote {
  border-left: 3px solid var(--accent, var(--brand));
  margin: 1.25em 0;
  padding: 0.5em 0 0.5em 1.25em;
  color: var(--text-secondary, var(--text2, var(--text)));
  font-style: italic;
  line-height: var(--lh-base, 1.75);
}

/* ═══════════════════════════════════════════
   MODO ENFOQUE (focus-mode)
   ═══════════════════════════════════════════ */

body.focus-mode .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}
body.focus-mode .topbar {
  opacity: 0;
  pointer-events: none;
}
body.focus-mode .layout {
  grid-template-columns: 1fr;
}
body.focus-mode .editor-toolbar {
  opacity: 0.3;
  transition: opacity 300ms ease;
}
body.focus-mode .editor-toolbar:hover {
  opacity: 1;
}
body.focus-mode .ink-bar {
  opacity: 0 !important;
  pointer-events: none !important;
}
body.focus-mode .editor-body {
  max-width: var(--editor-max-w, 65ch);
  margin: 0 auto;
  padding-top: 48px;
  font-size: var(--step-0, clamp(0.9375rem, 0.875rem + 0.25vw, 1.0625rem));
  line-height: var(--lh-base, 1.75);
}
body.focus-mode #notesPanelMain .editor-body {
  padding-top: 36px;
}
body.focus-mode.focus-mode .fab {
  opacity: 0.3;
}
body.focus-mode.focus-mode .fab:hover {
  opacity: 1;
}
/* Fade transition for focus mode */
body.focus-mode .sidebar,
body.focus-mode .topbar,
body.focus-mode .editor-toolbar {
  transition: opacity 300ms ease, transform 300ms ease;
}

/* ═══════════════════════════════════════════
   FONDOS DE PAPEL PARA EL CANVAS
   ═══════════════════════════════════════════ */

/* Grid background */
.canvas-bg-grid .ink-canvas,
.ink-canvas.canvas-bg-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}
[data-theme="catppuccin-latte"] .canvas-bg-grid .ink-canvas,
[data-theme="catppuccin-latte"] .ink-canvas.canvas-bg-grid,
[data-theme="rose-pine-dawn"] .canvas-bg-grid .ink-canvas,
[data-theme="rose-pine-dawn"] .ink-canvas.canvas-bg-grid,
[data-theme="tokyo-day"] .canvas-bg-grid .ink-canvas,
[data-theme="tokyo-day"] .ink-canvas.canvas-bg-grid,
[data-theme="everforest-light"] .canvas-bg-grid .ink-canvas,
[data-theme="everforest-light"] .ink-canvas.canvas-bg-grid {
  background-image:
    linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
}

/* Dot grid background */
.canvas-bg-dot .ink-canvas,
.ink-canvas.canvas-bg-dot {
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 20px 20px;
}
[data-theme="catppuccin-latte"] .canvas-bg-dot .ink-canvas,
[data-theme="catppuccin-latte"] .ink-canvas.canvas-bg-dot,
[data-theme="rose-pine-dawn"] .canvas-bg-dot .ink-canvas,
[data-theme="rose-pine-dawn"] .ink-canvas.canvas-bg-dot,
[data-theme="tokyo-day"] .canvas-bg-dot .ink-canvas,
[data-theme="tokyo-day"] .ink-canvas.canvas-bg-dot,
[data-theme="everforest-light"] .canvas-bg-dot .ink-canvas,
[data-theme="everforest-light"] .ink-canvas.canvas-bg-dot {
  background-image: radial-gradient(circle, rgba(0,0,0,0.07) 1px, transparent 1px);
}

/* Ruled (lined) paper background */
.canvas-bg-ruled .ink-canvas,
.ink-canvas.canvas-bg-ruled {
  background-image: linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 100% 28px;
}
[data-theme="catppuccin-latte"] .canvas-bg-ruled .ink-canvas,
[data-theme="catppuccin-latte"] .ink-canvas.canvas-bg-ruled,
[data-theme="rose-pine-dawn"] .canvas-bg-ruled .ink-canvas,
[data-theme="rose-pine-dawn"] .ink-canvas.canvas-bg-ruled,
[data-theme="tokyo-day"] .canvas-bg-ruled .ink-canvas,
[data-theme="tokyo-day"] .ink-canvas.canvas-bg-ruled,
[data-theme="everforest-light"] .canvas-bg-ruled .ink-canvas,
[data-theme="everforest-light"] .ink-canvas.canvas-bg-ruled {
  background-image: linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px);
}

/* Canvas paper selector UI */
.paper-selector {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.paper-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text2);
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}
.paper-btn:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.paper-btn--active {
  background: rgba(var(--brand-rgb),0.12);
  border-color: rgba(var(--brand-rgb),0.3);
  color: var(--brand);
}

/* ═══════════════════════════════════════════
   ARCHIVE PANEL
   ═══════════════════════════════════════════ */

.archive-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: default;
  transition: background 0.15s;
}
.archive-item:hover { background: var(--surface3); }
.archive-item__icon { font-size: 14px; flex-shrink: 0; }
.archive-item__title { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.archive-item__date { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.archive-item__restore {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
  border-radius: 4px;
}
.archive-item__restore:hover { background: var(--surface3); }

/* ═══════════════════════════════════════════
   TAG SUGGESTIONS MEJORADOS
   ═══════════════════════════════════════════ */

.tag-suggestion {
  appearance: none;
  border: 1px dashed var(--line) !important;
  background: transparent;
  color: var(--text2);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  cursor: pointer;
  transition: background 80ms ease, color 80ms ease;
  font-family: inherit;
}
.tag-suggestion:hover {
  background: rgba(var(--brand-rgb),0.1);
  color: var(--brand);
  border-color: var(--brand) !important;
}
.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   UI POLISH — mejoras visuales finales
   ═══════════════════════════════════════════ */

/* ── Empty states mejorados ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}
.empty-state__icon {
  font-size: 48px;
  opacity: 0.3;
  line-height: 1;
}
.empty-state__text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text2);
}
.empty-state__sub {
  font-size: 13px;
  color: var(--muted);
  opacity: 0.7;
  max-width: 280px;
}

/* ── Entry list / Note list items: mejor feedback hover ── */
.entry-item {
  position: relative;
  transition: background 120ms ease, border-color 120ms ease, transform 100ms ease;
}
.entry-item:hover {
  background: rgba(255,255,255,0.04);
  transform: translateX(2px);
}
.entry-item--selected {
  background: rgba(var(--brand-rgb),0.12) !important;
  border-color: rgba(var(--brand-rgb),0.3) !important;
}
/* Light themes hover */
[data-theme="catppuccin-latte"] .entry-item:hover,
[data-theme="rose-pine-dawn"] .entry-item:hover,
[data-theme="tokyo-day"] .entry-item:hover,
[data-theme="everforest-light"] .entry-item:hover { background: rgba(0,0,0,0.03); }

/* ── Note cards: mejor elevación y hover ── */
.note-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-swift);
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
}
.note-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px rgba(var(--brand-rgb),0.1), 0px 4px 12px rgba(0,0,0,0.08);
}

/* ── Note item: mejor feedback ── */
.note-item {
  border-radius: 8px;
  transition: background 120ms ease;
}
.note-item:hover {
  background: var(--surface3);
}
.note-item--selected {
  background: var(--surface3) !important;
  outline: 1px solid var(--brand);
  outline-offset: -1px;
}

/* ── Calendar day: mejor hover ── */
.cal-day {
  border-radius: 8px;
  transition: background 100ms ease, transform 80ms ease;
}
.cal-day:hover {
  background: rgba(255,255,255,0.05);
  transform: scale(1.08);
}
.cal-day--today {
  background: rgba(var(--brand-rgb),0.15);
  color: var(--brand);
  font-weight: 700;
}
.cal-day--selected {
  background: var(--brand) !important;
  color: #fff !important;
  font-weight: 700;
  transform: scale(1.08);
}

/* ── Dialog mejorado ── */
.dialog {
  border: 1px solid var(--line2);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06), 0px 8px 24px -4px rgba(0,0,0,0.10), 0px 32px 48px -8px rgba(0,0,0,0.15);
  width: min(400px, calc(100vw - 24px));
  padding: 0;
  animation: dialogIn 200ms var(--ease-swift);
}
.dialog::backdrop {
  background: rgba(0,0,0,0.45);
  animation: fadeIn 150ms ease;
}
@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.dialog__form {
  display: grid;
  gap: 12px;
  padding: 20px;
}
.dialog__msg {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}
.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ── Quick Switcher mejorado ── */
.dialog--wide {
  width: min(520px, 90vw);
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
}
.qs-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.qs-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}
.qs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 100ms ease;
}
.qs-item:hover, .qs-item--active {
  background: var(--surface3);
}

/* ── Sidebar search: mejor integración ── */
.sidebar__search {
  padding: 8px 12px 4px;
}
.search-input-wrap {
  position: relative;
}
.search-input-wrap .input {
  padding-left: 28px;
}
.search-input-wrap::before {
  content: "🔍";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.4;
  pointer-events: none;
}

/* ── Stats bar pulida ── */
.sidebar__stats {
  padding: 8px 12px;
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.sidebar__stats span {
  font-weight: 600;
  color: var(--text);
}
.sidebar__stats .stat-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(var(--brand-rgb),0.08);
  border: 1px solid rgba(var(--brand-rgb),0.15);
  border-radius: 4px;
  padding: 0 6px;
  font-size: 10px;
  color: var(--brand);
}

/* ── Ink bar: más elegante ── */
.ink-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid var(--line2);
  background: rgba(19,24,36,0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  transition: opacity 220ms ease, transform 220ms ease;
  white-space: nowrap;
}
.ink-bar--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

/* ── FAB mejorado ── */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 15;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: none;
  background: var(--fab-gradient);
  color: #fff;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0px 4px 12px rgba(0,0,0,0.2);
  display: grid;
  place-items: center;
  transition: transform var(--duration-base) var(--ease-swift),
              box-shadow var(--duration-base) var(--ease-swift);
  user-select: none;
}
.fab:hover { transform: scale(1.08) translateY(-2px); box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0px 8px 24px rgba(0,0,0,0.3); }
.fab:active { transform: scale(0.95); }

/* ── Focus mode refinado ── */
body.focus-mode .sidebar {
  transition: opacity 350ms ease, transform 350ms ease;
}
body.focus-mode .topbar {
  transition: opacity 350ms ease;
}
body.focus-mode .editor-toolbar {
  transition: opacity 350ms ease;
}
body.focus-mode .editor-body {
  max-width: 720px;
  margin: 0 auto;
  font-size: 17px;
  line-height: 1.9;
  padding-top: 48px;
}
body.focus-mode #notesPanelMain .editor-body {
  padding-top: 36px;
}

/* ── Scrollbar personalizada ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line2) transparent;
}

/* ── Selection color ── */
::selection {
  background: rgba(var(--brand-rgb),0.3);
  color: var(--text);
}

/* ── Input focus glow ── */
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb),0.12);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb),0.25);
}

/* ── Brand animation ── */
.brand__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: conic-gradient(from 90deg, var(--brand), var(--brand2), var(--brand));
  box-shadow: 0 0 6px rgba(var(--brand-rgb),0.2);
  flex-shrink: 0;
  animation: brandPulse 3s ease-in-out infinite;
}
@keyframes brandPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(var(--brand-rgb),0.2); }
  50% { box-shadow: 0 0 12px rgba(var(--brand-rgb),0.35); }
}

/* ── Status bar para mostrar marca de stylus ── */
.status--brand {
  color: var(--brand);
  font-size: 10px;
}

/* ── Tags en notas: más integrados ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(var(--brand-rgb),0.1);
  border: 1px solid rgba(var(--brand-rgb),0.18);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  transition: background 80ms ease;
}
.tag:hover {
  background: rgba(var(--brand-rgb),0.16);
}

/* ── Folder items hover ── */
.folder-item {
  border-radius: 6px;
  transition: background 80ms ease, padding-left 80ms ease;
}
.folder-item:hover {
  background: rgba(255,255,255,0.04);
  padding-left: 8px;
}
.folder-item--active {
  color: var(--text);
  background: rgba(var(--brand-rgb),0.08);
  padding-left: 8px;
}

/* ── Meta section ── */
.sidebar__meta {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  transition: opacity 150ms ease;
}

/* ── Animación de carga inicial ── */
@keyframes skeletonPulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { opacity: 0.6; }
}
.skeleton {
  animation: skeletonPulse 1.5s ease-in-out infinite;
  border-radius: 6px;
  background: var(--surface3);
}

/* ── Transición suave para mostrar/ocultar paneles ── */
.editor-wrap {
  transition: opacity 200ms ease;
}

/* ═══════════════════════════════════════════
   📚 BOOK READER (PDF)
   ═══════════════════════════════════════════ */

.books-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Library ── */

.book-list-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.books-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--line);
}

.books-header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.book-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.book-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: background 150ms ease;
  border: 1px solid transparent;
}

.book-item:hover {
  background: var(--surface2);
}

.book-item--active {
  border-color: var(--brand);
  background: var(--surface2);
}

.book-item__cover {
  font-size: 28px;
  flex-shrink: 0;
}

.book-item__info {
  flex: 1;
  min-width: 0;
}

.book-item__title {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-item__meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.book-item__delete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 150ms ease;
}

.book-item:hover .book-item__delete {
  opacity: 1;
}

.book-item__delete:hover {
  color: var(--danger);
  background: var(--surface3);
}

.book-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
}

.book-empty__icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.book-empty__text {
  font-size: 16px;
  font-weight: 500;
}

.book-empty__sub {
  font-size: 12px;
  margin-top: 4px;
}

.book-upload-area {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  border: 2px dashed var(--line2);
  border-radius: var(--radius-lg);
  margin: var(--space-md);
}

.book-upload-area__icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.book-upload-area__text {
  font-size: 13px;
}

/* ── Reader ── */

.book-reader-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.reader-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px var(--space-lg);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  z-index: 10;
}

.reader-title {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.reader-zoom {
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ── Toolbar ── */

.reader-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px var(--space-lg);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}

.reader-tool {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 15px;
  transition: all 150ms ease;
  color: var(--text);
}

.reader-tool:hover {
  background: var(--surface2);
}

.reader-tool--active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.reader-tool-divider {
  width: 1px;
  height: 22px;
  background: var(--line2);
  margin: 0 4px;
}

.reader-color {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: transparent;
}

.reader-width {
  width: 60px;
  cursor: pointer;
  accent-color: var(--brand);
}

/* ── Book Upload Area ── */
.book-upload-area {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  margin: 16px 0;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.book-upload-area:hover {
  border-color: var(--brand);
  background: var(--surface2);
}
.book-upload-area--drag {
  border-color: var(--brand);
  background: var(--surface2);
  transform: scale(1.02);
}
.book-upload-area__icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.book-upload-area__text {
  font-size: 14px;
  color: var(--text2);
}

/* ── Flipbook Reader ── */

.flip-book {
  display: none;
  position: relative;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  background: #fff;
}

.page {
  position: relative;
  background: #fff;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.pdf-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.drawing-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  touch-action: none;
  pointer-events: auto;
}

.book-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.book-empty__icon { font-size: 64px; margin-bottom: 16px; }
.book-empty__title { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.book-empty__sub { font-size: 14px; }

.book-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
}
.book-item:hover { background: var(--surface2); }
.book-item__info { flex: 1; min-width: 0; }
.book-item__title { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-item__meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.book-item__bar { height: 3px; background: var(--line); border-radius: 2px; width: 60px; overflow: hidden; }
.book-item__bar-fill { height: 100%; background: var(--brand); border-radius: 2px; transition: width 0.3s; }
.book-item__delete {
  background: none; border: none; cursor: pointer; opacity: 0.3; font-size: 14px; padding: 4px;
  transition: opacity 0.15s;
}
.book-item__delete:hover { opacity: 1; }

.reader-tool--active {
  background: var(--brand) !important;
  color: #fff !important;
}

/* ── Canvas Area ── */

.reader-canvas-area {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  background: var(--surface);
  position: relative;
}

.reader-page-wrapper {
  position: relative;
  display: inline-block;
  margin: var(--space-lg);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  background: #fff;
  line-height: 0;
}

.reader-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.reader-ann-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  touch-action: none;
  cursor: default;
}

/* ── Footer ── */

.reader-footer {
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.reader-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px var(--space-lg);
  gap: 12px;
}

.reader-page-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}

.reader-page-jump {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.reader-bookmarks {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px var(--space-lg) 8px;
  overflow-x: auto;
}

.reader-bookmarks-list {
  display: flex;
  gap: 4px;
}

.book-bookmark-item {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
}

.book-bookmark-item:hover {
  background: var(--surface2);
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .reader-toolbar {
    padding: 4px 8px;
    gap: 2px;
  }
  .reader-tool {
    padding: 4px 6px;
    font-size: 13px;
  }
  .reader-nav {
    flex-direction: column;
    gap: 6px;
  }
  .books-header {
    padding: var(--space-sm) var(--space-md);
  }
}
